private void ExportSettings() { string defaultFileName = $"eeprom_settings_{base.GetSanitizedPrinterName()}.ini"; AggContext.FileDialogs.SaveFileDialog( new SaveFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Export EEPROM Settings".Localize(), Title = "Export EEPROM".Localize(), FileName = defaultFileName }, (saveParams) => { if (!string.IsNullOrEmpty(saveParams.FileName)) { currentEePromSettings.Export(saveParams.FileName); } }); }
public EePromRepetierWindow() : base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale) { AlwaysOnTopOfMain = true; BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentEePromSettings = new EePromRepetierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.ParentBottomTop; topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; topToBottom.Padding = new BorderDouble(3, 0); FlowLayoutWidget row = new FlowLayoutWidget(); row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; GuiWidget descriptionWidget = AddDescription("Description".Localize()); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); GuiWidget valueText = new TextWidget("Value".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; valueText.Margin = new BorderDouble(left: 5, right: 60); row.AddChild(valueText); topToBottom.AddChild(row); { ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.ParentLeftRight; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; topToBottom.AddChild(settingsAreaScrollBox); settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsColmun.HAnchor = HAnchor.Max_FitToChildren_ParentWidth; settingsAreaScrollBox.AddChild(settingsColmun); } FlowLayoutWidget buttonBar = new FlowLayoutWidget(); buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; // put in the save button { Button buttonSave = textImageButtonFactory.Generate("Save To EEPROM".Localize()); buttonSave.Margin = new BorderDouble(0, 3); buttonSave.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Save(); currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonSave); } CreateSpacer(buttonBar); // put in the import button { Button buttonImport = textImageButtonFactory.Generate("Import".Localize() + "..."); buttonImport.Margin = new BorderDouble(0, 3); buttonImport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.OpenFileDialog( new OpenFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Import EEPROM Settings".Localize(), Title = "Import EEPROM".Localize(), }, (openParams) => { if (!string.IsNullOrEmpty(openParams.FileName)) { currentEePromSettings.Import(openParams.FileName); RebuildUi(); } }); }); }; buttonBar.AddChild(buttonImport); } // put in the export button { Button buttonExport = textImageButtonFactory.Generate("Export".Localize() + "..."); buttonExport.Margin = new BorderDouble(0, 3); buttonExport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.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); } }); }); }; buttonBar.AddChild(buttonExport); } // put in the cancel button { Button buttonCancel = textImageButtonFactory.Generate("Close".Localize()); buttonCancel.Margin = new BorderDouble(10, 3, 0, 3); buttonCancel.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonCancel); } topToBottom.AddChild(buttonBar); this.AddChild(topToBottom); Title = "Firmware EEPROM Settings".Localize(); ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }
public EePromRepetierWindow() : base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale) { AlwaysOnTopOfMain = true; BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; currentEePromSettings = new EePromRepetierStorage(); FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); topToBottom.VAnchor = Agg.UI.VAnchor.ParentBottomTop; topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight; topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; topToBottom.Padding = new BorderDouble(3, 0); FlowLayoutWidget row = new FlowLayoutWidget(); row.HAnchor = Agg.UI.HAnchor.ParentLeftRight; row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; GuiWidget descriptionWidget = AddDescription(LocalizedString.Get("Description")); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); GuiWidget valueText = new TextWidget(LocalizedString.Get("Value"), textColor: ActiveTheme.Instance.PrimaryTextColor); valueText.VAnchor = Agg.UI.VAnchor.ParentCenter; valueText.Margin = new BorderDouble(left: 5, right: 60); row.AddChild(valueText); topToBottom.AddChild(row); { ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.ParentLeftRight; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor; topToBottom.AddChild(settingsAreaScrollBox); settingsColmun = new FlowLayoutWidget(FlowDirection.TopToBottom); settingsColmun.HAnchor = HAnchor.Max_FitToChildren_ParentWidth; settingsAreaScrollBox.AddChild(settingsColmun); } FlowLayoutWidget buttonBar = new FlowLayoutWidget(); buttonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth; buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; // put in the save button { Button buttonSave = textImageButtonFactory.Generate("Save To EEPROM".Localize()); buttonSave.Margin = new BorderDouble(0, 3); buttonSave.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Save(); currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonSave); } CreateSpacer(buttonBar); // put in the import button { Button buttonImport = textImageButtonFactory.Generate("Import".Localize() + "..."); buttonImport.Margin = new BorderDouble(0, 3); buttonImport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.OpenFileDialog( new OpenFileDialogParams("EEPROM Settings|*.ini") { ActionButtonLabel = "Import EEPROM Settings".Localize(), Title = "Import EEPROM".Localize(), }, (openParams) => { if (!string.IsNullOrEmpty(openParams.FileName)) { currentEePromSettings.Import(openParams.FileName); RebuildUi(); } }); }); }; buttonBar.AddChild(buttonImport); } // put in the export button { Button buttonExport = textImageButtonFactory.Generate("Export".Localize() + "..."); buttonExport.Margin = new BorderDouble(0, 3); buttonExport.Click += (sender, e) => { UiThread.RunOnIdle(() => { FileDialog.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); } }); }); }; buttonBar.AddChild(buttonExport); } // put in the cancel button { Button buttonCancel = textImageButtonFactory.Generate("Close".Localize()); buttonCancel.Margin = new BorderDouble(10, 3, 0, 3); buttonCancel.Click += (sender, e) => { UiThread.RunOnIdle(() => { currentEePromSettings.Clear(); currentEePromSettings.eventAdded -= NewSettingReadFromPrinter; Close(); }); }; buttonBar.AddChild(buttonCancel); } topToBottom.AddChild(buttonBar); this.AddChild(topToBottom); Title = LocalizedString.Get("Firmware EEPROM Settings"); ShowAsSystemWindow(); currentEePromSettings.Clear(); PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents); currentEePromSettings.eventAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(); #if SIMULATE_CONNECTION UiThread.RunOnIdle(AddSimulatedItems); #endif }