mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-03 03:31:35 -05:00
Add a Zoom To Area button to the plate header
The header gets a fourth zoom button that starts the existing Zoom Window action, with a matching dashed-window icon also shown on View > Zoom To > Area. It stays out of the inspection's live zoom controls: inspection owns Escape, so a zoom window could not be cancelled there.
This commit is contained in:
1 parent
eec6ed0125
commit
5e2606f679
6 files changed
+47
-2
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using OpenNest.Actions;
|
||||
using OpenNest.CNC;
|
||||
using OpenNest.Diagnostics;
|
||||
using OpenNest.Forms;
|
||||
@@ -321,6 +322,32 @@ public class CuttingValidationPanelTests
|
||||
Assert.Equal(1, editor.PlateManager.CurrentIndex);
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void HeaderZoomToAreaStartsZoomWindowButIsLockedDuringInspection() => RunSta(() =>
|
||||
{
|
||||
using var editor = RapidEditor();
|
||||
editor.Show();
|
||||
editor.PlateManager.LoadAt(0);
|
||||
var view = editor.PlateView;
|
||||
var area = Assert.IsType<Button>(editor.Controls.Find("btnZoomToArea", true).Single());
|
||||
Assert.Equal("Zoom To Area", area.AccessibleName);
|
||||
Assert.NotNull(area.Image);
|
||||
|
||||
area.PerformClick();
|
||||
Assert.IsType<ActionZoomWindow>(view.Actions.CurrentAction);
|
||||
|
||||
// Inspection owns Escape, so a zoom window could not be cancelled there.
|
||||
view.SetAction(typeof(ActionSelect));
|
||||
editor.OpenValidationInspection();
|
||||
var panel = editor.CuttingInspection!;
|
||||
Pump(() => panel.ValidationReport != null && !panel.IsPlanning);
|
||||
Assert.False(area.Enabled);
|
||||
area.PerformClick();
|
||||
Assert.IsType<ActionSelect>(view.Actions.CurrentAction);
|
||||
panel.RequestClose();
|
||||
Assert.True(area.Enabled);
|
||||
});
|
||||
|
||||
private static void InvokeView(Control target, string name, params object[] args) => target.GetType()
|
||||
.GetMethod(name, BindingFlags.NonPublic | BindingFlags.Instance)!.Invoke(target, args);
|
||||
|
||||
|
||||
@@ -153,15 +153,21 @@ namespace OpenNest.Forms
|
||||
zoomToFitButton.AccessibleName = "Zoom To Fit";
|
||||
zoomToFitButton.Click += (s, e) => PlateView.ZoomToFit();
|
||||
|
||||
var zoomToAreaButton = CreateNavButton(Resources.zoom_area);
|
||||
zoomToAreaButton.Name = "btnZoomToArea";
|
||||
zoomToAreaButton.AccessibleName = "Zoom To Area";
|
||||
zoomToAreaButton.Click += (s, e) => PlateView.SetAction(typeof(ActionZoomWindow));
|
||||
|
||||
var toolTip = new ToolTip(components);
|
||||
toolTip.SetToolTip(zoomOutButton, "Zoom Out (Ctrl+Minus)");
|
||||
toolTip.SetToolTip(zoomInButton, "Zoom In (Ctrl+Plus)");
|
||||
toolTip.SetToolTip(zoomToFitButton, "Zoom To Fit (F)");
|
||||
toolTip.SetToolTip(zoomToAreaButton, "Zoom To Area");
|
||||
|
||||
// Keep navigation and zoom controls together in the header.
|
||||
var navPanel = new Panel
|
||||
{
|
||||
Width = btnSize.Width * 7 + 8,
|
||||
Width = btnSize.Width * 8 + 8,
|
||||
Height = btnSize.Height,
|
||||
Anchor = AnchorStyles.None,
|
||||
};
|
||||
@@ -181,6 +187,7 @@ namespace OpenNest.Forms
|
||||
zoomOutButton.Location = new Point(btnSize.Width * 4 + 8, 0);
|
||||
zoomInButton.Location = new Point(btnSize.Width * 5 + 8, 0);
|
||||
zoomToFitButton.Location = new Point(btnSize.Width * 6 + 8, 0);
|
||||
zoomToAreaButton.Location = new Point(btnSize.Width * 7 + 8, 0);
|
||||
|
||||
var separator = new Panel
|
||||
{
|
||||
@@ -193,7 +200,7 @@ namespace OpenNest.Forms
|
||||
navPanel.Controls.AddRange(
|
||||
new Control[]
|
||||
{
|
||||
plateButtons, separator, zoomOutButton, zoomInButton, zoomToFitButton
|
||||
plateButtons, separator, zoomOutButton, zoomInButton, zoomToFitButton, zoomToAreaButton
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Generated
+1
@@ -520,6 +520,7 @@ namespace OpenNest.Forms
|
||||
//
|
||||
// mnuViewZoomToArea
|
||||
//
|
||||
mnuViewZoomToArea.Image = Properties.Resources.zoom_area;
|
||||
mnuViewZoomToArea.Name = "mnuViewZoomToArea";
|
||||
mnuViewZoomToArea.Size = new System.Drawing.Size(118, 22);
|
||||
mnuViewZoomToArea.Text = "Area";
|
||||
|
||||
+7
@@ -338,6 +338,13 @@ namespace OpenNest.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap zoom_area {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("zoom_area", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
|
||||
@@ -145,6 +145,9 @@
|
||||
<data name="zoom_all" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\zoom_all.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="zoom_area" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\zoom_area.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="move_first" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\move_first.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 781 B |
Reference in new issue
Block a user