From 4224ff8755ed8face2b417e40dbbd76509eaa415 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Fri, 18 Jan 2019 12:13:31 -0800 Subject: [PATCH] Made the loading and unloading actions on the actions bar Made better styling --- .../PrintLeveling/LoadFilamentWizard.cs | 10 +-- .../PrintLeveling/UnloadFilamentWizard.cs | 10 +-- .../WizardPages/SelectMaterialPage.cs | 9 +-- .../ControlElements/StyledMessageBoxWindow.cs | 2 +- .../PartPreviewWindow/PrinterTabPage.cs | 62 +++++++++++-------- 5 files changed, 43 insertions(+), 50 deletions(-) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs index d353b10a3..262e38d2a 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs @@ -345,17 +345,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { if (printer.Connection.PrinterIsPaused) { - contentRow.AddChild(new VerticalSpacer()); - - contentRow.AddChild(this.CreateTextField("You can optionally click below to resume your paused print.".Localize() + ":")); - var resumePrintingButton = new TextButton("Resume Printing".Localize(), theme) { Name = "Resume Printing Button", BackgroundColor = theme.MinimalShade, - VAnchor = Agg.UI.VAnchor.Absolute, - HAnchor = Agg.UI.HAnchor.Fit | Agg.UI.HAnchor.Left, - Margin = new BorderDouble(10, 15, 0, 15) }; resumePrintingButton.Click += (s, e) => { @@ -363,7 +356,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling printer.Connection.Resume(); }; - contentRow.AddChild(resumePrintingButton); + theme.ApplyPrimaryActionStyle(resumePrintingButton); + this.AddPageAction(resumePrintingButton); } } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs index 7aeead5d2..1890f00b4 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs @@ -205,25 +205,19 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling public DoneUnloadingPage(PrinterSetupWizard setupWizard) : base(setupWizard, "Success".Localize(), "Success!\n\nYour filament should now be unloaded".Localize()) { - contentRow.AddChild(new VerticalSpacer()); - - contentRow.AddChild(this.CreateTextField("You can optionally click below to get help loading new material".Localize() + ":")); - var loadFilamentButton = new TextButton("Load Filament".Localize(), theme) { Name = "Load Filament", BackgroundColor = theme.MinimalShade, - VAnchor = Agg.UI.VAnchor.Absolute, - HAnchor = Agg.UI.HAnchor.Fit | Agg.UI.HAnchor.Left, - Margin = new BorderDouble(10, 10, 0, 15) }; loadFilamentButton.Click += (s, e) => { loadFilamentButton.Parents().First().Close(); LoadFilamentWizard.Start(printer, theme, true); }; + theme.ApplyPrimaryActionStyle(loadFilamentButton); - contentRow.AddChild(loadFilamentButton); + this.AddPageAction(loadFilamentButton); } public override void PageIsBecomingActive() diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs index 6a2fb0013..d17382ed1 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/SelectMaterialPage.cs @@ -55,24 +55,19 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { NextButton.Visible = false; - contentRow.AddChild(this.CreateTextField("Optionally, click below to get help loading this material".Localize() + ":")); - var loadFilamentButton = new TextButton("Load Filament".Localize(), theme) { Name = "Load Filament", BackgroundColor = theme.MinimalShade, - VAnchor = Agg.UI.VAnchor.Absolute, - HAnchor = Agg.UI.HAnchor.Fit | Agg.UI.HAnchor.Left, - Margin = new BorderDouble(10, 10, 0, 15) }; loadFilamentButton.Click += (s, e) => { wizardContext.ShowNextPage(this.DialogWindow); }; - contentRow.AddChild(loadFilamentButton); + this.AddPageAction(loadFilamentButton); - var selectButton = new TextButton("Select".Localize(), theme) + var selectButton = new TextButton("Already Loaded".Localize(), theme) { Name = "Already Loaded Button", BackgroundColor = theme.MinimalShade diff --git a/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs b/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs index d501cad22..5e8d5ca3d 100644 --- a/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs +++ b/MatterControlLib/ControlElements/StyledMessageBoxWindow.cs @@ -57,7 +57,7 @@ namespace MatterHackers.MatterControl new MessageBoxPage(callback, message, caption, messageType, extraWidgetsToAdd, 400, 300, yesOk, noCancel, ApplicationController.Instance.Theme, useMarkdown)); } - private class MessageBoxPage : DialogPage + public class MessageBoxPage : DialogPage { private string unwrappedMessage; private GuiWidget messageContainer; diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index 185eae33e..8c7e9ec83 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -256,35 +256,45 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (printePauseEventArgs.filamentRunout) { - string filamentPauseMessage = "Your 3D print has been paused.\n\nOut of filament, or jam, detected. Please load more filament or clear the jam.".Localize(); - - var optionText = this.CreateTextField("Optionally, click below to get help unloading this material".Localize() + ":"); - - var unloadFilamentButton = new TextButton("Unload Filament".Localize(), theme) + UiThread.RunOnIdle(() => { - Name = "unload Filament", - BackgroundColor = theme.MinimalShade, - VAnchor = Agg.UI.VAnchor.Absolute, - HAnchor = Agg.UI.HAnchor.Fit | Agg.UI.HAnchor.Left, - Margin = new BorderDouble(10, 10, 0, 15) - }; - - unloadFilamentButton.Click += (s, e2) => - { - UiThread.RunOnIdle(() => + var unloadFilamentButton = new TextButton("Unload Filament".Localize(), theme) { - unloadFilamentButton.Parents().First().Close(); - UnloadFilamentWizard.Start(printer, theme, true); - }); - }; + Name = "unload Filament", + BackgroundColor = theme.MinimalShade, + VAnchor = Agg.UI.VAnchor.Absolute, + HAnchor = Agg.UI.HAnchor.Fit | Agg.UI.HAnchor.Left, + Margin = new BorderDouble(10, 10, 0, 15) + }; - UiThread.RunOnIdle(() => StyledMessageBox.ShowMessageBox(ResumePrint, - filamentPauseMessage.FormatWith(printePauseEventArgs.layerNumber), - pauseCaption, - new GuiWidget[] { optionText, unloadFilamentButton }, - StyledMessageBox.MessageType.YES_NO, - "Resume".Localize(), - "OK".Localize())); + unloadFilamentButton.Click += (s, e2) => + { + UiThread.RunOnIdle(() => + { + unloadFilamentButton.Parents().First().Close(); + UnloadFilamentWizard.Start(printer, theme, true); + }); + }; + + theme.ApplyPrimaryActionStyle(unloadFilamentButton); + + string filamentPauseMessage = "Your 3D print has been paused.\n\nOut of filament, or jam, detected. Please load more filament or clear the jam.".Localize(); + + var messageBox = new MessageBoxPage(ResumePrint, + filamentPauseMessage.FormatWith(printePauseEventArgs.layerNumber), + pauseCaption, + StyledMessageBox.MessageType.YES_NO_WITHOUT_HIGHLIGHT, + null, + 500, + 400, + "Resume".Localize(), + "OK".Localize(), + ApplicationController.Instance.Theme, false); + + messageBox.AddPageAction(unloadFilamentButton); + + DialogWindow.Show(messageBox); + }); } } }