private void button1_Click(object sender, EventArgs e) { sandBox.Reset(); Thread thread = new Thread(new ThreadStart(delegate() { sandBox.Run(1000000); })); thread.Name = "Sand Thread " + threadCount++; thread.Start(); }
public MainWindow() { InitializeComponent(); MyInitializeComponent(); Debug.Listeners.Add(new TextWriterTraceListener(System.Console.Out)); img = Graphics.FromHwnd(pictureBox1.Handle); sandBox = SandBox.GetInstance(img, Math.Min(pictureBox1.ClientSize.Height, pictureBox1.ClientSize.Width), 1, 30); Thread thread = new Thread(new ThreadStart(delegate() { sandBox.Run(1000000); })); thread.Name = "Sand Thread " + threadCount++; thread.Start(); FormClosing += delegate(object o, FormClosingEventArgs e) { sandBox.IsRunning = false; }; pictureBox1.MouseDown += delegate(object o, MouseEventArgs evt) { MouseIsDown = true; sandBox.FallingPoint = evt.Location; sandBox.IsPaused = false; }; pictureBox1.MouseUp += delegate(object o, MouseEventArgs evt) { MouseIsDown = false; sandBox.FallingPoint = evt.Location; sandBox.IsPaused = true; }; pictureBox1.MouseMove += delegate(object o, MouseEventArgs evt) { if (MouseIsDown) { sandBox.FallingPoint = evt.Location; } }; }
public MainWindow() { InitializeComponent(); MyInitializeComponent(); Debug.Listeners.Add(new TextWriterTraceListener(System.Console.Out)); img = Graphics.FromHwnd(pictureBox1.Handle); sandBox = SandBox.GetInstance(img, Math.Min(pictureBox1.ClientSize.Height, pictureBox1.ClientSize.Width), 1, 30); Thread thread = new Thread(new ThreadStart(delegate() { sandBox.Run(1000000); })); thread.Name = "Sand Thread " + threadCount++; thread.Start(); FormClosing += delegate(object o, FormClosingEventArgs e) { sandBox.IsRunning = false; }; pictureBox1.MouseDown += delegate(object o, MouseEventArgs evt) { MouseIsDown = true; sandBox.FallingPoint = evt.Location; sandBox.IsPaused = false; }; pictureBox1.MouseUp += delegate(object o, MouseEventArgs evt) { MouseIsDown = false; sandBox.FallingPoint = evt.Location; sandBox.IsPaused = true; }; pictureBox1.MouseMove += delegate(object o, MouseEventArgs evt) { if(MouseIsDown) sandBox.FallingPoint = evt.Location; }; }