From 5a908c7973160741c78cbaffc37b1e212a2ebb84 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 13 May 2016 11:37:22 -0700 Subject: [PATCH] Working on edit button for printer --- ActionBar/PrinterActionRow.cs | 41 +++++++++++++++++- ControlElements/TextImageButtonFactory.cs | 2 +- MatterControlApplication.cs | 27 ++++++++++++ PartPreviewWindow/View3D/View3DWidget.cs | 2 +- .../SettingsControlSelectors.cs | 4 +- .../{icon_edit_32x32.png => icon_edit.png} | Bin Submodules/agg-sharp | 2 +- 7 files changed, 71 insertions(+), 7 deletions(-) rename StaticData/Icons/{icon_edit_32x32.png => icon_edit.png} (100%) diff --git a/ActionBar/PrinterActionRow.cs b/ActionBar/PrinterActionRow.cs index b79fd220f..74c013ebc 100644 --- a/ActionBar/PrinterActionRow.cs +++ b/ActionBar/PrinterActionRow.cs @@ -152,12 +152,49 @@ namespace MatterHackers.MatterControl.ActionBar this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); - this.AddChild(selectActivePrinterButton); + + FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() + { + HAnchor = HAnchor.ParentLeftRight, + }; + printerSelectorAndEditButton.AddChild(selectActivePrinterButton); + Button editButton = TextImageButtonFactory.GetThemedEditButton(); + editButton.VAnchor = VAnchor.ParentCenter; + editButton.Click += EditButton_Click; + printerSelectorAndEditButton.AddChild(editButton); + this.AddChild(printerSelectorAndEditButton); + this.AddChild(resetConnectionButton); //this.AddChild(CreateOptionsMenu()); } - protected override void AddHandlers() + private void EditButton_Click(object sender, EventArgs e) + { + Button editButton = sender as Button; + if (editButton != null) + { + editButton.Closed += (s, e2) => + { + editButton.Click -= EditButton_Click; + }; + + Task.Run((Action)AutomationTest); + } + } + + private void AutomationTest() + { + AutomationRunner test = new AutomationRunner("C:/TestImages"); + test.Wait(2); + test.ClickByName("SettingsAndControls"); + test.Wait(2); + test.ClickImage("BackButton.png"); + + //ImageIO.SaveImageData("test.png", test.GetCurrentScreen()); + } + + + protected override void AddHandlers() { ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); diff --git a/ControlElements/TextImageButtonFactory.cs b/ControlElements/TextImageButtonFactory.cs index eb9c15cf1..e79469087 100644 --- a/ControlElements/TextImageButtonFactory.cs +++ b/ControlElements/TextImageButtonFactory.cs @@ -228,7 +228,7 @@ namespace MatterHackers.MatterControl public static Button GetThemedEditButton() { - ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit_32x32.png", 16, 16); + ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit.png", 16, 16); Button editButton; if (ActiveTheme.Instance.IsDarkTheme) diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index 6bfc226fb..e866bf164 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -590,6 +590,7 @@ namespace MatterHackers.MatterControl if (firstDraw) { + DrawAfter += ShowNamesUnderMouse; firstDraw = false; foreach (string arg in commandLineArgs) { @@ -757,6 +758,32 @@ namespace MatterHackers.MatterControl #endif } + bool showNamesUnderMouse = false; + public override void OnKeyDown(KeyEventArgs keyEvent) + { + if (keyEvent.KeyCode == Keys.F2) + { + Task.Run((Action)AutomationTest); + } + else if (keyEvent.KeyCode == Keys.F1) + { + showNamesUnderMouse = !showNamesUnderMouse; + } + + base.OnKeyDown(keyEvent); + } + + private void AutomationTest() + { + AutomationRunner test = new AutomationRunner(); + test.ClickByName("Library Tab", 5); + test.ClickByName("Queue Tab", 5); + test.ClickByName("Queue Item SkeletonArm_Med", 5); + test.ClickByName("3D View Edit", 5); + test.Wait(.2); + test.DragByName("SkeletonArm_Med_IObject3D", 5); + test.DropByName("SkeletonArm_Med_IObject3D", 5, offset: new Point2D(0, -40)); + } public static void CheckKnownAssemblyConditionalCompSymbols() { MatterControlApplication.AssertDebugNotDefined(); diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 52fbb6eb5..cc3f06cf4 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -212,7 +212,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow addButton.Enabled = false; } - ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit_32x32.png", 14, 14); + ImageBuffer normalImage = StaticData.Instance.LoadIcon("icon_edit.png", 14, 14); if (!ActiveTheme.Instance.IsDarkTheme) { diff --git a/SlicerConfiguration/SettingsControlSelectors.cs b/SlicerConfiguration/SettingsControlSelectors.cs index e7df459c2..481f25de4 100644 --- a/SlicerConfiguration/SettingsControlSelectors.cs +++ b/SlicerConfiguration/SettingsControlSelectors.cs @@ -93,7 +93,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration editButton = TextImageButtonFactory.GetThemedEditButton(); editButton.VAnchor = VAnchor.ParentCenter; - editButton.Margin = new BorderDouble(right: 6); + editButton.Margin = new BorderDouble(left: 6); editButton.Click += (sender, e) => { if (layerType == NamedSettingsLayers.Material) @@ -145,8 +145,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } }; - container.AddChild(editButton); container.AddChild(dropDownList); + container.AddChild(editButton); return container; } diff --git a/StaticData/Icons/icon_edit_32x32.png b/StaticData/Icons/icon_edit.png similarity index 100% rename from StaticData/Icons/icon_edit_32x32.png rename to StaticData/Icons/icon_edit.png diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 8ef10cd1b..1cefd7402 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 8ef10cd1bc7fd51122ee3c518f0a20a375ab82a9 +Subproject commit 1cefd740213b2b8e071c579e45546d7fcbdabe8a