Added cancel option to load example data

This commit is contained in:
AJ
2025-01-01 01:30:47 -05:00
parent 08b3aa9182
commit 491b98f983

View File

@@ -286,14 +286,17 @@ namespace CutList.Forms
UpdateRunButtonState(); UpdateRunButtonState();
} }
private void LoadExampleData() private void LoadExampleData(bool clearCurrentData = true)
{ {
const int PartCount = 50; const int PartCount = 50;
const double Min = 1; const double Min = 1;
const double Max = 120; const double Max = 120;
parts.Clear(); if (clearCurrentData)
bins.Clear(); {
parts.Clear();
bins.Clear();
}
var random = new Random(); var random = new Random();
@@ -314,7 +317,6 @@ namespace CutList.Forms
LengthInputValue = "144\"", LengthInputValue = "144\"",
Quantity = 9999 Quantity = 9999
}); });
} }
private static readonly Random random = new Random(); private static readonly Random random = new Random();
@@ -326,14 +328,19 @@ namespace CutList.Forms
private void toolStripButton3_Click(object sender, EventArgs e) private void toolStripButton3_Click(object sender, EventArgs e)
{ {
var clearData = true;
if (parts.Count > 0 || bins.Count > 0) 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); var dialogResult = MessageBox.Show("Are you sure you want to clear the current data?", "Clear Data", MessageBoxButtons.YesNoCancel);
if (result == DialogResult.No)
if (dialogResult == DialogResult.Cancel)
return; return;
clearData = dialogResult == DialogResult.Yes;
} }
LoadExampleData(); LoadExampleData(clearData);
} }
} }