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); } }