From c09ed8b65cd944984cb201d4e50ba63d3e9d80ce Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 18 Jun 2018 15:25:53 -0700 Subject: [PATCH] Add Export button to footer, RunOnIdle durations to ensure refresh --- EeProm/EePromMarlinWindow.cs | 65 +++++++++++-------- EeProm/EePromRepetierWindow.cs | 48 ++++++++------ .../View3D/PrinterBar/PrinterActionsBar.cs | 4 +- 3 files changed, 66 insertions(+), 51 deletions(-) diff --git a/EeProm/EePromMarlinWindow.cs b/EeProm/EePromMarlinWindow.cs index d73a83531..879a123a6 100644 --- a/EeProm/EePromMarlinWindow.cs +++ b/EeProm/EePromMarlinWindow.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2014, Lars Brubaker +Copyright (c) 2018, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -165,6 +165,13 @@ namespace MatterHackers.MatterControl.EeProm }); }; this.AddPageAction(buttonSave); + + var exportButton = theme.CreateDialogButton("Export".Localize()); + exportButton.Click += (s, e) => + { + UiThread.RunOnIdle(this.ExportSettings, .1); + }; + this.AddPageAction(exportButton); } printerConnection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); @@ -188,15 +195,15 @@ namespace MatterHackers.MatterControl.EeProm ActionButtonLabel = "Import EEPROM Settings".Localize(), Title = "Import EEPROM".Localize(), }, - (openParams) => + (openParams) => + { + if (!string.IsNullOrEmpty(openParams.FileName)) { - if (!string.IsNullOrEmpty(openParams.FileName)) - { - currentEePromSettings.Import(openParams.FileName); - SetUiToPrinterSettings(null, null); - } - }); - }); + currentEePromSettings.Import(openParams.FileName); + SetUiToPrinterSettings(null, null); + } + }); + }, .1); }; // put in the export button @@ -204,25 +211,7 @@ namespace MatterHackers.MatterControl.EeProm menuItem.Name = "Export Menu Item"; menuItem.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - string defaultFileNameNoPath = "eeprom_settings.ini"; - AggContext.FileDialogs.SaveFileDialog( - new SaveFileDialogParams("EEPROM Settings|*.ini") - { - ActionButtonLabel = "Export EEPROM Settings".Localize(), - Title = "Export EEPROM".Localize(), - FileName = defaultFileNameNoPath - }, - (saveParams) => - { - if (!string.IsNullOrEmpty(saveParams.FileName) - && saveParams.FileName != defaultFileNameNoPath) - { - currentEePromSettings.Export(saveParams.FileName); - } - }); - }); + UiThread.RunOnIdle(this.ExportSettings, .1); }; popupMenu.CreateHorizontalLine(); @@ -242,6 +231,26 @@ namespace MatterHackers.MatterControl.EeProm } } + private void ExportSettings() + { + string defaultFileNameNoPath = "eeprom_settings.ini"; + AggContext.FileDialogs.SaveFileDialog( + new SaveFileDialogParams("EEPROM Settings|*.ini") + { + ActionButtonLabel = "Export EEPROM Settings".Localize(), + Title = "Export EEPROM".Localize(), + FileName = defaultFileNameNoPath + }, + (saveParams) => + { + if (!string.IsNullOrEmpty(saveParams.FileName) + && saveParams.FileName != defaultFileNameNoPath) + { + currentEePromSettings.Export(saveParams.FileName); + } + }); + } + private GuiWidget CreateMHNumEdit(ref MHNumberEdit numberEditToCreate) { numberEditToCreate = new MHNumberEdit(0, pixelWidth: 80, allowNegatives: true, allowDecimals: true) diff --git a/EeProm/EePromRepetierWindow.cs b/EeProm/EePromRepetierWindow.cs index 3cdd0d7c0..d4d01386d 100644 --- a/EeProm/EePromRepetierWindow.cs +++ b/EeProm/EePromRepetierWindow.cs @@ -143,37 +143,20 @@ namespace MatterHackers.MatterControl.EeProm RebuildUi(); } }); - }); + }, .1); }; menuItem = popupMenu.CreateMenuItem("Export".Localize()); menuItem.Name = "Export Menu Item"; menuItem.Click += (s, e) => { - UiThread.RunOnIdle(() => - { - AggContext.FileDialogs.SaveFileDialog( - new SaveFileDialogParams("EEPROM Settings|*.ini") - { - ActionButtonLabel = "Export EEPROM Settings".Localize(), - Title = "Export EEPROM".Localize(), - FileName = "eeprom_settings.ini" - }, - (saveParams) => - { - if (!string.IsNullOrEmpty(saveParams.FileName)) - { - currentEePromSettings.Export(saveParams.FileName); - } - }); - }); + UiThread.RunOnIdle(this.ExportSettings, .1); }; }; } // put in the save button var buttonSave = theme.CreateDialogButton("Save To EEPROM".Localize()); - buttonSave.Margin = new BorderDouble(0, 3); buttonSave.Click += (s, e) => { UiThread.RunOnIdle(() => @@ -185,6 +168,13 @@ namespace MatterHackers.MatterControl.EeProm }; this.AddPageAction(buttonSave); + var exportButton = theme.CreateDialogButton("Export".Localize()); + exportButton.Click += (s, e) => + { + UiThread.RunOnIdle(this.ExportSettings, .1); + }; + this.AddPageAction(exportButton); + currentEePromSettings.Clear(); printerConnection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; @@ -195,6 +185,24 @@ namespace MatterHackers.MatterControl.EeProm #endif } + private void ExportSettings() + { + AggContext.FileDialogs.SaveFileDialog( + new SaveFileDialogParams("EEPROM Settings|*.ini") + { + ActionButtonLabel = "Export EEPROM Settings".Localize(), + Title = "Export EEPROM".Localize(), + FileName = "eeprom_settings.ini" + }, + (saveParams) => + { + if (!string.IsNullOrEmpty(saveParams.FileName)) + { + currentEePromSettings.Export(saveParams.FileName); + } + }); + } + #if SIMULATE_CONNECTION int count; void AddSimulatedItems(object state) @@ -296,7 +304,7 @@ namespace MatterHackers.MatterControl.EeProm private GuiWidget AddDescription(string description) { var holder = new GuiWidget(340, 40); - holder.AddChild(new TextWidget(description, pointSize: theme.FontSize10, textColor: ActiveTheme.Instance.PrimaryTextColor) + holder.AddChild(new TextWidget(description, pointSize: theme.DefaultFontSize, textColor: ActiveTheme.Instance.PrimaryTextColor) { VAnchor = VAnchor.Center }); diff --git a/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs b/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs index a9d542ade..ed82640be 100644 --- a/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs +++ b/PartPreviewWindow/View3D/PrinterBar/PrinterActionsBar.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2017, Lars Brubaker, John Lewin +Copyright (c) 2018, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -31,7 +31,6 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.IO; -using System.Linq; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; @@ -42,7 +41,6 @@ using MatterHackers.MatterControl.EeProm; using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.PrintHistory; using MatterHackers.MatterControl.SlicerConfiguration; -using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.PartPreviewWindow {