private void OnSettingsOKClick(object sender, RoutedEventArgs e) { int?a = AIntegerUpDown.Value; int?b = BIntegerUpDown.Value; int?c = CIntegerUpDown.Value; int?iter = IterIntegerUpDown.Value; Color?foregroundColor = ForegroundColorPicker.SelectedColor; Color?backgroundColor = BackgroundColorPicker.SelectedColor; double?strokeThichness = (double)StrokeDecimalUpDown.Value; if (a.HasValue && b.HasValue && c.HasValue && iter.HasValue && foregroundColor.HasValue && backgroundColor.HasValue) { Settings = new SpirographSettings(a.Value, b.Value, c.Value, iter.Value, foregroundColor.Value, backgroundColor.Value, strokeThichness.Value); DialogResult = true; Close(); } }
public MainWindow(SpirographSettings settings) { InitializeComponent(); SpirographSettings = settings; PreviousSettings = new SpirographSettings(SpirographSettings); }
public SettingsDialog(SpirographSettings settings, int maxSpiroValue) { MaxSpiroValue = maxSpiroValue; InitializeComponent(); Settings = settings; SetDialogChildControlValues(); }
public Spirograph(SpirographSettings settings) { A = settings.A; B = settings.B; C = settings.C; Iterations = settings.Iter; StrokeThickness = settings.StrokeThickness; LineColor = settings.ForegroundColor; BackgroundColor = settings.BackgroundColor; }
private void DrawSpirograph() { SetCanvasSize(); var halfCanvasWidth = SpiroCanvas.Width / 2; if (SpirographSettings.IsSpirographRadiusLarger(halfCanvasWidth)) { var warningDialog = new WarningDialog { Owner = this }; // // dialogResult is true when either the Previous or Draw button have been // clicked. False is returned if the user clicked on the close dialog // button. // var dialogResult = warningDialog.ShowDialog(); if (dialogResult.HasValue && dialogResult.Value == true) { if (warningDialog.Response == WarningResponse.UsePreviousSettings) { SpirographSettings = PreviousSettings; } } // // dialogResult is false and indicates that the user aborted // changing the spirograph settings. // else { return; } } SpiroCanvas.Children.Clear(); theSpirograph = new Spirograph(SpirographSettings); theSpirograph.Draw(SpiroCanvas); if (!SpirographSettings.IsSpirographRadiusLarger(halfCanvasWidth)) { PreviousSettings = new SpirographSettings(SpirographSettings); } }
private bool LoadSpirographUserSettings(out Point windowLocation, out Point windowSize, out SpirographSettings spirographSettings) { theUserSettings = new SpirographUserSettings(); windowLocation = new Point(theUserSettings.Left, theUserSettings.Top); windowSize = new Point(theUserSettings.Width, theUserSettings.Height); spirographSettings = new SpirographSettings(theUserSettings.A, theUserSettings.B, theUserSettings.C, theUserSettings.Iterations, theUserSettings.ForegroundColor, theUserSettings.BackgroundColor, theUserSettings.BrushThickness); return(windowLocation != null && windowSize != null && spirographSettings != null); }
public SpirographSettings(SpirographSettings previousSettings) : this(previousSettings.A, previousSettings.B, previousSettings.C, previousSettings.Iter, previousSettings.ForegroundColor, previousSettings.BackgroundColor, previousSettings.StrokeThickness) { }