mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-10-16 06:31:36 -04:00
Add cutting action icons and toolbar shortcuts
This commit is contained in:
1 parent
1d745d20ba
commit
efc2b73709
7 files changed
+97
No files matched your search
@@ -12,6 +12,35 @@ namespace OpenNest.WinForms.Tests.Forms;
|
||||
[Collection("Fill operation lifetime")]
|
||||
public class NestReportExportTests
|
||||
{
|
||||
[Fact]
|
||||
public void CuttingToolbarExposesExistingActionsAndOnlyAvailablePosts() => RunSta(() =>
|
||||
{
|
||||
using var host = new TestMainForm();
|
||||
var toolbar = (ToolStrip)typeof(MainForm)
|
||||
.GetField("toolStrip1", BindingFlags.Instance | BindingFlags.NonPublic)!
|
||||
.GetValue(host)!;
|
||||
foreach (var name in new[] { "btnCutPlanner", "btnManualSequence", "btnPost" })
|
||||
{
|
||||
var item = Assert.Single(toolbar.Items.Find(name, false));
|
||||
Assert.Equal(24, item.Image!.Width);
|
||||
Assert.Equal(24, item.Image.Height);
|
||||
}
|
||||
|
||||
var post = Assert.IsType<ToolStripDropDownButton>(toolbar.Items["btnPost"]);
|
||||
var menu = Menu(host, "mnuNestPost");
|
||||
Assert.Equal(menu.Visible, post.Visible);
|
||||
Assert.Equal(menu.DropDownItems.Count, post.DropDownItems.Count);
|
||||
// Without a document these toolbar shortcuts must be harmless.
|
||||
((ToolStripButton)toolbar.Items["btnCutPlanner"]!).PerformClick();
|
||||
((ToolStripButton)toolbar.Items["btnManualSequence"]!).PerformClick();
|
||||
foreach (ToolStripMenuItem item in menu.DropDownItems)
|
||||
{
|
||||
var toolbarItem = Assert.Single(post.DropDownItems.OfType<ToolStripMenuItem>(),
|
||||
candidate => candidate.Text == item.Text);
|
||||
Assert.Same(item.Tag, toolbarItem.Tag);
|
||||
}
|
||||
});
|
||||
|
||||
[Fact]
|
||||
public void MenuFollowsActiveDocument() => RunSta(() =>
|
||||
{
|
||||
|
||||
@@ -36,6 +36,17 @@ namespace OpenNest.Forms
|
||||
private bool databaseOpenInProgress;
|
||||
private readonly ToolStripMenuItem storageModeMenu = new("Storage Mode...");
|
||||
private readonly ToolStripMenuItem exportNestMenu = new("Export .nest...");
|
||||
private readonly ToolStripDropDownButton postButton = new()
|
||||
{
|
||||
Name = "btnPost",
|
||||
Text = "Post",
|
||||
ToolTipText = "Post CNC program",
|
||||
DisplayStyle = ToolStripItemDisplayStyle.Image,
|
||||
Image = Resources.post,
|
||||
ImageScaling = ToolStripItemImageScaling.None,
|
||||
Padding = new Padding(5, 0, 5, 0),
|
||||
Visible = false,
|
||||
};
|
||||
|
||||
private const float ZoomInFactor = 1.5f;
|
||||
private const float ZoomOutFactor = 1.0f / ZoomInFactor;
|
||||
@@ -93,6 +104,11 @@ namespace OpenNest.Forms
|
||||
public MainForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
toolStrip1.Items.Add(CreateActionButton("btnCutPlanner", "Plan Cutting",
|
||||
Resources.cut_planner, PlatePlanCutting_Click));
|
||||
toolStrip1.Items.Add(CreateActionButton("btnManualSequence", "Manual Sequence",
|
||||
Resources.manual_sequence, ManualSequenceParts_Click));
|
||||
toolStrip1.Items.Add(postButton);
|
||||
storageModeMenu.Click += StorageMode_Click;
|
||||
exportNestMenu.Click += ExportNest_Click;
|
||||
mnuFile.DropDownItems.Insert(mnuFile.DropDownItems.IndexOf(mnuFileExport), exportNestMenu);
|
||||
@@ -543,6 +559,23 @@ namespace OpenNest.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private static ToolStripButton CreateActionButton(string name, string text, Image image,
|
||||
EventHandler click)
|
||||
{
|
||||
var button = new ToolStripButton
|
||||
{
|
||||
Name = name,
|
||||
Text = text,
|
||||
ToolTipText = text,
|
||||
DisplayStyle = ToolStripItemDisplayStyle.Image,
|
||||
Image = image,
|
||||
ImageScaling = ToolStripItemImageScaling.None,
|
||||
Padding = new Padding(5, 0, 5, 0),
|
||||
};
|
||||
button.Click += click;
|
||||
return button;
|
||||
}
|
||||
|
||||
private void LoadPosts()
|
||||
{
|
||||
var exepath = Assembly.GetEntryAssembly().Location;
|
||||
@@ -565,6 +598,10 @@ namespace OpenNest.Forms
|
||||
postProcessorMenuItem.Click += PostProcessor_Click;
|
||||
mnuNestPost.DropDownItems.Add(postProcessorMenuItem);
|
||||
|
||||
var toolbarPost = new ToolStripMenuItem(postProcessor.Name) { Tag = postProcessor };
|
||||
toolbarPost.Click += PostProcessor_Click;
|
||||
postButton.DropDownItems.Add(toolbarPost);
|
||||
|
||||
if (postProcessor is IMaterialProvidingPostProcessor materialProvider)
|
||||
PostProcessorMaterials.AddFrom(materialProvider);
|
||||
}
|
||||
@@ -572,6 +609,7 @@ namespace OpenNest.Forms
|
||||
}
|
||||
|
||||
mnuNestPost.Visible = mnuNestPost.DropDownItems.Count > 0;
|
||||
postButton.Visible = postButton.DropDownItems.Count > 0;
|
||||
}
|
||||
|
||||
#region Overrides
|
||||
|
||||
+21
@@ -73,6 +73,27 @@ namespace OpenNest.Properties {
|
||||
/// <summary>
|
||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap cut_planner {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("cut_planner", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap manual_sequence {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("manual_sequence", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap post {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("post", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap clear {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("clear", resourceCulture);
|
||||
|
||||
@@ -190,4 +190,13 @@
|
||||
<data name="shapes" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\shapes.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="cut_planner" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\cut_planner.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="post" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\post.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="manual_sequence" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\manual_sequence.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 908 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 989 B |
Reference in new issue
Block a user