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 RepetierEEPromPage(PrinterConfig printer) : base(printer) { AlwaysOnTopOfMain = true; this.WindowTitle = "Firmware EEPROM Settings".Localize(); currentEePromSettings = new EePromRepetierStorage(); var topToBottom = contentRow; var row = new FlowLayoutWidget { HAnchor = HAnchor.Stretch, }; GuiWidget descriptionWidget = AddDescription("Description".Localize()); descriptionWidget.Margin = new BorderDouble(left: 3); row.AddChild(descriptionWidget); CreateSpacer(row); row.AddChild(new TextWidget("Value".Localize(), pointSize: theme.FontSize10, textColor: theme.TextColor) { VAnchor = VAnchor.Center, Margin = new BorderDouble(left: 5, right: 60) }); topToBottom.AddChild(row); { var settingsAreaScrollBox = new ScrollableWidget(true); settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch; settingsAreaScrollBox.AnchorAll(); settingsAreaScrollBox.BackgroundColor = theme.MinimalShade; topToBottom.AddChild(settingsAreaScrollBox); settingsColumn = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.MaxFitOrStretch }; settingsAreaScrollBox.AddChild(settingsColumn); } if (headerRow is OverflowBar overflowBar) { overflowBar.ExtendOverflowMenu = (popupMenu) => { var menuItem = popupMenu.CreateMenuItem("Import".Localize()); menuItem.Name = "Import Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(() => { AggContext.FileDialogs.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(); } }); }, .1); }; menuItem = popupMenu.CreateMenuItem("Export".Localize()); menuItem.Name = "Export Menu Item"; menuItem.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; }; } // put in the save button var buttonSave = theme.CreateDialogButton("Save To EEPROM".Localize()); buttonSave.Click += (s, e) => { currentEePromSettings.Save(printer.Connection); currentEePromSettings.Clear(); this.DialogWindow.Close(); }; this.AddPageAction(buttonSave); var exportButton = theme.CreateDialogButton("Export".Localize()); exportButton.Click += (s, e) => { UiThread.RunOnIdle(this.ExportSettings, .1); }; this.AddPageAction(exportButton); currentEePromSettings.Clear(); printer.Connection.LineReceived += currentEePromSettings.Add; currentEePromSettings.SettingAdded += NewSettingReadFromPrinter; currentEePromSettings.AskPrinterForSettings(printer.Connection); #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 }