From 3307e204ee485c35d43ac3ee0d96aafb6f2bec97 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 16 Jul 2022 07:46:44 -0700 Subject: [PATCH 01/15] All buttons switch to agg themed buttons --- .../ActionBar/TemperatureWidgetExtruder.cs | 2 +- .../ApplicationView/Application.cs | 2 +- .../ApplicationView/BrandMenuButton.cs | 2 +- .../Themes/ThemeConfigExtensions.cs | 22 +- .../SetupWizards/LoadFilamentWizard.cs | 2 +- .../SetupWizards/UnloadFilamentWizard.cs | 2 +- .../WizardPages/SelectMaterialPage.cs | 5 +- .../PrintLeveling/WizardPages/WizardPage.cs | 2 +- .../CustomWidgets/CalibrationTabWidget.cs | 2 +- .../CustomWidgets/DockingTabControl.cs | 2 +- .../CustomWidgets/HelpArticleHeader.cs | 2 +- .../CustomWidgets/InlineListItemEdit.cs | 2 +- .../CustomWidgets/InlineStringEdit.cs | 4 +- .../LibrarySelector/FolderBreadCrumbWidget.cs | 2 +- .../CustomWidgets/SimpleButton.cs | 665 ------------------ .../CustomWidgets/TreeView/TreeNode.cs | 4 +- .../DesignTools/OpenSCAD/OpenSCADBuilder.cs | 4 +- .../DesignTools/PublicPropertyEditor.cs | 12 +- MatterControlLib/DialogPages/AboutPage.cs | 2 +- MatterControlLib/DialogPages/StartupPage.cs | 8 +- .../DialogPages/UpdateControlView.cs | 6 +- .../Library/Widgets/CloneSettingsPage.cs | 2 +- .../Library/Widgets/ExpandCheckboxButton.cs | 4 +- .../Widgets/HardwarePage/PrinterDetails.cs | 2 +- .../Library/Widgets/HardwareTreeView.cs | 6 +- .../Library/Widgets/LibraryWidget.cs | 2 +- .../Library/Widgets/PrintLibraryWidget.cs | 4 +- .../Widgets/StorePage/ArticleSection.cs | 2 +- .../Library/Widgets/StorePage/ExplorePanel.cs | 4 +- .../Widgets/StorePage/ProductSection.cs | 2 +- .../PartPreviewWindow/DesignTabPage.cs | 2 +- .../PartPreviewWindow/DropButton.cs | 2 +- .../GCodeDetails/GCodeOptionsPanel.cs | 12 +- .../PartPreviewWindow/GCodePanel.cs | 2 +- .../PartPreviewWindow/ItemColorButton.cs | 4 +- .../PartPreviewWindow/MainViewWidget.cs | 4 +- .../PartPreviewWindow/NewTabButton.cs | 4 +- .../PartPreviewWindow/OperationIconButton.cs | 2 +- .../PartPreviewWindow/PopupMenuButton.cs | 6 +- .../PartPreviewWindow/PrinterTabPage.cs | 12 +- .../PartPreviewWindow/RenderOptionsButton.cs | 2 +- .../PartPreviewWindow/RunningTaskRow.cs | 6 +- .../PartPreviewWindow/SaveAsPage.cs | 4 +- .../PartPreviewWindow/SelectedObjectPanel.cs | 12 +- .../View3D/ColorSwatchSelector.cs | 2 +- .../View3D/GridOptionsPanel.cs | 2 +- .../View3D/PrinterBar/ExportSlaPopupMenu.cs | 2 +- .../View3D/PrinterBar/OverflowBar.cs | 10 +- .../View3D/PrinterBar/PrintPopupMenu.cs | 4 +- .../View3D/PrinterBar/PrinterActionsBar.cs | 20 +- .../View3D/PrinterBar/PrinterConnectButton.cs | 6 +- .../View3D/PrinterBar/SliceButton.cs | 2 +- .../PrinterBar/ValidationErrorsPanel.cs | 2 +- .../PrinterBar/WidgetAnimationExtensions.cs | 2 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 32 +- .../PartPreviewWindow/ViewStyleButton.cs | 4 +- .../PartPreviewWindow/ViewToolBarControls.cs | 22 +- .../ControlWidgets/CalibrationControls.cs | 2 +- .../ControlWidgets/MacroControls.cs | 4 +- .../ControlWidgets/MovementControls.cs | 14 +- .../PrinterCalibrationWizard.cs | 4 +- .../ControlWidgets/TemperatureControls.cs | 8 +- .../PrinterControls/JogControls.cs | 6 +- .../ApplicationSettingsPage.cs | 10 +- .../SettingsManagement/UpdateSettingsPage.cs | 2 +- MatterControlLib/SetupWizard/DialogPage.cs | 2 +- MatterControlLib/SetupWizard/HelpTreePanel.cs | 2 +- .../SetupWizard/Printer/OpenPrinterPage.cs | 4 +- MatterControlLib/SetupWizard/TourPopover.cs | 2 +- .../PresetSelectorWidget.cs | 2 +- .../SliceSettingsWidget.cs | 2 +- .../UIFields/ComPortField.cs | 2 +- .../UIFields/EnumDisplayField.cs | 18 +- .../UIFields/IpAddessField.cs | 4 +- .../UIFields/ListStringField.cs | 2 +- .../UIFields/MarkdownEditField.cs | 2 +- StaticData/Translations/Master.txt | 3 + Submodules/agg-sharp | 2 +- .../MatterControl/PopupAnchorTests.cs | 36 +- 79 files changed, 218 insertions(+), 881 deletions(-) delete mode 100644 MatterControlLib/CustomWidgets/SimpleButton.cs diff --git a/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs b/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs index e109885e3..889937d68 100644 --- a/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs +++ b/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs @@ -381,7 +381,7 @@ namespace MatterHackers.MatterControl.ActionBar // material can be changed even when the printer is not connected alwaysEnabled.Add(materialSettingsRow); // add in a shop button - var shopButton = new TextIconButton("Shop".Localize(), StaticData.Instance.LoadIcon("cart.png", 16, 16).SetToColor(menuTheme.TextColor), theme) + var shopButton = new ThemedTextIconButton("Shop".Localize(), StaticData.Instance.LoadIcon("cart.png", 16, 16).SetToColor(menuTheme.TextColor), theme) { BackgroundColor = theme.SlightShade, HoverColor = theme.SlightShade.WithAlpha(75), diff --git a/MatterControlLib/ApplicationView/Application.cs b/MatterControlLib/ApplicationView/Application.cs index 912378e6f..47eb47d80 100644 --- a/MatterControlLib/ApplicationView/Application.cs +++ b/MatterControlLib/ApplicationView/Application.cs @@ -505,7 +505,7 @@ namespace MatterHackers.MatterControl progressPanel.AddChild( new TextWidget(ex.Message, pointSize: theme.FontSize9, textColor: errorTextColor)); - var closeButton = new TextButton("Close", theme) + var closeButton = new ThemedTextButton("Close", theme) { BackgroundColor = theme.SlightShade, HAnchor = HAnchor.Right, diff --git a/MatterControlLib/ApplicationView/BrandMenuButton.cs b/MatterControlLib/ApplicationView/BrandMenuButton.cs index e4a3edaca..bd384ac61 100644 --- a/MatterControlLib/ApplicationView/BrandMenuButton.cs +++ b/MatterControlLib/ApplicationView/BrandMenuButton.cs @@ -62,7 +62,7 @@ namespace MatterHackers.MatterControl }; this.AddChild(row); - row.AddChild(new IconButton(StaticData.Instance.LoadIcon("mh-app-logo.png", 16, 16).SetToColor(theme.TextColor), theme) + row.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("mh-app-logo.png", 16, 16).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, diff --git a/MatterControlLib/ApplicationView/Themes/ThemeConfigExtensions.cs b/MatterControlLib/ApplicationView/Themes/ThemeConfigExtensions.cs index 44b0072c8..7b752b273 100644 --- a/MatterControlLib/ApplicationView/Themes/ThemeConfigExtensions.cs +++ b/MatterControlLib/ApplicationView/Themes/ThemeConfigExtensions.cs @@ -90,11 +90,11 @@ namespace MatterHackers.MatterControl menuButton.HoverColor = hoverColor; break; - case SimpleFlowButton flowButton: + case ThemedFlowButton flowButton: flowButton.HoverColor = hoverColor; break; - case SimpleButton button: + case ThemedButton button: button.HoverColor = hoverColor; break; } @@ -161,7 +161,7 @@ namespace MatterHackers.MatterControl foreach (var actionButton in namedActionButtons.Group) { - var button = new TextButton(actionButton.Title, theme) + var button = new ThemedTextButton(actionButton.Title, theme) { Border = new BorderDouble(1, 0, 0, 0), BorderColor = theme.MinimalShade, @@ -227,9 +227,9 @@ namespace MatterHackers.MatterControl return popupMenu; } - public static RadioTextButton CreateMicroRadioButton(this ThemeConfig theme, string text, IList siblingRadioButtonList = null) + public static ThemedRadioTextButton CreateMicroRadioButton(this ThemeConfig theme, string text, IList siblingRadioButtonList = null) { - var radioButton = new RadioTextButton(text, theme, theme.FontSize8) + var radioButton = new ThemedRadioTextButton(text, theme, theme.FontSize8) { SiblingRadioButtonList = siblingRadioButtonList, Padding = new BorderDouble(5, 0), @@ -266,7 +266,7 @@ namespace MatterHackers.MatterControl public static GuiWidget CreateSearchButton(this ThemeConfig theme) { - return new IconButton(StaticData.Instance.LoadIcon("icon_search_24x24.png", 16, 16).SetToColor(theme.TextColor), theme) + return new ThemedIconButton(StaticData.Instance.LoadIcon("icon_search_24x24.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Search".Localize(), }; @@ -288,7 +288,7 @@ namespace MatterHackers.MatterControl GuiWidget innerButton; if (buttonParams.ButtonText == null) { - innerButton = new IconButton(buttonParams.Icon, theme) + innerButton = new ThemedIconButton(buttonParams.Icon, theme) { Name = buttonParams.ButtonName + " Inner SplitButton", Enabled = buttonParams.ButtonEnabled, @@ -302,7 +302,7 @@ namespace MatterHackers.MatterControl { if (buttonParams.Icon == null) { - innerButton = new TextButton(buttonParams.ButtonText, theme) + innerButton = new ThemedTextButton(buttonParams.ButtonText, theme) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, @@ -311,7 +311,7 @@ namespace MatterHackers.MatterControl } else { - innerButton = new TextIconButton(buttonParams.ButtonText, buttonParams.Icon, theme) + innerButton = new ThemedTextIconButton(buttonParams.ButtonText, buttonParams.Icon, theme) { Name = buttonParams.ButtonName, Enabled = buttonParams.ButtonEnabled, @@ -375,11 +375,11 @@ namespace MatterHackers.MatterControl switch (guiWidget) { - case SimpleFlowButton flowButton: + case ThemedFlowButton flowButton: flowButton.HoverColor = parentIsToolbar ? theme.ToolbarButtonHover : Color.Transparent; break; - case SimpleButton button: + case ThemedButton button: button.HoverColor = parentIsToolbar ? theme.ToolbarButtonHover : Color.Transparent; break; } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/LoadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/LoadFilamentWizard.cs index 007108bc6..5e945bdc3 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/LoadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/LoadFilamentWizard.cs @@ -425,7 +425,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling if (printer.Connection.Paused) { - var resumePrintingButton = new TextButton("Resume Printing".Localize(), theme) + var resumePrintingButton = new ThemedTextButton("Resume Printing".Localize(), theme) { Name = "Resume Printing Button", BackgroundColor = theme.MinimalShade, diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/UnloadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/UnloadFilamentWizard.cs index cccd079e0..5abc7c28e 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/UnloadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/UnloadFilamentWizard.cs @@ -237,7 +237,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling public DoneUnloadingPage(PrinterSetupWizard setupWizard, int extruderIndex) : base(setupWizard, "Filament Unloaded".Localize(), "Success!\n\nYour filament should now be unloaded".Localize()) { - var loadFilamentButton = new TextButton("Load Filament".Localize(), theme) + var loadFilamentButton = new ThemedTextButton("Load Filament".Localize(), theme) { Name = "Load Filament", BackgroundColor = theme.MinimalShade, diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs index ec5694b03..646d9a78d 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs @@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project. */ using MatterHackers.Agg; +using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.ActionBar; using MatterHackers.MatterControl.CustomWidgets; @@ -64,7 +65,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { NextButton.Visible = false; - var loadFilamentButton = new TextButton("Load Filament".Localize(), theme) + var loadFilamentButton = new ThemedTextButton("Load Filament".Localize(), theme) { Name = "Load Filament", BackgroundColor = theme.MinimalShade, @@ -86,7 +87,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { NextButton.Visible = false; - var alreadyLoadedButton = new TextButton("Already Loaded".Localize(), theme) + var alreadyLoadedButton = new ThemedTextButton("Already Loaded".Localize(), theme) { Name = "Already Loaded Button", BackgroundColor = theme.MinimalShade diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs index 54250ff63..a20553bb3 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WizardPage.cs @@ -148,7 +148,7 @@ namespace MatterHackers.MatterControl public void ShowWizardFinished(Action doneClicked = null) { - var doneButton = new TextButton("Done".Localize(), theme) + var doneButton = new ThemedTextButton("Done".Localize(), theme) { Name = "Done Button", BackgroundColor = theme.MinimalShade diff --git a/MatterControlLib/CustomWidgets/CalibrationTabWidget.cs b/MatterControlLib/CustomWidgets/CalibrationTabWidget.cs index 087ce7e40..91c7b62c7 100644 --- a/MatterControlLib/CustomWidgets/CalibrationTabWidget.cs +++ b/MatterControlLib/CustomWidgets/CalibrationTabWidget.cs @@ -312,7 +312,7 @@ namespace MatterHackers.MatterControl base.OnDraw(graphics2D); } - private class CalibrationPad : IconButton + private class CalibrationPad : ThemedIconButton { public event EventHandler Hovered; diff --git a/MatterControlLib/CustomWidgets/DockingTabControl.cs b/MatterControlLib/CustomWidgets/DockingTabControl.cs index 5b11b3f31..a015d62aa 100644 --- a/MatterControlLib/CustomWidgets/DockingTabControl.cs +++ b/MatterControlLib/CustomWidgets/DockingTabControl.cs @@ -167,7 +167,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { string imageFile = this.ControlIsPinned ? "Pushpin.png" : "PushpinUnpin.png"; - var pinTabButton = new IconButton(StaticData.Instance.LoadIcon(imageFile, 16, 16).SetToColor(theme.TextColor), theme) + var pinTabButton = new ThemedIconButton(StaticData.Instance.LoadIcon(imageFile, 16, 16).SetToColor(theme.TextColor), theme) { Name = "Pin Settings Button", ToolTipText = this.ControlIsPinned ? "Unpin".Localize() : "Pin".Localize() diff --git a/MatterControlLib/CustomWidgets/HelpArticleHeader.cs b/MatterControlLib/CustomWidgets/HelpArticleHeader.cs index 3cd719d51..161081510 100644 --- a/MatterControlLib/CustomWidgets/HelpArticleHeader.cs +++ b/MatterControlLib/CustomWidgets/HelpArticleHeader.cs @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.ActionArea.VAnchor = VAnchor.Stretch; this.ActionArea.MinimumSize = new Vector2(0, titleText.Height); - var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) + var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = editToolTipText ?? "Edit".Localize(), Name = helpArticle.Name + " Edit" diff --git a/MatterControlLib/CustomWidgets/InlineListItemEdit.cs b/MatterControlLib/CustomWidgets/InlineListItemEdit.cs index bb6881670..f91398f87 100644 --- a/MatterControlLib/CustomWidgets/InlineListItemEdit.cs +++ b/MatterControlLib/CustomWidgets/InlineListItemEdit.cs @@ -43,7 +43,7 @@ namespace MatterHackers.MatterControl.CustomWidgets public InlineListItemEdit(string title, ThemeConfig theme, string automationName, bool boldFont = false) : base(title, theme, automationName, boldFont) { - var removeButton = new IconButton(StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor), theme) + var removeButton = new ThemedIconButton(StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Delete".Localize(), Visible = true, diff --git a/MatterControlLib/CustomWidgets/InlineStringEdit.cs b/MatterControlLib/CustomWidgets/InlineStringEdit.cs index 6bb1236b0..6fbba2868 100644 --- a/MatterControlLib/CustomWidgets/InlineStringEdit.cs +++ b/MatterControlLib/CustomWidgets/InlineStringEdit.cs @@ -73,7 +73,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.ActionArea.VAnchor = VAnchor.Stretch; this.ActionArea.MinimumSize = new Vector2(0, titleText.Height); - saveButton = new IconButton(StaticData.Instance.LoadIcon("fa-save_16.png", 16, 16).SetToColor(theme.TextColor), theme) + saveButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-save_16.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Save".Localize(), Visible = false, @@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.CustomWidgets var icon = editable ? StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor) : new ImageBuffer(16, 16); - editButton = new IconButton(icon, theme) + editButton = new ThemedIconButton(icon, theme) { ToolTipText = "Edit".Localize(), Name = automationName + " Edit", diff --git a/MatterControlLib/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs b/MatterControlLib/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs index 2260d83de..db763f672 100644 --- a/MatterControlLib/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs +++ b/MatterControlLib/CustomWidgets/LibrarySelector/FolderBreadCrumbWidget.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { this.CloseChildren(); - var backButton = new IconButton(StaticData.Instance.LoadIcon(Path.Combine("Library", "back.png"), 20, 20).SetToColor(theme.TextColor), theme) + var backButton = new ThemedIconButton(StaticData.Instance.LoadIcon(Path.Combine("Library", "back.png"), 20, 20).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Fit | VAnchor.Center, Enabled = currentContainer.Parent != null, diff --git a/MatterControlLib/CustomWidgets/SimpleButton.cs b/MatterControlLib/CustomWidgets/SimpleButton.cs deleted file mode 100644 index 23e321e2f..000000000 --- a/MatterControlLib/CustomWidgets/SimpleButton.cs +++ /dev/null @@ -1,665 +0,0 @@ -/* -Copyright (c) 2019, John Lewin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, -either expressed or implied, of the FreeBSD Project. -*/ - -using System; -using System.Collections.Generic; -using MatterHackers.Agg; -using MatterHackers.Agg.Image; -using MatterHackers.Agg.UI; -using MatterHackers.Agg.VertexSource; -using MatterHackers.ImageProcessing; -using MatterHackers.VectorMath; - -namespace MatterHackers.MatterControl.CustomWidgets -{ - public class SimpleButton : GuiWidget - { - protected ThemeConfig theme; - - private bool hasKeyboardFocus; - - public SimpleButton(ThemeConfig theme) - { - this.theme = theme; - this.HoverColor = theme.SlightShade; - this.MouseDownColor = theme.MinimalShade; - this.Margin = 0; - this.Cursor = Cursors.Hand; - - this.TabStop = true; - } - - public Color HoverColor { get; set; } = Color.Transparent; - - public Color MouseDownColor { get; set; } = Color.Transparent; - - public override void OnMouseDown(MouseEventArgs mouseEvent) - { - base.OnMouseDown(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseUp(MouseEventArgs mouseEvent) - { - base.OnMouseUp(mouseEvent); - this.Invalidate(); - } - - protected override void OnClick(MouseEventArgs mouseEvent) - { - if (mouseEvent.Button == MouseButtons.Left) - { - base.OnClick(mouseEvent); - } - } - - public override void OnKeyUp(KeyEventArgs keyEvent) - { - if (keyEvent.KeyCode == Keys.Enter - || keyEvent.KeyCode == Keys.Space) - { - UiThread.RunOnIdle(this.InvokeClick); - } - - base.OnKeyUp(keyEvent); - } - - public override void OnMouseEnterBounds(MouseEventArgs mouseEvent) - { - Invalidate(); - base.OnMouseEnterBounds(mouseEvent); - } - - public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent) - { - Invalidate(); - base.OnMouseLeaveBounds(mouseEvent); - } - - public override Color BackgroundColor - { - get - { - var firstWidgetUnderMouse = ContainsFirstUnderMouseRecursive(); - if (this.MouseCaptured - && firstWidgetUnderMouse - && this.Enabled) - { - return this.MouseDownColor; - } - else if (firstWidgetUnderMouse - && this.Enabled) - { - return this.HoverColor; - } - else - { - return base.BackgroundColor; - } - } - set => base.BackgroundColor = value; - } - - public override void OnFocusChanged(EventArgs e) - { - hasKeyboardFocus = this.Focused && !ContainsFirstUnderMouseRecursive(); - this.Invalidate(); - - base.OnFocusChanged(e); - } - - public override void OnDraw(Graphics2D graphics2D) - { - base.OnDraw(graphics2D); - - if (this.TabStop - && hasKeyboardFocus) - { - var bounds = this.LocalBounds; - var stroke = 1 * GuiWidget.DeviceScale; - var expand = stroke / 2; - var rect = new RoundedRect(bounds.Left + expand, - bounds.Bottom + expand, - bounds.Right - expand, - bounds.Top - expand); - rect.radius(BackgroundRadius.SW, - BackgroundRadius.SE, - BackgroundRadius.NE, - BackgroundRadius.NW); - - var rectOutline = new Stroke(rect, stroke); - - graphics2D.Render(rectOutline, theme.EditFieldColors.Focused.BorderColor); - } - } - } - - public class SimpleFlowButton : FlowLayoutWidget - { - private bool mouseInBounds = false; - - protected ThemeConfig theme; - - public SimpleFlowButton(ThemeConfig theme) - { - this.theme = theme; - this.HoverColor = theme.SlightShade; - this.MouseDownColor = theme.MinimalShade; - this.Margin = 0; - } - - public Color HoverColor { get; set; } = Color.Transparent; - - public Color MouseDownColor { get; set; } = Color.Transparent; - - public override void OnMouseEnterBounds(MouseEventArgs mouseEvent) - { - mouseInBounds = true; - base.OnMouseEnterBounds(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent) - { - mouseInBounds = false; - base.OnMouseLeaveBounds(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseDown(MouseEventArgs mouseEvent) - { - base.OnMouseDown(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseUp(MouseEventArgs mouseEvent) - { - base.OnMouseUp(mouseEvent); - this.Invalidate(); - } - - public override Color BackgroundColor - { - get - { - if (this.MouseCaptured - && mouseInBounds - && this.Enabled) - { - return this.MouseDownColor; - } - else if (mouseInBounds - && this.Enabled) - { - return this.HoverColor; - } - else - { - return base.BackgroundColor; - } - } - set => base.BackgroundColor = value; - } - } - - public class IconButton : SimpleButton - { - protected ImageWidget imageWidget; - - protected ImageBuffer image; - - private IconButton(ThemeConfig theme) - : base(theme) - { - } - - public IconButton(ImageBuffer icon, ThemeConfig theme) - : base(theme) - { - image = icon; - this.HAnchor = HAnchor.Absolute; - this.VAnchor = VAnchor.Absolute | VAnchor.Center; - this.Height = theme.ButtonHeight; - this.Width = theme.ButtonHeight; - this.BackgroundRadius = theme.ButtonRadius * GuiWidget.DeviceScale; - - imageWidget = new ImageWidget(icon, listenForImageChanged: false) - { - HAnchor = HAnchor.Center, - VAnchor = VAnchor.Center, - Selectable = false - }; - - this.AddChild(imageWidget); - } - - public ImageBuffer IconImage => this.Enabled ? image : this.DisabledImage; - - internal void SetIcon(ImageBuffer icon) - { - image = icon; - imageWidget.Image = icon; - _disabledImage = null; - } - - private ImageBuffer _disabledImage; - - public ImageBuffer DisabledImage - { - get - { - // Lazy construct on first access - if (_disabledImage == null) - { - _disabledImage = image.AjustAlpha(0.2); - } - - return _disabledImage; - } - } - - public override void OnEnabledChanged(EventArgs e) - { - imageWidget.Image = this.Enabled ? image : this.DisabledImage; - this.Invalidate(); - - base.OnEnabledChanged(e); - } - } - - public class RadioIconButton : IconButton, IRadioButton - { - public IList SiblingRadioButtonList { get; set; } - - public event EventHandler CheckedStateChanged; - - public bool ToggleButton { get; set; } = false; - - public RadioIconButton(ImageBuffer icon, ThemeConfig theme) - : base(icon, theme) - { - } - - protected override void OnClick(MouseEventArgs mouseEvent) - { - base.OnClick(mouseEvent); - - bool newValue = this.ToggleButton ? !this.Checked : true; - - bool checkStateChanged = newValue != this.Checked; - - this.Checked = newValue; - - // After setting CheckedState, fire event if different - if (checkStateChanged) - { - OnCheckStateChanged(); - } - } - - private bool _checked; - - public bool Checked - { - get => _checked; - set - { - if (_checked != value) - { - _checked = value; - if (_checked) - { - this.UncheckSiblings(); - } - - this.BackgroundColor = _checked ? theme.MinimalShade : Color.Transparent; - - Invalidate(); - } - } - } - - public virtual void OnCheckStateChanged() - { - CheckedStateChanged?.Invoke(this, null); - } - - public override void OnDraw(Graphics2D graphics2D) - { - if (this.Checked) - { - if (BackgroundRadius.SW + BackgroundRadius.NW == Width) - { - void Render(double startRatio) - { - var stroke = 4 * GuiWidget.DeviceScale; - var angle = MathHelper.Tau / 4; - var start = MathHelper.Tau * startRatio - angle / 2; - var end = MathHelper.Tau * startRatio + angle / 2; - var arc = new Arc(Width / 2, Height / 2, Width / 2 - stroke / 2, Height / 2 - stroke / 2, start, end); - var background = new Stroke(arc, stroke); - graphics2D.Render(background, theme.PrimaryAccentColor.WithAlpha(100)); - } - - Render(1.0 / 3.0 + .75); - Render(2.0 / 3.0 + .75); - Render(1.0 + .75); - } - else - { - graphics2D.Rectangle(0, 0, LocalBounds.Right, 2 * DeviceScale, theme.PrimaryAccentColor); - } - } - - base.OnDraw(graphics2D); - } - } - - public class RadioTextButton : TextButton, IRadioButton - { - public IList SiblingRadioButtonList { get; set; } - - public event EventHandler CheckedStateChanged; - - public RadioTextButton(string text, ThemeConfig theme, double pointSize = -1) - : base(text, theme, pointSize) - { - this.SelectedBackgroundColor = theme.SlightShade; - } - - public override Color BackgroundColor - { - get - { - var firstWidgetUnderMouse = ContainsFirstUnderMouseRecursive(); - if (this.MouseCaptured - && firstWidgetUnderMouse - && this.Enabled) - { - if (Checked) - { - return SelectedBackgroundColor.AdjustLightness(.9).ToColor(); - } - - return this.MouseDownColor; - } - else if (firstWidgetUnderMouse - && this.Enabled) - { - if (Checked) - { - return SelectedBackgroundColor.AdjustLightness(.8).ToColor(); - } - - return this.HoverColor; - } - else - { - return base.BackgroundColor; - } - } - set => base.BackgroundColor = value; - } - - protected override void OnClick(MouseEventArgs mouseEvent) - { - base.OnClick(mouseEvent); - - bool newValue = true; - - bool checkStateChanged = newValue != this.Checked; - - this.Checked = newValue; - - // After setting CheckedState, fire event if different - if (checkStateChanged) - { - OnCheckStateChanged(); - } - } - - public Color SelectedBackgroundColor { get; set; } - - public Color UnselectedBackgroundColor { get; set; } - - private bool _checked; - - public bool Checked - { - get => _checked; - set - { - if (_checked != value) - { - _checked = value; - if (_checked) - { - this.UncheckSiblings(); - } - - OnCheckStateChanged(); - } - - this.BackgroundColor = _checked ? this.SelectedBackgroundColor : this.UnselectedBackgroundColor; - } - } - - public bool DrawUnderline { get; set; } = true; - - public override void OnMouseEnterBounds(MouseEventArgs mouseEvent) - { - base.OnMouseEnterBounds(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent) - { - base.OnMouseLeaveBounds(mouseEvent); - this.Invalidate(); - } - - public virtual void OnCheckStateChanged() - { - CheckedStateChanged?.Invoke(this, null); - } - - public override void OnDraw(Graphics2D graphics2D) - { - if (this.Checked && DrawUnderline) - { - graphics2D.Rectangle(LocalBounds.Left, 0, LocalBounds.Right, 2, theme.PrimaryAccentColor); - } - - base.OnDraw(graphics2D); - } - } - - public class TextButton : SimpleButton - { - private readonly TextWidget textWidget; - - public TextButton(string text, ThemeConfig theme, double pointSize = -1) - : base(theme) - { - this.HAnchor = HAnchor.Fit; - this.VAnchor = VAnchor.Absolute | VAnchor.Center; - this.Height = theme.ButtonHeight; - this.Padding = theme.TextButtonPadding; - this.TabStop = true; - - this.BackgroundRadius = theme.ButtonRadius * GuiWidget.DeviceScale; - - var textSize = (pointSize != -1) ? pointSize : theme.DefaultFontSize; - - this.AddChild(textWidget = new TextWidget(text, pointSize: textSize, textColor: theme.TextColor) - { - HAnchor = HAnchor.Center, - VAnchor = VAnchor.Center, - AutoExpandBoundsToText = true - }); - } - - public Color TextColor - { - get => textWidget.TextColor; - set => textWidget.TextColor = value; - } - - public override string Text - { - get => textWidget.Text; - set => textWidget.Text = value; - } - - public override bool Enabled - { - get => base.Enabled; - set - { - base.Enabled = value; - textWidget.Enabled = value; - } - } - } - - public class TextIconButton : SimpleFlowButton - { - private TextWidget textWidget; - - public bool DrawIconOverlayOnDisabled { get; set; } = false; - - public TextIconButton(string text, ImageBuffer icon, ThemeConfig theme) - : base(theme) - { - this.HAnchor = HAnchor.Fit; - this.VAnchor = VAnchor.Absolute | VAnchor.Center; - this.Height = theme.ButtonHeight; - this.Padding = theme.TextButtonPadding; - - this.BackgroundRadius = theme.ButtonRadius * GuiWidget.DeviceScale; - - this.AddChild(ImageWidget = new ImageWidget(icon) - { - VAnchor = VAnchor.Center, - Selectable = false - }); - - // TODO: Only needed because TextWidget violates normal padding/margin rules - var textContainer = new GuiWidget() - { - Padding = new BorderDouble(8, 4, 2, 4), - HAnchor = HAnchor.Fit, - VAnchor = VAnchor.Center | VAnchor.Fit, - Selectable = false - }; - this.AddChild(textContainer); - - textContainer.AddChild(textWidget = new TextWidget(text, pointSize: theme.DefaultFontSize, textColor: theme.TextColor)); - } - - public override void OnDraw(Graphics2D graphics2D) - { - base.OnDraw(graphics2D); - - // now draw an overlay on the image if it is disabled - if (DrawIconOverlayOnDisabled && !ImageWidget.Enabled) - { - graphics2D.Render(new RoundedRect(ImageWidget.TransformToParentSpace(this, ImageWidget.LocalBounds), 0), - theme.BackgroundColor.WithAlpha(200)); - } - } - - public void SetIcon(ImageBuffer imageBuffer) - { - ImageWidget.Image = imageBuffer; - } - - public ImageWidget ImageWidget { get; } - - public override string Text { get => textWidget.Text; set => textWidget.Text = value; } - } - - public class HoverIconButton : IconButton - { - private ImageBuffer normalImage; - - private ImageBuffer hoverImage; - - // Single ImageBuffer constructor creates a grayscale copy for use as the normal image - // and uses the original as the hover image - public HoverIconButton(ImageBuffer icon, ThemeConfig theme) - : this(MakeGrayscale(icon), icon, theme) - { - } - - public HoverIconButton(ImageBuffer icon, ImageBuffer hoverIcon, ThemeConfig theme) - : base(icon, theme) - { - normalImage = icon; - hoverImage = hoverIcon; - - this.HAnchor = HAnchor.Absolute; - this.VAnchor = VAnchor.Absolute | VAnchor.Center; - this.Height = theme.ButtonHeight; - this.Width = theme.ButtonHeight; - - imageWidget = new ImageWidget(icon, listenForImageChanged: false) - { - HAnchor = HAnchor.Center, - VAnchor = VAnchor.Center, - }; - - this.AddChild(imageWidget); - } - - public static ImageBuffer MakeGrayscale(ImageBuffer icon) - { - var hoverIcon = new ImageBuffer(icon); - ApplicationController.Instance.MakeGrayscale(hoverIcon); - - return hoverIcon; - } - - public override void OnMouseEnterBounds(MouseEventArgs mouseEvent) - { - imageWidget.Image = hoverImage; - - base.OnMouseEnterBounds(mouseEvent); - this.Invalidate(); - } - - public override void OnMouseLeaveBounds(MouseEventArgs mouseEvent) - { - imageWidget.Image = normalImage; - - base.OnMouseLeaveBounds(mouseEvent); - this.Invalidate(); - } - } -} \ No newline at end of file diff --git a/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs b/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs index 403379511..16ad9f4c8 100644 --- a/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs +++ b/MatterControlLib/CustomWidgets/TreeView/TreeNode.cs @@ -522,7 +522,7 @@ namespace MatterHackers.MatterControl.CustomWidgets private readonly ImageBuffer arrowRight; private readonly ImageBuffer arrowDown; private readonly ImageBuffer placeholder; - private readonly IconButton imageButton = null; + private readonly ThemedIconButton imageButton = null; public TreeExpandWidget(ThemeConfig theme) { @@ -532,7 +532,7 @@ namespace MatterHackers.MatterControl.CustomWidgets this.Margin = new BorderDouble(right: 4); - imageButton = new IconButton(placeholder, theme) + imageButton = new ThemedIconButton(placeholder, theme) { MinimumSize = new Vector2(16 * DeviceScale, 16 * DeviceScale), VAnchor = VAnchor.Center, diff --git a/MatterControlLib/DesignTools/OpenSCAD/OpenSCADBuilder.cs b/MatterControlLib/DesignTools/OpenSCAD/OpenSCADBuilder.cs index 9d45a8b4b..ee0e15dc8 100644 --- a/MatterControlLib/DesignTools/OpenSCAD/OpenSCADBuilder.cs +++ b/MatterControlLib/DesignTools/OpenSCAD/OpenSCADBuilder.cs @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.Library } else { - var editButton = new TextButton("Edit".Localize(), theme) + var editButton = new ThemedTextButton("Edit".Localize(), theme) { Margin = 5, ToolTipText = "Edit OpenSCAD script".Localize() @@ -118,7 +118,7 @@ namespace MatterHackers.MatterControl.Library }; actionButtons.AddChild(editButton); - var updateButton = new TextButton("Update".Localize(), theme) + var updateButton = new ThemedTextButton("Update".Localize(), theme) { Margin = 5, ToolTipText = "Compile model".Localize() diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index b469331cf..940976a27 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -162,7 +162,7 @@ namespace MatterHackers.MatterControl.DesignTools var showUpdate = context.item.GetType().GetCustomAttributes(typeof(ShowUpdateButtonAttribute), true).FirstOrDefault() as ShowUpdateButtonAttribute; if (showUpdate?.Show == true) { - var updateButton = new TextButton("Update".Localize(), theme) + var updateButton = new ThemedTextButton("Update".Localize(), theme) { Margin = 5, BackgroundColor = theme.MinimalShade, @@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.DesignTools { foreach (var editorButtonData in editorButtonProvider.GetEditorButtonsData()) { - var editorButton = new TextButton(editorButtonData.Name, theme) + var editorButton = new ThemedTextButton(editorButtonData.Name, theme) { Margin = 5, ToolTipText = editorButtonData.HelpText, @@ -984,7 +984,7 @@ namespace MatterHackers.MatterControl.DesignTools { // This is the AssetPath property of an asset object, add a button to set the AssetPath from a file // Change button - var changeButton = new TextButton(property.Description, theme) + var changeButton = new ThemedTextButton(property.Description, theme) { BackgroundColor = theme.MinimalShade, Margin = 3 @@ -1254,7 +1254,7 @@ namespace MatterHackers.MatterControl.DesignTools VAnchor = VAnchor.Center }; searchRow.AddChild(searchField); - var searchButton = new IconButton(StaticData.Instance.LoadIcon("icon_search_24x24.png", 16, 16).SetToColor(theme.TextColor), theme) + var searchButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_search_24x24.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Search".Localize(), }; @@ -1499,7 +1499,7 @@ namespace MatterHackers.MatterControl.DesignTools public static GuiWidget GetUnlockRow(ThemeConfig theme, string url) { - var detailsLink = new TextIconButton("Unlock".Localize(), StaticData.Instance.LoadIcon("locked.png", 16, 16).SetToColor(theme.TextColor), theme) + var detailsLink = new ThemedTextIconButton("Unlock".Localize(), StaticData.Instance.LoadIcon("locked.png", 16, 16).SetToColor(theme.TextColor), theme) { Margin = 5, ToolTipText = "Visit MatterHackers.com to Purchase".Localize() @@ -1517,7 +1517,7 @@ namespace MatterHackers.MatterControl.DesignTools { if (item.GetType().GetCustomAttributes(typeof(WebPageLinkAttribute), true).FirstOrDefault() is WebPageLinkAttribute unlockLink) { - var detailsLink = new TextIconButton(unlockLink.ButtonName.Localize(), StaticData.Instance.LoadIcon("internet.png", 16, 16).SetToColor(theme.TextColor), theme) + var detailsLink = new ThemedTextIconButton(unlockLink.ButtonName.Localize(), StaticData.Instance.LoadIcon("internet.png", 16, 16).SetToColor(theme.TextColor), theme) { BackgroundColor = theme.MinimalShade, ToolTipText = unlockLink.Url, diff --git a/MatterControlLib/DialogPages/AboutPage.cs b/MatterControlLib/DialogPages/AboutPage.cs index b60b11f46..b364efe43 100644 --- a/MatterControlLib/DialogPages/AboutPage.cs +++ b/MatterControlLib/DialogPages/AboutPage.cs @@ -127,7 +127,7 @@ namespace MatterHackers.MatterControl foreach (var item in data.OrderBy(i => i.Name)) { - var linkButton = new IconButton(linkIcon, theme); + var linkButton = new ThemedIconButton(linkIcon, theme); linkButton.Click += (s, e) => UiThread.RunOnIdle(() => { ApplicationController.LaunchBrowser(item.Url); diff --git a/MatterControlLib/DialogPages/StartupPage.cs b/MatterControlLib/DialogPages/StartupPage.cs index 0ce46f522..81618d9b0 100644 --- a/MatterControlLib/DialogPages/StartupPage.cs +++ b/MatterControlLib/DialogPages/StartupPage.cs @@ -109,8 +109,8 @@ namespace MatterHackers.MatterControl graphics = pulseImage.NewGraphics2D(); graphics.ImageRenderQuality = Graphics2D.TransformQuality.Best; graphics.RenderMaxSize(pulseLogo, pulseImage.Width / 2 - logoWidth / 2, pulseImage.Height * .42, logoWidth, bounds.Height, out _, preScale: false); - IconButton lastButton = null; - buttonRow.AddChild(AddButtonText(lastButton = new IconButton(pulseImage, theme) + ThemedIconButton lastButton = null; + buttonRow.AddChild(AddButtonText(lastButton = new ThemedIconButton(pulseImage, theme) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, @@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl return printerImage; } - buttonRow.AddChild(AddButtonText(lastButton = new IconButton(CreateButtonImage("3d_printer.png"), theme) + buttonRow.AddChild(AddButtonText(lastButton = new ThemedIconButton(CreateButtonImage("3d_printer.png"), theme) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, @@ -147,7 +147,7 @@ namespace MatterHackers.MatterControl this.DialogWindow.Close(); }); - buttonRow.AddChild(AddButtonText(lastButton = new IconButton(CreateButtonImage("edit_design.png"), theme) + buttonRow.AddChild(AddButtonText(lastButton = new ThemedIconButton(CreateButtonImage("edit_design.png"), theme) { HAnchor = HAnchor.Fit, VAnchor = VAnchor.Fit, diff --git a/MatterControlLib/DialogPages/UpdateControlView.cs b/MatterControlLib/DialogPages/UpdateControlView.cs index 39eff96da..eafc98fda 100644 --- a/MatterControlLib/DialogPages/UpdateControlView.cs +++ b/MatterControlLib/DialogPages/UpdateControlView.cs @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl this.AddChild(new HorizontalSpacer()); - checkUpdateButton = new IconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 14, 14).SetToColor(theme.TextColor), theme) + checkUpdateButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 14, 14).SetToColor(theme.TextColor), theme) { ToolTipText = "Check for Update".Localize(), BackgroundColor = theme.MinimalShade, @@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl this.MinimumSize = new Vector2(0, checkUpdateButton.Height); - downloadButton = new TextButton("Download Update".Localize(), theme) + downloadButton = new ThemedTextButton("Download Update".Localize(), theme) { BackgroundColor = theme.MinimalShade, Visible = false @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl }; this.AddChild(downloadButton); - installButton = new TextButton("Install Update".Localize(), theme) + installButton = new ThemedTextButton("Install Update".Localize(), theme) { BackgroundColor = theme.MinimalShade, Visible = false diff --git a/MatterControlLib/Library/Widgets/CloneSettingsPage.cs b/MatterControlLib/Library/Widgets/CloneSettingsPage.cs index 5749b6cf6..334f0d229 100644 --- a/MatterControlLib/Library/Widgets/CloneSettingsPage.cs +++ b/MatterControlLib/Library/Widgets/CloneSettingsPage.cs @@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl.Library.Widgets // Must come before pathButton.Click definition RadioButton copyAndCalibrateOption = null; - var openButton = new IconButton(StaticData.Instance.LoadIcon("fa-folder-open_16.png", 16, 16).SetToColor(theme.TextColor), theme) + var openButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-folder-open_16.png", 16, 16).SetToColor(theme.TextColor), theme) { BackgroundColor = theme.MinimalShade, Margin = new BorderDouble(left: 8), diff --git a/MatterControlLib/Library/Widgets/ExpandCheckboxButton.cs b/MatterControlLib/Library/Widgets/ExpandCheckboxButton.cs index 0ad461abc..d9ffc83c7 100644 --- a/MatterControlLib/Library/Widgets/ExpandCheckboxButton.cs +++ b/MatterControlLib/Library/Widgets/ExpandCheckboxButton.cs @@ -41,7 +41,7 @@ namespace MatterHackers.MatterControl.CustomWidgets { public event EventHandler CheckedStateChanged; - private IconButton imageButton; + private ThemedIconButton imageButton; private ImageBuffer arrowRight; @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.CustomWidgets arrowRight = StaticData.Instance.LoadIcon("fa-angle-right_12.png", 12, 12).SetToColor(theme.TextColor); arrowDown = StaticData.Instance.LoadIcon("fa-angle-down_12.png", 12, 12).SetToColor(theme.TextColor); - imageButton = new IconButton(arrowRight, theme) + imageButton = new ThemedIconButton(arrowRight, theme) { MinimumSize = new Vector2(theme.ButtonHeight, theme.ButtonHeight), VAnchor = VAnchor.Center, diff --git a/MatterControlLib/Library/Widgets/HardwarePage/PrinterDetails.cs b/MatterControlLib/Library/Widgets/HardwarePage/PrinterDetails.cs index fe5a45466..e9223716e 100644 --- a/MatterControlLib/Library/Widgets/HardwarePage/PrinterDetails.cs +++ b/MatterControlLib/Library/Widgets/HardwarePage/PrinterDetails.cs @@ -68,7 +68,7 @@ namespace MatterHackers.MatterControl.Library.Widgets.HardwarePage if (showOpenButton) { - var openButton = new TextButton("Open".Localize(), theme) + var openButton = new ThemedTextButton("Open".Localize(), theme) { BackgroundColor = theme.AccentMimimalOverlay, Margin = Margin.Clone(right: 17) diff --git a/MatterControlLib/Library/Widgets/HardwareTreeView.cs b/MatterControlLib/Library/Widgets/HardwareTreeView.cs index 9b1b1ef52..033a597fb 100644 --- a/MatterControlLib/Library/Widgets/HardwareTreeView.cs +++ b/MatterControlLib/Library/Widgets/HardwareTreeView.cs @@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.Library.Widgets mainRow.AddChild(new HorizontalSpacer()); // add in the create pulse button - var createPulse = new IconButton(StaticData.Instance.LoadIcon("pulse_logo.png", 18, 18).SetToColor(theme.TextColor), theme) + var createPulse = new ThemedIconButton(StaticData.Instance.LoadIcon("pulse_logo.png", 18, 18).SetToColor(theme.TextColor), theme) { Name = "Setup Pulse", VAnchor = VAnchor.Center, @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.Library.Widgets mainRow.AddChild(createPulse); // add in the create printer button - var createPrinter = new IconButton(StaticData.Instance.LoadIcon("md-add-circle_18.png", 18, 18).SetToColor(theme.TextColor), theme) + var createPrinter = new ThemedIconButton(StaticData.Instance.LoadIcon("md-add-circle_18.png", 18, 18).SetToColor(theme.TextColor), theme) { Name = "Create Printer", VAnchor = VAnchor.Center, @@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.Library.Widgets mainRow.AddChild(createPrinter); // add in the import printer button - var importPrinter = new IconButton(StaticData.Instance.LoadIcon("md-import_18.png", 18, 18).SetToColor(theme.TextColor), theme) + var importPrinter = new ThemedIconButton(StaticData.Instance.LoadIcon("md-import_18.png", 18, 18).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, diff --git a/MatterControlLib/Library/Widgets/LibraryWidget.cs b/MatterControlLib/Library/Widgets/LibraryWidget.cs index 35e3882a8..e2cd35acf 100644 --- a/MatterControlLib/Library/Widgets/LibraryWidget.cs +++ b/MatterControlLib/Library/Widgets/LibraryWidget.cs @@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl.Library.Widgets DoubleClickBehavior = LibraryListView.DoubleClickBehaviors.PreviewItem }; - navBar = new OverflowBar(theme) + navBar = new OverflowBar(theme, "File".Localize()) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, diff --git a/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs b/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs index b11106504..18af46bab 100644 --- a/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs +++ b/MatterControlLib/Library/Widgets/PrintLibraryWidget.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2019, Kevin Pope, John Lewin +Copyright (c) 2022, Kevin Pope, John Lewin, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.Library.Widgets Border = new BorderDouble(top: 1) }; - navBar = new OverflowBar(theme) + navBar = new OverflowBar(theme, "File".Localize()) { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit, diff --git a/MatterControlLib/Library/Widgets/StorePage/ArticleSection.cs b/MatterControlLib/Library/Widgets/StorePage/ArticleSection.cs index 83fdfa133..e6954108c 100644 --- a/MatterControlLib/Library/Widgets/StorePage/ArticleSection.cs +++ b/MatterControlLib/Library/Widgets/StorePage/ArticleSection.cs @@ -95,7 +95,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab if (content.group_items.Count > maxStuff) { - var moreButton = new TextButton("More".Localize() + "...", theme) + var moreButton = new ThemedTextButton("More".Localize() + "...", theme) { BackgroundColor = theme.MinimalShade, Margin = new BorderDouble(right: leftRightMargin), diff --git a/MatterControlLib/Library/Widgets/StorePage/ExplorePanel.cs b/MatterControlLib/Library/Widgets/StorePage/ExplorePanel.cs index 2a79ddc89..2c11c9f4f 100644 --- a/MatterControlLib/Library/Widgets/StorePage/ExplorePanel.cs +++ b/MatterControlLib/Library/Widgets/StorePage/ExplorePanel.cs @@ -222,7 +222,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab { // add the article group button to the button group // add a content section connected to the button - var sectionButton = new TextButton(content.group_title, theme); + var sectionButton = new ThemedTextButton(content.group_title, theme); sectionSelectButtons.AddChild(sectionButton); var articleSection = new ArticleSection(content, theme) { @@ -242,7 +242,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab case "product_group": { - var sectionButton = new TextButton(content.group_title, theme); + var sectionButton = new ThemedTextButton(content.group_title, theme); sectionSelectButtons.AddChild(sectionButton); var exploreSection = new ProductSection(content, theme) { diff --git a/MatterControlLib/Library/Widgets/StorePage/ProductSection.cs b/MatterControlLib/Library/Widgets/StorePage/ProductSection.cs index 34141377a..09a1c0b85 100644 --- a/MatterControlLib/Library/Widgets/StorePage/ProductSection.cs +++ b/MatterControlLib/Library/Widgets/StorePage/ProductSection.cs @@ -41,7 +41,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab private List allIconViews = new List(); private FeedSectionData content; private ThemeConfig theme; - private TextButton moreButton; + private ThemedTextButton moreButton; public ProductSection(FeedSectionData content, ThemeConfig theme) { diff --git a/MatterControlLib/PartPreviewWindow/DesignTabPage.cs b/MatterControlLib/PartPreviewWindow/DesignTabPage.cs index a681620b1..7dbf68e28 100644 --- a/MatterControlLib/PartPreviewWindow/DesignTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/DesignTabPage.cs @@ -190,7 +190,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var expandedImage = StaticData.Instance.LoadIcon("expand.png", 16, 16).SetToColor(theme.TextColor); var collapsedImage = StaticData.Instance.LoadIcon("collapse.png", 16, 16).SetToColor(theme.TextColor); - var expandBarButton = new IconButton(expanded ? collapsedImage : expandedImage, theme) + var expandBarButton = new ThemedIconButton(expanded ? collapsedImage : expandedImage, theme) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Absolute | VAnchor.Bottom, diff --git a/MatterControlLib/PartPreviewWindow/DropButton.cs b/MatterControlLib/PartPreviewWindow/DropButton.cs index df4fd4c66..aeb12432d 100644 --- a/MatterControlLib/PartPreviewWindow/DropButton.cs +++ b/MatterControlLib/PartPreviewWindow/DropButton.cs @@ -35,7 +35,7 @@ using MatterHackers.MatterControl.CustomWidgets; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class DropButton : SimpleButton + public class DropButton : ThemedButton { public bool MenuVisible { get; private set; } diff --git a/MatterControlLib/PartPreviewWindow/GCodeDetails/GCodeOptionsPanel.cs b/MatterControlLib/PartPreviewWindow/GCodeDetails/GCodeOptionsPanel.cs index 75f6783fe..3fc95329f 100644 --- a/MatterControlLib/PartPreviewWindow/GCodeDetails/GCodeOptionsPanel.cs +++ b/MatterControlLib/PartPreviewWindow/GCodeDetails/GCodeOptionsPanel.cs @@ -43,9 +43,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class GCodeOptionsPanel : FlowLayoutWidget { - private RadioIconButton speedsButton; - private RadioIconButton materialsButton; - private RadioIconButton noColorButton; + private ThemedRadioIconButton speedsButton; + private ThemedRadioIconButton materialsButton; + private ThemedRadioIconButton noColorButton; private View3DConfig gcodeOptions; public GCodeOptionsPanel(ISceneContext sceneContext, PrinterConfig printer, ThemeConfig theme) @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var buttonGroup = new ObservableCollection(); - speedsButton = new RadioIconButton(StaticData.Instance.LoadIcon("speeds.png", 16, 16).SetToColor(theme.TextColor), theme) + speedsButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("speeds.png", 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroup, Name = "Speeds Button", @@ -74,7 +74,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow buttonPanel.AddChild(speedsButton); - materialsButton = new RadioIconButton(StaticData.Instance.LoadIcon("materials.png", 16, 16).SetToColor(theme.TextColor), theme) + materialsButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("materials.png", 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroup, Name = "Materials Button", @@ -87,7 +87,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow buttonPanel.AddChild(materialsButton); - noColorButton = new RadioIconButton(StaticData.Instance.LoadIcon("no-color.png", 16, 16).SetToColor(theme.TextColor), theme) + noColorButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("no-color.png", 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroup, Name = "No Color Button", diff --git a/MatterControlLib/PartPreviewWindow/GCodePanel.cs b/MatterControlLib/PartPreviewWindow/GCodePanel.cs index d5d3849e6..db5e445c0 100644 --- a/MatterControlLib/PartPreviewWindow/GCodePanel.cs +++ b/MatterControlLib/PartPreviewWindow/GCodePanel.cs @@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow VAnchor = VAnchor.Fit }); - var copyButton = new TextButton("copy".Localize(), theme, 8) + var copyButton = new ThemedTextButton("copy".Localize(), theme, 8) { Padding = 5, Margin = new BorderDouble(0, 0, 15, 0), diff --git a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs index f71dea13c..f268f3906 100644 --- a/MatterControlLib/PartPreviewWindow/ItemColorButton.cs +++ b/MatterControlLib/PartPreviewWindow/ItemColorButton.cs @@ -241,7 +241,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; } - var resetButton = rightContent.AddChild(new TextIconButton("Clear".Localize(), StaticData.Instance.LoadIcon("transparent_grid.png", 16, 16), theme) + var resetButton = rightContent.AddChild(new ThemedTextIconButton("Clear".Localize(), StaticData.Instance.LoadIcon("transparent_grid.png", 16, 16), theme) { Margin = new BorderDouble(0, 0, 0, 3), HAnchor = HAnchor.Fit | HAnchor.Left, @@ -258,7 +258,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (getPickedColor != null) { - var selectButton = rightContent.AddChild(new TextIconButton("Select".Localize(), StaticData.Instance.LoadIcon("eye_dropper.png", 16, 16).SetToColor(theme.TextColor), theme) + var selectButton = rightContent.AddChild(new ThemedTextIconButton("Select".Localize(), StaticData.Instance.LoadIcon("eye_dropper.png", 16, 16).SetToColor(theme.TextColor), theme) { Margin = 0, HAnchor = HAnchor.Fit | HAnchor.Left, diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 0947c5c21..4b4ce61f0 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -830,7 +830,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; moveButtons.AddChild(textWidget); var buttonSize = 24 * DeviceScale; - var moveLeftButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor).MirrorX(), theme) + var moveLeftButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor).MirrorX(), theme) { Width = buttonSize, Height = buttonSize, @@ -846,7 +846,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; moveButtons.AddChild(moveLeftButton); - var moveRightButton = new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor), theme) + var moveRightButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 14, 14).SetToColor(theme.TextColor), theme) { Width = buttonSize, Height = buttonSize, diff --git a/MatterControlLib/PartPreviewWindow/NewTabButton.cs b/MatterControlLib/PartPreviewWindow/NewTabButton.cs index 2fd896662..e5b8277c3 100644 --- a/MatterControlLib/PartPreviewWindow/NewTabButton.cs +++ b/MatterControlLib/PartPreviewWindow/NewTabButton.cs @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.VAnchor = VAnchor.Center; this.theme = theme; - IconButton = new IconButton(imageBuffer, theme) + IconButton = new ThemedIconButton(imageBuffer, theme) { HAnchor = HAnchor.Left, Height = theme.MicroButtonHeight, @@ -105,6 +105,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public ITab LastTab { get; set; } - public IconButton IconButton { get; } + public ThemedIconButton IconButton { get; } } } \ No newline at end of file diff --git a/MatterControlLib/PartPreviewWindow/OperationIconButton.cs b/MatterControlLib/PartPreviewWindow/OperationIconButton.cs index 52e6dd193..be86a72e8 100644 --- a/MatterControlLib/PartPreviewWindow/OperationIconButton.cs +++ b/MatterControlLib/PartPreviewWindow/OperationIconButton.cs @@ -32,7 +32,7 @@ using MatterHackers.MatterControl.CustomWidgets; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class OperationIconButton : IconButton + public class OperationIconButton : ThemedIconButton { private SceneOperation sceneOperation; private ISceneContext sceneContext; diff --git a/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs b/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs index 46bd70a89..ff97bea32 100644 --- a/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs +++ b/MatterControlLib/PartPreviewWindow/PopupMenuButton.cs @@ -56,12 +56,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } public PopupMenuButton(ImageBuffer imageBuffer, ThemeConfig theme) - : this(new IconButton(imageBuffer, theme), theme) + : this(new ThemedIconButton(imageBuffer, theme), theme) { } public PopupMenuButton(string text, ImageBuffer imageBuffer, ThemeConfig theme) - : this(new TextIconButton(text, imageBuffer, theme) + : this(new ThemedTextIconButton(text, imageBuffer, theme) { Padding = new BorderDouble(5, 0, 5, 0), }, theme) @@ -86,7 +86,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } public PopupMenuButton(string text, ThemeConfig theme) - : this(new TextButton(text, theme) + : this(new ThemedTextButton(text, theme) { Selectable = false, Padding = theme.TextButtonPadding.Clone(right: 5) diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index edb542f28..928da4b1f 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -306,7 +306,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { UiThread.RunOnIdle(() => { - var unloadFilamentButton = new TextButton("Unload Filament".Localize(), theme) + var unloadFilamentButton = new ThemedTextButton("Unload Filament".Localize(), theme) { Name = "unload Filament", BackgroundColor = theme.MinimalShade, @@ -680,7 +680,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // add in the move up button var babyStepAmount = .02; - var upButton = babySteppingControls.AddChild(new IconButton(StaticData.Instance.LoadIcon("Up Arrow.png", 32, 32).SetToColor(theme.TextColor), theme) + var upButton = babySteppingControls.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("Up Arrow.png", 32, 32).SetToColor(theme.TextColor), theme) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Absolute, @@ -719,7 +719,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }); // add in the move down button - var downButton = babySteppingControls.AddChild(new IconButton(StaticData.Instance.LoadIcon("Down Arrow.png", 32, 32).SetToColor(theme.TextColor), theme) + var downButton = babySteppingControls.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("Down Arrow.png", 32, 32).SetToColor(theme.TextColor), theme) { HAnchor = HAnchor.Center, VAnchor = VAnchor.Absolute, @@ -765,7 +765,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // we can only reslice on 64 bit, because in 64 bit we always have the gcode loaded if (IntPtr.Size == 8 || ApplicationController.Instance.Allow32BitReSlice) { - var resliceButton = new TextButton("Re-Slice", theme) + var resliceButton = new ThemedTextButton("Re-Slice", theme) { VAnchor = VAnchor.Center, HAnchor = HAnchor.Right, @@ -842,7 +842,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow resliceMessageRow.AddChild(switchButtonRow); - var switchButton = new TextButton("Switch", theme) + var switchButton = new ThemedTextButton("Switch", theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(5), @@ -865,7 +865,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow resliceMessageRow.Visible = false; }; - var cancelButton = new TextButton("Cancel", theme) + var cancelButton = new ThemedTextButton("Cancel", theme) { VAnchor = VAnchor.Center, Margin = new BorderDouble(0, 5), diff --git a/MatterControlLib/PartPreviewWindow/RenderOptionsButton.cs b/MatterControlLib/PartPreviewWindow/RenderOptionsButton.cs index 32402b720..52b2f6cbf 100644 --- a/MatterControlLib/PartPreviewWindow/RenderOptionsButton.cs +++ b/MatterControlLib/PartPreviewWindow/RenderOptionsButton.cs @@ -44,7 +44,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; - this.AddChild(new IconButton(StaticData.Instance.LoadIcon("web.png", 16, 16), theme) + this.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("web.png", 16, 16), theme) { Selectable = false }); diff --git a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs index 96beff314..76397be2f 100644 --- a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs +++ b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs @@ -227,7 +227,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (string.IsNullOrEmpty(buttonText)) { - return new IconButton(StaticData.Instance.LoadIcon(iconFilename, 12, 12).SetToColor(theme.TextColor), theme) + return new ThemedIconButton(StaticData.Instance.LoadIcon(iconFilename, 12, 12).SetToColor(theme.TextColor), theme) { Margin = theme.ButtonSpacing, Enabled = clickAction != null, @@ -239,7 +239,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { var oldSize = theme.DefaultFontSize; theme.DefaultFontSize = 8; - var pauseButton = new TextIconButton(buttonText, StaticData.Instance.LoadIcon(iconFilename, 12, 12).SetToColor(theme.TextColor), theme) + var pauseButton = new ThemedTextIconButton(buttonText, StaticData.Instance.LoadIcon(iconFilename, 12, 12).SetToColor(theme.TextColor), theme) { Margin = new BorderDouble(marginX, 0), Padding = new BorderDouble(7, 3), @@ -255,7 +255,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow ToolTipText = toolTip, Name = name, }; - ((TextIconButton)pauseButton).BackgroundRadius = pauseButton.Height / 2; + ((ThemedTextIconButton)pauseButton).BackgroundRadius = pauseButton.Height / 2; theme.DefaultFontSize = oldSize; return pauseButton; diff --git a/MatterControlLib/PartPreviewWindow/SaveAsPage.cs b/MatterControlLib/PartPreviewWindow/SaveAsPage.cs index 541db9f7a..e0c7245ca 100644 --- a/MatterControlLib/PartPreviewWindow/SaveAsPage.cs +++ b/MatterControlLib/PartPreviewWindow/SaveAsPage.cs @@ -121,7 +121,7 @@ namespace MatterHackers.MatterControl contentRow.AddChild(folderButtonRow); // add a create folder button - var createFolderButton = new TextIconButton("Create Folder".Localize(), icon, theme) + var createFolderButton = new ThemedTextIconButton("Create Folder".Localize(), icon, theme) { Enabled = isEnabled, VAnchor = VAnchor.Absolute, @@ -130,7 +130,7 @@ namespace MatterHackers.MatterControl createFolderButton.Name = "Create Folder In Button"; folderButtonRow.AddChild(createFolderButton); - var refreshButton = new IconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 16, 16).SetToColor(theme.TextColor), theme) + var refreshButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Refresh Folder".Localize(), Enabled = isEnabled, diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 9f4217a8b..5edd51bf9 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // put in a make permanent button var icon = StaticData.Instance.LoadIcon("apply.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(); - applyButton = new IconButton(icon, theme) + applyButton = new ThemedIconButton(icon, theme) { Margin = theme.ButtonSpacing, ToolTipText = "Apply".Localize(), @@ -115,7 +115,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow toolbar.AddChild(applyButton); // put in a remove button - cancelButton = new IconButton(StaticData.Instance.LoadIcon("cancel.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), theme) + cancelButton = new ThemedIconButton(StaticData.Instance.LoadIcon("cancel.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), theme) { Margin = theme.ButtonSpacing, ToolTipText = "Cancel".Localize(), @@ -174,8 +174,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public GuiWidget ContentPanel { get; set; } private readonly JsonPathContext pathGetter = new JsonPathContext(); - private readonly IconButton applyButton; - private readonly IconButton cancelButton; + private readonly ThemedIconButton applyButton; + private readonly ThemedIconButton cancelButton; private readonly PopupMenuButton overflowButton; private readonly InteractiveScene scene; private readonly FlowLayoutWidget primaryActionsPanel; @@ -214,7 +214,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow foreach (var primaryAction in primaryActions) { // TODO: Run visible/enable rules on actions, conditionally add/enable as appropriate - var button = new IconButton(primaryAction.Icon(theme), theme) + var button = new ThemedIconButton(primaryAction.Icon(theme), theme) { // Name = namedAction.Title + " Button", ToolTipText = primaryAction.Title, @@ -648,7 +648,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } - private class OperationButton : TextButton + private class OperationButton : ThemedTextButton { private readonly SceneOperation sceneOperation; private readonly ISceneContext sceneContext; diff --git a/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs b/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs index e304335f1..8d71ff5dd 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/ColorSwatchSelector.cs @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow switch (rowIndex) { case 0: - var resetButton = new IconButton(StaticData.Instance.LoadIcon("transparent_grid.png"), theme) + var resetButton = new ThemedIconButton(StaticData.Instance.LoadIcon("transparent_grid.png"), theme) { Width = scaledButtonSize, Height = scaledButtonSize, diff --git a/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs b/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs index ab752c76e..58ecfa667 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/GridOptionsPanel.cs @@ -49,7 +49,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var gridDistance = object3DControlLayer.SnapGridDistance; - textButton = this.AddChild(new TextButton(gridDistance.ToString(), theme) + textButton = this.AddChild(new ThemedTextButton(gridDistance.ToString(), theme) { Selectable = false, HAnchor = HAnchor.Center diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ExportSlaPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ExportSlaPopupMenu.cs index c19d3c4e2..62af0fa99 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ExportSlaPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ExportSlaPopupMenu.cs @@ -221,7 +221,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return exportPanel; }; - this.AddChild(new TextButton("Export".Localize(), theme) + this.AddChild(new ThemedTextButton("Export".Localize(), theme) { Selectable = false, Padding = theme.TextButtonPadding.Clone(right: 5) diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs index 6310b57d1..5a0729081 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2022, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,11 +33,9 @@ using System.IO; using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Image; -using MatterHackers.Agg.ImageProcessing; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; using MatterHackers.ImageProcessing; -using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.Library.Widgets; namespace MatterHackers.MatterControl.PartPreviewWindow @@ -47,8 +45,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow protected static HashSet ignoredTypes = new HashSet { typeof(HorizontalLine), typeof(TextEditWithInlineCancel) }; protected static HashSet ignoredInMenuTypes = new HashSet { typeof(VerticalLine), typeof(HorizontalLine), typeof(TextEditWithInlineCancel), typeof(HorizontalSpacer) }; - public OverflowBar(ThemeConfig theme) - : this(null, theme) + public OverflowBar(ThemeConfig theme, string text = null) + : this(null, theme, text) { } public OverflowBar(ImageBuffer icon, ThemeConfig theme, string text = null) @@ -153,7 +151,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow PopupMenu.MenuItem menuItem; - var iconButton = widget as IconButton; + var iconButton = widget as ThemedIconButton; var iconImage = iconButton?.IconImage; diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs index 9ef92b840..86c91bf20 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrintPopupMenu.cs @@ -303,7 +303,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow return printPanel; }; - this.AddChild(new TextButton("Print".Localize(), theme) + this.AddChild(new ThemedTextButton("Print".Localize(), theme) { Selectable = false, Padding = theme.TextButtonPadding.Clone(right: 5) @@ -318,7 +318,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // Enable print option when no validation Errors exists printEnabled = printer.PrintButtonEnabled(); - var startPrintButton = new TextButton(buttonText, theme) + var startPrintButton = new ThemedTextButton(buttonText, theme) { Name = "Start Print Button", Enabled = printEnabled diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs index d726aaebc..7147d8326 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs @@ -57,11 +57,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow internal GuiWidget sliceButton; - private RadioIconButton layers2DButton; - internal RadioIconButton layers3DButton; - internal RadioIconButton modelViewButton; + private ThemedRadioIconButton layers2DButton; + internal ThemedRadioIconButton layers3DButton; + internal ThemedRadioIconButton modelViewButton; - private Dictionary viewModes = new Dictionary(); + private Dictionary viewModes = new Dictionary(); public PrinterActionsBar(PrinterConfig printer, PrinterTabPage printerTabPage, ThemeConfig theme) : base(null, theme, "Printer Options".Localize()) @@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // add the reset button first (if there is one) if (printer.Settings.GetValue(SettingsKey.show_reset_connection)) { - var resetConnectionButton = new TextIconButton( + var resetConnectionButton = new ThemedTextIconButton( "Reset".Localize(), StaticData.Instance.LoadIcon("e_stop.png", 14, 14).SetToColor(theme.TextColor), theme) @@ -154,7 +154,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var buttonGroupB = new ObservableCollection(); var iconPath = Path.Combine("ViewTransformControls", "model.png"); - modelViewButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) + modelViewButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Model View Button", @@ -170,7 +170,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow viewModes.Add(PartViewMode.Model, modelViewButton); iconPath = Path.Combine("ViewTransformControls", "gcode_3d.png"); - layers3DButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) + layers3DButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers3D Button", @@ -187,7 +187,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.AddChild(layers3DButton); iconPath = Path.Combine("ViewTransformControls", "gcode_2d.png"); - layers2DButton = new RadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) + layers2DButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(iconPath, 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupB, Name = "Layers2D Button", @@ -239,8 +239,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow printer.ViewState.ViewModeChanged += (s, e) => { - if (viewModes[e.ViewMode] is RadioIconButton activeButton - && viewModes[e.PreviousMode] is RadioIconButton previousButton + if (viewModes[e.ViewMode] is ThemedRadioIconButton activeButton + && viewModes[e.PreviousMode] is ThemedRadioIconButton previousButton && !buttonIsBeingClicked) { // Show slide to animation from previous to current, on completion update view to current by setting active.Checked diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs index be39f2479..5eb84ea61 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/PrinterConnectButton.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.ActionBar this.Margin = 0; this.Padding = 0; - connectButton = new TextIconButton( + connectButton = new ThemedTextIconButton( "Connect".Localize(), StaticData.Instance.LoadIcon("connect.png", 14, 14).SetToColor(theme.TextColor), theme) @@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.ActionBar theme.ApplyPrimaryActionStyle(connectButton); // add the cancel stop button - cancelConnectButton = new TextIconButton( + cancelConnectButton = new ThemedTextIconButton( "Cancel".Localize(), StaticData.Instance.LoadIcon("connect.png", 14, 14).SetToColor(theme.TextColor), theme) @@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl.ActionBar }); this.AddChild(cancelConnectButton); - disconnectButton = new TextIconButton( + disconnectButton = new ThemedTextIconButton( "Disconnect".Localize(), StaticData.Instance.LoadIcon("connect.png", 14, 14).SetToColor(theme.TextColor), theme) diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs index 963502eb5..059be0dbc 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/SliceButton.cs @@ -38,7 +38,7 @@ using System.Threading.Tasks; namespace MatterHackers.MatterControl.PartPreviewWindow { - public class SliceButton : TextButton + public class SliceButton : ThemedTextButton { private PrinterConfig printer; private PrinterTabPage printerTabPage; diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ValidationErrorsPanel.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ValidationErrorsPanel.cs index 3e39748a5..2666dd3ac 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ValidationErrorsPanel.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/ValidationErrorsPanel.cs @@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow else { // Show info indicator hinting that hover will reveal additional details - row.AddChild(new IconButton(infoImage, theme) + row.AddChild(new ThemedIconButton(infoImage, theme) { Selectable = false }); diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs index 5918a899b..42e076b8b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/WidgetAnimationExtensions.cs @@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow flashBackground.Start(); } - public static void SlideToNewState(this RadioIconButton widget, RadioIconButton newActiveButton, OverflowBar parent, Action animationComplete, ThemeConfig theme) + public static void SlideToNewState(this ThemedRadioIconButton widget, ThemedRadioIconButton newActiveButton, OverflowBar parent, Action animationComplete, ThemeConfig theme) { double displayTime = 600; double elapsedMs = 0; diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 2b4a350a7..b4220267e 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -100,10 +100,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow public PrinterConfig Printer { get; private set; } private readonly PrinterTabPage printerTabPage; - private RadioIconButton translateButton; - private RadioIconButton rotateButton; - private RadioIconButton zoomButton; - private RadioIconButton partSelectButton; + private ThemedRadioIconButton translateButton; + private ThemedRadioIconButton rotateButton; + private ThemedRadioIconButton zoomButton; + private ThemedRadioIconButton partSelectButton; public View3DWidget(PrinterConfig printer, ISceneContext sceneContext, ViewToolBarControls viewControls3D, ThemeConfig theme, DesignTabPage printerTabBase, Object3DControlsLayer.EditorType editorType = Object3DControlsLayer.EditorType.Part) { @@ -247,7 +247,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow titleAndTreeView.AddChild(treeView); workspaceName.ActionArea.AddChild( - new IconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 12, 12).SetToColor(theme.TextColor), theme) + new ThemedIconButton(StaticData.Instance.LoadIcon("fa-angle-right_12.png", 12, 12).SetToColor(theme.TextColor), theme) { Enabled = false }, @@ -257,7 +257,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow workspaceName.ActionArea.Children().First().Margin = 0; // Resize buttons - foreach (var iconButton in workspaceName.Descendants()) + foreach (var iconButton in workspaceName.Descendants()) { iconButton.Height = 26; iconButton.Width = 26; @@ -355,7 +355,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow // add the view controls var buttonGroupA = new ObservableCollection(); - partSelectButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "partSelect.png"), 16, 16).SetToColor(theme.TextColor), theme) + partSelectButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "partSelect.png"), 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Select Parts".Localize(), @@ -368,7 +368,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow partSelectButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.PartSelect; buttonGroupA.Add(partSelectButton); - rotateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "rotate.png"), 16, 16).SetToColor(theme.TextColor), theme) + rotateButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "rotate.png"), 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Rotate View".Localize(), @@ -380,7 +380,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow rotateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Rotate; buttonGroupA.Add(rotateButton); - translateButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "translate.png"), 16, 16).SetToColor(theme.TextColor), theme) + translateButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "translate.png"), 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Move View".Localize(), @@ -392,7 +392,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow translateButton.Click += (s, e) => viewControls3D.ActiveButton = ViewControls3DButtons.Translate; buttonGroupA.Add(translateButton); - zoomButton = new RadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "scale.png"), 16, 16).SetToColor(theme.TextColor), theme) + zoomButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon(Path.Combine("ViewTransformControls", "scale.png"), 16, 16).SetToColor(theme.TextColor), theme) { SiblingRadioButtonList = buttonGroupA, ToolTipText = "Zoom View".Localize(), @@ -465,7 +465,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; // add the home button - var homeButton = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16).SetToColor(theme.TextColor), theme) + var homeButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Reset View".Localize(), Margin = theme.ButtonSpacing @@ -474,7 +474,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow homeButton.MouseLeaveBounds += (s1, e1) => ApplicationController.Instance.UiHint = ""; AddRoundButton(homeButton, RotatedMargin(homeButton, MathHelper.Tau * .3)).Click += (s, e) => viewControls3D.NotifyResetView(); - var zoomToSelectionButton = new IconButton(StaticData.Instance.LoadIcon("select.png", 16, 16).SetToColor(theme.TextColor), theme) + var zoomToSelectionButton = new ThemedIconButton(StaticData.Instance.LoadIcon("select.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Zoom to selection button", ToolTipText = "Zoom to Selection".Localize(), @@ -496,7 +496,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var turntableEnabled = UserSettings.Instance.get(UserSettingsKey.TurntableMode) != "False"; TrackballTumbleWidget.TurntableEnabled = turntableEnabled; - var turnTableButton = new RadioIconButton(StaticData.Instance.LoadIcon("spin.png", 16, 16).SetToColor(theme.TextColor), theme) + var turnTableButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("spin.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Turntable Mode".Localize(), Margin = theme.ButtonSpacing, @@ -522,7 +522,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var perspectiveEnabled = UserSettings.Instance.get(UserSettingsKey.PerspectiveMode) != false.ToString(); TrackballTumbleWidget.ChangeProjectionMode(perspectiveEnabled, false); - var projectionButton = new RadioIconButton(StaticData.Instance.LoadIcon("perspective.png", 16, 16).SetToColor(theme.TextColor), theme) + var projectionButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("perspective.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Projection mode button", ToolTipText = "Perspective Mode".Localize(), @@ -551,7 +551,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow cubeCenterFromRightTop.X -= bottomButtonOffset; // put in the bed and build volume buttons - var bedButton = new RadioIconButton(StaticData.Instance.LoadIcon("bed.png", 16, 16).SetToColor(theme.TextColor), theme) + var bedButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("bed.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Bed Button", ToolTipText = "Show Print Bed".Localize(), @@ -560,7 +560,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow SiblingRadioButtonList = new List(), }; AddRoundButton(bedButton, new Vector2((cubeCenterFromRightTop.X + 18 * scale - bedButton.Width / 2) / scale, startHeight)); - var printAreaButton = new RadioIconButton(StaticData.Instance.LoadIcon("print_area.png", 16, 16).SetToColor(theme.TextColor), theme) + var printAreaButton = new ThemedRadioIconButton(StaticData.Instance.LoadIcon("print_area.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Bed Button", ToolTipText = BuildHeightValid() ? "Show Print Area".Localize() : "Define printer build height to enable", diff --git a/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs b/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs index 5d65f032d..694b18e12 100644 --- a/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs +++ b/MatterControlLib/PartPreviewWindow/ViewStyleButton.cs @@ -42,7 +42,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class ViewStyleButton : DropButton { - private IconButton iconButton; + private ThemedIconButton iconButton; private ISceneContext sceneContext; private Dictionary viewData; @@ -67,7 +67,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; var renderType = sceneContext.ViewState.RenderType; - this.AddChild(iconButton = new IconButton(viewData[renderType].image, theme) + this.AddChild(iconButton = new ThemedIconButton(viewData[renderType].image, theme) { Selectable = false }); diff --git a/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs b/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs index 481b3f109..c294cf2f0 100644 --- a/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs +++ b/MatterControlLib/PartPreviewWindow/ViewToolBarControls.cs @@ -88,8 +88,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow private MainViewWidget mainViewWidget = null; private readonly PopupMenuButton bedMenuButton; private readonly UndoBuffer undoBuffer; - private readonly IconButton undoButton; - private readonly IconButton redoButton; + private readonly ThemedIconButton undoButton; + private readonly ThemedIconButton redoButton; public ViewToolBarControls(PartWorkspace workspace, ThemeConfig theme, UndoBuffer undoBuffer, bool isPrinterType, bool showPrintButton) { @@ -123,7 +123,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow this.AddChild(new ToolbarSeparator(theme.GetBorderColor(50), theme.SeparatorMargin)); - undoButton = new IconButton(StaticData.Instance.LoadIcon("undo.png", 16, 16).SetToColor(theme.TextColor), theme) + undoButton = new ThemedIconButton(StaticData.Instance.LoadIcon("undo.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "3D View Undo", ToolTipText = "Undo".Localize(), @@ -140,7 +140,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; this.AddChild(undoButton); - redoButton = new IconButton(StaticData.Instance.LoadIcon("redo.png", 16, 16).SetToColor(theme.TextColor), theme) + redoButton = new ThemedIconButton(StaticData.Instance.LoadIcon("redo.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "3D View Redo", Margin = theme.ButtonSpacing, @@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (showPrintButton) { - var printButton = new TextButton("Print", theme) + var printButton = new ThemedTextButton("Print", theme) { Name = "Print Button", BackgroundColor = theme.AccentMimimalOverlay @@ -253,7 +253,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (namedAction.Icon != null) { - button = new IconButton(namedAction.Icon(theme), theme) + button = new ThemedIconButton(namedAction.Icon(theme), theme) { Name = namedAction.Title + " Button", ToolTipText = namedAction.Title, @@ -271,7 +271,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } else { - button = new TextButton(namedAction.Title, theme) + button = new ThemedTextButton(namedAction.Title, theme) { Name = namedAction.Title + " Button", Margin = theme.ButtonSpacing, @@ -484,7 +484,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow buttonGroup.AddChild(operationButton); } - var collapseButton = buttonGroup.AddChild(new IconButton(StaticData.Instance.LoadIcon("collapse_single.png", 8, 16).SetToColor(theme.TextColor), theme)); + var collapseButton = buttonGroup.AddChild(new ThemedIconButton(StaticData.Instance.LoadIcon("collapse_single.png", 8, 16).SetToColor(theme.TextColor), theme)); collapseButton.Width = 16 * DeviceScale; collapseButton.ToolTipText = "Collapse".Localize(); @@ -536,7 +536,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (defaultOperation != operation) { // Update button - var iconButton = actionAndDropDown.Children.OfType().First(); + var iconButton = actionAndDropDown.Children.OfType().First(); iconButton.SetIcon(operation.Icon(theme)); iconButton.ToolTipText = operation.HelpText ?? operation.Title; @@ -743,7 +743,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow popupMenu.DrawArrow = true; openLibraryButton.Selectable = true; - if (popupMenu.Children().FirstOrDefault() is SimpleButton simpleButton) + if (popupMenu.Children().FirstOrDefault() is ThemedButton simpleButton) { simpleButton.Padding = 0; }; @@ -779,7 +779,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow if (operation is OperationGroup operationGroup && button is PopupMenuButton splitButton - && button.Descendants().FirstOrDefault() is IconButton iconButton) + && button.Descendants().FirstOrDefault() is ThemedIconButton iconButton) { var defaultOperation = operationGroup.GetDefaultOperation(); iconButton.Enabled = defaultOperation.IsEnabled(sceneContext); diff --git a/MatterControlLib/PrinterControls/ControlWidgets/CalibrationControls.cs b/MatterControlLib/PrinterControls/ControlWidgets/CalibrationControls.cs index c86d6763c..07df9a225 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/CalibrationControls.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/CalibrationControls.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.PrinterControls null, theme)); - var runWizardButton = new IconButton(StaticData.Instance.LoadIcon("compass.png", 16, 16).SetToColor(theme.TextColor), theme) + var runWizardButton = new ThemedIconButton(StaticData.Instance.LoadIcon("compass.png", 16, 16).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, diff --git a/MatterControlLib/PrinterControls/ControlWidgets/MacroControls.cs b/MatterControlLib/PrinterControls/ControlWidgets/MacroControls.cs index 2dc17b04c..ee87935be 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/MacroControls.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/MacroControls.cs @@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.PrinterControls { foreach (GCodeMacro macro in printer.Settings.Macros) { - var macroButton = new TextButton(GCodeMacro.FixMacroName(macro.Name), theme) + var macroButton = new ThemedTextButton(GCodeMacro.FixMacroName(macro.Name), theme) { BackgroundColor = theme.MinimalShade, Margin = new BorderDouble(right: 5) @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.PrinterControls { var widget = new MacroControls(printer, theme); - var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme); + var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme); editButton.Click += (s, e) => { DialogWindow.Show(new MacroListPage(printer.Settings)); diff --git a/MatterControlLib/PrinterControls/ControlWidgets/MovementControls.cs b/MatterControlLib/PrinterControls/ControlWidgets/MovementControls.cs index a984a817c..5ad151db3 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/MovementControls.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/MovementControls.cs @@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.PrinterControls { var widget = new MovementControls(printer, new XYZColors(theme), theme); - var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme); + var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme); editButton.Click += (s, e) => widget.EditOptions(); return new SectionWidget( @@ -130,7 +130,7 @@ namespace MatterHackers.MatterControl.PrinterControls Margin = new BorderDouble(bottom: 10) }; - var homeIcon = new IconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16).SetToColor(theme.TextColor), theme) + var homeIcon = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-home_16.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Home X, Y and Z".Localize(), BackgroundColor = theme.MinimalShade, @@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.PrinterControls homeIcon.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ); toolbar.AddChild(homeIcon); - var homeXButton = new TextButton("X", theme) + var homeXButton = new ThemedTextButton("X", theme) { ToolTipText = "Home X".Localize(), BackgroundColor = theme.MinimalShade, @@ -148,7 +148,7 @@ namespace MatterHackers.MatterControl.PrinterControls homeXButton.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.X); toolbar.AddChild(homeXButton); - var homeYButton = new TextButton("Y", theme) + var homeYButton = new ThemedTextButton("Y", theme) { ToolTipText = "Home Y".Localize(), BackgroundColor = theme.MinimalShade, @@ -157,7 +157,7 @@ namespace MatterHackers.MatterControl.PrinterControls homeYButton.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.Y); toolbar.AddChild(homeYButton); - var homeZButton = new TextButton("Z", theme) + var homeZButton = new ThemedTextButton("Z", theme) { ToolTipText = "Home Z".Localize(), BackgroundColor = theme.MinimalShade, @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.PrinterControls if (printer.Settings.GetValue(SettingsKey.has_c_axis)) { - var homeCButton = new TextButton("C", theme) + var homeCButton = new ThemedTextButton("C", theme) { ToolTipText = "Home C".Localize(), BackgroundColor = theme.MinimalShade, @@ -196,7 +196,7 @@ namespace MatterHackers.MatterControl.PrinterControls toolbar.AddChild(new HorizontalSpacer()); // Create 'Release' button - var disableMotors = new TextButton("Release".Localize(), theme) + var disableMotors = new ThemedTextButton("Release".Localize(), theme) { BackgroundColor = theme.MinimalShade, }; diff --git a/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs b/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs index d08d4381f..539f67931 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/PrinterCalibrationWizard.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl MinimumSize = new Vector2(125, 0) }); - var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) + var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) { Name = "Edit Leveling Data Button", ToolTipText = "Edit Leveling Data".Localize(), @@ -345,7 +345,7 @@ namespace MatterHackers.MatterControl private GuiWidget AddRunStageButton(string title, ThemeConfig theme, ISetupWizard stage, FlowLayoutWidget leftToRight) { - var runStage = leftToRight.AddChild(new TextButton(title, theme) + var runStage = leftToRight.AddChild(new ThemedTextButton(title, theme) { VAnchor = VAnchor.Bottom, Enabled = printer.Connection.IsConnected && !printer.Connection.Printing && !printer.Connection.Paused, diff --git a/MatterControlLib/PrinterControls/ControlWidgets/TemperatureControls.cs b/MatterControlLib/PrinterControls/ControlWidgets/TemperatureControls.cs index c526f2498..c9923a1d0 100644 --- a/MatterControlLib/PrinterControls/ControlWidgets/TemperatureControls.cs +++ b/MatterControlLib/PrinterControls/ControlWidgets/TemperatureControls.cs @@ -42,8 +42,8 @@ namespace MatterHackers.MatterControl.PrinterControls public class TemperatureControls : FlowLayoutWidget { private PrinterConfig printer; - private TextButton preHeatButton; - private TextButton offButton; + private ThemedTextButton preHeatButton; + private ThemedTextButton offButton; private TemperatureControls(PrinterConfig printer, ThemeConfig theme) : base(FlowDirection.TopToBottom) @@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.PrinterControls var container = new FlowLayoutWidget(); heatersRow.AddChild(container); - preHeatButton = new TextButton("Preheat".Localize(), theme) + preHeatButton = new ThemedTextButton("Preheat".Localize(), theme) { BackgroundColor = theme.MinimalShade, Margin = new BorderDouble(right: 10) @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.PrinterControls printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay); }; - offButton = new TextButton("Off".Localize(), theme) + offButton = new ThemedTextButton("Off".Localize(), theme) { BackgroundColor = theme.MinimalShade, }; diff --git a/MatterControlLib/PrinterControls/JogControls.cs b/MatterControlLib/PrinterControls/JogControls.cs index 98213c64c..d473cb861 100644 --- a/MatterControlLib/PrinterControls/JogControls.cs +++ b/MatterControlLib/PrinterControls/JogControls.cs @@ -287,7 +287,7 @@ namespace MatterHackers.MatterControl Margin = new BorderDouble(left: 10) }; - keyboardImage = new IconButton(StaticData.Instance.LoadIcon("hot_key_small_white.png", 19, 12).SetToColor(theme.TextColor), theme) + keyboardImage = new ThemedIconButton(StaticData.Instance.LoadIcon("hot_key_small_white.png", 19, 12).SetToColor(theme.TextColor), theme) { HAnchor = HAnchor.Center, Margin = new BorderDouble(5), @@ -699,7 +699,7 @@ namespace MatterHackers.MatterControl return xyGrid; } - public class MoveButton : TextButton + public class MoveButton : ThemedTextButton { //Amounts in millimeters public double MoveAmount { get; set; } = 10; @@ -743,7 +743,7 @@ namespace MatterHackers.MatterControl } } - public class ExtrudeButton : TextButton + public class ExtrudeButton : ThemedTextButton { //Amounts in millimeters public double MoveAmount = 10; diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index ee76ef2a5..c834cc2f1 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl theme.ApplyBoxStyle(generalSection); // Print Notifications - var configureNotificationsButton = new IconButton(configureIcon, theme) + var configureNotificationsButton = new ThemedIconButton(configureIcon, theme) { Name = "Configure Notification Settings Button", ToolTipText = "Configure Notifications".Localize(), @@ -267,7 +267,7 @@ namespace MatterHackers.MatterControl TextWidget sectionLabel = null; - var textSizeApplyButton = new TextButton("Apply".Localize(), theme) + var textSizeApplyButton = new ThemedTextButton("Apply".Localize(), theme) { VAnchor = VAnchor.Center, BackgroundColor = theme.SlightShade, @@ -351,7 +351,7 @@ namespace MatterHackers.MatterControl true, false); - var openCacheButton = new IconButton(StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16).SetToColor(theme.TextColor), theme) + var openCacheButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-link_16.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Open Folder".Localize(), }; @@ -367,7 +367,7 @@ namespace MatterHackers.MatterControl theme), advancedPanel); - var clearCacheButton = new HoverIconButton(StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor), theme) + var clearCacheButton = new ThemedHoverIconButton(StaticData.Instance.LoadIcon("remove.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Clear Cache".Localize(), }; @@ -386,7 +386,7 @@ namespace MatterHackers.MatterControl #if DEBUG var configureIcon = StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(theme.TextColor); - var configurePluginsButton = new IconButton(configureIcon, theme) + var configurePluginsButton = new ThemedIconButton(configureIcon, theme) { ToolTipText = "Configure Plugins".Localize(), Margin = 0 diff --git a/MatterControlLib/SettingsManagement/UpdateSettingsPage.cs b/MatterControlLib/SettingsManagement/UpdateSettingsPage.cs index 4037bcbb7..19e8bd32c 100644 --- a/MatterControlLib/SettingsManagement/UpdateSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/UpdateSettingsPage.cs @@ -190,7 +190,7 @@ namespace MatterHackers.MatterControl }; generalPanel.AddChild(buttonContainer); - var updateButton = new TextButton("Update Setting".Localize(), theme) + var updateButton = new ThemedTextButton("Update Setting".Localize(), theme) { Margin = new BorderDouble(0, 3, 20, 0), Name = setting.key + " Update", diff --git a/MatterControlLib/SetupWizard/DialogPage.cs b/MatterControlLib/SetupWizard/DialogPage.cs index cd93429b6..4ce50c1ff 100644 --- a/MatterControlLib/SetupWizard/DialogPage.cs +++ b/MatterControlLib/SetupWizard/DialogPage.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2019, Lars Brubaker, John Lewin +Copyright (c) 2022, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/MatterControlLib/SetupWizard/HelpTreePanel.cs b/MatterControlLib/SetupWizard/HelpTreePanel.cs index 0d53963ba..f4978c7cf 100644 --- a/MatterControlLib/SetupWizard/HelpTreePanel.cs +++ b/MatterControlLib/SetupWizard/HelpTreePanel.cs @@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl theme.ApplyBottomBorder(toolbar); - toolbar.AddChild(new TextButton("MatterControl Help".Localize(), theme) + toolbar.AddChild(new ThemedTextButton("MatterControl Help".Localize(), theme) { Padding = new BorderDouble(6, 0), Selectable = false diff --git a/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs b/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs index 11d611a35..b17c3f40b 100644 --- a/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs +++ b/MatterControlLib/SetupWizard/Printer/OpenPrinterPage.cs @@ -112,7 +112,7 @@ namespace MatterHackers.MatterControl public abstract class SelectablePrinterPage : DialogPage { - protected TextButton nextButton; + protected ThemedTextButton nextButton; protected TreeNode rootPrintersNode; public SelectablePrinterPage(string continueButtonText) @@ -129,7 +129,7 @@ namespace MatterHackers.MatterControl treeView.ScrollArea.HAnchor = HAnchor.Stretch; contentRow.AddChild(treeView); - nextButton = new TextButton(continueButtonText, theme) + nextButton = new ThemedTextButton(continueButtonText, theme) { Enabled = false }; diff --git a/MatterControlLib/SetupWizard/TourPopover.cs b/MatterControlLib/SetupWizard/TourPopover.cs index 611af5a93..7975fd835 100644 --- a/MatterControlLib/SetupWizard/TourPopover.cs +++ b/MatterControlLib/SetupWizard/TourPopover.cs @@ -258,7 +258,7 @@ namespace MatterHackers.MatterControl.Tour return new RectangleDouble(0, 0, totalWidth, totalHeight); } - private class ArrowButton : TextButton + private class ArrowButton : ThemedTextButton { public ArrowButton(string text, ArrowDirection arrowDirection, ThemeConfig theme, double pointSize = -1) : base(text, theme, pointSize) diff --git a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs index b95e32ff3..77bb0ec45 100644 --- a/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs +++ b/MatterControlLib/SlicerConfiguration/PresetSelectorWidget.cs @@ -102,7 +102,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration Name = "Preset Pulldown Container" }; - editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) + editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) { ToolTipText = "Edit Selected Setting".Localize(), Enabled = dropDownList.SelectedIndex != -1, diff --git a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs index 12a735246..84a01d2a1 100644 --- a/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs +++ b/MatterControlLib/SlicerConfiguration/SliceSettingsWidget.cs @@ -348,7 +348,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (settingsSection.Name == "Slice Simple" && UserSettings.Instance.get(UserSettingsKey.SliceSettingsMoreClicked) != "true") { - var button = new TextButton("More".Localize(), theme, 8) + var button = new ThemedTextButton("More".Localize(), theme, 8) { VAnchor = VAnchor.Center, BackgroundColor = new Color(theme.AccentMimimalOverlay, 50), diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs index fd0a3308e..215af7d53 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs @@ -107,7 +107,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration if (ShowPortWizardButton) { - var configureIcon = new IconButton(StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(theme.TextColor), theme) + var configureIcon = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Center, Margin = theme.ButtonSpacing, diff --git a/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs b/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs index 6cee490d2..20009a68d 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/EnumDisplayField.cs @@ -119,7 +119,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } } - private void EnableReduceWidth(RadioTextButton enumTab) + private void EnableReduceWidth(ThemedRadioTextButton enumTab) { var deviceScale = GuiWidget.DeviceScale; var padingSize = enumTab.Padding.Left * deviceScale; @@ -194,7 +194,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { var localIndex = index; - var radioButton = new RadioTextButton(item.name, theme) + var radioButton = new ThemedRadioTextButton(item.name, theme) { ToolTipText = item.description, }; @@ -206,7 +206,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration radioButton.CheckedStateChanged += (s, e) => { - var button = s as RadioTextButton; + var button = s as ThemedRadioTextButton; button.TextColor = button.Checked ? theme.BackgroundColor : theme.TextColor; }; @@ -258,9 +258,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.Content = menuRow; } - public static RadioTextButton CreateThemedRadioButton(string text, string key, string toolTipText, bool startChecked, Action setChecked, ThemeConfig theme) + public static ThemedRadioTextButton CreateThemedRadioButton(string text, string key, string toolTipText, bool startChecked, Action setChecked, ThemeConfig theme) { - var radioButton = new RadioTextButton(text, theme) + var radioButton = new ThemedRadioTextButton(text, theme) { VAnchor = VAnchor.Center | VAnchor.Fit, DrawUnderline = false, @@ -276,7 +276,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration radioButton.CheckedStateChanged += (s, e) => { - var button = s as RadioTextButton; + var button = s as ThemedRadioTextButton; button.TextColor = button.Checked ? theme.BackgroundColor : theme.TextColor; }; @@ -294,9 +294,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return radioButton; } - public static TextButton CreateThemedButton(string text, string key, string toolTipText, ThemeConfig theme) + public static ThemedTextButton CreateThemedButton(string text, string key, string toolTipText, ThemeConfig theme) { - var button = new TextButton(text, theme) + var button = new ThemedTextButton(text, theme) { VAnchor = VAnchor.Center | VAnchor.Fit, BackgroundRadius = (theme.ButtonRadius + 4) * GuiWidget.DeviceScale, @@ -333,7 +333,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration iconImage = StaticData.Instance.LoadIcon(iconPath); } - var radioButton = new RadioIconButton(iconImage, theme) + var radioButton = new ThemedRadioIconButton(iconImage, theme) { ToolTipText = item.description == null ? item.name : item.description, }; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs index 492d570b4..1fc5c7319 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/IpAddessField.cs @@ -18,7 +18,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration class IpAddessField : UIField { private DropDownList dropdownList; - private IconButton refreshButton; + private ThemedIconButton refreshButton; private PrinterConfig printer; private ThemeConfig theme; @@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var widget = new FlowLayoutWidget(); widget.AddChild(dropdownList); - refreshButton = new IconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 14, 14).SetToColor(theme.TextColor), theme) + refreshButton = new ThemedIconButton(StaticData.Instance.LoadIcon("fa-refresh_14.png", 14, 14).SetToColor(theme.TextColor), theme) { Margin = new BorderDouble(left: 5) }; diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs index 44fbe471a..8ec466b8f 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ListStringField.cs @@ -96,7 +96,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration this.Content.AddChild(inlineEdit); } - var addItem = new IconButton(StaticData.Instance.LoadIcon("md-add-circle_18.png", 18, 18).SetToColor(theme.TextColor), theme) + var addItem = new ThemedIconButton(StaticData.Instance.LoadIcon("md-add-circle_18.png", 18, 18).SetToColor(theme.TextColor), theme) { HAnchor = HAnchor.Right | HAnchor.Absolute, Width = theme.ButtonHeight, diff --git a/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs b/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs index 2239fd6b6..590033fe0 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/MarkdownEditField.cs @@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public override void Initialize(int tabIndex) { - var editButton = new IconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) + var editButton = new ThemedIconButton(StaticData.Instance.LoadIcon("icon_edit.png", 16, 16).SetToColor(theme.TextColor), theme) { VAnchor = VAnchor.Top, ToolTipText = "Edit".Localize(), diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index fb12aef41..f860fe8ba 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -202,6 +202,9 @@ Translated:Action Recommended English:Action Required Translated:Action Required +English:Actions +Translated:Actions + English:Add Translated:Add diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index f3a1fbc74..32f66080e 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit f3a1fbc748f00e0b7318909b0854a5627fa0476d +Subproject commit 32f66080ec934759c1dd7050e620652dfda347e7 diff --git a/Tests/MatterControl.Tests/MatterControl/PopupAnchorTests.cs b/Tests/MatterControl.Tests/MatterControl/PopupAnchorTests.cs index 493ecd1bc..309110310 100644 --- a/Tests/MatterControl.Tests/MatterControl/PopupAnchorTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/PopupAnchorTests.cs @@ -1,14 +1,14 @@ -using System; +/* +Copyright (c) 2022, Lars Brubaker +All rights reserved. +*/ + +using System; using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; -using MatterHackers.GuiAutomation; -using MatterHackers.MatterControl; -using MatterHackers.MatterControl.CustomWidgets; -using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.Tests.Automation; using MatterHackers.VectorMath; using NUnit.Framework; @@ -43,7 +43,7 @@ namespace MatterControl.Tests.MatterControl { systemWindow.Padding = systemWindow.Padding.Clone(bottom: 180); - var button = new TextButton("Popup", systemWindow.Theme) + var button = new ThemedTextButton("Popup", systemWindow.Theme) { Name = "targetA", VAnchor = VAnchor.Bottom, @@ -102,7 +102,7 @@ namespace MatterControl.Tests.MatterControl { Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -138,7 +138,7 @@ namespace MatterControl.Tests.MatterControl { Mate = new MateOptions(MateEdge.Left, MateEdge.Top) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -174,7 +174,7 @@ namespace MatterControl.Tests.MatterControl { Mate = new MateOptions(MateEdge.Left, MateEdge.Top) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -210,7 +210,7 @@ namespace MatterControl.Tests.MatterControl { Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -249,7 +249,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -291,7 +291,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -335,7 +335,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top), }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -377,7 +377,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), AltMate = new MateOptions(MateEdge.Left, MateEdge.Top), }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -424,7 +424,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Top), AltMate = new MateOptions(MateEdge.Left, MateEdge.Bottom) }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -476,7 +476,7 @@ namespace MatterControl.Tests.MatterControl Mate = new MateOptions(MateEdge.Left, MateEdge.Bottom), AltMate = new MateOptions(MateEdge.Right, MateEdge.Top), }, - new TextButton("Popup", systemWindow.Theme) + new ThemedTextButton("Popup", systemWindow.Theme) { Name = "buttonA", VAnchor = VAnchor.Bottom, @@ -502,7 +502,7 @@ namespace MatterControl.Tests.MatterControl } - private static async Task AnchorTests(PopupsTestWindow systemWindow, MatePoint anchor, MatePoint popup, TextButton button, Action validator, Action rowAdjuster = null) + private static async Task AnchorTests(PopupsTestWindow systemWindow, MatePoint anchor, MatePoint popup, ThemedTextButton button, Action validator, Action rowAdjuster = null) { await systemWindow.RunTest(testRunner => { From d098ff83b8cc320c16d4afde5b94c1aab8a1c36d Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 29 Jul 2022 13:41:41 -0700 Subject: [PATCH 02/15] updated enum --- MatterControlLib/DesignTools/SupportGenerator.cs | 2 +- Submodules/agg-sharp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MatterControlLib/DesignTools/SupportGenerator.cs b/MatterControlLib/DesignTools/SupportGenerator.cs index 2def7afaa..df025d9c5 100644 --- a/MatterControlLib/DesignTools/SupportGenerator.cs +++ b/MatterControlLib/DesignTools/SupportGenerator.cs @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl.DesignTools } } - public static ITraceable CreateTraceData(FaceList faceList, List vertexList, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.LegacySlowConstructionFastTracing) + public static ITraceable CreateTraceData(FaceList faceList, List vertexList, BvhCreationOptions bvhCreationOptions = BvhCreationOptions.BottomUpClustering) { var allPolys = new List(); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 32f66080e..7db8dbacd 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 32f66080ec934759c1dd7050e620652dfda347e7 +Subproject commit 7db8dbacdf8d4db1e1eb8afc0ec2598f5c8088c8 From 4e603a7f0db4f9af11f84227011baea1ead89820 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Wed, 3 Aug 2022 16:49:34 -0700 Subject: [PATCH 03/15] latest agg --- Submodules/agg-sharp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 7db8dbacd..fca955fe3 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 7db8dbacdf8d4db1e1eb8afc0ec2598f5c8088c8 +Subproject commit fca955fe34e0ee63a8d74f10de47b183810fd1c0 From 4c226457eadb85af93cbc9ad2a590c342f950b67 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 4 Aug 2022 11:39:43 -0700 Subject: [PATCH 04/15] Show the right theme while running tests --- MatterControlLib/ApplicationView/AppContext.cs | 5 ++++- StaticData/Translations/Master.txt | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/MatterControlLib/ApplicationView/AppContext.cs b/MatterControlLib/ApplicationView/AppContext.cs index b29ae6704..393b0ad15 100644 --- a/MatterControlLib/ApplicationView/AppContext.cs +++ b/MatterControlLib/ApplicationView/AppContext.cs @@ -164,7 +164,10 @@ namespace MatterHackers.MatterControl var themeConfig = JsonConvert.DeserializeObject(json); themeConfig.EnsureDefaults(); - ThemeConfigExtensions.RebuildTheme(ThemeSet.Theme); + if (ThemeSet?.Theme != null) + { + ThemeConfigExtensions.RebuildTheme(ThemeSet.Theme); + } return themeConfig; } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index f860fe8ba..adf735e2b 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1819,6 +1819,9 @@ Translated:Filament Unloaded English:Filament Volume Translated:Filament Volume +English:File +Translated:File + English:File May Cause Problems Translated:File May Cause Problems From 19d46d6afd78e8808dd94838b50bd45f104b9831 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sat, 23 Jul 2022 10:16:23 -0700 Subject: [PATCH 05/15] better bvh debugging --- MatterControlLib/ApplicationView/AppContext.cs | 7 ++----- Submodules/agg-sharp | 2 +- .../MatterControl/MatterControlUtilities.cs | 6 ++++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/MatterControlLib/ApplicationView/AppContext.cs b/MatterControlLib/ApplicationView/AppContext.cs index 393b0ad15..b896a1180 100644 --- a/MatterControlLib/ApplicationView/AppContext.cs +++ b/MatterControlLib/ApplicationView/AppContext.cs @@ -164,11 +164,8 @@ namespace MatterHackers.MatterControl var themeConfig = JsonConvert.DeserializeObject(json); themeConfig.EnsureDefaults(); - if (ThemeSet?.Theme != null) - { - ThemeConfigExtensions.RebuildTheme(ThemeSet.Theme); - } - + ThemeConfigExtensions.RebuildTheme(themeConfig); + return themeConfig; } } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index fca955fe3..5abd29704 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit fca955fe34e0ee63a8d74f10de47b183810fd1c0 +Subproject commit 5abd29704a4358afab0366bbe21c42066b9cd15d diff --git a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs index bbe723395..661ea5a25 100644 --- a/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs +++ b/Tests/MatterControl.Tests/MatterControl/MatterControlUtilities.cs @@ -751,6 +751,12 @@ namespace MatterHackers.MatterControl.Tests.Automation if (!testRunner.NameExists(libraryRowItemName, .2)) { + while (!testRunner.NameExists("Bread Crumb Button Home", .2)) + { + testRunner.ClickByName("Library Up Button") + .Delay(); + } + // go back to the home section testRunner.ClickByName("Bread Crumb Button Home") .Delay(); From a9b1081bed7735d4fa4acb5a02267c1812493019 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Tue, 9 Aug 2022 08:48:05 -0700 Subject: [PATCH 06/15] Making 2D Paths a more natural part of the system --- .../ApplicationView/SceneOperations.cs | 57 +++++-------------- .../CustomWidgets/SceneOperation.cs | 5 -- .../EditorTools/LithophanePlugin.cs | 1 - .../Operations/FindSliceObject3D.cs | 4 +- .../Operations/Image/ImageToPathObject3D.cs | 4 +- .../Operations/Image/ImageToPathObject3D_2.cs | 4 +- .../Operations/Image/PathObject3D.cs | 4 +- .../Operations/Object3DExtensions.cs | 22 ++----- .../Operations/Path/InflatePathObject3D.cs | 6 +- .../Operations/Path/LinearExtrudeObject3D.cs | 30 +++++----- .../Operations/Path/MergePathObject3D.cs | 10 ++-- .../Operations/Path/OutlinePathObject3D.cs | 21 ++++--- .../Operations/Path/RevolveObject3D.cs | 16 +++--- .../Operations/Path/SmoothPathObject3D.cs | 6 +- .../DesignTools/Primitives/BaseObject3D.cs | 20 +++---- .../DesignTools/Primitives/BoxPathObject3D.cs | 4 +- .../DesignTools/Primitives/TextObject3D.cs | 36 +++++++++++- .../Primitives/TextPathObject3D.cs | 4 +- .../View3D/Actions/SubtractPathObject3D.cs | 8 +-- Submodules/agg-sharp | 2 +- 20 files changed, 122 insertions(+), 142 deletions(-) diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index 0627282fb..ef417765f 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -73,7 +73,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("AddBase") { - OperationType = typeof(IObject3D), TitleGetter = () => "Add Base".Localize(), ResultType = typeof(BaseObject3D), Action = (sceneContext) => @@ -100,9 +99,9 @@ namespace MatterHackers.MatterControl Icon = (theme) => StaticData.Instance.LoadIcon("add_base.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), // this is for when base is working with generic meshes - //IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem is IPathObject), + //IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && !(sceneContext.Scene.SelectedItem.IsPathObject()), // this is for when only IPathObjects are working correctly - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.DescendantsAndSelf().Where(i => i is IPathObject).Any(), + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.DescendantsAndSelf().Where(i => i.IsPathObject()).Any(), }; } @@ -220,7 +219,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("EditComponent") { - OperationType = typeof(IObject3D), TitleGetter = () => "Edit Component".Localize(), ResultType = typeof(ComponentObject3D), Action = (sceneContext) => @@ -286,7 +284,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("ImageConverter") { - OperationType = typeof(ImageObject3D), TitleGetter = () => "Image Converter".Localize(), ResultType = typeof(ComponentObject3D), Action = (sceneContext) => @@ -350,7 +347,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("ImageToPath") { - OperationType = typeof(ImageObject3D), TitleGetter = () => "Image to Path".Localize(), ResultType = typeof(ImageToPathObject3D_2), Action = (sceneContext) => @@ -385,7 +381,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("InflatePath") { - OperationType = typeof(IPathObject), TitleGetter = () => "Inflate Path".Localize(), ResultType = typeof(InflatePathObject3D), Action = (sceneContext) => @@ -407,7 +402,7 @@ namespace MatterHackers.MatterControl }, Icon = (theme) => StaticData.Instance.LoadIcon("inflate_path.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject, + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.IsPathObject(), }; } @@ -415,14 +410,14 @@ namespace MatterHackers.MatterControl { return new SceneOperation("LinearExtrude") { - OperationType = typeof(IPathObject), TitleGetter = () => "Linear Extrude".Localize(), ResultType = typeof(LinearExtrudeObject3D), Action = (sceneContext) => { var scene = sceneContext.Scene; var sceneItem = scene.SelectedItem; - if (sceneItem is IPathObject pathObject) + var pathObject = sceneItem.GetVertexSource(); + if (pathObject != null) { var extrude = new LinearExtrudeObject3D(); @@ -440,7 +435,7 @@ namespace MatterHackers.MatterControl }, Icon = (theme) => StaticData.Instance.LoadIcon("linear_extrude.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject, + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.IsPathObject(), }; } @@ -448,14 +443,14 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Revolve") { - OperationType = typeof(IPathObject), TitleGetter = () => "Revolve".Localize(), ResultType = typeof(RevolveObject3D), Action = (sceneContext) => { var scene = sceneContext.Scene; var sceneItem = scene.SelectedItem; - if (sceneItem is IPathObject pathObject) + var pathObject = sceneItem.GetVertexSource(); + if (pathObject != null) { var revolve = new RevolveObject3D(); @@ -473,7 +468,7 @@ namespace MatterHackers.MatterControl }, Icon = (theme) => StaticData.Instance.LoadIcon("revolve.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject, + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.IsPathObject(), }; } @@ -529,7 +524,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Mirror") { - OperationType = typeof(IObject3D), ResultType = typeof(MirrorObject3D_2), TitleGetter = () => "Mirror".Localize(), Action = (sceneContext) => @@ -546,7 +540,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("OutlinePath") { - OperationType = typeof(IPathObject), TitleGetter = () => "Outline Path".Localize(), ResultType = typeof(OutlinePathObject3D), Action = (sceneContext) => @@ -567,7 +560,7 @@ namespace MatterHackers.MatterControl }, Icon = (theme) => StaticData.Instance.LoadIcon("outline.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject, + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.IsPathObject(), }; } @@ -575,7 +568,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Rotate") { - OperationType = typeof(IObject3D), ResultType = typeof(RotateObject3D_2), TitleGetter = () => "Rotate".Localize(), Action = (sceneContext) => @@ -592,7 +584,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Scale") { - OperationType = typeof(IObject3D), ResultType = typeof(ScaleObject3D_3), TitleGetter = () => "Scale".Localize(), Action = (sceneContext) => @@ -609,7 +600,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("SmoothPath") { - OperationType = typeof(IPathObject), TitleGetter = () => "Smooth Path".Localize(), ResultType = typeof(SmoothPathObject3D), Action = (sceneContext) => @@ -630,7 +620,7 @@ namespace MatterHackers.MatterControl }, Icon = (theme) => StaticData.Instance.LoadIcon("smooth_path.png", 16, 16).SetToColor(theme.TextColor).SetPreMultiply(), HelpTextGetter = () => "A path must be selected".Localize().Stars(), - IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem is IPathObject, + IsEnabled = (sceneContext) => sceneContext.Scene.SelectedItem != null && sceneContext.Scene.SelectedItem.IsPathObject(), }; } @@ -638,7 +628,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Translate") { - OperationType = typeof(IObject3D), ResultType = typeof(TranslateObject3D), TitleGetter = () => "Translate".Localize(), Action = (sceneContext) => @@ -655,7 +644,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Advanced Array") { - OperationType = typeof(IObject3D), ResultType = typeof(ArrayAdvancedObject3D), TitleGetter = () => "Advanced Array".Localize(), Action = (sceneContext) => @@ -676,7 +664,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Align") { - OperationType = typeof(IObject3D), ResultType = typeof(AlignObject3D_2), TitleGetter = () => "Align".Localize(), Action = (sceneContext) => @@ -939,7 +926,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Combine") { - OperationType = typeof(IObject3D), ResultType = typeof(CombineObject3D_2), TitleGetter = () => "Combine".Localize(), Action = (sceneContext) => @@ -965,7 +951,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Curve") { - OperationType = typeof(IObject3D), ResultType = typeof(CurveObject3D_3), TitleGetter = () => "Curve".Localize(), Action = (sceneContext) => @@ -983,7 +968,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Dual Extrusion Align") { - OperationType = typeof(IObject3D), TitleGetter = () => "Dual Extrusion Align".Localize(), Action = (sceneContext) => { @@ -1031,7 +1015,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Fit to Bounds") { - OperationType = typeof(IObject3D), ResultType = typeof(FitToBoundsObject3D_3), TitleGetter = () => "Fit to Bounds".Localize(), Action = async (sceneContext) => @@ -1053,7 +1036,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Fit to Cylinder") { - OperationType = typeof(IObject3D), ResultType = typeof(FitToCylinderObject3D), TitleGetter = () => "Fit to Cylinder".Localize(), Action = async (sceneContext) => @@ -1075,7 +1057,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Group") { - OperationType = typeof(SelectionGroupObject3D), ResultType = typeof(GroupHolesAppliedObject3D), TitleGetter = () => "Group".Localize(), Action = (sceneContext) => @@ -1097,7 +1078,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Hollow Out") { - OperationType = typeof(IObject3D), ResultType = typeof(HollowOutObject3D), TitleGetter = () => "Hollow Out".Localize(), Action = (sceneContext) => @@ -1115,7 +1095,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Intersect") { - OperationType = typeof(IObject3D), ResultType = typeof(IntersectionObject3D_2), TitleGetter = () => "Intersect".Localize(), Action = (sceneContext) => @@ -1141,14 +1120,14 @@ namespace MatterHackers.MatterControl { return item != null && !(item is ImageObject3D) - && !(item is IPathObject); + && !(item.IsPathObject()); } private static bool IsPathObject(IObject3D item) { return item != null && !(item is ImageObject3D) - && (item is IPathObject); + && (item.IsPathObject()); } private static SceneOperation LayFlatOperation() @@ -1217,7 +1196,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Linear Array") { - OperationType = typeof(IObject3D), ResultType = typeof(ArrayLinearObject3D), TitleGetter = () => "Linear Array".Localize(), Action = (sceneContext) => @@ -1238,7 +1216,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Pinch") { - OperationType = typeof(IObject3D), ResultType = typeof(PinchObject3D_3), TitleGetter = () => "Pinch".Localize(), Action = (sceneContext) => @@ -1256,7 +1233,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Plane Cut") { - OperationType = typeof(IObject3D), ResultType = typeof(PlaneCutObject3D), TitleGetter = () => "Plane Cut".Localize(), Action = (sceneContext) => @@ -1274,7 +1250,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Find Slice") { - OperationType = typeof(IObject3D), ResultType = typeof(PlaneCutObject3D), TitleGetter = () => "Find Slice".Localize(), Action = (sceneContext) => @@ -1292,7 +1267,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Radial Array") { - OperationType = typeof(IObject3D), ResultType = typeof(ArrayRadialObject3D), TitleGetter = () => "Radial Array".Localize(), Action = (sceneContext) => @@ -1313,7 +1287,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Reduce") { - OperationType = typeof(IObject3D), ResultType = typeof(DecimateObject3D), TitleGetter = () => "Reduce".Localize(), Action = (sceneContext) => @@ -1372,7 +1345,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Repair") { - OperationType = typeof(IObject3D), ResultType = typeof(RepairObject3D), TitleGetter = () => "Repair".Localize(), Action = (sceneContext) => @@ -1390,7 +1362,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Subtract & Replace") { - OperationType = typeof(IObject3D), ResultType = typeof(SubtractAndReplaceObject3D_2), TitleGetter = () => "Subtract & Replace".Localize(), Action = (sceneContext) => new SubtractAndReplaceObject3D_2().WrapSelectedItemAndSelect(sceneContext.Scene), @@ -1404,7 +1375,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Subtract") { - OperationType = typeof(IObject3D), ResultType = typeof(SubtractObject3D_2), TitleGetter = () => "Subtract".Localize(), Action = (sceneContext) => @@ -1523,7 +1493,6 @@ namespace MatterHackers.MatterControl { return new SceneOperation("Twist") { - OperationType = typeof(IObject3D), ResultType = typeof(TwistObject3D), TitleGetter = () => "Twist".Localize(), Action = (sceneContext) => diff --git a/MatterControlLib/CustomWidgets/SceneOperation.cs b/MatterControlLib/CustomWidgets/SceneOperation.cs index 3d2175d40..d600f49bc 100644 --- a/MatterControlLib/CustomWidgets/SceneOperation.cs +++ b/MatterControlLib/CustomWidgets/SceneOperation.cs @@ -65,11 +65,6 @@ namespace MatterHackers.Agg.UI public string Title => this.TitleGetter?.Invoke(); - /// - /// Gets or sets the type that this operation can be applied to - /// - public Type OperationType { get; set; } - /// /// Gets or sets if this operation should be shown in right click and modify menu. /// diff --git a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs index 33a80c21f..52afd8793 100644 --- a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs +++ b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs @@ -75,7 +75,6 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane new SceneOperation("Lithophane") { TitleGetter = () => "Lithophane".Localize(), - OperationType = typeof(ImageObject3D), ResultType = typeof(LithophaneObject3D), Action = (sceneContext) => { diff --git a/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs b/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs index 4058af75b..64352322c 100644 --- a/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs @@ -42,7 +42,7 @@ using Polygons = System.Collections.Generic.List _vertexSource; diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index d80c8d2c4..831fda8f9 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -161,12 +161,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer) { - if (item is IPathObject pathObject) + if (item.VertexSource != null) { using (item.RebuildLock()) { var newPathObject = new PathObject3D(); - newPathObject.VertexSource = new VertexStorage(pathObject.VertexSource); + newPathObject.VertexSource = new VertexStorage(item.VertexSource); // and replace us with the children var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject }); @@ -187,19 +187,14 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public static void DrawPath(this IObject3D item) { - if (item is IPathObject pathObject) + if (item.VertexSource != null) { - if (pathObject.VertexSource == null) - { - return; - } - bool first = true; var lastPosition = Vector2.Zero; var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ; maxXYZ = maxXYZ.Transform(item.Matrix.Inverted); var firstMove = Vector2.Zero; - foreach (var vertex in pathObject.VertexSource.Vertices()) + foreach (var vertex in item.VertexSource.Vertices()) { var position = vertex.position; if (first) @@ -248,18 +243,13 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty(); - if (item is IPathObject pathObject) + if (item.VertexSource != null) { - if (pathObject.VertexSource == null) - { - return box; - } - var lastPosition = Vector2.Zero; var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ; maxXYZ = maxXYZ.Transform(item.Matrix.Inverted); - foreach (var vertex in pathObject.VertexSource.Vertices()) + foreach (var vertex in item.VertexSource.Vertices()) { var position = vertex.position; diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index 86d16cde6..ff09dd015 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -50,9 +50,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations Sharp, } - public class InflatePathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider + public class InflatePathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider { - public IVertexSource VertexSource { get; set; } = new VertexStorage(); + public override IVertexSource VertexSource { get; set; } = new VertexStorage(); public InflatePathObject3D() { @@ -111,7 +111,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations private void InsetPath() { - var path = this.Children.OfType()?.FirstOrDefault(); + var path = this.Children.Where(c => c.VertexSource != null).FirstOrDefault(); if (path == null) { // clear our existing data diff --git a/MatterControlLib/DesignTools/Operations/Path/LinearExtrudeObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/LinearExtrudeObject3D.cs index 56ebb6036..c4b35c440 100644 --- a/MatterControlLib/DesignTools/Operations/Path/LinearExtrudeObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/LinearExtrudeObject3D.cs @@ -75,19 +75,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public override bool CanApply => true; - [JsonIgnore] - private IVertexSource VertexSource + public override IVertexSource GetVertexSource() { - get - { - var item = this.Descendants().Where((d) => d is IPathObject).FirstOrDefault(); - if (item is IPathObject pathItem) - { - return pathItem.VertexSource; - } - - return null; - } + return this.CombinedVisibleChildrenPaths(); } public override void Apply(UndoBuffer undoBuffer) @@ -162,7 +152,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations null, (reporter, cancellationToken) => { - var vertexSource = this.VertexSource; + var vertexSource = this.GetVertexSource(); List<(double height, double inset)> bevel = null; #if DEBUG if (BevelTop) @@ -178,12 +168,18 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } #endif - - Mesh = VertexSourceToMesh.Extrude(this.VertexSource, height, bevel); - if (Mesh.Vertices.Count == 0) + if (this.GetVertexSource() != null) { - Mesh = null; + Mesh = VertexSourceToMesh.Extrude(this.GetVertexSource(), height, bevel); + if (Mesh.Vertices.Count == 0) + { + Mesh = null; + } } + else + { + Mesh = null; + } UiThread.RunOnIdle(() => { diff --git a/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs index 63c4a5500..01953641b 100644 --- a/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs @@ -43,7 +43,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class MergePathObject3D : OperationSourceContainerObject3D, IPathObject, IEditorDraw, IObject3DControlsProvider + public class MergePathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider { private ClipperLib.ClipType clipType; private string operationName; @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations Name = name; } - public IVertexSource VertexSource { get; set; } = new VertexStorage(); + public override IVertexSource VertexSource { get; set; } = new VertexStorage(); public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { @@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } var first = participants.First(); - var resultsVertexSource = (first as IPathObject).VertexSource.Transform(first.Matrix); + var resultsVertexSource = first.VertexSource.Transform(first.Matrix); var totalOperations = participants.Count() - 1; double amountPerOperation = 1.0 / totalOperations; @@ -145,9 +145,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations foreach (var item in participants) { if (item != first - && item is IPathObject pathItem) + && item.VertexSource != null) { - var itemVertexSource = pathItem.VertexSource.Transform(item.Matrix); + var itemVertexSource = item.VertexSource.Transform(item.Matrix); resultsVertexSource = resultsVertexSource.MergePaths(itemVertexSource, clipType); diff --git a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs index 3752c8839..1ad9cf18f 100644 --- a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs @@ -45,10 +45,8 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools.Operations { - public class OutlinePathObject3D : Object3D, IPathObject, IEditorDraw, IObject3DControlsProvider + public class OutlinePathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider { - public IVertexSource VertexSource { get; set; } = new VertexStorage(); - public OutlinePathObject3D() { Name = "Outline Path".Localize(); @@ -57,7 +55,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations [Description("The with of the outline.")] public DoubleOrExpression OutlineWidth { get; set; } = 3; - public DoubleOrExpression Ratio { get; set; } = .5; + [Description("The offset of the outside of the outline as a ratio of the width.")] + public DoubleOrExpression Offset { get; set; } = .5; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public ExpandStyles InnerStyle { get; set; } = ExpandStyles.Sharp; @@ -110,7 +109,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { InsetPath(); // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); + this.Mesh = VertexStorage.Extrude(Constants.PathPolygonsHeight); } Invalidate(InvalidateType.DisplayValues); @@ -122,20 +121,20 @@ namespace MatterHackers.MatterControl.DesignTools.Operations private void InsetPath() { - var path = this.Children.OfType().FirstOrDefault(); + var path = this.CombinedVisibleChildrenPaths(); if (path == null) { // clear our existing data - VertexSource = new VertexStorage(); + VertexStorage = new VertexStorage(); return; } - var aPolys = path.VertexSource.CreatePolygons(); + var aPolys = path.CreatePolygons(); var offseter = new ClipperOffset(); var outlineWidth = OutlineWidth.Value(this); - var ratio = Ratio.Value(this); + var ratio = Offset.Value(this); offseter.AddPaths(aPolys, InflatePathObject3D.GetJoinType(OuterStyle), EndType.etClosedPolygon); var outerLoops = new List>(); @@ -150,9 +149,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations var allLoops = outerLoops; allLoops.AddRange(innerLoops); - VertexSource = allLoops.CreateVertexStorage(); + VertexStorage = allLoops.CreateVertexStorage(); - (VertexSource as VertexStorage).Add(0, 0, ShapePath.FlagsAndCommand.Stop); + VertexStorage.Add(0, 0, ShapePath.FlagsAndCommand.Stop); } public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) diff --git a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs index 57d973ac3..9ea6b9db0 100644 --- a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs @@ -70,10 +70,10 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { get { - var item = this.Descendants().Where((d) => d is IPathObject).FirstOrDefault(); - if (item is IPathObject pathItem) + var item = this.Descendants().Where(c => c.VertexSource != null).FirstOrDefault(); + if (item != null) { - return pathItem.VertexSource; + return item.VertexSource; } return null; @@ -131,7 +131,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - (Vector3, Vector3) GetStartEnd(IPathObject pathObject) + (Vector3, Vector3) GetStartEnd(IObject3D pathObject) { // draw the line that is the rotation point var aabb = this.GetAxisAlignedBoundingBox(); @@ -147,9 +147,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { var child = this.Children.FirstOrDefault(); - if (child is IPathObject pathObject) + if (child?.VertexSource != null) { - var (start, end) = GetStartEnd(pathObject); + var (start, end) = GetStartEnd(child); layer.World.Render3DLine(start, end, Color.Red, true); layer.World.Render3DLine(start, end, Color.Red.WithAlpha(20), false); } @@ -158,9 +158,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer) { var child = this.Children.FirstOrDefault(); - if (child is IPathObject pathObject) + if (child.VertexSource != null) { - var (start, end) = GetStartEnd(pathObject); + var (start, end) = GetStartEnd(child); return new AxisAlignedBoundingBox(new Vector3[] { start, end }); } diff --git a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs index 87af4111b..510aa7d4e 100644 --- a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs @@ -46,9 +46,9 @@ using Polygons = System.Collections.Generic.List().FirstOrDefault(); + var path = this.Children.Where(c => c.VertexSource != null).FirstOrDefault(); if (path == null) { // clear our existing data diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs index 6a06e6bdd..da58b9c73 100644 --- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs @@ -150,15 +150,15 @@ namespace MatterHackers.MatterControl.DesignTools { get { - var vertexSource = (IPathObject)this.Descendants().FirstOrDefault((i) => i is IPathObject); + var vertexSource = this.Descendants().FirstOrDefault(i => i.VertexSource != null)?.VertexSource; var hasMesh = this.Descendants().Where(m => m.Mesh != null).Any(); - return vertexSource?.VertexSource == null && hasMesh; + return vertexSource == null && hasMesh; } } [JsonIgnore] - public IVertexSource VertexSource + public override IVertexSource VertexSource { get { @@ -176,16 +176,16 @@ namespace MatterHackers.MatterControl.DesignTools return meshVertexCache.vertexSource; } - var vertexSource = (IPathObject)this.Descendants().FirstOrDefault((i) => i is IPathObject); - return vertexSource?.VertexSource; + var vertexSource = this.Descendants().FirstOrDefault((i) => i.VertexSource != null)?.VertexSource; + return vertexSource; } set { - var vertexSource = this.Children.OfType().FirstOrDefault(); - if (vertexSource != null) + var pathObject = this.Children.FirstOrDefault(i => i.VertexSource != null); + if (pathObject != null) { - vertexSource.VertexSource = value; + pathObject.VertexSource = value; } } } @@ -438,8 +438,8 @@ namespace MatterHackers.MatterControl.DesignTools changeSet.Add(nameof(Centering), BaseType == BaseTypes.Circle); changeSet.Add(nameof(ExtrusionHeight), BaseType != BaseTypes.None); - var vertexSource = (IPathObject)this.Descendants().FirstOrDefault((i) => i is IPathObject); - var meshSource = this.Descendants().Where((i) => i.Mesh != null); + var vertexSource = this.Descendants().FirstOrDefault((i) => i.VertexSource != null)?.VertexSource; + var meshSource = this.Descendants().Where((i) => i.Mesh != null); changeSet.Add(nameof(CalculationHeight), vertexSource == null && meshSource.Where(m => m.Mesh != null).Any()); diff --git a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs index 2ecf96a9d..03365039a 100644 --- a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs @@ -42,7 +42,7 @@ using Newtonsoft.Json; namespace MatterHackers.MatterControl.DesignTools { - public class BoxPathObject3D : PrimitiveObject3D, IPathObject, IObject3DControlsProvider, IEditorDraw + public class BoxPathObject3D : PrimitiveObject3D, IObject3DControlsProvider, IEditorDraw { public BoxPathObject3D() { @@ -55,7 +55,7 @@ namespace MatterHackers.MatterControl.DesignTools [JsonIgnore] private IVertexSource _vertexSource = new VertexStorage(); - public IVertexSource VertexSource + public override IVertexSource VertexSource { get => _vertexSource; diff --git a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs index 7166475be..39b27269b 100644 --- a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs @@ -48,6 +48,16 @@ using Newtonsoft.Json.Converters; namespace MatterHackers.MatterControl.DesignTools { + public enum OutputDimensions + { + [EnumNameAttribute("2D")] + [DescriptionAttribute("Create a 2D Path")] + Output2D, + [EnumNameAttribute("3D")] + [DescriptionAttribute("Create a 3D Mesh")] + Output3D + } + [HideChildrenFromTreeView] public class TextObject3D : Object3D, IPropertyGridModifier { @@ -97,9 +107,23 @@ namespace MatterHackers.MatterControl.DesignTools [JsonConverter(typeof(StringEnumConverter))] public NamedTypeFace Font { get; set; } = NamedTypeFace.Nunito_Bold; + [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] + // [Icons(new string[] { "align_left.png", "align_center_x.png", "align_right.png" }, InvertIcons = true)] + public OutputDimensions Output { get; set; } = OutputDimensions.Output3D; + public override bool CanApply => true; - public override void Apply(UndoBuffer undoBuffer) + public override IVertexSource GetVertexSource() + { + if (Output == OutputDimensions.Output2D) + { + return this.CombinedVisibleChildrenPaths(); + } + + return null; + } + + public override void Apply(UndoBuffer undoBuffer) { // change this from a text object to a group var newContainer = new GroupObject3D(); @@ -159,6 +183,7 @@ namespace MatterHackers.MatterControl.DesignTools else { Mesh = null; + var extrusionHeight = Output == OutputDimensions.Output2D ? Constants.PathPolygonsHeight : this.Height.Value(this); this.Children.Modify(list => { list.Clear(); @@ -212,10 +237,16 @@ namespace MatterHackers.MatterControl.DesignTools default: letterObject = new Object3D() { - Mesh = VertexSourceToMesh.Extrude(scaledLetterPrinter, this.Height.Value(this)), + Mesh = VertexSourceToMesh.Extrude(scaledLetterPrinter, extrusionHeight), Matrix = Matrix4X4.CreateTranslation(offset.X, 0, 0), Name = leterNumber.ToString("000") + " - '" + letter.ToString() + "'" }; + if (Output == OutputDimensions.Output2D) + { + letterObject.VertexStorage = new VertexStorage( + new VertexSourceApplyTransform( + new VertexStorage(scaledLetterPrinter), Affine.NewTranslation(offset.X, offset.Y))); + } offset.X += letterPrinter.GetSize(letter.ToString()).X * pointsToMm; break; } @@ -283,6 +314,7 @@ namespace MatterHackers.MatterControl.DesignTools change.SetRowVisible(nameof(MultiLineText), () => MultiLine); change.SetRowVisible(nameof(Alignment), () => MultiLine); change.SetRowVisible(nameof(NameToWrite), () => !MultiLine); + change.SetRowVisible(nameof(Height), () => Output == OutputDimensions.Output3D); } } } \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs index 83d33e5a6..05a7360eb 100644 --- a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs @@ -48,7 +48,7 @@ using Newtonsoft.Json.Converters; namespace MatterHackers.MatterControl.DesignTools { - public class TextPathObject3D : Object3D, IPathObject, IEditorDraw + public class TextPathObject3D : Object3D, IEditorDraw { public TextPathObject3D() { @@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl.DesignTools public override bool CanApply => true; - public IVertexSource VertexSource { get; set; } = new VertexStorage(); + public override IVertexSource VertexSource { get; set; } = new VertexStorage(); public override void Apply(UndoBuffer undoBuffer) { diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs index 733d0ec3d..ad4f435fe 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs @@ -47,7 +47,7 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow.View3D { - public class SubtractPathObject3D : OperationSourceContainerObject3D, IPathObject, IEditorDraw, IObject3DControlsProvider + public class SubtractPathObject3D : OperationSourceContainerObject3D, IEditorDraw, IObject3DControlsProvider { public SubtractPathObject3D() { @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [DisplayName("Part(s) to Subtract")] public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); - public IVertexSource VertexSource { get; set; } = new VertexStorage(); + public override IVertexSource VertexSource { get; set; } = new VertexStorage(); public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { @@ -198,11 +198,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D bool first = true; foreach (var keep in keepVisibleItems) { - var resultsVertexSource = (keep as IPathObject).VertexSource.Transform(keep.Matrix); + var resultsVertexSource = keep.VertexSource.Transform(keep.Matrix); foreach (var remove in removeVisibleItems) { - resultsVertexSource = resultsVertexSource.MergePaths(((IPathObject)remove).VertexSource.Transform(remove.Matrix), ClipperLib.ClipType.ctDifference); + resultsVertexSource = resultsVertexSource.MergePaths(remove.VertexSource.Transform(remove.Matrix), ClipperLib.ClipType.ctDifference); // report our progress ratioCompleted += amountPerOperation; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 5abd29704..d9a37aa87 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 5abd29704a4358afab0366bbe21c42066b9cd15d +Subproject commit d9a37aa87794203eb741f0713a3dfe9210383393 From aadec8b9f5f9d19f7a2c48954d2b9bb2872232f4 Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Tue, 9 Aug 2022 16:21:39 -0700 Subject: [PATCH 07/15] more path work --- .../DesignTools/Operations/Object3DExtensions.cs | 11 +++++++++++ .../Operations/Path/InflatePathObject3D.cs | 10 ++++------ .../DesignTools/Primitives/TextObject3D.cs | 5 ++++- Submodules/agg-sharp | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index 831fda8f9..41e05329b 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -87,6 +87,17 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } + public static void RefreshToolBar(this IObject3D item) + { + var sceneContext = item.ContainingScene(); + if (sceneContext != null) + { + // deselect than re-select the item + sceneContext.SelectedItem = null; + sceneContext.SelectedItem = item; + } + } + public static void ShowRenameDialog(this IObject3D item, UndoBuffer undoBuffer) { DialogWindow.Show( diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index ff09dd015..052a5975c 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -52,8 +52,6 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public class InflatePathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider { - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - public InflatePathObject3D() { Name = "Inflate Path".Localize(); @@ -101,7 +99,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { InsetPath(); // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); + this.Mesh = VertexStorage.Extrude(Constants.PathPolygonsHeight); } this.CancelAllParentBuilding(); @@ -111,15 +109,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations private void InsetPath() { - var path = this.Children.Where(c => c.VertexSource != null).FirstOrDefault(); + var path = this.CombinedVisibleChildrenPaths(); if (path == null) { // clear our existing data - VertexSource = new VertexStorage(); + VertexStorage = new VertexStorage(); return; } - VertexSource = path.VertexSource.Offset(Inflate.Value(this), GetJoinType(Style)); + VertexStorage = path.Offset(Inflate.Value(this), GetJoinType(Style)); } internal static JoinType GetJoinType(ExpandStyles style) diff --git a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs index 39b27269b..ca5ec9707 100644 --- a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs @@ -108,7 +108,6 @@ namespace MatterHackers.MatterControl.DesignTools public NamedTypeFace Font { get; set; } = NamedTypeFace.Nunito_Bold; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] - // [Icons(new string[] { "align_left.png", "align_center_x.png", "align_right.png" }, InvertIcons = true)] public OutputDimensions Output { get; set; } = OutputDimensions.Output3D; public override bool CanApply => true; @@ -315,6 +314,10 @@ namespace MatterHackers.MatterControl.DesignTools change.SetRowVisible(nameof(Alignment), () => MultiLine); change.SetRowVisible(nameof(NameToWrite), () => !MultiLine); change.SetRowVisible(nameof(Height), () => Output == OutputDimensions.Output3D); + if (change.Changed == nameof(Output)) + { + this.RefreshToolBar(); + } } } } \ No newline at end of file diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index d9a37aa87..36ca84b13 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit d9a37aa87794203eb741f0713a3dfe9210383393 +Subproject commit 36ca84b13297ae1521c8493a09f35140834018fd From f5c8b2008c151b43aff0cbca2436a35994baf006 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Thu, 11 Aug 2022 18:37:06 -0700 Subject: [PATCH 08/15] fixing more pathing code --- .../Operations/Image/ImageToPathObject3D_2.cs | 4 +--- .../Operations/Object3DExtensions.cs | 4 ++-- .../Operations/Path/InflatePathObject3D.cs | 2 +- .../Operations/Path/OutlinePathObject3D.cs | 2 +- .../DesignTools/Primitives/TextObject3D.cs | 23 ++++++++++++++++--- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs index 62fcc11ba..3d12ef3a4 100644 --- a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D_2.cs @@ -173,8 +173,6 @@ namespace MatterHackers.MatterControl.DesignTools [MaxDecimalPlaces(2)] public double MinSurfaceArea {get; set; } = 1; - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - public void AddObject3DControls(Object3DControlsLayer object3DControlsLayer) { object3DControlsLayer.AddControls(ControlTypes.Standard2D); @@ -273,7 +271,7 @@ namespace MatterHackers.MatterControl.DesignTools affine *= Affine.NewTranslation(-aabb.XSize / 2, -aabb.YSize / 2); rawVectorShape.transform(affine); - this.VertexSource = rawVectorShape; + this.VertexStorage = rawVectorShape; progressReporter?.Invoke(1, null); } diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index 41e05329b..d756b4fff 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -198,14 +198,14 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public static void DrawPath(this IObject3D item) { - if (item.VertexSource != null) + if (item.GetVertexSource() != null) { bool first = true; var lastPosition = Vector2.Zero; var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ; maxXYZ = maxXYZ.Transform(item.Matrix.Inverted); var firstMove = Vector2.Zero; - foreach (var vertex in item.VertexSource.Vertices()) + foreach (var vertex in item.GetVertexSource().Vertices()) { var position = vertex.position; if (first) diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index 052a5975c..5baa95458 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -58,7 +58,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } [Description("The amount to expand the path lines.")] - public DoubleOrExpression Inflate { get; set; } = 1; + public DoubleOrExpression Inflate { get; set; } = .2; [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] public ExpandStyles Style { get; set; } = ExpandStyles.Sharp; diff --git a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs index 1ad9cf18f..7d6bb8cad 100644 --- a/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/OutlinePathObject3D.cs @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } [Description("The with of the outline.")] - public DoubleOrExpression OutlineWidth { get; set; } = 3; + public DoubleOrExpression OutlineWidth { get; set; } = .5; [Description("The offset of the outside of the outline as a ratio of the width.")] public DoubleOrExpression Offset { get; set; } = .5; diff --git a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs index ca5ec9707..ce6c27813 100644 --- a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs @@ -40,6 +40,7 @@ using MatterHackers.DataConverters3D; using MatterHackers.DataConverters3D.UndoCommands; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools.Operations; +using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.PolygonMesh; using MatterHackers.PolygonMesh.Processors; using MatterHackers.VectorMath; @@ -59,9 +60,11 @@ namespace MatterHackers.MatterControl.DesignTools } [HideChildrenFromTreeView] - public class TextObject3D : Object3D, IPropertyGridModifier + public class TextObject3D : Object3D, IPropertyGridModifier, IEditorDraw { - [JsonConverter(typeof(StringEnumConverter))] + private bool refreshToolBar; + + [JsonConverter(typeof(StringEnumConverter))] public enum TextAlign { Left, @@ -304,6 +307,10 @@ namespace MatterHackers.MatterControl.DesignTools Invalidate(InvalidateType.DisplayValues); this.CancelAllParentBuilding(); Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Children)); + if (refreshToolBar) + { + this.RefreshToolBar(); + } }); }); } @@ -316,8 +323,18 @@ namespace MatterHackers.MatterControl.DesignTools change.SetRowVisible(nameof(Height), () => Output == OutputDimensions.Output3D); if (change.Changed == nameof(Output)) { - this.RefreshToolBar(); + refreshToolBar = true; } } + + public void DrawEditor(Object3DControlsLayer object3DControlLayer, DrawEventArgs e) + { + this.DrawPath(); + } + + public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer) + { + return this.GetWorldspaceAabbOfDrawPath(); + } } } \ No newline at end of file From 6e3c4be07c03f97338b52c958015b81d82a50841 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 12 Aug 2022 18:05:37 -0700 Subject: [PATCH 09/15] Improving path objects --- .../ApplicationView/Application.cs | 51 +---- .../ApplicationView/SceneOperations.cs | 2 +- .../Operations/Image/PathObject3D.cs | 19 -- .../Operations/Path/RevolveObject3D.cs | 37 +--- .../Operations/Path/SmoothPathObject3D.cs | 14 +- .../DesignTools/Primitives/TextObject3D.cs | 7 +- .../Primitives/TextPathObject3D.cs | 208 ------------------ .../DesignAppsCollectionContainer.cs | 6 +- .../MatterControl/PrimitivesContainer.cs | 4 +- Submodules/agg-sharp | 2 +- .../CreateLibraryFolder.cs | 52 ++--- .../DesignTools/SheetTests.cs | 4 +- .../MatterControl/SliceSettingsFieldTests.cs | 2 +- 13 files changed, 51 insertions(+), 357 deletions(-) delete mode 100644 MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs diff --git a/MatterControlLib/ApplicationView/Application.cs b/MatterControlLib/ApplicationView/Application.cs index 47eb47d80..6a40b1356 100644 --- a/MatterControlLib/ApplicationView/Application.cs +++ b/MatterControlLib/ApplicationView/Application.cs @@ -529,60 +529,11 @@ namespace MatterHackers.MatterControl ReportStartupProgress(0, "ShowAsSystemWindow"); - AddTextWidgetRightClickMenu(); + InternalTextEditWidget.AddTextWidgetRightClickMenu(ApplicationController.Instance.MenuTheme); return rootSystemWindow; } - public static void AddTextWidgetRightClickMenu() - { - InternalTextEditWidget.DefaultRightClick += (s, e) => - { - var textEditWidget = s as InternalTextEditWidget; - var theme = ApplicationController.Instance.MenuTheme; - var popupMenu = new PopupMenu(theme); - - var cut = popupMenu.CreateMenuItem("Cut".Localize()); - cut.Enabled = !string.IsNullOrEmpty(s.Selection); - cut.Click += (s2, e2) => - { - textEditWidget?.CopySelection(); - textEditWidget?.DeleteSelection(); - }; - - var copy = popupMenu.CreateMenuItem("Copy".Localize()); - copy.Enabled = !string.IsNullOrEmpty(s.Selection); - copy.Click += (s2, e2) => - { - textEditWidget?.CopySelection(); - }; - - var paste = popupMenu.CreateMenuItem("Paste".Localize()); - paste.Enabled = Clipboard.Instance.ContainsText; - paste.Click += (s2, e2) => - { - textEditWidget?.PasteFromClipboard(); - }; - - popupMenu.CreateSeparator(); - - var selectAll = popupMenu.CreateMenuItem("Select All".Localize()); - selectAll.Enabled = !string.IsNullOrEmpty(textEditWidget.Text); - selectAll.Click += (s2, e2) => - { - textEditWidget?.SelectAll(); - }; - - textEditWidget.KeepMenuOpen = true; - popupMenu.Closed += (s3, e3) => - { - textEditWidget.KeepMenuOpen = false; - }; - - popupMenu.ShowMenu(s, e); - }; - } - private static void SystemWindow_KeyPressed(object sender, KeyPressEventArgs keyEvent) { if (sender is SystemWindow systemWindow) diff --git a/MatterControlLib/ApplicationView/SceneOperations.cs b/MatterControlLib/ApplicationView/SceneOperations.cs index ef417765f..c082bc87b 100644 --- a/MatterControlLib/ApplicationView/SceneOperations.cs +++ b/MatterControlLib/ApplicationView/SceneOperations.cs @@ -894,7 +894,7 @@ namespace MatterHackers.MatterControl { SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath") }); - PrimaryOperations.Add(typeof(TextPathObject3D), new List + PrimaryOperations.Add(typeof(TextObject3D), new List { SceneOperations.ById("LinearExtrude"), SceneOperations.ById("Revolve"), SceneOperations.ById("InflatePath"), SceneOperations.ById("OutlinePath") }); diff --git a/MatterControlLib/DesignTools/Operations/Image/PathObject3D.cs b/MatterControlLib/DesignTools/Operations/Image/PathObject3D.cs index d1f47b273..c4f39b49e 100644 --- a/MatterControlLib/DesignTools/Operations/Image/PathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Image/PathObject3D.cs @@ -28,34 +28,15 @@ either expressed or implied, of the FreeBSD Project. */ using MatterHackers.Agg.UI; -using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.PartPreviewWindow; -using MatterHackers.PolygonMesh.Processors; using MatterHackers.VectorMath; -using Newtonsoft.Json; -using System.Collections.Generic; namespace MatterHackers.MatterControl.DesignTools { public class PathObject3D : Object3D, IEditorDraw { - [JsonIgnore] - private IVertexSource _vertexSource = new VertexStorage(); - - public override IVertexSource VertexSource - { - get => _vertexSource; - - set - { - _vertexSource = value; - // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); - } - } - public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { this.DrawPath(); diff --git a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs index 9ea6b9db0..faa68f0c2 100644 --- a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs @@ -27,7 +27,6 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -65,21 +64,6 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public override bool CanApply => true; - [JsonIgnore] - private IVertexSource VertexSource - { - get - { - var item = this.Descendants().Where(c => c.VertexSource != null).FirstOrDefault(); - if (item != null) - { - return item.VertexSource; - } - - return null; - } - } - public override void Apply(UndoBuffer undoBuffer) { if (Mesh == null) @@ -131,11 +115,11 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - (Vector3, Vector3) GetStartEnd(IObject3D pathObject) + (Vector3, Vector3) GetStartEnd(IObject3D pathObject, IVertexSource path) { // draw the line that is the rotation point var aabb = this.GetAxisAlignedBoundingBox(); - var vertexSource = this.VertexSource.Transform(Matrix); + var vertexSource = path.Transform(Matrix); var bounds = vertexSource.GetBounds(); var lineX = bounds.Left + AxisPosition.Value(this); @@ -146,10 +130,10 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { - var child = this.Children.FirstOrDefault(); - if (child?.VertexSource != null) + var path = this.CombinedVisibleChildrenPaths(); + if (path == null) { - var (start, end) = GetStartEnd(child); + var (start, end) = GetStartEnd(this, path); layer.World.Render3DLine(start, end, Color.Red, true); layer.World.Render3DLine(start, end, Color.Red.WithAlpha(20), false); } @@ -157,14 +141,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer) { - var child = this.Children.FirstOrDefault(); - if (child.VertexSource != null) - { - var (start, end) = GetStartEnd(child); - return new AxisAlignedBoundingBox(new Vector3[] { start, end }); - } - - return AxisAlignedBoundingBox.Empty(); + return this.GetWorldspaceAabbOfDrawPath(); } private CancellationTokenSource cancellationToken; @@ -209,7 +186,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations (reporter, cancellationTokenSource) => { this.cancellationToken = cancellationTokenSource as CancellationTokenSource; - var vertexSource = this.VertexSource; + var vertexSource = this.CombinedVisibleChildrenPaths(); var pathBounds = vertexSource.GetBounds(); vertexSource = vertexSource.Translate(-pathBounds.Left - axisPosition, 0); Mesh mesh = VertexSourceToMesh.Revolve(vertexSource, diff --git a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs index 510aa7d4e..92bc1a004 100644 --- a/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/SmoothPathObject3D.cs @@ -28,9 +28,7 @@ either expressed or implied, of the FreeBSD Project. */ using System; -using System.Collections.Generic; using System.ComponentModel; -using System.Linq; using System.Threading.Tasks; using ClipperLib; using MatterHackers.Agg.UI; @@ -48,8 +46,6 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { public class SmoothPathObject3D : Object3D, IEditorDraw, IObject3DControlsProvider { - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - public SmoothPathObject3D() { Name = "Smooth Path".Localize(); @@ -105,7 +101,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations DoSmoothing((long)(SmoothDistance.Value(this) * 1000), Iterations.Value(this)); // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); + this.Mesh = VertexStorage.Extrude(Constants.PathPolygonsHeight); UiThread.RunOnIdle(() => { @@ -121,15 +117,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations private void DoSmoothing(long maxDist, int interations) { bool closedPath = true; - var path = this.Children.Where(c => c.VertexSource != null).FirstOrDefault(); + var path = this.CombinedVisibleChildrenPaths(); if (path == null) { // clear our existing data - VertexSource = new VertexStorage(); + VertexStorage = new VertexStorage(); return; } - var sourceVertices = path.VertexSource; + var sourceVertices = path; var inputPolygons = sourceVertices.CreatePolygons(); @@ -180,7 +176,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations outputPolygons = ClipperLib.Clipper.CleanPolygons(outputPolygons, Math.Max(maxDist / 10, 1.415)); } - VertexSource = outputPolygons.CreateVertexStorage(); + VertexStorage = outputPolygons.CreateVertexStorage(); } public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) diff --git a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs index ce6c27813..7b5d3a30a 100644 --- a/MatterControlLib/DesignTools/Primitives/TextObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/TextObject3D.cs @@ -78,10 +78,15 @@ namespace MatterHackers.MatterControl.DesignTools Color = Operations.Object3DExtensions.PrimitiveColors["Text"]; } - public static async Task Create() + public static async Task Create(bool setTo2D = false) { var item = new TextObject3D(); + if (!setTo2D) + { + item.Output = OutputDimensions.Output2D; + } + await item.Rebuild(); return item; diff --git a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs deleted file mode 100644 index 05a7360eb..000000000 --- a/MatterControlLib/DesignTools/Primitives/TextPathObject3D.cs +++ /dev/null @@ -1,208 +0,0 @@ -/* -Copyright (c) 2018, Lars Brubaker, John Lewin -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -The views and conclusions contained in the software and documentation are those -of the authors and should not be interpreted as representing official policies, -either expressed or implied, of the FreeBSD Project. -*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Threading.Tasks; -using MatterHackers.Agg.Font; -using MatterHackers.Agg.Transform; -using MatterHackers.Agg.UI; -using MatterHackers.Agg.VertexSource; -using MatterHackers.DataConverters3D; -using MatterHackers.DataConverters3D.UndoCommands; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.DesignTools.Operations; -using MatterHackers.MatterControl.PartPreviewWindow; -using MatterHackers.PolygonMesh; -using MatterHackers.PolygonMesh.Processors; -using MatterHackers.VectorMath; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; - -namespace MatterHackers.MatterControl.DesignTools -{ - public class TextPathObject3D : Object3D, IEditorDraw - { - public TextPathObject3D() - { - Name = "Text".Localize(); - Color = Operations.Object3DExtensions.PrimitiveColors["Text"]; - } - - public static async Task Create() - { - var item = new TextPathObject3D(); - - await item.Rebuild(); - return item; - } - - [DisplayName("Text")] - public StringOrExpression Text { get; set; } = "Text"; - - public DoubleOrExpression PointSize { get; set; } = 24; - - [Sortable] - [JsonConverter(typeof(StringEnumConverter))] - public NamedTypeFace Font { get; set; } = new NamedTypeFace(); - - public override bool CanApply => true; - - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - - public override void Apply(UndoBuffer undoBuffer) - { - // change this from a text object to a group - var newContainer = new GroupObject3D(); - newContainer.CopyProperties(this, Object3DPropertyFlags.All); - foreach (var child in this.Children) - { - newContainer.Children.Add(child.Clone()); - } - - undoBuffer.AddAndDo(new ReplaceCommand(new[] { this }, new[] { newContainer })); - } - - public override async void OnInvalidate(InvalidateArgs invalidateArgs) - { - if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Children) - || invalidateArgs.InvalidateType.HasFlag(InvalidateType.Matrix) - || invalidateArgs.InvalidateType.HasFlag(InvalidateType.Mesh)) - && invalidateArgs.Source != this - && !RebuildLocked) - { - await Rebuild(); - } - else if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateArgs.Source == this)) - { - await Rebuild(); - } - else if (SheetObject3D.NeedsRebuild(this, invalidateArgs)) - { - await Rebuild(); - } - else - { - base.OnInvalidate(invalidateArgs); - } - } - - public override Task Rebuild() - { - this.DebugDepth("Rebuild"); - using (RebuildLock()) - { - double pointsToMm = 0.352778; - - var printer = new TypeFacePrinter(Text.Value(this), new StyledTypeFace(ApplicationController.GetTypeFace(Font), PointSize.Value(this))) - { - ResolutionScale = 10 - }; - - var scaledLetterPrinter = new VertexSourceApplyTransform(printer, Affine.NewScaling(pointsToMm)); - var vertexSource = new VertexStorage(); - - foreach (var vertex in scaledLetterPrinter.Vertices()) - { - if (vertex.IsMoveTo) - { - vertexSource.MoveTo(vertex.position); - } - else if (vertex.IsLineTo) - { - vertexSource.LineTo(vertex.position); - } - else if (vertex.IsClose) - { - vertexSource.ClosePolygon(); - } - } - - vertexSource = (VertexStorage)vertexSource.Union(vertexSource); - - this.VertexSource = vertexSource; - - // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); - } - - this.CancelAllParentBuilding(); - Parent?.Invalidate(new InvalidateArgs(this, InvalidateType.Path)); - return Task.CompletedTask; - } - - public override Mesh Mesh - { - get - { - if (base.Mesh == null) - { - using (this.RebuildLock()) - { - var bounds = this.VertexSource.GetBounds(); - - if (bounds.Width == 0 || bounds.Height == 0) - { - bounds = new Agg.RectangleDouble(0, 0, 60, 20); - } - - var center = bounds.Center; - var mesh = PlatonicSolids.CreateCube(Math.Max(8, bounds.Width), Math.Max(8, bounds.Height), 0.2); - - mesh.Translate(new Vector3(center.X, center.Y, 0)); - - base.Mesh = mesh; - } - } - - return base.Mesh; - } - } - - private Mesh InitMesh() - { - if (!string.IsNullOrWhiteSpace(Text.Value(this))) - { - } - - return null; - } - - public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) - { - this.DrawPath(); - } - - public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer) - { - return this.GetWorldspaceAabbOfDrawPath(); - } - } -} \ No newline at end of file diff --git a/MatterControlLib/Library/Providers/MatterControl/DesignAppsCollectionContainer.cs b/MatterControlLib/Library/Providers/MatterControl/DesignAppsCollectionContainer.cs index 52b5d0c91..f1bfebfdc 100644 --- a/MatterControlLib/Library/Providers/MatterControl/DesignAppsCollectionContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/DesignAppsCollectionContainer.cs @@ -96,10 +96,6 @@ namespace MatterHackers.MatterControl.Library "Calibration Face".Localize(), async () => await XyCalibrationFaceObject3D.Create()) { DateCreated = new System.DateTime(index++) }, - new GeneratorItem( - "Text2".Localize(), - async () => await TextPathObject3D.Create()) - { DateCreated = new System.DateTime(index++) }, new GeneratorItem( "Path".Localize(), () => @@ -112,7 +108,7 @@ namespace MatterHackers.MatterControl.Library var path = new PathObject3D() { - VertexSource = storage + VertexStorage = storage }; return Task.FromResult(path); diff --git a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs index d3ed518ac..cadedc09e 100644 --- a/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs +++ b/MatterControlLib/Library/Providers/MatterControl/PrimitivesContainer.cs @@ -81,7 +81,7 @@ namespace MatterHackers.MatterControl.Library { DateCreated = new DateTime(index++) }, new GeneratorItem( "Text".Localize(), - async () => await TextObject3D.Create()) + async () => await TextObject3D.Create(true)) { DateCreated = new DateTime(index++) }, new GeneratorItem( "Cylinder".Localize(), @@ -218,7 +218,7 @@ namespace MatterHackers.MatterControl.Library { DateCreated = new DateTime(index++) }, new GeneratorItem( "Text".Localize(), - async () => await TextPathObject3D.Create()) + async () => await TextObject3D.Create()) { DateCreated = new DateTime(index++) }, new GeneratorItem( "Oval".Localize(), diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 36ca84b13..d061bb620 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 36ca84b13297ae1521c8493a09f35140834018fd +Subproject commit d061bb620e8fa595aa2d2509dc33bb7874140278 diff --git a/Tests/MatterControl.AutomationTests/CreateLibraryFolder.cs b/Tests/MatterControl.AutomationTests/CreateLibraryFolder.cs index 07f52d800..7fe8c6188 100644 --- a/Tests/MatterControl.AutomationTests/CreateLibraryFolder.cs +++ b/Tests/MatterControl.AutomationTests/CreateLibraryFolder.cs @@ -27,44 +27,40 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System; -using System.Threading; -using System.Threading.Tasks; using MatterHackers.Agg.UI; -using MatterHackers.Agg.UI.Tests; -using MatterHackers.GuiAutomation; using NUnit.Framework; +using System.Threading.Tasks; using TestInvoker; namespace MatterHackers.MatterControl.Tests.Automation { - [TestFixture, Category("MatterControl.UI.Automation")] - public class CreateLibraryFolder - { - [Test, ChildProcessTest] - public async Task CreateFolderStartsWithTextFieldFocusedAndEditable() - { - await MatterControlUtilities.RunTest((testRunner) => - { - testRunner.OpenPartTab(); + [TestFixture, Category("MatterControl.UI.Automation")] + public class CreateLibraryFolder + { + [Test, ChildProcessTest] + public async Task CreateFolderStartsWithTextFieldFocusedAndEditable() + { + await MatterControlUtilities.RunTest((testRunner) => + { + testRunner.OpenPartTab(); - testRunner.NavigateToFolder("Local Library Row Item Collection"); - testRunner.InvokeLibraryCreateFolderDialog(); + testRunner.NavigateToFolder("Local Library Row Item Collection"); + testRunner.InvokeLibraryCreateFolderDialog(); - testRunner.Delay(.5); - testRunner.Type("Test Text"); - testRunner.Delay(.5); + testRunner.Delay(.5); + testRunner.Type("Test Text"); + testRunner.Delay(.5); - var textWidgetMH = testRunner.GetWidgetByName("InputBoxPage TextEditWidget", out _) as ThemedTextEditWidget; + var textWidgetMH = testRunner.GetWidgetByName("InputBoxPage TextEditWidget", out _) as ThemedTextEditWidget; - Assert.IsTrue(textWidgetMH != null, "Found Text Widget"); - Assert.IsTrue(textWidgetMH.Text == "Test Text", "Had the right text"); + Assert.IsTrue(textWidgetMH != null, "Found Text Widget"); + Assert.IsTrue(textWidgetMH.Text == "Test Text", "Had the right text"); - testRunner.ClickByName("Cancel Wizard Button"); - testRunner.Delay(.5); + testRunner.ClickByName("Cancel Wizard Button"); + testRunner.Delay(.5); - return Task.CompletedTask; - }); - } - } + return Task.CompletedTask; + }); + } + } } \ No newline at end of file diff --git a/Tests/MatterControl.AutomationTests/DesignTools/SheetTests.cs b/Tests/MatterControl.AutomationTests/DesignTools/SheetTests.cs index bddede25e..383313202 100644 --- a/Tests/MatterControl.AutomationTests/DesignTools/SheetTests.cs +++ b/Tests/MatterControl.AutomationTests/DesignTools/SheetTests.cs @@ -34,7 +34,7 @@ namespace MatterHackers.MatterControl.Tests.Automation Name = "Main Window", }; - Application.AddTextWidgetRightClickMenu(); + InternalTextEditWidget.AddTextWidgetRightClickMenu(ApplicationController.Instance.MenuTheme); AutomationRunner.TimeToMoveMouse = .1; @@ -189,7 +189,7 @@ namespace MatterHackers.MatterControl.Tests.Automation Name = "Main Window", }; - Application.AddTextWidgetRightClickMenu(); + InternalTextEditWidget.AddTextWidgetRightClickMenu(ApplicationController.Instance.MenuTheme); AutomationRunner.TimeToMoveMouse = .1; diff --git a/Tests/MatterControl.Tests/MatterControl/SliceSettingsFieldTests.cs b/Tests/MatterControl.Tests/MatterControl/SliceSettingsFieldTests.cs index cde545f0e..e9b096c94 100644 --- a/Tests/MatterControl.Tests/MatterControl/SliceSettingsFieldTests.cs +++ b/Tests/MatterControl.Tests/MatterControl/SliceSettingsFieldTests.cs @@ -358,7 +358,7 @@ namespace MatterControl.Tests.MatterControl Name = "Main Window", }; - Application.AddTextWidgetRightClickMenu(); + InternalTextEditWidget.AddTextWidgetRightClickMenu(ApplicationController.Instance.MenuTheme); AutomationRunner.TimeToMoveMouse = .1; From 9e2aad86514b36bd99ee06296eadc776130c58cb Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 14 Aug 2022 08:13:22 -0700 Subject: [PATCH 10/15] deprecated vertexsource --- .../EditorTools/RotateControls/PathControl.cs | 2 +- .../Operations/FindSliceObject3D.cs | 9 +- .../Operations/Image/ImageToPathObject3D.cs | 6 +- .../Operations/Object3DExtensions.cs | 8 +- .../Operations/Path/MergePathObject3D.cs | 12 ++- .../Operations/Path/RevolveObject3D.cs | 18 ++-- .../DesignTools/Primitives/BaseObject3D.cs | 85 +++++++------------ .../DesignTools/Primitives/BoxPathObject3D.cs | 27 ++---- .../View3D/Actions/SubtractPathObject3D.cs | 12 ++- StaticData/Translations/Master.txt | 3 + Submodules/agg-sharp | 2 +- 11 files changed, 74 insertions(+), 110 deletions(-) diff --git a/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs b/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs index 2ca502e88..f0d91cd23 100644 --- a/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs +++ b/MatterControlLib/DesignTools/EditorTools/RotateControls/PathControl.cs @@ -195,7 +195,7 @@ namespace MatterHackers.Plugins.EditorTools if (selectedItem is PathObject3D pathObject) { - var vertexStorage = pathObject.VertexSource as VertexStorage; + var vertexStorage = pathObject.VertexStorage; activePoints = vertexStorage.Vertices(); diff --git a/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs b/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs index 64352322c..8b94d5067 100644 --- a/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/FindSliceObject3D.cs @@ -51,8 +51,7 @@ namespace MatterHackers.MatterControl.DesignTools public double SliceHeight { get; set; } = 10; - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - + private double cutMargin = .01; public (Mesh mesh, Polygons polygons) Cut(IObject3D item) @@ -84,7 +83,7 @@ namespace MatterHackers.MatterControl.DesignTools { var newPathObject = new PathObject3D() { - VertexSource = new VertexStorage(this.VertexSource) + VertexStorage = new VertexStorage(this.GetVertexSource()) }; base.Apply(undoBuffer, new IObject3D[] { newPathObject }); @@ -151,7 +150,7 @@ namespace MatterHackers.MatterControl.DesignTools (reporter, cancellationToken) => { var polygons = new Polygons(); - VertexSource = polygons.PolygonToPathStorage(); + VertexStorage = polygons.PolygonToPathStorage(); var newChildren = new List(); foreach (var sourceItem in SourceContainer.VisibleMeshes()) @@ -169,7 +168,7 @@ namespace MatterHackers.MatterControl.DesignTools newChildren.Add(newMesh); } - VertexSource = polygons.PolygonToPathStorage(); + VertexStorage = polygons.PolygonToPathStorage(); RemoveAllButSource(); SourceContainer.Visible = false; diff --git a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs index c1b770fde..8c569f3b5 100644 --- a/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Image/ImageToPathObject3D.cs @@ -33,8 +33,6 @@ either expressed or implied, of the FreeBSD Project. /*********************************************************************/ using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; using System.Linq; using System.Threading.Tasks; using ClipperLib; @@ -179,8 +177,6 @@ namespace MatterHackers.MatterControl.DesignTools [Slider(0, 1)] public DoubleOrExpression RangeEnd { get; set; } = 1; - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - private IThresholdFunction ThresholdFunction { get @@ -281,7 +277,7 @@ namespace MatterHackers.MatterControl.DesignTools affine *= Affine.NewTranslation(-aabb.XSize / 2, -aabb.YSize / 2); rawVectorShape.transform(affine); - this.VertexSource = rawVectorShape; + this.VertexStorage = rawVectorShape; progressReporter?.Invoke(1, null); } diff --git a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs index d756b4fff..84fe73fa8 100644 --- a/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs +++ b/MatterControlLib/DesignTools/Operations/Object3DExtensions.cs @@ -172,12 +172,12 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public static void FlattenToPathObject(this IObject3D item, UndoBuffer undoBuffer) { - if (item.VertexSource != null) + if (item.GetVertexSource() != null) { using (item.RebuildLock()) { var newPathObject = new PathObject3D(); - newPathObject.VertexSource = new VertexStorage(item.VertexSource); + newPathObject.VertexStorage = new VertexStorage(item.GetVertexSource()); // and replace us with the children var replaceCommand = new ReplaceCommand(new[] { item }, new[] { newPathObject }); @@ -254,13 +254,13 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { AxisAlignedBoundingBox box = AxisAlignedBoundingBox.Empty(); - if (item.VertexSource != null) + if (item.GetVertexSource() != null) { var lastPosition = Vector2.Zero; var maxXYZ = item.GetAxisAlignedBoundingBox().MaxXYZ; maxXYZ = maxXYZ.Transform(item.Matrix.Inverted); - foreach (var vertex in item.VertexSource.Vertices()) + foreach (var vertex in item.GetVertexSource().Vertices()) { var position = vertex.position; diff --git a/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs index 01953641b..927925b26 100644 --- a/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/MergePathObject3D.cs @@ -55,8 +55,6 @@ namespace MatterHackers.MatterControl.DesignTools.Operations Name = name; } - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { this.DrawPath(); @@ -102,7 +100,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); + this.Mesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight); UiThread.RunOnIdle(() => { @@ -135,7 +133,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } var first = participants.First(); - var resultsVertexSource = first.VertexSource.Transform(first.Matrix); + var resultsVertexSource = first.GetVertexSource().Transform(first.Matrix); var totalOperations = participants.Count() - 1; double amountPerOperation = 1.0 / totalOperations; @@ -145,9 +143,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations foreach (var item in participants) { if (item != first - && item.VertexSource != null) + && item.GetVertexSource() != null) { - var itemVertexSource = item.VertexSource.Transform(item.Matrix); + var itemVertexSource = item.GetVertexSource().Transform(item.Matrix); resultsVertexSource = resultsVertexSource.MergePaths(itemVertexSource, clipType); @@ -157,7 +155,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } } - this.VertexSource = resultsVertexSource; + this.VertexStorage = new VertexStorage(resultsVertexSource); SourceContainer.Visible = false; } diff --git a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs index faa68f0c2..44bc1a73e 100644 --- a/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/RevolveObject3D.cs @@ -49,10 +49,15 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public class RevolveObject3D : Object3D, IEditorDraw { [MaxDecimalPlaces(2)] + [Slider(0, 360, snapDistance: 1)] + public DoubleOrExpression Rotation { get; set; } = 0; + + [MaxDecimalPlaces(2)] + [Slider(-30, 30, snapDistance: 1)] public DoubleOrExpression AxisPosition { get; set; } = 0; [MaxDecimalPlaces(2)] - [Slider(3, 360, snapDistance: 1)] + [Slider(0, 360, snapDistance: 1)] public DoubleOrExpression StartingAngle { get; set; } = 0; [MaxDecimalPlaces(2)] @@ -131,7 +136,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { var path = this.CombinedVisibleChildrenPaths(); - if (path == null) + if (path != null) { var (start, end) = GetStartEnd(this, path); layer.World.Render3DLine(start, end, Color.Red, true); @@ -162,7 +167,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations this.DebugDepth("Rebuild"); bool valuesChanged = false; - var startingAngle = StartingAngle.ClampIfNotCalculated(this, 0, 360 - .01, ref valuesChanged); + var rotation = MathHelper.DegreesToRadians(Rotation.ClampIfNotCalculated(this, 0, 360, ref valuesChanged)); + var startingAngle = StartingAngle.ClampIfNotCalculated(this, 0, 360 - .01, ref valuesChanged); var endingAngle = EndingAngle.ClampIfNotCalculated(this, startingAngle + .01, 360, ref valuesChanged); var sides = Sides.Value(this); var axisPosition = AxisPosition.Value(this); @@ -187,7 +193,8 @@ namespace MatterHackers.MatterControl.DesignTools.Operations { this.cancellationToken = cancellationTokenSource as CancellationTokenSource; var vertexSource = this.CombinedVisibleChildrenPaths(); - var pathBounds = vertexSource.GetBounds(); + vertexSource = vertexSource.Rotate(rotation); + var pathBounds = vertexSource.GetBounds(); vertexSource = vertexSource.Translate(-pathBounds.Left - axisPosition, 0); Mesh mesh = VertexSourceToMesh.Revolve(vertexSource, sides, @@ -195,8 +202,9 @@ namespace MatterHackers.MatterControl.DesignTools.Operations MathHelper.DegreesToRadians(360 - startingAngle), false); + var transform = Matrix4X4.CreateTranslation(pathBounds.Left + axisPosition, 0, 0) * Matrix4X4.CreateRotationZ(-rotation); // take the axis offset out - mesh.Transform(Matrix4X4.CreateTranslation(pathBounds.Left + axisPosition, 0, 0)); + mesh.Transform(transform); if (mesh.Vertices.Count == 0) { diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs index da58b9c73..0e5e1467f 100644 --- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs @@ -130,7 +130,27 @@ namespace MatterHackers.MatterControl.DesignTools base.Cancel(undoBuffer); } - private (IVertexSource vertexSource, double height) meshVertexCache; + private double cacheHeight; + + public override IVertexSource GetVertexSource() + { + var paths = this.CombinedVisibleChildrenPaths(); + if (paths == null) + { + var calculationHeight = CalculationHeight.Value(this); + if (VertexStorage == null || cacheHeight != calculationHeight) + { + var aabb = this.GetAxisAlignedBoundingBox(); + var cutPlane = new Plane(Vector3.UnitZ, new Vector3(0, 0, aabb.MinXYZ.Z + calculationHeight)); + VertexStorage = new VertexStorage(GetSlicePaths(this, cutPlane)); + cacheHeight = calculationHeight; + } + + return VertexStorage; + } + + return paths; + } public static IVertexSource GetSlicePaths(IObject3D source, Plane plane) { @@ -146,50 +166,6 @@ namespace MatterHackers.MatterControl.DesignTools return totalSlice.CreateVertexStorage(); } - private bool OutlineIsFromMesh - { - get - { - var vertexSource = this.Descendants().FirstOrDefault(i => i.VertexSource != null)?.VertexSource; - var hasMesh = this.Descendants().Where(m => m.Mesh != null).Any(); - - return vertexSource == null && hasMesh; - } - } - - [JsonIgnore] - public override IVertexSource VertexSource - { - get - { - if (OutlineIsFromMesh) - { - var calculationHeight = CalculationHeight.Value(this); - if (meshVertexCache.vertexSource == null || meshVertexCache.height != calculationHeight) - { - var aabb = this.GetAxisAlignedBoundingBox(); - var cutPlane = new Plane(Vector3.UnitZ, new Vector3(0, 0, aabb.MinXYZ.Z + calculationHeight)); - meshVertexCache.vertexSource = GetSlicePaths(this, cutPlane); - meshVertexCache.height = calculationHeight; - } - - return meshVertexCache.vertexSource; - } - - var vertexSource = this.Descendants().FirstOrDefault((i) => i.VertexSource != null)?.VertexSource; - return vertexSource; - } - - set - { - var pathObject = this.Children.FirstOrDefault(i => i.VertexSource != null); - if (pathObject != null) - { - pathObject.VertexSource = value; - } - } - } - public static async Task Create() { var item = new BaseObject3D(); @@ -207,7 +183,7 @@ namespace MatterHackers.MatterControl.DesignTools && !RebuildLocked) { // make sure we clear our cache - meshVertexCache.vertexSource = null; + VertexStorage = null; await Rebuild(); } else if ((invalidateArgs.InvalidateType.HasFlag(InvalidateType.Properties) && invalidateArgs.Source == this)) @@ -248,7 +224,7 @@ namespace MatterHackers.MatterControl.DesignTools }); // and create the base - var vertexSource = this.VertexSource; + var vertexSource = GetVertexSource(); // Convert VertexSource into expected Polygons Polygons polygonShape = (vertexSource == null) ? null : vertexSource.CreatePolygons(); @@ -317,9 +293,10 @@ namespace MatterHackers.MatterControl.DesignTools } else { - var outsidePolygons = new List>(); + var outsidePolygons = new Polygons(); // remove all holes from the polygons so we only center the major outlines - var polygons = VertexSource.CreatePolygons(); + var polygons = GetVertexSource().CreatePolygons(); + polygons = polygons.GetCorrectedWinding(); foreach (var polygon in polygons) { @@ -438,7 +415,7 @@ namespace MatterHackers.MatterControl.DesignTools changeSet.Add(nameof(Centering), BaseType == BaseTypes.Circle); changeSet.Add(nameof(ExtrusionHeight), BaseType != BaseTypes.None); - var vertexSource = this.Descendants().FirstOrDefault((i) => i.VertexSource != null)?.VertexSource; + var vertexSource = GetVertexSource(); var meshSource = this.Descendants().Where((i) => i.Mesh != null); changeSet.Add(nameof(CalculationHeight), vertexSource == null && meshSource.Where(m => m.Mesh != null).Any()); @@ -464,9 +441,9 @@ namespace MatterHackers.MatterControl.DesignTools public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { - if (OutlineIsFromMesh) + if (GetVertexSource() != null) { - layer.World.RenderPathOutline(CalcTransform(), VertexSource, Agg.Color.Red, 5); + layer.World.RenderPathOutline(CalcTransform(), GetVertexSource(), Agg.Color.Red, 5); // turn the lighting back on GL.Enable(EnableCap.Lighting); @@ -475,10 +452,10 @@ namespace MatterHackers.MatterControl.DesignTools public AxisAlignedBoundingBox GetEditorWorldspaceAABB(Object3DControlsLayer layer) { - if (OutlineIsFromMesh) + if (GetVertexSource() != null) { // TODO: Untested. - return layer.World.GetWorldspaceAabbOfRenderPathOutline(CalcTransform(), VertexSource, 5); + return layer.World.GetWorldspaceAabbOfRenderPathOutline(CalcTransform(), GetVertexSource(), 5); } return AxisAlignedBoundingBox.Empty(); } diff --git a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs index 03365039a..8486eee38 100644 --- a/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BoxPathObject3D.cs @@ -27,7 +27,6 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using System.Collections.Generic; using System.Threading.Tasks; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; @@ -35,10 +34,8 @@ using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.PartPreviewWindow; -using MatterHackers.PolygonMesh; using MatterHackers.PolygonMesh.Processors; using MatterHackers.VectorMath; -using Newtonsoft.Json; namespace MatterHackers.MatterControl.DesignTools { @@ -52,21 +49,6 @@ namespace MatterHackers.MatterControl.DesignTools public override string ThumbnailName => "Box"; - [JsonIgnore] - private IVertexSource _vertexSource = new VertexStorage(); - - public override IVertexSource VertexSource - { - get => _vertexSource; - - set - { - _vertexSource = value; - // set the mesh to show the path - this.Mesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); - } - } - public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { this.DrawPath(); @@ -128,9 +110,12 @@ namespace MatterHackers.MatterControl.DesignTools { using (new CenterAndHeightMaintainer(this)) { - var width = Width.Value(this); - var depth = Depth.Value(this); - VertexSource = new RoundedRect(-width / 2, -depth / 2, width / 2, depth / 2, 0); + bool valuesChanged = false; + var width = Width.ClampIfNotCalculated(this, .01, 10000, ref valuesChanged); + var depth = Depth.ClampIfNotCalculated(this, .01, 10000, ref valuesChanged); + VertexStorage = new VertexStorage(new RoundedRect(-width / 2, -depth / 2, width / 2, depth / 2, 0)); + + this.Mesh = VertexStorage.Extrude(Constants.PathPolygonsHeight); } } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs index ad4f435fe..c91076011 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs @@ -57,8 +57,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D [DisplayName("Part(s) to Subtract")] public SelectedChildren SelectedChildren { get; set; } = new SelectedChildren(); - public override IVertexSource VertexSource { get; set; } = new VertexStorage(); - public void DrawEditor(Object3DControlsLayer layer, DrawEventArgs e) { this.DrawPath(); @@ -125,7 +123,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } // set the mesh to show the path - var extrudeMesh = this.VertexSource.Extrude(Constants.PathPolygonsHeight); + var extrudeMesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight); if(extrudeMesh.Vertices.Count() > 5) { this.Mesh = extrudeMesh; @@ -198,11 +196,11 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D bool first = true; foreach (var keep in keepVisibleItems) { - var resultsVertexSource = keep.VertexSource.Transform(keep.Matrix); + var resultsVertexSource = keep.GetVertexSource().Transform(keep.Matrix); foreach (var remove in removeVisibleItems) { - resultsVertexSource = resultsVertexSource.MergePaths(remove.VertexSource.Transform(remove.Matrix), ClipperLib.ClipType.ctDifference); + resultsVertexSource = resultsVertexSource.MergePaths(remove.GetVertexSource().Transform(remove.Matrix), ClipperLib.ClipType.ctDifference); // report our progress ratioCompleted += amountPerOperation; @@ -212,12 +210,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D if (first) { - this.VertexSource = resultsVertexSource; + this.VertexStorage = new VertexStorage(resultsVertexSource); first = false; } else { - this.VertexSource.MergePaths(resultsVertexSource, ClipperLib.ClipType.ctUnion); + this.GetVertexSource().MergePaths(resultsVertexSource, ClipperLib.ClipType.ctUnion); } } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index adf735e2b..ce8fb208a 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -4258,6 +4258,9 @@ Translated:Rotate: Right Mouse Button | Ctrl + Left Mouse Button | Arrow Keys English:Rotate: Right Mouse Button, Ctrl + Left Mouse Button, Arrow Keys Translated:Rotate: Right Mouse Button, Ctrl + Left Mouse Button, Arrow Keys +English:Rotation +Translated:Rotation + English:Rotation Distance Translated:Rotation Distance diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index d061bb620..837ccc782 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit d061bb620e8fa595aa2d2509dc33bb7874140278 +Subproject commit 837ccc782954724ae26d080a9b063112a70a527b From 33cb9dafd2e4f23f84c4ce9fbb87abe959f9b26a Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 14 Aug 2022 20:51:01 -0700 Subject: [PATCH 11/15] Make mesh merge on export an option --- .../CustomWidgets/ExportPrintItemPage.cs | 2 +- MatterControlLib/Library/Export/AmfExport.cs | 2 +- .../Library/Export/GCodeExport.cs | 4 +- .../Library/Export/IExportPlugin.cs | 2 +- MatterControlLib/Library/Export/MeshExport.cs | 6 +-- MatterControlLib/Library/Export/StlExport.cs | 48 +++++++++++++++++-- StaticData/Translations/Master.txt | 6 +++ Submodules/agg-sharp | 2 +- 8 files changed, 60 insertions(+), 12 deletions(-) diff --git a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs index 53f65337b..0d63fc141 100644 --- a/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs +++ b/MatterControlLib/CustomWidgets/ExportPrintItemPage.cs @@ -156,7 +156,7 @@ namespace MatterHackers.MatterControl if (plugin is IExportWithOptions pluginWithOptions) { - var optionPanel = pluginWithOptions.GetOptionsPanel(); + var optionPanel = pluginWithOptions.GetOptionsPanel(libraryItems); if (optionPanel != null) { optionPanel.HAnchor = HAnchor.Stretch; diff --git a/MatterControlLib/Library/Export/AmfExport.cs b/MatterControlLib/Library/Export/AmfExport.cs index a8061b881..89d5dc7a3 100644 --- a/MatterControlLib/Library/Export/AmfExport.cs +++ b/MatterControlLib/Library/Export/AmfExport.cs @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl.Library.Export var firstItem = libraryItems.OfType().FirstOrDefault(); if (firstItem is ILibraryAsset libraryItem) { - bool exportSuccessful = await MeshExport.ExportMesh(libraryItem, outputPath, progress); + bool exportSuccessful = await MeshExport.ExportMesh(libraryItem, outputPath, true, progress); if (exportSuccessful) { return null; diff --git a/MatterControlLib/Library/Export/GCodeExport.cs b/MatterControlLib/Library/Export/GCodeExport.cs index 039192934..c4bfced15 100644 --- a/MatterControlLib/Library/Export/GCodeExport.cs +++ b/MatterControlLib/Library/Export/GCodeExport.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.Library.Export public virtual bool ExportPossible(ILibraryAsset libraryItem) => true; - public GuiWidget GetOptionsPanel() + public GuiWidget GetOptionsPanel(IEnumerable libraryItems) { var container = new FlowLayoutWidget() { @@ -132,7 +132,7 @@ namespace MatterHackers.MatterControl.Library.Export } else { - spiralVaseOverride = SpiralVaseOptions.FORCE_ON; + spiralVaseOverride = SpiralVaseOptions.USE_SETTINGS; } }; container.AddChild(spiralVaseCheckbox); diff --git a/MatterControlLib/Library/Export/IExportPlugin.cs b/MatterControlLib/Library/Export/IExportPlugin.cs index 958e4beba..2410b66c8 100644 --- a/MatterControlLib/Library/Export/IExportPlugin.cs +++ b/MatterControlLib/Library/Export/IExportPlugin.cs @@ -62,6 +62,6 @@ namespace MatterHackers.MatterControl public interface IExportWithOptions : IExportPlugin { - GuiWidget GetOptionsPanel(); + GuiWidget GetOptionsPanel(IEnumerable libraryItems); } } diff --git a/MatterControlLib/Library/Export/MeshExport.cs b/MatterControlLib/Library/Export/MeshExport.cs index abcd5d6ff..0a0d2ca31 100644 --- a/MatterControlLib/Library/Export/MeshExport.cs +++ b/MatterControlLib/Library/Export/MeshExport.cs @@ -40,7 +40,7 @@ namespace MatterHackers.MatterControl.Library.Export { public static class MeshExport { - public static async Task ExportMesh(ILibraryItem source, string filePathToSave, IProgress progress) + public static async Task ExportMesh(ILibraryItem source, string filePathToSave, bool mergeMeshes, IProgress progress) { try { @@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.Library.Export { // If the content is an IObject3D, then we need to load it and MeshFileIO save to the target path var content = await contentItem.GetObject3D(null); - return Object3D.Save(content, filePathToSave, CancellationToken.None, reportProgress: (ratio, name) => + return Object3D.Save(content, filePathToSave, mergeMeshes, CancellationToken.None, reportProgress: (ratio, name) => { status.Progress0To1 = ratio; progress.Report(status); @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.Library.Export IObject3D item = Object3D.Load(result.Stream, Path.GetExtension(streamContent.FileName), CancellationToken.None); if (item != null) { - return Object3D.Save(item, filePathToSave, CancellationToken.None, reportProgress: (ratio, name) => + return Object3D.Save(item, filePathToSave, mergeMeshes, CancellationToken.None, reportProgress: (ratio, name) => { status.Progress0To1 = ratio; progress.Report(status); diff --git a/MatterControlLib/Library/Export/StlExport.cs b/MatterControlLib/Library/Export/StlExport.cs index 0c3c4c0a9..af841920d 100644 --- a/MatterControlLib/Library/Export/StlExport.cs +++ b/MatterControlLib/Library/Export/StlExport.cs @@ -37,13 +37,16 @@ using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; +using MatterHackers.DataConverters3D; using MatterHackers.Localizations; namespace MatterHackers.MatterControl.Library.Export { - public class StlExport : IExportPlugin + public class StlExport : IExportPlugin, IExportWithOptions { - public int Priority => 2; + private bool mergeMeshes = true; + + public int Priority => 2; public string ButtonText => "STL File".Localize(); @@ -79,7 +82,7 @@ namespace MatterHackers.MatterControl.Library.Export first = false; } - if (!await MeshExport.ExportMesh(item, filename, progress)) + if (!await MeshExport.ExportMesh(item, filename, mergeMeshes, progress)) { badExports.Add(item.Name); } @@ -99,5 +102,44 @@ namespace MatterHackers.MatterControl.Library.Export } }; } + + public GuiWidget GetOptionsPanel(IEnumerable libraryItems) + { + var exportMeshCount = 0; + foreach (var item in libraryItems.OfType()) + { + if (item is ILibraryObject3D contentItem) + { + var object3D = contentItem.GetObject3D(null).Result; + exportMeshCount += object3D.VisibleMeshes().Count(); + } + } + + if (exportMeshCount < 2) + { + return null; + } + + var container = new FlowLayoutWidget() + { + Margin = new BorderDouble(left: 40, bottom: 10), + }; + + var theme = AppContext.Theme; + + var unionAllPartsCheckbox = new CheckBox("Merge faces into single mesh".Localize(), theme.TextColor, 10) + { + Checked = true, + Cursor = Cursors.Hand, + ToolTipText = "Disable to expart all faces without merging".Localize() + }; + unionAllPartsCheckbox.CheckedStateChanged += (s, e) => + { + mergeMeshes = unionAllPartsCheckbox.Checked; + }; + container.AddChild(unionAllPartsCheckbox); + + return container; + } } } diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index ce8fb208a..b7ad410ca 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -1327,6 +1327,9 @@ Translated:Direction English:Disable Fan For The First Translated:Disable Fan For The First +English:Disable to expart all faces without merging +Translated:Disable to expart all faces without merging + English:Disabled: {0} Translated:Disabled: {0} @@ -2887,6 +2890,9 @@ Translated:Medium Precision English:Merge Translated:Merge +English:Merge faces into single mesh +Translated:Merge faces into single mesh + English:Merge Overlapping Lines Translated:Merge Overlapping Lines diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 837ccc782..0fee6ab0d 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 837ccc782954724ae26d080a9b063112a70a527b +Subproject commit 0fee6ab0d2d61107717114258b06182815bc11d7 From 844b3fdb14a95380caf95017a8bc23395030baff Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Sun, 14 Aug 2022 21:30:40 -0700 Subject: [PATCH 12/15] Fix path subtract --- .../Operations/Path/InflatePathObject3D.cs | 8 ++++---- .../DesignTools/Primitives/BaseObject3D.cs | 14 ++++++++++---- .../View3D/Actions/SubtractPathObject3D.cs | 17 ++++++++++------- Submodules/agg-sharp | 2 +- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs index 5baa95458..b1993c07d 100644 --- a/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/Path/InflatePathObject3D.cs @@ -120,16 +120,16 @@ namespace MatterHackers.MatterControl.DesignTools.Operations VertexStorage = path.Offset(Inflate.Value(this), GetJoinType(Style)); } - internal static JoinType GetJoinType(ExpandStyles style) + public static JoinType GetJoinType(ExpandStyles style) { - ClipperLib.JoinType joinType = ClipperLib.JoinType.jtMiter; + ClipperLib.JoinType joinType = JoinType.jtMiter; switch (style) { case ExpandStyles.Flat: - joinType = ClipperLib.JoinType.jtSquare; + joinType = JoinType.jtSquare; break; case ExpandStyles.Round: - joinType = ClipperLib.JoinType.jtRound; + joinType = JoinType.jtRound; break; } diff --git a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs index 0e5e1467f..f6e02974c 100644 --- a/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/BaseObject3D.cs @@ -39,6 +39,7 @@ using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters2D; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; +using MatterHackers.MatterControl.DesignTools.Operations; using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.PolygonMesh.Csg; using MatterHackers.PolygonMesh.Processors; @@ -90,6 +91,9 @@ namespace MatterHackers.MatterControl.DesignTools [Slider(0, 10, Easing.EaseType.Quadratic, snapDistance: .1)] public DoubleOrExpression InfillAmount { get; set; } = 3; + [EnumDisplay(Mode = EnumDisplayAttribute.PresentationMode.Buttons)] + public ExpandStyles Style { get; set; } = ExpandStyles.Round; + [DisplayName("Height")] [Slider(1, 50, Easing.EaseType.Quadratic, useSnappingGrid: true)] public DoubleOrExpression ExtrusionHeight { get; set; } = 5; @@ -368,18 +372,19 @@ namespace MatterHackers.MatterControl.DesignTools var infillAmount = InfillAmount.Value(this); var baseSize = BaseSize.Value(this); var extrusionHeight = ExtrusionHeight.Value(this); + var joinType = InflatePathObject3D.GetJoinType(Style); if (BaseType == BaseTypes.Outline && infillAmount > 0) { - basePolygons = polysToOffset.Offset((baseSize + infillAmount) * scalingForClipper); - basePolygons = basePolygons.Offset(-infillAmount * scalingForClipper); + basePolygons = polysToOffset.Offset((baseSize + infillAmount) * scalingForClipper, joinType); + basePolygons = basePolygons.Offset(-infillAmount * scalingForClipper, joinType); } else { - basePolygons = polysToOffset.Offset(baseSize * scalingForClipper); + basePolygons = polysToOffset.Offset(baseSize * scalingForClipper, joinType); } - basePolygons = ClipperLib.Clipper.CleanPolygons(basePolygons, 10); + basePolygons = Clipper.CleanPolygons(basePolygons, 10); VertexStorage rawVectorShape = basePolygons.PolygonToPathStorage(); var vectorShape = new VertexSourceApplyTransform(rawVectorShape, Affine.NewScaling(1.0 / scalingForClipper)); @@ -414,6 +419,7 @@ namespace MatterHackers.MatterControl.DesignTools changeSet.Add(nameof(InfillAmount), BaseType == BaseTypes.Outline); changeSet.Add(nameof(Centering), BaseType == BaseTypes.Circle); changeSet.Add(nameof(ExtrusionHeight), BaseType != BaseTypes.None); + changeSet.Add(nameof(Style), BaseType != BaseTypes.Circle); var vertexSource = GetVertexSource(); var meshSource = this.Descendants().Where((i) => i.Mesh != null); diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs index c91076011..c61347e36 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/SubtractPathObject3D.cs @@ -123,14 +123,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.View3D } // set the mesh to show the path - var extrudeMesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight); - if(extrudeMesh.Vertices.Count() > 5) + if (this.GetVertexSource() != null) { - this.Mesh = extrudeMesh; - } - else - { - this.Mesh = null; + var extrudeMesh = this.GetVertexSource().Extrude(Constants.PathPolygonsHeight); + if (extrudeMesh.Vertices.Count() > 5) + { + this.Mesh = extrudeMesh; + } + else + { + this.Mesh = null; + } } UiThread.RunOnIdle(() => diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 0fee6ab0d..c2b8646bf 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 0fee6ab0d2d61107717114258b06182815bc11d7 +Subproject commit c2b8646bf496a0ecf99338e513cf96cb6fdeed17 From 7bf216ccdb9a13c158df506fb24a379c28165223 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 15 Aug 2022 18:13:08 -0700 Subject: [PATCH 13/15] More dual contouring testing --- .../Primitives/DualContouringObject3D.cs | 80 ++++++++++++++++--- Submodules/agg-sharp | 2 +- 2 files changed, 68 insertions(+), 14 deletions(-) diff --git a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs index 9b90c22be..5dbc76e1b 100644 --- a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs @@ -59,7 +59,10 @@ namespace MatterHackers.MatterControl.DesignTools public enum Shapes { Box, - Sphere + Union1, + Union2, + Sphere, + Cylinder, } public Shapes Shape { get; set; } = Shapes.Box; @@ -89,21 +92,72 @@ namespace MatterHackers.MatterControl.DesignTools { using (RebuildLock()) { +#if true using (new CenterAndHeightMaintainer(this)) { -#if true - ISdf shape = new Sphere() - { - Radius = Size - }; + ISdf shape = null; + switch (Shape) + { + case Shapes.Box: + shape = new Box() + { + Size = new Vector3(Size, Size, Size) + }; + break; - if (Shape == Shapes.Box) - { - shape = new Box() - { - Size = new Vector3(Size, Size, Size) - }; - } + case Shapes.Union1: + shape = new Union() + { + Items = new ISdf[] + { + new Transform(new Box() + { + Size = new Vector3(Size, Size, Size) + }, Matrix4X4.CreateRotationX(MathHelper.Tau * .2)), + new Box() + { + Size = new Vector3(Size, Size, Size) + }, + new Transform(new Box() + { + Size = new Vector3(Size, Size, Size) + }, Matrix4X4.CreateRotationY(MathHelper.Tau * .2)), + } + }; + break; + + case Shapes.Union2: + shape = new Union() + { + Items = new ISdf[] + { + new Transform(new Sphere() + { + Radius = Size / 2 + }, Matrix4X4.CreateTranslation(4, 0, 0)), + new Transform(new Box() + { + Size = new Vector3(Size, Size, Size) + }, Matrix4X4.CreateRotationY(MathHelper.Tau * .2)), + } + }; + break; + + case Shapes.Sphere: + shape = new Sphere() + { + Radius = Size + }; + break; + + case Shapes.Cylinder: + shape = new Cylinder() + { + Radius = Size, + Height = Size + }; + break; + } var bounds = shape.Bounds; bounds.Expand(.1); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index c2b8646bf..3ae73a123 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit c2b8646bf496a0ecf99338e513cf96cb6fdeed17 +Subproject commit 3ae73a123c0d97a6ed9692bfcbf0599f4d904e84 From 3603831e5e388040c1702184f71c32d258bbc523 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 16 Aug 2022 17:10:17 -0700 Subject: [PATCH 14/15] Making Dual Contouring have a ref implementation using marching cubes --- .../Primitives/DualContouringObject3D.cs | 109 +++++++++++------- StaticData/Translations/Master.txt | 3 + Submodules/agg-sharp | 2 +- 3 files changed, 70 insertions(+), 44 deletions(-) diff --git a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs index 5dbc76e1b..dd2af3f53 100644 --- a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs @@ -29,14 +29,28 @@ either expressed or implied, of the FreeBSD Project. using System.Threading.Tasks; using DualContouring; +using g3; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; +using MatterHackers.PolygonMesh; +using MatterHackers.PolygonMesh.Processors; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { public class DualContouringObject3D : Object3D { + public enum Shapes + { + Box, + [EnumName("2 Boxes")] + Boxes2, + [EnumName("3 Boxes")] + Boxes3, + Sphere, + Cylinder, + } + public DualContouringObject3D() { Name = "Dual Contouring".Localize(); @@ -50,23 +64,21 @@ namespace MatterHackers.MatterControl.DesignTools return item; } + public Shapes Shape { get; set; } = Shapes.Box; + + public OuptutTypes Ouptput { get; set; } + public int Iterations { get; set; } = 5; public double Size { get; set; } = 15; public double Threshold { get; set; } = .001; - - public enum Shapes - { - Box, - Union1, - Union2, - Sphere, - Cylinder, - } - - public Shapes Shape { get; set; } = Shapes.Box; - + + public enum OuptutTypes + { + DualContouring, + MarchingCubes, + } public override async void OnInvalidate(InvalidateArgs invalidateArgs) { @@ -92,20 +104,19 @@ namespace MatterHackers.MatterControl.DesignTools { using (RebuildLock()) { -#if true using (new CenterAndHeightMaintainer(this)) { ISdf shape = null; - switch (Shape) - { - case Shapes.Box: + switch (Shape) + { + case Shapes.Box: shape = new Box() { Size = new Vector3(Size, Size, Size) }; break; - case Shapes.Union1: + case Shapes.Boxes3: shape = new Union() { Items = new ISdf[] @@ -113,7 +124,7 @@ namespace MatterHackers.MatterControl.DesignTools new Transform(new Box() { Size = new Vector3(Size, Size, Size) - }, Matrix4X4.CreateRotationX(MathHelper.Tau * .2)), + }, Matrix4X4.CreateRotationZ(MathHelper.Tau * .2) * Matrix4X4.CreateRotationX(MathHelper.Tau * .2)), new Box() { Size = new Vector3(Size, Size, Size) @@ -121,12 +132,12 @@ namespace MatterHackers.MatterControl.DesignTools new Transform(new Box() { Size = new Vector3(Size, Size, Size) - }, Matrix4X4.CreateRotationY(MathHelper.Tau * .2)), + }, Matrix4X4.CreateRotationY(MathHelper.Tau * .2) * Matrix4X4.CreateRotationX(MathHelper.Tau * .3)), } }; break; - case Shapes.Union2: + case Shapes.Boxes2: shape = new Union() { Items = new ISdf[] @@ -138,26 +149,26 @@ namespace MatterHackers.MatterControl.DesignTools new Transform(new Box() { Size = new Vector3(Size, Size, Size) - }, Matrix4X4.CreateRotationY(MathHelper.Tau * .2)), + }, Matrix4X4.CreateRotationZ(MathHelper.Tau * .2)), } }; - break; - - case Shapes.Sphere: - shape = new Sphere() + break; + + case Shapes.Sphere: + shape = new Sphere() { Radius = Size }; - break; - - case Shapes.Cylinder: - shape = new Cylinder() - { - Radius = Size, - Height = Size - }; - break; - } + break; + + case Shapes.Cylinder: + shape = new Cylinder() + { + Radius = Size, + Height = Size + }; + break; + } var bounds = shape.Bounds; bounds.Expand(.1); @@ -165,15 +176,13 @@ namespace MatterHackers.MatterControl.DesignTools { Iterations = 7; } - var root = Octree.BuildOctree(shape.Sdf, bounds.MinXYZ, bounds.Size, Iterations, Threshold); - Mesh = Octree.GenerateMeshFromOctree(root); -#else - var c = new MarchingCubes(); - c.Generate(); - MeshNormals.QuickCompute(c.Mesh); // generate normals - Mesh = c.Mesh.ToMesh(); -#endif + if (Ouptput == OuptutTypes.DualContouring) + { + var root = Octree.BuildOctree(shape.Sdf, bounds.MinXYZ, bounds.Size, Iterations, Threshold); + + Mesh = Octree.GenerateMeshFromOctree(root); + } } } @@ -184,5 +193,19 @@ namespace MatterHackers.MatterControl.DesignTools return Task.CompletedTask; }); } + + public class SdfToImplicit : ImplicitFunction3d + { + public ISdf Sdf { get; set; } + public SdfToImplicit(ISdf sdf) + { + Sdf = sdf; + } + + public double Value(ref Vector3d pt) + { + return Sdf.Sdf(new Vector3(pt.x, pt.y, pt.z)); + } + } } } \ No newline at end of file diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index b7ad410ca..5514ac9c1 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -3382,6 +3382,9 @@ Translated:Other English:Other Speeds Translated:Other Speeds +English:Ouptput +Translated:Ouptput + English:Outer Diameter Translated:Outer Diameter diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 3ae73a123..84b6947e4 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 3ae73a123c0d97a6ed9692bfcbf0599f4d904e84 +Subproject commit 84b6947e49f3fb1cdb5e777ecf7451f8369c91ea From b4d91a2f7bdeadaac0961a5d7b7a57768d40c557 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Tue, 16 Aug 2022 17:17:04 -0700 Subject: [PATCH 15/15] Butter names --- .../DesignTools/Primitives/DualContouringObject3D.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs index dd2af3f53..f3714bf48 100644 --- a/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/DualContouringObject3D.cs @@ -44,9 +44,9 @@ namespace MatterHackers.MatterControl.DesignTools { Box, [EnumName("2 Boxes")] - Boxes2, + Box_And_Sphere, [EnumName("3 Boxes")] - Boxes3, + Boxes_3, Sphere, Cylinder, } @@ -116,7 +116,7 @@ namespace MatterHackers.MatterControl.DesignTools }; break; - case Shapes.Boxes3: + case Shapes.Boxes_3: shape = new Union() { Items = new ISdf[] @@ -137,7 +137,7 @@ namespace MatterHackers.MatterControl.DesignTools }; break; - case Shapes.Boxes2: + case Shapes.Box_And_Sphere: shape = new Union() { Items = new ISdf[] @@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.DesignTools new Transform(new Sphere() { Radius = Size / 2 - }, Matrix4X4.CreateTranslation(4, 0, 0)), + }, Matrix4X4.CreateTranslation(-3, -2, 0)), new Transform(new Box() { Size = new Vector3(Size, Size, Size)