private void clear_Click(object sender, RoutedEventArgs e) { if (slider.Value >= 1) { string sValue = Convert.ToString(slider.Value); sizeText.Text = sValue + " x " + sValue; int width = Convert.ToInt32(slider.Value); int height = Convert.ToInt32(slider.Value); foreach (Button button in ButtonList.buttons) { playArea.Children.Remove(button); } foreach (ColumnDefinition column in ButtonList.columns) { playArea.ColumnDefinitions.Remove(column); } foreach (RowDefinition row in ButtonList.rows) { playArea.RowDefinitions.Remove(row); } AliveDead.CreateDictionary(width, height); CreateButtonsAndGrid(width, height); livesText.Text = "Alive: 0"; } }
private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e) { if (slider.Value >= 1) { string sValue = Convert.ToString(slider.Value); sizeText.Text = sValue + " x " + sValue; int width = Convert.ToInt32(slider.Value); int height = Convert.ToInt32(slider.Value); foreach (Button button in ButtonList.buttons) { playArea.Children.Remove(button); } foreach (ColumnDefinition column in ButtonList.columns) { playArea.ColumnDefinitions.Remove(column); } foreach (RowDefinition row in ButtonList.rows) { playArea.RowDefinitions.Remove(row); } AliveDead.CreateDictionary(width, height); CreateButtonsAndGrid(width, height); //AliveDead.ApplyStatus(); } }
public MainWindow() { InitializeComponent(); // this is where i would take the input AliveDead.CreateDictionary(5, 5); _backgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true }; _backgroundWorker.DoWork += backgroundWorker_DoWork; _backgroundWorker.RunWorkerCompleted += backgroundWorker_RunWorkerCompleted; nextButton.Focus(); CreateButtonsAndGrid(5, 5); underPop.Text = "<" + Convert.ToString(AliveDead.underPopulated); overPop.Text = ">" + Convert.ToString(AliveDead.overPopulated); growthS.Text = ">=" + Convert.ToString(AliveDead.growthStart); growthE.Text = "<=" + Convert.ToString(AliveDead.growthEnd); slider.Value = 50; }