public EePromMarlinWidget()
            : base(700, 480)
        {
            Title = LocalizedString.Get("Marlin Firmware EEPROM Settings");

            currentEePromSettings             = new EePromMarlinSettings();
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            mainContainer.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            mainContainer.Padding         = new BorderDouble(3, 0);

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            topToBottom.Padding         = new BorderDouble(top: 3);

            // the top button bar
            {
                FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
                topButtonBar.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                CreateMainButton(ref buttonReLoadSettings, topButtonBar, "Re-Load Default Settings");
                buttonReLoadSettings.Click += buttonReLoadSettings_Click;

                topButtonBar.Margin = new BorderDouble(0, 3);

                CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Set Default To Factory Settings");
                buttonSetToFactorySettings.Click += SetToFactorySettings;

                mainContainer.AddChild(topButtonBar);
            }

            topToBottom.AddChild(Create4FieldSet("Steps per mm:",
                                                 "X:", ref stepsPerMmX,
                                                 "Y:", ref stepsPerMmY,
                                                 "Z:", ref stepsPerMmZ,
                                                 "E:", ref stepsPerMmE));

            topToBottom.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:",
                                                 "X:", ref maxFeedrateMmPerSX,
                                                 "Y:", ref maxFeedrateMmPerSY,
                                                 "Z:", ref maxFeedrateMmPerSZ,
                                                 "E:", ref maxFeedrateMmPerSE));

            topToBottom.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:",
                                                 "X:", ref maxAccelerationMmPerSSqrdX,
                                                 "Y:", ref maxAccelerationMmPerSSqrdY,
                                                 "Z:", ref maxAccelerationMmPerSSqrdZ,
                                                 "E:", ref maxAccelerationMmPerSSqrdE));

            topToBottom.AddChild(CreateField("Acceleration:", ref acceleration));
            topToBottom.AddChild(CreateField("Retract Acceleration:", ref retractAcceleration));

            topToBottom.AddChild(Create3FieldSet("PID settings:",
                                                 "P:", ref pidP,
                                                 "I:", ref pidI,
                                                 "D:", ref pidD));

            topToBottom.AddChild(Create3FieldSet("Homing Offset:",
                                                 "X:", ref homingOffsetX,
                                                 "Y:", ref homingOffsetY,
                                                 "Z:", ref homingOffsetZ));

            topToBottom.AddChild(CreateField("Min feedrate [mm/s]:", ref minFeedrate));
            topToBottom.AddChild(CreateField("Min travel feedrate [mm/s]:", ref minTravelFeedrate));
            topToBottom.AddChild(CreateField("Minimum segment time [ms]:", ref minSegmentTime));
            topToBottom.AddChild(CreateField("Maximum X-Y jerk [mm/s]:", ref maxXYJerk));
            topToBottom.AddChild(CreateField("Maximum Z jerk [mm/s]:", ref maxZJerk));

            GuiWidget topBottomSpacer = new GuiWidget(1, 1);

            topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
            topToBottom.AddChild(topBottomSpacer);

            mainContainer.AddChild(topToBottom);

            // the bottom button bar
            {
                FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
                bottomButtonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
                bottomButtonBar.Margin          = new BorderDouble(0, 3);

                CreateMainButton(ref buttonSetActive, bottomButtonBar, "Make Settings Active");
                buttonSetActive.Click += buttonSetActive_Click;

                CreateMainButton(ref buttonSave, bottomButtonBar, "Make Settings Active\nAnd Save To Default");
                buttonSave.Click += buttonSave_Click;

                CreateSpacer(bottomButtonBar);

                CreateMainButton(ref buttonAbort, bottomButtonBar, "Cancel");
                buttonAbort.Click += buttonAbort_Click;

                mainContainer.AddChild(bottomButtonBar);
            }

            PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            AddChild(mainContainer);

            ShowAsSystemWindow();

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
Exemple #2
0
        public MarlinEEPromPage(PrinterConfig printer)
            : base(printer)
        {
            AlwaysOnTopOfMain = true;
            this.WindowTitle  = "Marlin Firmware EEPROM Settings".Localize();

            currentEePromSettings             = new EePromMarlinSettings(printer.Connection);
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            // the center content
            var conterContent = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                VAnchor = VAnchor.Fit | VAnchor.Top,
                HAnchor = HAnchor.Stretch
            };

            // add a scroll container
            var settingsAreaScrollBox = new ScrollableWidget(true);

            settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.Stretch;
            settingsAreaScrollBox.AnchorAll();
            settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            contentRow.AddChild(settingsAreaScrollBox);

            settingsAreaScrollBox.AddChild(conterContent);

            conterContent.AddChild(Create4FieldSet("Steps per mm".Localize() + ":",
                                                   "X:", ref stepsPerMmX,
                                                   "Y:", ref stepsPerMmY,
                                                   "Z:", ref stepsPerMmZ,
                                                   "E:", ref stepsPerMmE));

            conterContent.AddChild(Create4FieldSet("Maximum feedrates [mm/s]".Localize() + ":",
                                                   "X:", ref maxFeedrateMmPerSX,
                                                   "Y:", ref maxFeedrateMmPerSY,
                                                   "Z:", ref maxFeedrateMmPerSZ,
                                                   "E:", ref maxFeedrateMmPerSE));

            conterContent.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]".Localize() + ":",
                                                   "X:", ref maxAccelerationMmPerSSqrdX,
                                                   "Y:", ref maxAccelerationMmPerSSqrdY,
                                                   "Z:", ref maxAccelerationMmPerSSqrdZ,
                                                   "E:", ref maxAccelerationMmPerSSqrdE));

            conterContent.AddChild(CreateField("Acceleration Printing".Localize() + ":", ref accelerationPrintingMoves));
            conterContent.AddChild(CreateField("Acceleration Travel".Localize() + ":", ref accelerationTravelMoves));
            conterContent.AddChild(CreateField("Retract Acceleration".Localize() + ":", ref accelerationRetraction));

            conterContent.AddChild(Create3FieldSet("PID Settings".Localize() + ":",
                                                   "P:", ref pidP,
                                                   "I:", ref pidI,
                                                   "D:", ref pidD));

            conterContent.AddChild(Create3FieldSet("Bed PID Settings".Localize() + ":",
                                                   "P:", ref bedPidP,
                                                   "I:", ref bedPidI,
                                                   "D:", ref bedPidD));

            conterContent.AddChild(Create3FieldSet("Homing Offset".Localize() + ":",
                                                   "X:", ref homingOffsetX,
                                                   "Y:", ref homingOffsetY,
                                                   "Z:", ref homingOffsetZ));

            conterContent.AddChild(CreateField("Min feedrate [mm/s]".Localize() + ":", ref minFeedrate));
            conterContent.AddChild(CreateField("Min travel feedrate [mm/s]".Localize() + ":", ref minTravelFeedrate));
            conterContent.AddChild(CreateField("Minimum segment time [ms]".Localize() + ":", ref minSegmentTime));
            conterContent.AddChild(CreateField("Maximum X-Y jerk [mm/s]".Localize() + ":", ref maxXYJerk));
            conterContent.AddChild(CreateField("Maximum Z jerk [mm/s]".Localize() + ":", ref maxZJerk));
            conterContent.AddChild(CreateField("Maximum E jerk [mm/s]".Localize() + ":", ref maxEJerk));

            // the bottom button bar
            var buttonSave = theme.CreateDialogButton("Save to EEProm".Localize());

            buttonSave.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                SaveSettingsToActive();
                currentEePromSettings.SaveToEeProm();
                this.DialogWindow.Close();
            });
            this.AddPageAction(buttonSave);

            var exportButton = theme.CreateDialogButton("Export".Localize());

            exportButton.Click += (s, e) =>
            {
                UiThread.RunOnIdle(this.ExportSettings, .1);
            };
            this.AddPageAction(exportButton);

            printer.Connection.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            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);
                                    SetUiToPrinterSettings(null, null);
                                }
                            });
                        }, .1);
                    };

                    // put in the export button
                    menuItem        = popupMenu.CreateMenuItem("Export".Localize());
                    menuItem.Name   = "Export Menu Item";
                    menuItem.Click += (s, e) =>
                    {
                        UiThread.RunOnIdle(this.ExportSettings, .1);
                    };

                    popupMenu.CreateHorizontalLine();

                    menuItem        = popupMenu.CreateMenuItem("Reset to Factory Defaults".Localize());
                    menuItem.Click += (s, e) =>
                    {
                        currentEePromSettings.SetPrinterToFactorySettings();
                        currentEePromSettings.Update();
                    };
                };
            }

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
        public EePromMarlinWindow()
            : base(700, 480)
        {
            AlwaysOnTopOfMain = true;
            Title             = "Marlin Firmware EEPROM Settings".Localize();

            currentEePromSettings             = new EePromMarlinSettings();
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            FlowLayoutWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            mainContainer.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            mainContainer.Padding         = new BorderDouble(3, 0);

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            topToBottom.Padding         = new BorderDouble(top: 3);

            // the top button bar
            {
                FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
                topButtonBar.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                topButtonBar.Margin = new BorderDouble(0, 3);

                Button buttonSetToFactorySettings = textImageButtonFactory.Generate("Reset to Factory Defaults".Localize());
                topButtonBar.AddChild(buttonSetToFactorySettings);

                buttonSetToFactorySettings.Click += (sender, e) =>
                {
                    currentEePromSettings.SetPrinterToFactorySettings();
                    currentEePromSettings.Update();
                };

                mainContainer.AddChild(topButtonBar);
            }

            topToBottom.AddChild(Create4FieldSet("Steps per mm:".Localize(),
                                                 "X:", ref stepsPerMmX,
                                                 "Y:", ref stepsPerMmY,
                                                 "Z:", ref stepsPerMmZ,
                                                 "E:", ref stepsPerMmE));

            topToBottom.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:".Localize(),
                                                 "X:", ref maxFeedrateMmPerSX,
                                                 "Y:", ref maxFeedrateMmPerSY,
                                                 "Z:", ref maxFeedrateMmPerSZ,
                                                 "E:", ref maxFeedrateMmPerSE));

            topToBottom.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:".Localize(),
                                                 "X:", ref maxAccelerationMmPerSSqrdX,
                                                 "Y:", ref maxAccelerationMmPerSSqrdY,
                                                 "Z:", ref maxAccelerationMmPerSSqrdZ,
                                                 "E:", ref maxAccelerationMmPerSSqrdE));

            topToBottom.AddChild(CreateField("Acceleration:".Localize(), ref acceleration));
            topToBottom.AddChild(CreateField("Retract Acceleration:".Localize(), ref retractAcceleration));

            topToBottom.AddChild(Create3FieldSet("PID settings:".Localize(),
                                                 "P:", ref pidP,
                                                 "I:", ref pidI,
                                                 "D:", ref pidD));

            topToBottom.AddChild(Create3FieldSet("Homing Offset:".Localize(),
                                                 "X:", ref homingOffsetX,
                                                 "Y:", ref homingOffsetY,
                                                 "Z:", ref homingOffsetZ));

            topToBottom.AddChild(CreateField("Min feedrate [mm/s]:".Localize(), ref minFeedrate));
            topToBottom.AddChild(CreateField("Min travel feedrate [mm/s]:".Localize(), ref minTravelFeedrate));
            topToBottom.AddChild(CreateField("Minimum segment time [ms]:".Localize(), ref minSegmentTime));
            topToBottom.AddChild(CreateField("Maximum X-Y jerk [mm/s]:".Localize(), ref maxXYJerk));
            topToBottom.AddChild(CreateField("Maximum Z jerk [mm/s]:".Localize(), ref maxZJerk));

            GuiWidget topBottomSpacer = new GuiWidget(1, 1);

            topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
            topToBottom.AddChild(topBottomSpacer);

            mainContainer.AddChild(topToBottom);

            // the bottom button bar
            {
                FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
                bottomButtonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
                bottomButtonBar.Margin          = new BorderDouble(0, 3);

                Button buttonSave = textImageButtonFactory.Generate("Save to EEProm".Localize());
                bottomButtonBar.AddChild(buttonSave);
                buttonSave.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        SaveSettingsToActive();
                        currentEePromSettings.SaveToEeProm();
                        Close();
                    });
                };

                CreateSpacer(bottomButtonBar);

                // put in the import button
