From 491b98f9835a77515bbb64140463779fd3a9bf48 Mon Sep 17 00:00:00 2001 From: AJ Date: Wed, 1 Jan 2025 01:30:47 -0500 Subject: [PATCH] Added cancel option to load example data --- CutList/Forms/MainForm.cs | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/CutList/Forms/MainForm.cs b/CutList/Forms/MainForm.cs index 6429ddf..fb0a35d 100644 --- a/CutList/Forms/MainForm.cs +++ b/CutList/Forms/MainForm.cs @@ -286,14 +286,17 @@ namespace CutList.Forms UpdateRunButtonState(); } - private void LoadExampleData() + private void LoadExampleData(bool clearCurrentData = true) { const int PartCount = 50; const double Min = 1; const double Max = 120; - parts.Clear(); - bins.Clear(); + if (clearCurrentData) + { + parts.Clear(); + bins.Clear(); + } var random = new Random(); @@ -314,7 +317,6 @@ namespace CutList.Forms LengthInputValue = "144\"", Quantity = 9999 }); - } private static readonly Random random = new Random(); @@ -326,14 +328,19 @@ namespace CutList.Forms private void toolStripButton3_Click(object sender, EventArgs e) { + var clearData = true; + if (parts.Count > 0 || bins.Count > 0) { - var result = MessageBox.Show("Are you sure you want to clear the current data?", "Clear Data", MessageBoxButtons.YesNo); - if (result == DialogResult.No) + var dialogResult = MessageBox.Show("Are you sure you want to clear the current data?", "Clear Data", MessageBoxButtons.YesNoCancel); + + if (dialogResult == DialogResult.Cancel) return; + + clearData = dialogResult == DialogResult.Yes; } - LoadExampleData(); + LoadExampleData(clearData); } }