Design page:
<Window x: Class = "RandomDome. MainWindow"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "webattack@163.com" Height = "350" Width = "525">
<Grid Background = "Green">
<Grid. RowDefinitions>
<RowDefinition> </RowDefinition>
</Grid. RowDefinitions>
<Grid. ColumnDefinitions>
<ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> </ColumnDefinition>
<ColumnDefinition> </ColumnDefinition>
</Grid. ColumnDefinitions> www.2cto.com
<TextBox Name = "tbX" Grid. row = "0" Grid. column = "0" Width = "100" Height = "50" FontSize = "24"> </TextBox>
<TextBox Name = "tbY" Grid. row = "0" Grid. column = "1" Width = "100" Height = "50" FontSize = "24"> </TextBox>
<Button Name = "btnBegin" Grid. row = "0" Grid. column = "2" Width = "100" Height = "50" Content = "Lucky Draw" Click = "btnBegin_Click"> </Button>
<Button Name = "btnEnd" Grid. row = "0" Grid. column = "3" Width = "100" Height = "50" Content = "pause" Click = "btnEnd_Click"> </Button>
</Grid>
</Window>
Code Page:
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using System. Windows;
Using System. Windows. Controls;
Using System. Windows. Data;
Using System. Windows. Documents;
Using System. Windows. Input;
Using System. Windows. Media;
Using System. Windows. Media. Imaging;
Using System. Windows. Navigation;
Using System. Windows. Shapes;
Using System. Threading;
Using System. Windows. Threading;
Namespace RandomDome
{
/// <Summary>
/// Interaction logic of MainWindow. xaml
/// </Summary>
Public partial class MainWindow: Window
{
Public MainWindow ()
{
InitializeComponent ();
}
Int I = 1;
Int j = 9;
DispatcherTimer dt = new DispatcherTimer ();
MediaPlayer player = new MediaPlayer ();
Private void btnBegin_Click (object sender, RoutedEventArgs e)
{
String mp = Environment. CurrentDirectory;
Int a = mp. LastIndexOf ('\\');
Int B = a-3;
Mp = mp. Substring (0, B );
Mp = mp + "\ music \ one night ";
Player. Open (new Uri (mp, UriKind. RelativeOrAbsolute ));
Player. Play ();
Dt. Interval = TimeSpan. FromMilliseconds (10 );
Dt. Tick + = new EventHandler (dt_Tick );
Dt. Start ();
}
Void dt_Tick (object sender, EventArgs e)
{
TbX. Text = I. ToString ();
TbY. Text = j. ToString ();
I ++;
J --;
If (I = 9)
{
I = 1;
}
If (j = 1)
{
J = 9;
}
}
Private void btnEnd_Click (object sender, RoutedEventArgs e)
{
Player. Stop ();
Dt. Stop ();
}
}
}