Visual Studio.NET - SilverLight Application For Finding the Area and Circumference of a Circle
Here is the SilverLight Application Source code and downloadable for finding the Area and Circumference of a Circle.
Click here to download the SilverLight Project in VS2010
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace Circle_AreaCircumference
{
public partial class MainPage : UserControl
{
public MainPage()
{
InitializeComponent();
}
private void Calculate_Click(object sender, RoutedEventArgs e)
{
double r = Convert.ToDouble(Radius.Text);
ResultA.Text = (Math.PI * r * r).ToString();
ResultC.Text = (Math.PI * 2 * r).ToString();
}
}
}
<UserControl x:Class="Circle_AreaCircumference.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
d:DesignHeight="180" d:DesignWidth="400">
<Grid x:Name="LayoutRoot" Background="#eeeeee">
<Grid.RowDefinitions>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" HorizontalAlignment="Left" Margin="30,15,0,0" VerticalAlignment="Center" Text="Radius of a Circle: " Height="20"></TextBlock>
<TextBox Grid.Row="0" HorizontalAlignment="Left" Margin="150,10,0,0" Name="Radius" Width="100" Height="25"></TextBox>
<Button Grid.Row="1" HorizontalAlignment="Left" Margin="70,0,0,0" Click="Calculate_Click" Content="Calculate Area and Circumference" Width="250" Height="25"></Button>
<TextBlock Grid.Row="2" HorizontalAlignment="Left" Margin="10,15,0,0" VerticalAlignment="Center" Text="Area: " Height="20"></TextBlock>
<TextBlock Grid.Row="2" HorizontalAlignment="Left" Margin="170,15,0,0" VerticalAlignment="Center" Text="Circumference: " Height="20"></TextBlock>
<TextBox Grid.Row="2" HorizontalAlignment="Left" Margin="60,10,0,0" Name="ResultA" Width="100" Height="25"></TextBox>
<TextBox Grid.Row="2" HorizontalAlignment="Left" Margin="260,10,0,0" Name="ResultC" Width="100" Height="25"></TextBox>
</Grid>
</UserControl>
|