mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-26 22:01:06 -04:00
refactor(ui): collapse MainForm menu delegators
Adds WithActive for handlers that only forward to the active nest document and collapses 32 of them to one line. The eight align and evenly-space items share Align_Click, reading their AlignType from Tag. Center Parts becomes CenterParts_Click and ignores a missing plate or an empty plate instead of throwing. The hidden, disabled Paste item loses its empty handler. SetValueForm, OptionsForm and ShapeLibraryForm are now disposed and owned by the main window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
93d118585f
commit
3541249441
7 files changed
+78
-275
No files matched your search
Generated
+9
-10
@@ -326,7 +326,6 @@ namespace OpenNest.Forms
|
||||
mnuEditPaste.Size = new System.Drawing.Size(164, 22);
|
||||
mnuEditPaste.Text = "Paste";
|
||||
mnuEditPaste.Visible = false;
|
||||
mnuEditPaste.Click += EditPaste_Click;
|
||||
//
|
||||
// toolStripMenuItem4
|
||||
//
|
||||
@@ -865,28 +864,28 @@ namespace OpenNest.Forms
|
||||
mnuPlateAlignLeft.Name = "mnuPlateAlignLeft";
|
||||
mnuPlateAlignLeft.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignLeft.Text = "Left";
|
||||
mnuPlateAlignLeft.Click += AlignLeft_Click;
|
||||
mnuPlateAlignLeft.Click += Align_Click;
|
||||
//
|
||||
// mnuPlateAlignRight
|
||||
//
|
||||
mnuPlateAlignRight.Name = "mnuPlateAlignRight";
|
||||
mnuPlateAlignRight.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignRight.Text = "Right";
|
||||
mnuPlateAlignRight.Click += AlignRight_Click;
|
||||
mnuPlateAlignRight.Click += Align_Click;
|
||||
//
|
||||
// mnuPlateAlignTop
|
||||
//
|
||||
mnuPlateAlignTop.Name = "mnuPlateAlignTop";
|
||||
mnuPlateAlignTop.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignTop.Text = "Top";
|
||||
mnuPlateAlignTop.Click += AlignTop_Click;
|
||||
mnuPlateAlignTop.Click += Align_Click;
|
||||
//
|
||||
// mnuPlateAlignBottom
|
||||
//
|
||||
mnuPlateAlignBottom.Name = "mnuPlateAlignBottom";
|
||||
mnuPlateAlignBottom.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignBottom.Text = "Bottom";
|
||||
mnuPlateAlignBottom.Click += AlignBottom_Click;
|
||||
mnuPlateAlignBottom.Click += Align_Click;
|
||||
//
|
||||
// toolStripMenuItem11
|
||||
//
|
||||
@@ -898,14 +897,14 @@ namespace OpenNest.Forms
|
||||
mnuPlateAlignHorizontal.Name = "mnuPlateAlignHorizontal";
|
||||
mnuPlateAlignHorizontal.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignHorizontal.Text = "Horizontally";
|
||||
mnuPlateAlignHorizontal.Click += AlignHorizontal_Click;
|
||||
mnuPlateAlignHorizontal.Click += Align_Click;
|
||||
//
|
||||
// mnuPlateAlignVertically
|
||||
//
|
||||
mnuPlateAlignVertically.Name = "mnuPlateAlignVertically";
|
||||
mnuPlateAlignVertically.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateAlignVertically.Text = "Vertically";
|
||||
mnuPlateAlignVertically.Click += AlignVertical_Click;
|
||||
mnuPlateAlignVertically.Click += Align_Click;
|
||||
//
|
||||
// toolStripMenuItem8
|
||||
//
|
||||
@@ -917,14 +916,14 @@ namespace OpenNest.Forms
|
||||
mnuPlateEvenlySpaceHorizontal.Name = "mnuPlateEvenlySpaceHorizontal";
|
||||
mnuPlateEvenlySpaceHorizontal.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateEvenlySpaceHorizontal.Text = "Evenly Space Horizontally";
|
||||
mnuPlateEvenlySpaceHorizontal.Click += EvenlySpaceHorizontally_Click;
|
||||
mnuPlateEvenlySpaceHorizontal.Click += Align_Click;
|
||||
//
|
||||
// mnuPlateEvenlySpaceVertical
|
||||
//
|
||||
mnuPlateEvenlySpaceVertical.Name = "mnuPlateEvenlySpaceVertical";
|
||||
mnuPlateEvenlySpaceVertical.Size = new System.Drawing.Size(209, 22);
|
||||
mnuPlateEvenlySpaceVertical.Text = "Evenly Space Vertically";
|
||||
mnuPlateEvenlySpaceVertical.Click += EvenlySpaceVertically_Click;
|
||||
mnuPlateEvenlySpaceVertical.Click += Align_Click;
|
||||
//
|
||||
// toolStripMenuItem23
|
||||
//
|
||||
@@ -936,7 +935,7 @@ namespace OpenNest.Forms
|
||||
centerPartsToolStripMenuItem.Name = "centerPartsToolStripMenuItem";
|
||||
centerPartsToolStripMenuItem.Size = new System.Drawing.Size(209, 22);
|
||||
centerPartsToolStripMenuItem.Text = "Center Parts";
|
||||
centerPartsToolStripMenuItem.Click += centerPartsToolStripMenuItem_Click;
|
||||
centerPartsToolStripMenuItem.Click += CenterParts_Click;
|
||||
//
|
||||
// toolStripMenuItem24
|
||||
//
|
||||
|
||||
@@ -144,19 +144,9 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void Export_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.Export();
|
||||
}
|
||||
private void Export_Click(object sender, EventArgs e) => WithActive(f => f.Export());
|
||||
|
||||
private void ExportAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.ExportAll();
|
||||
}
|
||||
private void ExportAll_Click(object sender, EventArgs e) => WithActive(f => f.ExportAll());
|
||||
|
||||
private void ExportNestReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -13,20 +13,15 @@ namespace OpenNest.Forms
|
||||
{
|
||||
#region Nest Menu Events
|
||||
|
||||
private void Import_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.Import();
|
||||
}
|
||||
private void Import_Click(object sender, EventArgs e) => WithActive(f => f.Import());
|
||||
|
||||
private void ShapeLibrary_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
|
||||
var form = new ShapeLibraryForm(activeForm.Nest.Drawings.Select(d => d.Name));
|
||||
form.ShowDialog();
|
||||
using var form = new ShapeLibraryForm(activeForm.Nest.Drawings.Select(d => d.Name));
|
||||
form.ShowDialog(this);
|
||||
|
||||
var drawings = form.GetDrawings();
|
||||
if (drawings.Count == 0)
|
||||
@@ -50,12 +45,7 @@ namespace OpenNest.Forms
|
||||
mnuNestDrawingLibrary.ToolTipText = databaseMode ? "" : NestStorage.DatabaseModeOnly;
|
||||
}
|
||||
|
||||
private void EditNest_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.ShowNestInfoEditor();
|
||||
}
|
||||
private void EditNest_Click(object sender, EventArgs e) => WithActive(f => f.ShowNestInfoEditor());
|
||||
|
||||
private void Clamps_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -87,40 +77,15 @@ namespace OpenNest.Forms
|
||||
view.Invalidate();
|
||||
}
|
||||
|
||||
private void RemoveEmptyPlates_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.Nest.Plates.RemoveEmptyPlates();
|
||||
}
|
||||
private void RemoveEmptyPlates_Click(object sender, EventArgs e) => WithActive(f => f.Nest.Plates.RemoveEmptyPlates());
|
||||
|
||||
private void LoadFirstPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateManager.LoadFirst();
|
||||
}
|
||||
private void LoadFirstPlate_Click(object sender, EventArgs e) => WithActive(f => f.PlateManager.LoadFirst());
|
||||
|
||||
private void LoadLastPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateManager.LoadLast();
|
||||
}
|
||||
private void LoadLastPlate_Click(object sender, EventArgs e) => WithActive(f => f.PlateManager.LoadLast());
|
||||
|
||||
private void LoadPreviousPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateManager.LoadPrevious();
|
||||
}
|
||||
private void LoadPreviousPlate_Click(object sender, EventArgs e) => WithActive(f => f.PlateManager.LoadPrevious());
|
||||
|
||||
private void LoadNextPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateManager.LoadNext();
|
||||
}
|
||||
private void LoadNextPlate_Click(object sender, EventArgs e) => WithActive(f => f.PlateManager.LoadNext());
|
||||
|
||||
private RemnantViewerForm remnantViewer;
|
||||
|
||||
@@ -193,13 +158,7 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void SequenceAllPlates_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
|
||||
activeForm.AutoSequenceAllPlates();
|
||||
}
|
||||
private void SequenceAllPlates_Click(object sender, EventArgs e) => WithActive(f => f.AutoSequenceAllPlates());
|
||||
|
||||
private void ValidateNest_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -239,27 +198,11 @@ namespace OpenNest.Forms
|
||||
new PostCommand(this, editForm.Nest, postProcessor).Run();
|
||||
}
|
||||
|
||||
private void CalculateNestCutTime_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
private void CalculateNestCutTime_Click(object sender, EventArgs e) => WithActive(f => f.CalculateNestCutTime());
|
||||
|
||||
activeForm.CalculateNestCutTime();
|
||||
}
|
||||
private void NestAssignLeadIns_Click(object sender, EventArgs e) => WithActive(f => f.AssignLeadInsAllPlates());
|
||||
|
||||
private void NestAssignLeadIns_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.AssignLeadInsAllPlates();
|
||||
}
|
||||
|
||||
private void NestRemoveLeadIns_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.RemoveLeadInsAllPlates();
|
||||
}
|
||||
private void NestRemoveLeadIns_Click(object sender, EventArgs e) => WithActive(f => f.RemoveLeadInsAllPlates());
|
||||
|
||||
#endregion Nest Menu Events
|
||||
}
|
||||
|
||||
@@ -9,12 +9,7 @@ namespace OpenNest.Forms
|
||||
{
|
||||
#region Plate Menu Events
|
||||
|
||||
private void SetAsNestDefault_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.SetCurrentPlateAsNestDefault();
|
||||
}
|
||||
private void SetAsNestDefault_Click(object sender, EventArgs e) => WithActive(f => f.SetCurrentPlateAsNestDefault());
|
||||
|
||||
private void AddPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -24,19 +19,9 @@ namespace OpenNest.Forms
|
||||
NavigationEnableCheck();
|
||||
}
|
||||
|
||||
private void EditPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.EditPlate();
|
||||
}
|
||||
private void EditPlate_Click(object sender, EventArgs e) => WithActive(f => f.EditPlate());
|
||||
|
||||
private void RemovePlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.RemoveCurrentPlate();
|
||||
}
|
||||
private void RemovePlate_Click(object sender, EventArgs e) => WithActive(f => f.RemoveCurrentPlate());
|
||||
|
||||
private void ResizeToFitParts_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -46,49 +31,17 @@ namespace OpenNest.Forms
|
||||
statusBar.UpdatePlate();
|
||||
}
|
||||
|
||||
private void RotateCw_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.RotateCw();
|
||||
}
|
||||
private void RotateCw_Click(object sender, EventArgs e) => WithActive(f => f.RotateCw());
|
||||
|
||||
private void RotateCcw_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.RotateCcw();
|
||||
}
|
||||
private void RotateCcw_Click(object sender, EventArgs e) => WithActive(f => f.RotateCcw());
|
||||
|
||||
private void Rotate180_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.Rotate180();
|
||||
}
|
||||
private void Rotate180_Click(object sender, EventArgs e) => WithActive(f => f.Rotate180());
|
||||
|
||||
private void OpenInExternalCad_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.OpenCurrentPlate();
|
||||
}
|
||||
private void OpenInExternalCad_Click(object sender, EventArgs e) => WithActive(f => f.OpenCurrentPlate());
|
||||
|
||||
private void CalculatePlateCutTime_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
private void CalculatePlateCutTime_Click(object sender, EventArgs e) => WithActive(f => f.CalculateCurrentPlateCutTime());
|
||||
|
||||
activeForm.CalculateCurrentPlateCutTime();
|
||||
}
|
||||
|
||||
private void AutoSequenceCurrentPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
|
||||
activeForm.AutoSequenceCurrentPlate();
|
||||
}
|
||||
private void AutoSequenceCurrentPlate_Click(object sender, EventArgs e) => WithActive(f => f.AutoSequenceCurrentPlate());
|
||||
|
||||
private void ManualSequenceParts_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -98,13 +51,7 @@ namespace OpenNest.Forms
|
||||
activeForm.PlateView.SetAction(typeof(ActionSetSequence));
|
||||
}
|
||||
|
||||
private void CutOff_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
|
||||
activeForm.PlateView.SetAction(typeof(ActionCutOff));
|
||||
}
|
||||
private void CutOff_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.SetAction(typeof(ActionCutOff)));
|
||||
|
||||
private void AutomaticCutOff_Click(object sender, EventArgs e) => ShowAutomaticCutOff(allPlates: false);
|
||||
|
||||
@@ -191,26 +138,11 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void PlateAssignLeadIns_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.AssignLeadIns_Click(sender, e);
|
||||
}
|
||||
private void PlateAssignLeadIns_Click(object sender, EventArgs e) => WithActive(f => f.AssignLeadIns_Click(sender, e));
|
||||
|
||||
private void PlatePlaceLeadIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlaceLeadIn_Click(sender, e);
|
||||
}
|
||||
private void PlatePlaceLeadIn_Click(object sender, EventArgs e) => WithActive(f => f.PlaceLeadIn_Click(sender, e));
|
||||
|
||||
private void PlateRemoveLeadIns_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.RemoveLeadIns_Click(sender, e);
|
||||
}
|
||||
private void PlateRemoveLeadIns_Click(object sender, EventArgs e) => WithActive(f => f.RemoveLeadIns_Click(sender, e));
|
||||
|
||||
#endregion Plate Menu Events
|
||||
}
|
||||
|
||||
@@ -11,13 +11,7 @@ namespace OpenNest.Forms
|
||||
{
|
||||
#region Tools Menu Events
|
||||
|
||||
private void MeasureArea_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
|
||||
activeForm.PlateView.SetAction(typeof(ActionSelectArea));
|
||||
}
|
||||
private void MeasureArea_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.SetAction(typeof(ActionSelectArea)));
|
||||
|
||||
private void BestFitViewer_Click(object sender, EventArgs e)
|
||||
{
|
||||
@@ -148,11 +142,11 @@ namespace OpenNest.Forms
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
var form = new SetValueForm();
|
||||
using var form = new SetValueForm();
|
||||
form.Text = "Set Offset Increment";
|
||||
form.Value = activeForm.PlateView.OffsetIncrementDistance;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.ShowDialog(this) == DialogResult.OK)
|
||||
activeForm.PlateView.OffsetIncrementDistance = form.Value;
|
||||
}
|
||||
|
||||
@@ -160,19 +154,19 @@ namespace OpenNest.Forms
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
var form = new SetValueForm();
|
||||
using var form = new SetValueForm();
|
||||
form.Text = "Set Rotation Increment";
|
||||
form.Value = activeForm.PlateView.RotateIncrementAngle;
|
||||
form.Maximum = 360;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
if (form.ShowDialog(this) == DialogResult.OK)
|
||||
activeForm.PlateView.RotateIncrementAngle = form.Value;
|
||||
}
|
||||
|
||||
private void Options_Click(object sender, EventArgs e)
|
||||
{
|
||||
var form = new OptionsForm();
|
||||
form.ShowDialog();
|
||||
using var form = new OptionsForm();
|
||||
form.ShowDialog(this);
|
||||
}
|
||||
|
||||
private void NestDefaults_Click(object sender, EventArgs e)
|
||||
@@ -209,77 +203,41 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void AlignLeft_Click(object sender, EventArgs e)
|
||||
private void InitializeAlignMenu()
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Left);
|
||||
mnuPlateAlignLeft.Tag = AlignType.Left;
|
||||
mnuPlateAlignRight.Tag = AlignType.Right;
|
||||
mnuPlateAlignTop.Tag = AlignType.Top;
|
||||
mnuPlateAlignBottom.Tag = AlignType.Bottom;
|
||||
mnuPlateAlignHorizontal.Tag = AlignType.Horizontally;
|
||||
mnuPlateAlignVertically.Tag = AlignType.Vertically;
|
||||
mnuPlateEvenlySpaceHorizontal.Tag = AlignType.EvenlySpaceHorizontally;
|
||||
mnuPlateEvenlySpaceVertical.Tag = AlignType.EvenlySpaceVertically;
|
||||
}
|
||||
|
||||
private void AlignRight_Click(object sender, EventArgs e)
|
||||
private void Align_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Right);
|
||||
}
|
||||
|
||||
private void AlignTop_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Top);
|
||||
}
|
||||
|
||||
private void AlignBottom_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Bottom);
|
||||
}
|
||||
|
||||
private void AlignVertical_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Vertically);
|
||||
}
|
||||
|
||||
private void AlignHorizontal_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.Horizontally);
|
||||
}
|
||||
|
||||
private void EvenlySpaceHorizontally_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.EvenlySpaceHorizontally);
|
||||
}
|
||||
|
||||
private void EvenlySpaceVertically_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.AlignSelected(AlignType.EvenlySpaceVertically);
|
||||
if (((ToolStripItem)sender).Tag is AlignType type)
|
||||
WithActive(f => f.PlateView.AlignSelected(type));
|
||||
}
|
||||
|
||||
#endregion Tools Menu Events
|
||||
|
||||
private void centerPartsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void CenterParts_Click(object sender, EventArgs e)
|
||||
{
|
||||
var plateCenter = this.activeForm.PlateView.Plate.BoundingBox(false).Center;
|
||||
var partsCenter = this.activeForm.PlateView.Parts.GetBoundingBox().Center;
|
||||
var view = activeForm?.PlateView;
|
||||
if (view?.Plate == null || view.Parts.Count == 0)
|
||||
return;
|
||||
|
||||
var plateCenter = view.Plate.BoundingBox(false).Center;
|
||||
var partsCenter = view.Parts.GetBoundingBox().Center;
|
||||
|
||||
var offset = plateCenter - partsCenter;
|
||||
|
||||
foreach (var part in this.activeForm.PlateView.Parts)
|
||||
{
|
||||
foreach (var part in view.Parts)
|
||||
part.Offset(offset);
|
||||
}
|
||||
|
||||
activeForm.PlateView.Invalidate();
|
||||
view.Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,8 +27,6 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void EditPaste_Click(object sender, EventArgs e) { }
|
||||
|
||||
private void EditCopy_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
@@ -43,12 +41,7 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private void EditSelectAll_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.SelectAllParts();
|
||||
}
|
||||
private void EditSelectAll_Click(object sender, EventArgs e) => WithActive(f => f.SelectAllParts());
|
||||
|
||||
#endregion Edit Menu Events
|
||||
|
||||
@@ -147,33 +140,13 @@ namespace OpenNest.Forms
|
||||
mnuViewDrawCutDirection.Checked = activeForm.PlateView.DrawCutDirection;
|
||||
}
|
||||
|
||||
private void ZoomToArea_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.SetAction(typeof(ActionZoomWindow));
|
||||
}
|
||||
private void ZoomToArea_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.SetAction(typeof(ActionZoomWindow)));
|
||||
|
||||
private void ZoomToFit_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.ZoomToFit();
|
||||
}
|
||||
private void ZoomToFit_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.ZoomToFit());
|
||||
|
||||
private void ZoomToPlate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.ZoomToPlate();
|
||||
}
|
||||
private void ZoomToPlate_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.ZoomToPlate());
|
||||
|
||||
private void ZoomToSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (activeForm == null)
|
||||
return;
|
||||
activeForm.PlateView.ZoomToSelected();
|
||||
}
|
||||
private void ZoomToSelected_Click(object sender, EventArgs e) => WithActive(f => f.PlateView.ZoomToSelected());
|
||||
|
||||
private void ZoomIn_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -64,6 +64,13 @@ namespace OpenNest.Forms
|
||||
Dispose();
|
||||
}
|
||||
|
||||
/// <summary>Runs <paramref name="action"/> on the active nest document, if there is one.</summary>
|
||||
private void WithActive(Action<EditNestForm> action)
|
||||
{
|
||||
if (activeForm != null)
|
||||
action(activeForm);
|
||||
}
|
||||
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
var inspection = MdiChildren.OfType<EditNestForm>()
|
||||
@@ -109,6 +116,7 @@ namespace OpenNest.Forms
|
||||
exportNestMenu.Click += ExportNest_Click;
|
||||
mnuFile.DropDownItems.Insert(mnuFile.DropDownItems.IndexOf(mnuFileExport), exportNestMenu);
|
||||
mnuFile.DropDownItems.Insert(mnuFile.DropDownItems.IndexOf(mnuFileExit), storageModeMenu);
|
||||
InitializeAlignMenu();
|
||||
UpdateOverlapMenu();
|
||||
MainWindowSettings.Load(this);
|
||||
|
||||
|
||||
Reference in new issue
Block a user