using System;
using System.Drawing;
using System.Collections;
using
using System.Windows.Forms;
using System.Data;
using System.Runtime;
using System.Threading;
//using System.Diagnostics;
namespace TransBall
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
///
private Point _mousePosition;
private Point _formPosition;
private bool isMouseDown = false;
private bool IfThreadStart;
Thread T1;
Thread T2;
Thread T3;
Thread T4;
Thread T5;
Thread T6;
private delegate void CALL(Control Tr);
private System.Windows.Forms.PictureBox btnExit;
private System.Windows.Forms.PictureBox btnStart;
private System.Windows.Forms.Label L1;
private System.Windows.Forms.Label L2;
private System.Windows.Forms.Label L3;
private System.Windows.Forms.Label L4;
private System.Windows.Forms.Label L5;
private System.Windows.Forms.Label L6;
private System.Windows.Forms.Label lblLast;
private components = null;
public MainForm()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
[STAThread]
static void Main()
{
Application.Run(new MainForm());
}
private void MainForm_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
_mousePosition = new Point( e.X, e.Y);//基于窗体的坐标
_formPosition = this.Location;
isMouseDown = true;
}
}
private void MainForm_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (isMouseDown)
{
Point currentMousePosition = Control.MousePosition;//光标相对于屏幕左上角的坐标
Point location = new Point(
(currentMousePosition.X - _mousePosition.X),
(currentMousePosition.Y - _mousePosition.Y));
this.Location = location;
//
// Debug.WriteLine( "this.Location.X:" + this.Location.X.ToString() );
// Debug.WriteLine( "Control.MousePosition.X:" + Control.MousePosition.X.ToString() );
// Debug.WriteLine( "Location.X:" + location.X.ToString() );
}
}
private void MainForm_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
private void btnExit_Click(object sender, System.EventArgs e)
{
this.Close();
Application.Exit();
}
private void btnStart_Click(object sender, System.EventArgs e)
{
if (IfThreadStart==false)
{
lblLast.Visible=false;
InThread A1 = new InThread();
A1.SetNumber(L1,000000);
T1 = new Thread(new ThreadStart(A1.RunInThread));
T1.Start();
InThread A2 = new InThread();
A2.SetNumber(L2,111111);
T2 = new Thread(new ThreadStart(A2.RunInThread));
T2.Start();
InThread A3 = new InThread();
A3.SetNumber(L3,222222);
T3 = new Thread(new ThreadStart(A3.RunInThread));
T3.Start();
InThread A4 = new InThread();
A4.SetNumber(L4,333333);
T4 = new Thread(new ThreadStart(A4.RunInThread));
T4.Start();
InThread A5 = new InThread();
A5.SetNumber(L5,444444);
T5 = new Thread(new ThreadStart(A5.RunInThread));
T5.Start();
InThread A6 = new InThread();
A6.SetNumber(L6,555555);
T6 = new Thread(new ThreadStart(A6.RunInThread));
T6.Start();
IfThreadStart=true;
}
else
{
T1.Abort();
T2.Abort();
T3.Abort();
T4.Abort();
T5.Abort();
T6.Abort();
lblLast.Text ="中奖号码:"+L1.Text +L2.Text+L3.Text+L4.Text+L5.Text +L6.Text;
lblLast.Visible=true;
IfThreadStart=false;
}
}
private void MainForm_Load(object sender, System.EventArgs e)
{
IfThreadStart = false;
}
}
}