#if true
                {
                    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);
                                    SetUiToPrinterSettings(null, null);
                                }
                            });
                        });
                    };
                    bottomButtonBar.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(() =>
                        {
                            string defaultFileNameNoPath = "eeprom_settings.ini";
                            FileDialog.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);
                                }
                            });
                        });
                    };
                    bottomButtonBar.AddChild(buttonExport);
                }
#endif

                Button buttonAbort = textImageButtonFactory.Generate("Close".Localize());
                bottomButtonBar.AddChild(buttonAbort);
                buttonAbort.Click += buttonAbort_Click;

                mainContainer.AddChild(bottomButtonBar);
            }

            PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

#if __ANDROID__
            TerminalWidget terminalWidget = new TerminalWidget(true);
            this.AddChild(new SoftKeyboardContentOffset(mainContainer));
            //mainContainer.Closed += (sender, e) => { Close(); };
#else
            AddChild(mainContainer);
#endif

            ShowAsSystemWindow();

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
        public EePromMarlinWidget()
            : base(700, 480)
        {
            Title = LocalizedString.Get("Marlin Firmware EEPROM Settings");

            currentEePromSettings = new EePromMarlinSettings();
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

			FlowLayoutWidget mainContainer = new FlowLayoutWidget (FlowDirection.TopToBottom);
			mainContainer.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
			mainContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
			mainContainer.Padding = new BorderDouble (3, 0);

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            topToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			topToBottom.Padding = new BorderDouble (top: 3);

            // the top button bar
            {
                FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
                topButtonBar.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                CreateMainButton(ref buttonReLoadSettings, topButtonBar, "Re-Load Default Settings");
                buttonReLoadSettings.Click += buttonReLoadSettings_Click;

				topButtonBar.Margin = new BorderDouble (0, 3);
                
                CreateMainButton(ref buttonSetToFactorySettings, topButtonBar, "Set Default To Factory Settings");
                buttonSetToFactorySettings.Click += SetToFactorySettings;

				mainContainer.AddChild(topButtonBar);
            }

            topToBottom.AddChild(Create4FieldSet("Steps per mm:",
                "X:", ref stepsPerMmX,
                "Y:", ref stepsPerMmY,
                "Z:", ref stepsPerMmZ,
                "E:", ref stepsPerMmE));

            topToBottom.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:",
                "X:", ref maxFeedrateMmPerSX,
                "Y:", ref maxFeedrateMmPerSY,
                "Z:", ref maxFeedrateMmPerSZ,
                "E:", ref maxFeedrateMmPerSE));

            topToBottom.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:",
                "X:", ref maxAccelerationMmPerSSqrdX,
                "Y:", ref maxAccelerationMmPerSSqrdY,
                "Z:", ref maxAccelerationMmPerSSqrdZ,
                "E:", ref maxAccelerationMmPerSSqrdE));

            topToBottom.AddChild(CreateField("Acceleration:", ref acceleration));
            topToBottom.AddChild(CreateField("Retract Acceleration:", ref retractAcceleration));

            topToBottom.AddChild(Create3FieldSet("PID settings:",
                "P:", ref pidP,
                "I:", ref pidI,
                "D:", ref pidD));

            topToBottom.AddChild(Create3FieldSet("Homing Offset:",
                "X:", ref homingOffsetX,
                "Y:", ref homingOffsetY,
                "Z:", ref homingOffsetZ));

            topToBottom.AddChild(CreateField("Min feedrate [mm/s]:", ref minFeedrate));
            topToBottom.AddChild(CreateField("Min travel feedrate [mm/s]:", ref minTravelFeedrate));
            topToBottom.AddChild(CreateField("Minimum segment time [ms]:", ref minSegmentTime));
            topToBottom.AddChild(CreateField("Maximum X-Y jerk [mm/s]:", ref maxXYJerk));
            topToBottom.AddChild(CreateField("Maximum Z jerk [mm/s]:", ref maxZJerk));

            GuiWidget topBottomSpacer = new GuiWidget(1, 1);
            topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
            topToBottom.AddChild(topBottomSpacer);

			mainContainer.AddChild (topToBottom);

            // the bottom button bar
            {
                FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
                bottomButtonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				bottomButtonBar.Margin = new BorderDouble (0, 3);

                CreateMainButton(ref buttonSetActive, bottomButtonBar, "Make Settings Active");
                buttonSetActive.Click += buttonSetActive_Click;

                CreateMainButton(ref buttonSave, bottomButtonBar, "Make Settings Active\nAnd Save To Default");
                buttonSave.Click += buttonSave_Click;

                CreateSpacer(bottomButtonBar);

                CreateMainButton(ref buttonAbort, bottomButtonBar, "Close");
                buttonAbort.Click += buttonAbort_Click;

				mainContainer.AddChild(bottomButtonBar);
            }

            PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

			AddChild(mainContainer);

            ShowAsSystemWindow();

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
		public EePromMarlinWindow()
			: base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
		{
			AlwaysOnTopOfMain = true;
			Title = "Marlin Firmware EEPROM Settings".Localize();

			currentEePromSettings = new EePromMarlinSettings();
			currentEePromSettings.eventAdded += SetUiToPrinterSettings;

			GuiWidget mainContainer = new GuiWidget();
			mainContainer.AnchorAll();
			mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
			mainContainer.Padding = new BorderDouble(3, 0);

			// space filling color
			GuiWidget spaceFiller = new GuiWidget(0, 500);
			spaceFiller.VAnchor = VAnchor.ParentBottom;
			spaceFiller.HAnchor = HAnchor.ParentLeftRight;
			spaceFiller.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			spaceFiller.Padding = new BorderDouble(top: 3);
			mainContainer.AddChild(spaceFiller);

			double topBarHeight = 0;
			// the top button bar
			{
				FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
				topButtonBar.HAnchor = HAnchor.ParentLeftRight;
				topButtonBar.VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop;
				topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

				topButtonBar.Margin = new BorderDouble(0, 3);

				Button buttonSetToFactorySettings = textImageButtonFactory.Generate("Reset to Factory Defaults".Localize());
				topButtonBar.AddChild(buttonSetToFactorySettings);

				buttonSetToFactorySettings.Click += (sender, e) =>
				{
					currentEePromSettings.SetPrinterToFactorySettings();
					currentEePromSettings.Update();
				};

				mainContainer.AddChild(topButtonBar);

				topBarHeight = topButtonBar.Height;
			}

			// the center content
			FlowLayoutWidget conterContent = new FlowLayoutWidget(FlowDirection.TopToBottom);
			conterContent.VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop;
			conterContent.HAnchor = HAnchor.ParentLeftRight;
			conterContent.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			conterContent.Padding = new BorderDouble(top: 3);
			conterContent.Margin = new BorderDouble(top: topBarHeight);

			conterContent.AddChild(Create4FieldSet("Steps per mm:".Localize(),
				"X:", ref stepsPerMmX,
				"Y:", ref stepsPerMmY,
				"Z:", ref stepsPerMmZ,
				"E:", ref stepsPerMmE));

			conterContent.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:".Localize(),
				"X:", ref maxFeedrateMmPerSX,
				"Y:", ref maxFeedrateMmPerSY,
				"Z:", ref maxFeedrateMmPerSZ,
				"E:", ref maxFeedrateMmPerSE));

			conterContent.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:".Localize(),
				"X:", ref maxAccelerationMmPerSSqrdX,
				"Y:", ref maxAccelerationMmPerSSqrdY,
				"Z:", ref maxAccelerationMmPerSSqrdZ,
				"E:", ref maxAccelerationMmPerSSqrdE));

			conterContent.AddChild(CreateField("Acceleration:".Localize(), ref acceleration));
			conterContent.AddChild(CreateField("Retract Acceleration:".Localize(), ref retractAcceleration));

			conterContent.AddChild(Create3FieldSet("PID settings:".Localize(),
				"P:", ref pidP,
				"I:", ref pidI,
				"D:", ref pidD));

			conterContent.AddChild(Create3FieldSet("Homing Offset:".Localize(),
				"X:", ref homingOffsetX,
				"Y:", ref homingOffsetY,
				"Z:", ref homingOffsetZ));

			conterContent.AddChild(CreateField("Min feedrate [mm/s]:".Localize(), ref minFeedrate));
			conterContent.AddChild(CreateField("Min travel feedrate [mm/s]:".Localize(), ref minTravelFeedrate));
			conterContent.AddChild(CreateField("Minimum segment time [ms]:".Localize(), ref minSegmentTime));
			conterContent.AddChild(CreateField("Maximum X-Y jerk [mm/s]:".Localize(), ref maxXYJerk));
			conterContent.AddChild(CreateField("Maximum Z jerk [mm/s]:".Localize(), ref maxZJerk));

			GuiWidget topBottomSpacer = new GuiWidget(1, 1);
			topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
			conterContent.AddChild(topBottomSpacer);

			mainContainer.AddChild(conterContent);

			// the bottom button bar
			{
				FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
				bottomButtonBar.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
				bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				bottomButtonBar.Margin = new BorderDouble(0, 3);

				Button buttonSave = textImageButtonFactory.Generate("Save to EEProm".Localize());
				bottomButtonBar.AddChild(buttonSave);
				buttonSave.Click += (sender, e) =>
				{
					UiThread.RunOnIdle(() =>
					{
						SaveSettingsToActive();
						currentEePromSettings.SaveToEeProm();
						Close();
					});
				};

				CreateSpacer(bottomButtonBar);

				// put in the import button
#if true
				{
					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);
											SetUiToPrinterSettings(null, null);
                                        }
									});
						});
					};
					bottomButtonBar.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(() =>
						{
							string defaultFileNameNoPath = "eeprom_settings.ini";
                            FileDialog.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);
										}
									});
						});
					};
					bottomButtonBar.AddChild(buttonExport);
				}
#endif

				Button buttonAbort = textImageButtonFactory.Generate("Close".Localize());
				bottomButtonBar.AddChild(buttonAbort);
				buttonAbort.Click += buttonAbort_Click;

				mainContainer.AddChild(bottomButtonBar);
			}

			PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

#if __ANDROID__
			this.AddChild(new SoftKeyboardContentOffset(mainContainer));
#else
			AddChild(mainContainer);
#endif

			ShowAsSystemWindow();

			// and ask the printer to send the settings
			currentEePromSettings.Update();

			foreach (GuiWidget widget in leftStuffToSize)
			{
				widget.Width = maxWidthOfLeftStuff;
			}
		}