diff --git a/ActionBar/ActionBarPlus.cs b/ActionBar/ActionBarPlus.cs index 58424472d..67e08b713 100644 --- a/ActionBar/ActionBarPlus.cs +++ b/ActionBar/ActionBarPlus.cs @@ -30,7 +30,6 @@ either expressed or implied, of the FreeBSD Project. using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.ActionBar; -using MatterHackers.MatterControl.PrintQueue; namespace MatterHackers.MatterControl { diff --git a/ActionBar/PrintActionRow.cs b/ActionBar/PrintActionRow.cs index e9208260b..89f257a3e 100644 --- a/ActionBar/PrintActionRow.cs +++ b/ActionBar/PrintActionRow.cs @@ -70,27 +70,12 @@ namespace MatterHackers.MatterControl.ActionBar private Button skipButton; private Button startButton; private Button finishSetupButton; - private TextImageButtonFactory textImageButtonFactory; private EventHandler unregisterEvents; public PrintActionRow() { this.HAnchor = HAnchor.ParentLeftRight; - textImageButtonFactory = new TextImageButtonFactory() - { - normalTextColor = RGBA_Bytes.White, - disabledTextColor = RGBA_Bytes.LightGray, - hoverTextColor = RGBA_Bytes.White, - pressedTextColor = RGBA_Bytes.White, - AllowThemeToAdjustImage = false, - borderWidth = 1, - FixedHeight = 52 * GuiWidget.DeviceScale, - fontSize = 14, - normalBorderColor = new RGBA_Bytes(255, 255, 255, 100), - hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100) - }; - AddChildElements(); // Add Handlers @@ -101,7 +86,9 @@ namespace MatterHackers.MatterControl.ActionBar protected void AddChildElements() { - addButton = textImageButtonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png",32,32).InvertLightness()); + var buttonFactory = ApplicationController.Instance.Theme.ActionRowButtonFactory; + + addButton = buttonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png",32,32).InvertLightness()); addButton.ToolTipText = "Add a file to be printed".Localize(); addButton.Margin = new BorderDouble(6, 6, 6, 3); addButton.Click += (s, e) => @@ -109,21 +96,21 @@ namespace MatterHackers.MatterControl.ActionBar UiThread.RunOnIdle(AddButtonOnIdle); }; - startButton = textImageButtonFactory.GenerateTooltipButton("Print".Localize(), StaticData.Instance.LoadIcon("icon_play_32x32.png",32,32).InvertLightness()); + startButton = buttonFactory.GenerateTooltipButton("Print".Localize(), StaticData.Instance.LoadIcon("icon_play_32x32.png",32,32).InvertLightness()); startButton.Name = "Start Print Button"; startButton.ToolTipText = "Begin printing the selected item.".Localize(); startButton.Margin = new BorderDouble(6, 6, 6, 3); startButton.Click += onStartButton_Click; - finishSetupButton = textImageButtonFactory.GenerateTooltipButton("Finish Setup...".Localize()); + finishSetupButton = buttonFactory.GenerateTooltipButton("Finish Setup...".Localize()); finishSetupButton.Name = "Finish Setup Button"; finishSetupButton.ToolTipText = "Run setup configuration for printer.".Localize(); finishSetupButton.Margin = new BorderDouble(6, 6, 6, 3); finishSetupButton.Click += onStartButton_Click; - touchScreenConnectButton = textImageButtonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("connect.png", 32,32).InvertLightness()); + touchScreenConnectButton = buttonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("connect.png", 32,32).InvertLightness()); touchScreenConnectButton.ToolTipText = "Connect to the printer".Localize(); - touchScreenConnectButton.Margin = new BorderDouble(6, 6, 6, 3); + touchScreenConnectButton.Margin = new BorderDouble(0, 6, 6, 3); touchScreenConnectButton.Click += (s, e) => { if (ActiveSliceSettings.Instance.PrinterSelected) @@ -144,7 +131,7 @@ namespace MatterHackers.MatterControl.ActionBar } }; - addPrinterButton = textImageButtonFactory.GenerateTooltipButton("Add Printer".Localize()); + addPrinterButton = buttonFactory.GenerateTooltipButton("Add Printer".Localize()); addPrinterButton.ToolTipText = "Select and add a new printer.".Localize(); addPrinterButton.Margin = new BorderDouble(6, 6, 6, 3); addPrinterButton.Click += (s, e) => @@ -152,7 +139,7 @@ namespace MatterHackers.MatterControl.ActionBar UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup(true)); }; - selectPrinterButton = textImageButtonFactory.GenerateTooltipButton("Select Printer".Localize()); + selectPrinterButton = buttonFactory.GenerateTooltipButton("Select Printer".Localize()); selectPrinterButton.ToolTipText = "Select an existing printer.".Localize(); selectPrinterButton.Margin = new BorderDouble(6, 6, 6, 3); selectPrinterButton.Click += (s, e) => @@ -160,7 +147,7 @@ namespace MatterHackers.MatterControl.ActionBar WizardWindow.Show("/SetupOptions", "Setup Wizard"); }; - resetConnectionButton = textImageButtonFactory.GenerateTooltipButton("Reset".Localize(), StaticData.Instance.LoadIcon("e_stop4.png", 32,32).InvertLightness()); + resetConnectionButton = buttonFactory.GenerateTooltipButton("Reset".Localize(), StaticData.Instance.LoadIcon("e_stop4.png", 32,32).InvertLightness()); resetConnectionButton.ToolTipText = "Reboots the firmware on the controller".Localize(); resetConnectionButton.Margin = new BorderDouble(6, 6, 6, 3); resetConnectionButton.Click += (s, e) => UiThread.RunOnIdle(PrinterConnectionAndCommunication.Instance.RebootBoard); @@ -289,9 +276,10 @@ namespace MatterHackers.MatterControl.ActionBar protected Button makeButton(string buttonText, string buttonToolTip = "") { - Button button = textImageButtonFactory.GenerateTooltipButton(buttonText); + Button button = ApplicationController.Instance.Theme.ActionRowButtonFactory.GenerateTooltipButton(buttonText); button.ToolTipText = buttonToolTip; button.Margin = new BorderDouble(0, 6, 6, 3); + return button; } diff --git a/ActionBar/PrintStatusRow.cs b/ActionBar/PrintStatusRow.cs index 97f93030d..7fffbc808 100644 --- a/ActionBar/PrintStatusRow.cs +++ b/ActionBar/PrintStatusRow.cs @@ -43,9 +43,7 @@ namespace MatterHackers.MatterControl.ActionBar { public class PrintStatusRow : FlowLayoutWidget { - private TextWidget activePrintLabel; private TextWidget activePrintName; - private PartThumbnailWidget activePrintPreviewImage; private TextWidget activePrintStatus; private TemperatureWidgetBase bedTemperatureWidget; private TemperatureWidgetBase extruderTemperatureWidget; @@ -55,7 +53,8 @@ namespace MatterHackers.MatterControl.ActionBar { UiThread.RunOnIdle(OnIdle); - this.Margin = new BorderDouble(6, 3, 6, 6); + this.Margin = 0; + this.Padding = 0; this.HAnchor = HAnchor.ParentLeftRight; AddChildElements(); @@ -75,31 +74,16 @@ namespace MatterHackers.MatterControl.ActionBar { UpdatePrintStatus(); }, ref unregisterEvents); - - PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents); - - onActivePrintItemChanged(null, null); } public override void OnClosed(ClosedEventArgs e) { - if (activePrintPreviewImage.ItemWrapper != null) - { - activePrintPreviewImage.ItemWrapper.SlicingOutputMessage -= PrintItem_SlicingOutputMessage; - } - unregisterEvents?.Invoke(this, null); base.OnClosed(e); } private void AddChildElements() { - activePrintPreviewImage = new PartThumbnailWidget(null, "part_icon_transparent_100x100.png", "building_thumbnail_100x100.png", PartThumbnailWidget.ImageSizes.Size115x115); - activePrintPreviewImage.VAnchor = VAnchor.ParentTop; - activePrintPreviewImage.Padding = new BorderDouble(0); - activePrintPreviewImage.HoverBackgroundColor = new RGBA_Bytes(); - activePrintPreviewImage.BorderWidth = 3; - FlowLayoutWidget temperatureWidgets = new FlowLayoutWidget(FlowDirection.TopToBottom); { extruderTemperatureWidget = new TemperatureWidgetExtruder(); @@ -123,7 +107,6 @@ namespace MatterHackers.MatterControl.ActionBar iconContainer.Margin = new BorderDouble(top: 3); iconContainer.AddChild(GetAutoLevelIndicator()); - this.AddChild(activePrintPreviewImage); this.AddChild(printStatusContainer); this.AddChild(iconContainer); this.AddChild(temperatureWidgets); @@ -134,30 +117,21 @@ namespace MatterHackers.MatterControl.ActionBar private FlowLayoutWidget CreateActivePrinterInfoWidget() { - FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom); - container.Margin = new BorderDouble(6, 0, 6, 0); - container.HAnchor = HAnchor.ParentLeftRight; - container.VAnchor |= VAnchor.ParentTop; - - FlowLayoutWidget topRow = new FlowLayoutWidget(); - topRow.Name = "PrintStatusRow.ActivePrinterInfo.TopRow"; - topRow.HAnchor = HAnchor.ParentLeftRight; - - activePrintLabel = getPrintStatusLabel("Next Print".Localize() + ":", pointSize: 11); - activePrintLabel.VAnchor = VAnchor.ParentTop; - - topRow.AddChild(activePrintLabel); + var container = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + Margin = new BorderDouble(6, 0, 6, 0), + HAnchor = HAnchor.ParentLeftRight, + VAnchor = VAnchor.ParentBottom | VAnchor.FitToChildren, + }; activePrintName = getPrintStatusLabel("this is the biggest name we will allow", pointSize: 14); activePrintName.AutoExpandBoundsToText = false; + container.AddChild(activePrintName); activePrintStatus = getPrintStatusLabel("this is the biggest label we will allow - bigger", pointSize: 11); activePrintStatus.AutoExpandBoundsToText = false; activePrintStatus.Text = ""; activePrintStatus.Margin = new BorderDouble(top: 3); - - container.AddChild(topRow); - container.AddChild(activePrintName); container.AddChild(activePrintStatus); return container; @@ -168,6 +142,7 @@ namespace MatterHackers.MatterControl.ActionBar ImageButtonFactory imageButtonFactory = new ImageButtonFactory(); imageButtonFactory.InvertImageColor = false; ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 16, 16).InvertLightness(); + Button autoLevelButton = imageButtonFactory.Generate(levelingImage, levelingImage); autoLevelButton.Margin = new Agg.BorderDouble(top: 3); autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize(); @@ -191,25 +166,6 @@ namespace MatterHackers.MatterControl.ActionBar return widget; } - private void onActivePrintItemChanged(object sender, EventArgs e) - { - // first we have to remove any link to an old part (the part currently in the view) - if (activePrintPreviewImage.ItemWrapper != null) - { - activePrintPreviewImage.ItemWrapper.SlicingOutputMessage -= PrintItem_SlicingOutputMessage; - } - - activePrintPreviewImage.ItemWrapper = PrinterConnectionAndCommunication.Instance.ActivePrintItem; - - // then hook up our new part - if (activePrintPreviewImage.ItemWrapper != null) - { - activePrintPreviewImage.ItemWrapper.SlicingOutputMessage += PrintItem_SlicingOutputMessage; - } - - activePrintPreviewImage.Invalidate(); - } - private void OnIdle() { if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting) @@ -340,7 +296,6 @@ namespace MatterHackers.MatterControl.ActionBar printerStatus = "Press 'Add' to choose an item to print".Localize(); } - activePrintLabel.Text = printLabel; activePrintStatus.Text = printerStatus; } } diff --git a/ActionBar/PrinterConnectAndSelectControl.cs b/ActionBar/PrinterConnectAndSelectControl.cs index 7da1b8314..cbd489898 100644 --- a/ActionBar/PrinterConnectAndSelectControl.cs +++ b/ActionBar/PrinterConnectAndSelectControl.cs @@ -43,7 +43,6 @@ namespace MatterHackers.MatterControl.ActionBar { public class PrinterConnectAndSelectControl : FlowLayoutWidget { - private TextImageButtonFactory actionBarButtonFactory = new TextImageButtonFactory(); private Button connectPrinterButton; private Button editPrinterButton; private string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize(); @@ -59,18 +58,6 @@ namespace MatterHackers.MatterControl.ActionBar { this.HAnchor = HAnchor.ParentLeftRight; - actionBarButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; - actionBarButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; - actionBarButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; - - actionBarButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected; - actionBarButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor; - actionBarButtonFactory.disabledBorderColor = ActiveTheme.Instance.SecondaryBackgroundColor; - - actionBarButtonFactory.hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor; - - actionBarButtonFactory.invertImageLocation = true; - actionBarButtonFactory.borderWidth = 0; this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; AddChildElements(); @@ -84,27 +71,16 @@ namespace MatterHackers.MatterControl.ActionBar protected void AddChildElements() { - actionBarButtonFactory.invertImageLocation = false; - actionBarButtonFactory.borderWidth = 1; - if (ActiveTheme.Instance.IsDarkTheme) - { - actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77); - } - else - { - actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190); - } - actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128); - + var buttonFactory = ApplicationController.Instance.Theme.PrinterConnectButtonFactory; // connect and disconnect buttons { var normalImage = StaticData.Instance.LoadIcon("connect.png", 32, 32); // Create the image button with the normal and disabled ImageBuffers - connectPrinterButton = actionBarButtonFactory.Generate("Connect".Localize().ToUpper(), normalImage); + connectPrinterButton = buttonFactory.Generate("Connect".Localize().ToUpper(), normalImage); connectPrinterButton.Name = "Connect to printer button"; connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); - connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); + connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3); connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; @@ -120,7 +96,7 @@ namespace MatterHackers.MatterControl.ActionBar } }; - disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 32, 32)); + disconnectPrinterButton = buttonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 32, 32)); disconnectPrinterButton.Name = "Disconnect from printer button"; disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); @@ -128,8 +104,6 @@ namespace MatterHackers.MatterControl.ActionBar disconnectPrinterButton.Cursor = Cursors.Hand; disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect); - actionBarButtonFactory.invertImageLocation = true; - this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); } @@ -179,7 +153,7 @@ namespace MatterHackers.MatterControl.ActionBar // reset connection button { string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); - Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); + Button resetConnectionButton = buttonFactory.Generate(resetConnectionText, "e_stop4.png"); resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); this.AddChild(resetConnectionButton); diff --git a/ApplicationView/ApplicationController.cs b/ApplicationView/ApplicationController.cs index 46beb3aed..830d0a0a4 100644 --- a/ApplicationView/ApplicationController.cs +++ b/ApplicationView/ApplicationController.cs @@ -57,6 +57,80 @@ namespace MatterHackers.MatterControl public class ApplicationController { + public class ThemeConfig + { + protected readonly int fizedHeightA = (int)(25 * GuiWidget.DeviceScale + .5); + protected readonly int fontSizeA = 11; + + protected readonly double fizedHeightB = 52 * GuiWidget.DeviceScale; + protected readonly int fontSizeB = 14; + + protected readonly int borderWidth = 1; + + public TextImageButtonFactory ImageButtonFactory { get; private set; } + public TextImageButtonFactory ActionRowButtonFactory { get; private set; } + public TextImageButtonFactory PrinterConnectButtonFactory { get; private set; } + + TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory(); + private EventHandler unregisterEvents; + + public ThemeConfig() + { + ActiveTheme.ThemeChanged.RegisterEvent((s, e) => RebuildTheme(), ref unregisterEvents); + RebuildTheme(); + } + + public void RebuildTheme() + { + this.ImageButtonFactory = new TextImageButtonFactory() + { + normalFillColor = RGBA_Bytes.Transparent, + normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), + normalTextColor = ActiveTheme.Instance.SecondaryTextColor, + pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, + hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, + hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200), + disabledFillColor = RGBA_Bytes.Transparent, + disabledBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100), + disabledTextColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 100), + FixedHeight = fizedHeightA, + fontSize = fontSizeA, + borderWidth = borderWidth + }; + + this.ActionRowButtonFactory = new TextImageButtonFactory() + { + normalTextColor = RGBA_Bytes.White, + disabledTextColor = RGBA_Bytes.LightGray, + hoverTextColor = RGBA_Bytes.White, + pressedTextColor = RGBA_Bytes.White, + AllowThemeToAdjustImage = false, + borderWidth = borderWidth, + FixedHeight = fizedHeightB, + fontSize = fontSizeB, + normalBorderColor = new RGBA_Bytes(255, 255, 255, 100), + hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100) + }; + + this.PrinterConnectButtonFactory = new TextImageButtonFactory() + { + normalTextColor = ActiveTheme.Instance.PrimaryTextColor, + normalBorderColor = (ActiveTheme.Instance.IsDarkTheme) ? new RGBA_Bytes(77, 77, 77) : new RGBA_Bytes(190, 190, 190), + hoverTextColor = ActiveTheme.Instance.PrimaryTextColor, + pressedTextColor = ActiveTheme.Instance.PrimaryTextColor, + disabledTextColor = ActiveTheme.Instance.TabLabelUnselected, + disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor, + disabledBorderColor = ActiveTheme.Instance.SecondaryBackgroundColor, + hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor, + hoverBorderColor = new RGBA_Bytes(128, 128, 128), + invertImageLocation = false, + borderWidth = 1 + }; + } + } + + public ThemeConfig Theme { get; set; } = new ThemeConfig(); + public Action RedeemDesignCode; public Action EnterShareCode; diff --git a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs index b91b39952..85bfd8eca 100644 --- a/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs +++ b/ConfigurationPage/PrinterSettings/PrinterSettingsView.cs @@ -16,28 +16,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage { public class HardwareSettingsWidget : SettingsViewBase { - private Button openGcodeTerminalButton; private Button openCameraButton; - private DisableableWidget eePromControlsContainer; - private DisableableWidget terminalCommunicationsContainer; - private EventHandler unregisterEvents; public HardwareSettingsWidget() : base("Hardware".Localize()) { - eePromControlsContainer = new DisableableWidget(); - eePromControlsContainer.AddChild(GetEEPromControl()); - terminalCommunicationsContainer = new DisableableWidget(); - terminalCommunicationsContainer.AddChild(GetGcodeTerminalControl()); - - mainContainer.AddChild(new HorizontalLine(50)); - mainContainer.AddChild(eePromControlsContainer); - mainContainer.AddChild(new HorizontalLine(50)); - - mainContainer.AddChild(terminalCommunicationsContainer); - DisableableWidget cameraContainer = new DisableableWidget(); cameraContainer.AddChild(GetCameraControl()); @@ -112,76 +97,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage return buttonRow; } - private FlowLayoutWidget GetGcodeTerminalControl() - { - FlowLayoutWidget buttonRow = new FlowLayoutWidget(); - buttonRow.HAnchor = HAnchor.ParentLeftRight; - buttonRow.Margin = new BorderDouble(0, 4); - - ImageBuffer terminalSettingsImage = StaticData.Instance.LoadIcon("terminal-24x24.png", 24, 24).InvertLightness(); - terminalSettingsImage.SetRecieveBlender(new BlenderPreMultBGRA()); - int iconSize = (int)(24 * GuiWidget.DeviceScale); - - if (!ActiveTheme.Instance.IsDarkTheme) - { - terminalSettingsImage.InvertLightness(); - } - - ImageWidget terminalIcon = new ImageWidget(terminalSettingsImage); - terminalIcon.Margin = new BorderDouble(right: 6, bottom: 6); - - TextWidget gcodeTerminalLabel = new TextWidget("G-Code Terminal".Localize()); - gcodeTerminalLabel.AutoExpandBoundsToText = true; - gcodeTerminalLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; - gcodeTerminalLabel.VAnchor = VAnchor.ParentCenter; - - openGcodeTerminalButton = textImageButtonFactory.Generate("Show Terminal".Localize().ToUpper()); - openGcodeTerminalButton.Name = "Show Terminal Button"; - openGcodeTerminalButton.Click += openGcodeTerminalButton_Click; - - buttonRow.AddChild(terminalIcon); - buttonRow.AddChild(gcodeTerminalLabel); - buttonRow.AddChild(new HorizontalSpacer()); - buttonRow.AddChild(openGcodeTerminalButton); - - return buttonRow; - } - - private static EePromMarlinWindow openEePromMarlinWidget = null; - private static EePromRepetierWindow openEePromRepetierWidget = null; - private string noEepromMappingMessage = "Oops! There is no eeprom mapping for your printer's firmware.".Localize() + "\n\n" + "You may need to wait a minute for your printer to finish initializing.".Localize(); - private string noEepromMappingTitle = "Warning - No EEProm Mapping".Localize(); - - private FlowLayoutWidget GetEEPromControl() - { - FlowLayoutWidget buttonRow = new FlowLayoutWidget(); - buttonRow.HAnchor = HAnchor.ParentLeftRight; - buttonRow.Margin = new BorderDouble(0, 4); - - TextWidget notificationSettingsLabel = new TextWidget("EEProm".Localize()); - notificationSettingsLabel.AutoExpandBoundsToText = true; - notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor; - notificationSettingsLabel.VAnchor = VAnchor.ParentCenter; - - ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24); - - if (!ActiveTheme.Instance.IsDarkTheme) - { - levelingImage.InvertLightness(); - } - ImageWidget levelingIcon = new ImageWidget(levelingImage); - levelingIcon.Margin = new BorderDouble(right: 6); - - Button configureEePromButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper()); - configureEePromButton.Click += configureEePromButton_Click; - - //buttonRow.AddChild(eePromIcon); - buttonRow.AddChild(notificationSettingsLabel); - buttonRow.AddChild(new HorizontalSpacer()); - buttonRow.AddChild(configureEePromButton); - - return buttonRow; - } private void AddHandlers() { @@ -194,66 +109,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage MatterControlApplication.Instance.OpenCameraPreview(); } - private void configureEePromButton_Click(object sender, EventArgs mouseEvent) - { - UiThread.RunOnIdle(()=> - { -#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware. - new MatterHackers.MatterControl.EeProm.EePromRepetierWidget(); -#else - switch (PrinterConnectionAndCommunication.Instance.FirmwareType) - { - case PrinterConnectionAndCommunication.FirmwareTypes.Repetier: - if (openEePromRepetierWidget != null) - { - openEePromRepetierWidget.BringToFront(); - } - else - { - openEePromRepetierWidget = new EePromRepetierWindow(); - openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) => - { - openEePromRepetierWidget = null; - }; - } - break; - - case PrinterConnectionAndCommunication.FirmwareTypes.Marlin: - if (openEePromMarlinWidget != null) - { - openEePromMarlinWidget.BringToFront(); - } - else - { - openEePromMarlinWidget = new EePromMarlinWindow(); - openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) => - { - openEePromMarlinWidget = null; - }; - } - break; - - default: - PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("M115"); - StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK); - break; - } -#endif - }); - } - - private void openGcodeTerminalButton_Click(object sender, EventArgs mouseEvent) - { - UiThread.RunOnIdle(TerminalWindow.Show); - } - private void SetEnabledStates() { if (!ActiveSliceSettings.Instance.PrinterSelected) { - // no printer selected - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); //cloudMonitorContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); } else // we at least have a printer selected @@ -266,19 +125,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage case PrinterConnectionAndCommunication.CommunicationStates.Disconnected: case PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect: case PrinterConnectionAndCommunication.CommunicationStates.FailedToConnect: - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); break; case PrinterConnectionAndCommunication.CommunicationStates.FinishedPrint: case PrinterConnectionAndCommunication.CommunicationStates.Connected: - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); break; case PrinterConnectionAndCommunication.CommunicationStates.PrintingFromSd: - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); break; case PrinterConnectionAndCommunication.CommunicationStates.PreparingToPrint: @@ -289,8 +142,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage case PrinterConnectionAndCommunication.DetailedPrintingState.HeatingBed: case PrinterConnectionAndCommunication.DetailedPrintingState.HeatingExtruder: case PrinterConnectionAndCommunication.DetailedPrintingState.Printing: - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); break; default: @@ -299,8 +150,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage break; case PrinterConnectionAndCommunication.CommunicationStates.Paused: - eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); - terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled); break; default: diff --git a/MatterControl.csproj b/MatterControl.csproj index 9c9d39165..59f5c8e78 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -205,6 +205,7 @@ + diff --git a/MatterControlApplication.cs b/MatterControlApplication.cs index bc4b62476..d45dad8e4 100644 --- a/MatterControlApplication.cs +++ b/MatterControlApplication.cs @@ -928,8 +928,8 @@ namespace MatterHackers.MatterControl } else { - //e.graphics2D.DrawString($"{child.widget.GetType().Name} -- -", start.x, start.y, backgroundColor: RGBA_Bytes.White, drawFromHintedCach: true); - //start.y += lineHeight; + e.graphics2D.DrawString($"{child.widget.GetType().Name} -- -", start.x, start.y, backgroundColor: RGBA_Bytes.White, drawFromHintedCach: true); + start.y += lineHeight; } } } diff --git a/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs index c5b8e2f20..4a15fe800 100644 --- a/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs +++ b/PartPreviewWindow/BaseClasses/PartPreview3DWidget.cs @@ -165,7 +165,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { // this is to add an image to the bed string imagePathAndFile = Path.Combine("OEMSettings", "bedimage.png"); - if (allowAutoRotate && StaticData.Instance.FileExists(imagePathAndFile)) + if (StaticData.Instance.FileExists(imagePathAndFile)) { if (wattermarkImage == null) { diff --git a/PartPreviewWindow/View3D/PrinterActionsBar.cs b/PartPreviewWindow/View3D/PrinterActionsBar.cs new file mode 100644 index 000000000..98ecfaa15 --- /dev/null +++ b/PartPreviewWindow/View3D/PrinterActionsBar.cs @@ -0,0 +1,128 @@ +/* +Copyright (c) 2017, 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 MatterHackers.Agg; +using MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.ActionBar; +using MatterHackers.MatterControl.EeProm; +using MatterHackers.MatterControl.PrinterCommunication; + +namespace MatterHackers.MatterControl.PartPreviewWindow +{ + + public partial class View3DWidget : PartPreview3DWidget + { + public class PrinterActionsBar : FlowLayoutWidget + { + private static EePromMarlinWindow openEePromMarlinWidget = null; + private static EePromRepetierWindow openEePromRepetierWidget = null; + private string noEepromMappingMessage = "Oops! There is no eeprom mapping for your printer's firmware.".Localize() + "\n\n" + "You may need to wait a minute for your printer to finish initializing.".Localize(); + private string noEepromMappingTitle = "Warning - No EEProm Mapping".Localize(); + + public PrinterActionsBar() + { + this.Padding = new BorderDouble(0, 0, 10, 0); + this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; + this.HAnchor = HAnchor.ParentLeftRight; + this.VAnchor = VAnchor.FitToChildren; + + var buttonFactory = ApplicationController.Instance.Theme.PrinterConnectButtonFactory; + + //ImageBuffer terminalSettingsImage = StaticData.Instance.LoadIcon("terminal-24x24.png", 24, 24).InvertLightness(); + var terminalButton = buttonFactory.Generate("Terminal".Localize().ToUpper()); + terminalButton.Name = "Show Terminal Button"; + terminalButton.Click += (s, e) => UiThread.RunOnIdle(TerminalWindow.Show); + this.AddChild(terminalButton); + + /* + ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 24, 24); + if (!ActiveTheme.Instance.IsDarkTheme) + { + levelingImage.InvertLightness(); + }*/ + Button configureEePromButton = buttonFactory.Generate("EEProm".Localize().ToUpper()); + configureEePromButton.Click += configureEePromButton_Click; + this.AddChild(configureEePromButton); + + this.AddChild(new PrinterConnectAndSelectControl()); + + this.AddChild(new PrintStatusRow()); + } + + private void configureEePromButton_Click(object sender, EventArgs mouseEvent) + { + UiThread.RunOnIdle(() => + { +#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware. + new MatterHackers.MatterControl.EeProm.EePromRepetierWidget(); +#else + switch (PrinterConnectionAndCommunication.Instance.FirmwareType) + { + case PrinterConnectionAndCommunication.FirmwareTypes.Repetier: + if (openEePromRepetierWidget != null) + { + openEePromRepetierWidget.BringToFront(); + } + else + { + openEePromRepetierWidget = new EePromRepetierWindow(); + openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) => + { + openEePromRepetierWidget = null; + }; + } + break; + + case PrinterConnectionAndCommunication.FirmwareTypes.Marlin: + if (openEePromMarlinWidget != null) + { + openEePromMarlinWidget.BringToFront(); + } + else + { + openEePromMarlinWidget = new EePromMarlinWindow(); + openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) => + { + openEePromMarlinWidget = null; + }; + } + break; + + default: + PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("M115"); + StyledMessageBox.ShowMessageBox(null, noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK); + break; + } +#endif + }); + } + } + } +} \ No newline at end of file diff --git a/PartPreviewWindow/View3D/View3DWidget.cs b/PartPreviewWindow/View3D/View3DWidget.cs index 206448b81..3f6da0b27 100644 --- a/PartPreviewWindow/View3D/View3DWidget.cs +++ b/PartPreviewWindow/View3D/View3DWidget.cs @@ -236,6 +236,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } } } + protected FlowLayoutWidget editPlateButtonsContainer; public View3DWidget(PrintItemWrapper printItemWrapper, Vector3 viewerVolume, Vector2 bedCenter, BedShape bedShape, WindowMode windowType, AutoRotate autoRotate, OpenMode openMode = OpenMode.Viewing) @@ -252,10 +253,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight; - FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); + var centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight); centerPartPreviewAndControls.Name = "centerPartPreviewAndControls"; centerPartPreviewAndControls.AnchorAll(); + var textImageButtonFactory = ApplicationController.Instance.Theme.ImageButtonFactory; + + mainContainerTopToBottom.AddChild(new PrinterActionsBar()); + GuiWidget viewArea = new GuiWidget(); viewArea.AnchorAll(); { diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index 5a25fb1f9..873d10ef6 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -190,6 +190,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow Margin = new BorderDouble(5); HAnchor |= Agg.UI.HAnchor.ParentLeft; VAnchor = Agg.UI.VAnchor.ParentTop; + + Margin = new BorderDouble(0, 0, 0, 72); rotateButton.Checked = true; BackgroundColor = new RGBA_Bytes(0, 0, 0, 120); diff --git a/PartPreviewWindow/ViewGcodeBasic.cs b/PartPreviewWindow/ViewGcodeBasic.cs index 3e20f31d2..7e8404f26 100644 --- a/PartPreviewWindow/ViewGcodeBasic.cs +++ b/PartPreviewWindow/ViewGcodeBasic.cs @@ -309,6 +309,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow }; viewControls3D = new ViewControls3D(meshViewerWidget); + viewControls3D.Margin = new BorderDouble(0, 0, 0, 40); viewControls3D.PartSelectVisible = false; AddChild(viewControls3D); diff --git a/StaticData/OEMSettings/bedimage.png b/StaticData/OEMSettings/bedimage.png new file mode 100644 index 000000000..fecbb6014 Binary files /dev/null and b/StaticData/OEMSettings/bedimage.png differ diff --git a/StaticData/OEMSettings/watermark.png b/StaticData/OEMSettings/watermark.png index a7d28c8c2..ce4ae57b5 100644 Binary files a/StaticData/OEMSettings/watermark.png and b/StaticData/OEMSettings/watermark.png differ diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index ad8046f6d..2f041b16f 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit ad8046f6de68f097bed7cfdefdc6520d42023e41 +Subproject commit 2f041b16f5296681be49afc13c6e70f01854a565