C # lottery host WPF

Source: Internet
Author: User


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 ();

}


}
}
 

 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.