From 298d5347fe83e8f0096b86d49313bc0d28e35f01 Mon Sep 17 00:00:00 2001 From: Lars Brubaker Date: Mon, 26 Oct 2020 16:40:36 -0700 Subject: [PATCH] fixing close box rendering --- .../History/PrintHistoryEditor.cs | 100 ++++++++++-------- .../View3D/PrinterBar/OverflowBar.cs | 2 +- MatterControlLib/SetupWizard/InputBoxPage.cs | 22 ++-- 3 files changed, 70 insertions(+), 54 deletions(-) diff --git a/MatterControlLib/History/PrintHistoryEditor.cs b/MatterControlLib/History/PrintHistoryEditor.cs index 5c9946810..62df2b548 100644 --- a/MatterControlLib/History/PrintHistoryEditor.cs +++ b/MatterControlLib/History/PrintHistoryEditor.cs @@ -37,6 +37,7 @@ using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PartPreviewWindow; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PrintHistory @@ -73,7 +74,7 @@ namespace MatterHackers.MatterControl.PrintHistory { var inputBoxPage = new InputBoxPage( "Print History Note".Localize(), - "Note".Localize(), + "", printTask.Note ?? "", "Enter Note Here".Localize(), string.IsNullOrEmpty(printTask.Note) ? "Add Note".Localize() : "Update".Localize(), @@ -88,7 +89,7 @@ namespace MatterHackers.MatterControl.PrintHistory AllowEmpty = true, }; - inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage, theme)); + inputBoxPage.ContentRow.AddChild(CreateDefaultOptions(inputBoxPage.TextEditWidget, theme), 0); DialogWindow.Show(inputBoxPage); @@ -174,38 +175,41 @@ namespace MatterHackers.MatterControl.PrintHistory { var issues = new string[] { - "Bad Thermistor", - "Bed Dislodged", - "Bowden Tube Popped Out", - "Computer Crashed", - "Computer Slow/Lagging", - "Couldn't Resume", - "Dislodged From Bed", - "Extruder Slipping", - "Filament Jam", - "Filament Runout", - "Filament Snapped", - "First Layer Bad Quality", - "Flooded Hot End", - "Initial Z Height Incorrect", - "Layer Shift", - "Power Outage", - "Print Quality", - "Rough Overhangs", - "Skipped Layers", - "Some Parts Lifted", - "Stringing / Poor retractions", - "Test Print", - "Thermal Runaway - Bed", - "Thermal Runaway - Hot End", - "Thermal Runaway", - "Took Too Long To Heat", - "User Error", - "Warping", - "Wouldn’t Slice Correctly", + "Bad Thermistor".Localize(), + "Bed Dislodged".Localize(), + "Bowden Tube Popped Out".Localize(), + "Computer Crashed".Localize(), + "Computer Slow/Lagging".Localize(), + "Couldn't Resume".Localize(), + "Dislodged From Bed".Localize(), + "Extruder Slipping".Localize(), + "Filament Jam".Localize(), + "Filament Runout".Localize(), + "Filament Snapped".Localize(), + "First Layer Bad Quality".Localize(), + "Flooded Hot End".Localize(), + "Initial Z Height Incorrect".Localize(), + "Layer Shift".Localize(), + "Power Outage".Localize(), + "Print Quality".Localize(), + "Rough Overhangs".Localize(), + "Skipped Layers".Localize(), + "Some Parts Lifted".Localize(), + "Stringing / Poor retractions".Localize(), + "Test Print".Localize(), + "Thermal Runaway - Bed".Localize(), + "Thermal Runaway - Hot End".Localize(), + "Thermal Runaway".Localize(), + "Took Too Long To Heat".Localize(), + "User Error".Localize(), + "Warping".Localize(), + "Wouldn’t Slice Correctly".Localize(), + "Other...".Localize() }; - var dropdownList = new MHDropDownList("Standard Issues".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale); + textField.Visible = false; + + var dropdownList = new MHDropDownList("What went wrong?".Localize(), theme, maxHeight: 300 * GuiWidget.DeviceScale); foreach (var issue in issues) { @@ -213,7 +217,17 @@ namespace MatterHackers.MatterControl.PrintHistory newItem.Selected += (sender, e) => { - textField.Text = issue; + if (dropdownList.SelectedIndex == issues.Length - 1) + { + textField.Text = ""; + textField.Visible = true; + UiThread.RunOnIdle(textField.Focus); + } + else + { + textField.Text = issue; + textField.Visible = false; + } }; } @@ -275,8 +289,8 @@ Support and tutorials:" + articles; : base("Close".Localize()) { this.WindowTitle = windowTitle; - this.HeaderText = windowTitle; - this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 400 * GuiWidget.DeviceScale); + this.HeaderText = printer.Settings.GetValue(SettingsKey.printer_name) + ": " + windowTitle; + this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 440 * GuiWidget.DeviceScale); var scrollable = new ScrollableWidget(autoScroll: true) { @@ -329,7 +343,7 @@ Support and tutorials:" + articles; { Name = "InputBoxPage TextEditWidget", HAnchor = HAnchor.Stretch, - Margin = new BorderDouble(5) + Margin = new BorderDouble(5), }; textEditWidget.ActualTextEditWidget.EditComplete += (s, e) => @@ -338,12 +352,11 @@ Support and tutorials:" + articles; printTask.CommitAndPushToServer(); }; - reasonSection.AddChild(textEditWidget); - - var dropDownList = PrintHistoryEditor.CreateDefaultOptions(textEditWidget, theme); + var dropDownList = CreateDefaultOptions(textEditWidget, theme); dropDownList.Margin = new BorderDouble(5, 0); dropDownList.HAnchor = HAnchor.Left; reasonSection.AddChild(dropDownList); + reasonSection.AddChild(textEditWidget); dropDownList.SelectionChanged += (s, e) => { @@ -372,9 +385,12 @@ Support and tutorials:" + articles; { DialogWindow.Show(this, 0); // this will cause a layout that fixes a display issue - this.Width += 1; - this.Width -= 1; - this.Descendants().First().ScrollPositionFromTop = new Vector2(0, 0); + scrollable.ScrollArea.BoundsChanged += (s, e) => + { + scrollable.ScrollPositionFromTop = new Vector2(0, 0); + }; + + scrollable.ScrollPositionFromTop = new Vector2(0, 0); }); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs index 1ffc61b74..1c248151b 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/PrinterBar/OverflowBar.cs @@ -51,7 +51,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { } public OverflowBar(ImageBuffer icon, ThemeConfig theme) - : base(theme.TabbarPadding, theme.CreateSmallResetButton()) + : base(theme.TabbarPadding) { this.theme = theme; diff --git a/MatterControlLib/SetupWizard/InputBoxPage.cs b/MatterControlLib/SetupWizard/InputBoxPage.cs index 093c5b29c..d7784957d 100644 --- a/MatterControlLib/SetupWizard/InputBoxPage.cs +++ b/MatterControlLib/SetupWizard/InputBoxPage.cs @@ -36,9 +36,9 @@ namespace MatterHackers.MatterControl { public class InputBoxPage : DialogPage { - private MHTextEditWidget textEditWidget; + public MHTextEditWidget TextEditWidget { get; private set; } - public override string Text { get => textEditWidget.Text; set => textEditWidget.Text = value; } + public override string Text { get => TextEditWidget.Text; set => TextEditWidget.Text = value; } public InputBoxPage(string windowTitle, string label, string initialValue, string emptyText, string actionButtonTitle, Action action) { @@ -56,22 +56,22 @@ namespace MatterHackers.MatterControl }); // Adds text box and check box to the above container - textEditWidget = new MHTextEditWidget(initialValue, theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: emptyText); - textEditWidget.Name = "InputBoxPage TextEditWidget"; - textEditWidget.HAnchor = HAnchor.Stretch; - textEditWidget.Margin = new BorderDouble(5); - textEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => + TextEditWidget = new MHTextEditWidget(initialValue, theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: emptyText); + TextEditWidget.Name = "InputBoxPage TextEditWidget"; + TextEditWidget.HAnchor = HAnchor.Stretch; + TextEditWidget.Margin = new BorderDouble(5); + TextEditWidget.ActualTextEditWidget.EnterPressed += (s, e) => { actionButton.InvokeClick(); }; - contentRow.AddChild(textEditWidget); + contentRow.AddChild(TextEditWidget); actionButton = theme.CreateDialogButton(actionButtonTitle); actionButton.Name = "InputBoxPage Action Button"; actionButton.Cursor = Cursors.Hand; actionButton.Click += (s, e) => { - string newName = textEditWidget.ActualTextEditWidget.Text; + string newName = TextEditWidget.ActualTextEditWidget.Text; if (!string.IsNullOrEmpty(newName) || AllowEmpty) { action.Invoke(newName); @@ -87,8 +87,8 @@ namespace MatterHackers.MatterControl { UiThread.RunOnIdle(() => { - textEditWidget.Focus(); - textEditWidget.ActualTextEditWidget.InternalTextEditWidget.SelectAll(); + TextEditWidget.Focus(); + TextEditWidget.ActualTextEditWidget.InternalTextEditWidget.SelectAll(); }); base.OnLoad(args); }