예제 #1
0
 private void IterN(object sender, RoutedEventArgs e)
 {
     if (!this.ThreadAlive && conway.HasMatrix())
     {
         int n = 0;
         if (Int32.TryParse(iterBox.Text, out n))
         {
             this.ThreadAlive = true;
             int selectedSpeed = Int32.Parse((String)this.speedSelector.GetValue(ComboBox.SelectionBoxItemProperty));
             var iterate       = new IterateThread(conway, this, selectedSpeed, n);
             thread = new Thread(iterate.Iterate);
             thread.Start();
         }
     }
 }
예제 #2
0
 private void OnClick(object sender, RoutedEventArgs e)
 {
     if (this.ThreadAlive || !conway.HasMatrix())
     {
         this.ThreadAlive = false;
         if (thread != null)
         {
             thread.Join();
         }
         boton.Content = "Ejecutar";
     }
     else
     {
         this.Renderer.AddDirty(conway);
         this.ThreadAlive = true;
         int selectedSpeed = Int32.Parse((String)this.speedSelector.GetValue(ComboBox.SelectionBoxItemProperty));
         var iterate       = new IterateThread(conway, this, selectedSpeed);
         thread = new Thread(iterate.Iterate);
         thread.Start();
         boton.Content = "Parar";
     }
 }