private void btnSettings_Click(object sender, RoutedEventArgs e) { var sd = new SettingsDialog(); sd.SettingApply += sd_SettingApply; sd.GridSettings = Settings; var ok = sd.ShowDialog(); if (ok.HasValue && ok.Value) { Settings = sd.GridSettings; if (grid.RowCount != Settings.RowCount || grid.ColCount != Settings.ColCount) CreateGrid(); } UpdateGridView(); UpdateUI(); }
private void btnOk_Click(object sender, RoutedEventArgs e) { var settings = GetSettings(); if (settings.RowCount != GridSettings.RowCount || settings.ColCount != GridSettings.ColCount) { var cmd = MessageBox.Show("Le dimensioni della griglia sono variate.\nLa griglia sarà creata di nuovo.\nVuoi continuare?", "LifeGame", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); if (cmd != MessageBoxResult.Yes) { return; } } DialogResult = true; GridSettings = settings; Close(); }
void UpdateGridView(GridSettings settings = null) { if (settings == null) settings = Settings; gridView.LiveCellBrush = new SolidColorBrush(settings.LiveCellFillColor); gridView.DeadCellBrush = new SolidColorBrush(settings.DeadCellFillColor); gridView.ShowGridLines = settings.ShowGridLines; gridView.CellSize = settings.CellSize; }
private GridSettings GetSettings() { var settings = new GridSettings() { LiveCellFillColor = cpLiveColor.SelectedColor != null ? cpLiveColor.SelectedColor.Value : Colors.Transparent, DeadCellFillColor = cpDeadColor.SelectedColor != null ? cpDeadColor.SelectedColor.Value : Colors.Transparent, RowCount = udRows.Value.Value, ColCount = udCols.Value.Value, CellSize = udCellSize.Value.Value, ShowGridLines = chkShowGridLines.IsChecked.GetValueOrDefault() }; return settings; }