refactor: Extract duplicate code in MainForm and CutListTools
Consolidate duplicate logic to reduce code smells identified by Roslyn Bridge: - Extract FlushPendingEdits() helper from Save() and Run() methods - Simplify ClearData() to delegate to LoadDocumentData() - Extract ConvertParts(), ConvertStockBins(), RunPackingAlgorithm() helpers - Move DTO classes to separate Models.cs file Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -137,11 +137,7 @@ namespace CutList.Forms
|
||||
|
||||
public void ClearData()
|
||||
{
|
||||
parts = new BindingList<PartInputItem>();
|
||||
bins = new BindingList<BinInputItem>();
|
||||
|
||||
itemBindingSource.DataSource = parts;
|
||||
binInputItemBindingSource.DataSource = bins;
|
||||
LoadDocumentData(new List<PartInputItem>(), new List<BinInputItem>());
|
||||
}
|
||||
|
||||
// Event handler delegates to presenter
|
||||
@@ -156,21 +152,21 @@ namespace CutList.Forms
|
||||
dataGridView2.AutoResizeColumns();
|
||||
}
|
||||
|
||||
private void Save()
|
||||
private void FlushPendingEdits()
|
||||
{
|
||||
// Flush any in-cell edits that haven't committed yet
|
||||
dataGridView1.EndEdit();
|
||||
dataGridView2.EndEdit();
|
||||
}
|
||||
|
||||
private void Save()
|
||||
{
|
||||
FlushPendingEdits();
|
||||
presenter.SaveDocument();
|
||||
}
|
||||
|
||||
private void Run()
|
||||
{
|
||||
// Flush any in-cell edits that haven't committed yet
|
||||
dataGridView1.EndEdit();
|
||||
dataGridView2.EndEdit();
|
||||
|
||||
FlushPendingEdits();
|
||||
presenter.Run();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user