private void AddAdjustmentControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
			GroupBox adjustmentControlsGroupBox = new GroupBox(new LocalizedString("Tuning Adjustment (while printing)").Translated);
            adjustmentControlsGroupBox.Margin = new BorderDouble(0);
            adjustmentControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            adjustmentControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            adjustmentControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            adjustmentControlsGroupBox.Height = 93;

            {
                FlowLayoutWidget tuningRatiosLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                tuningRatiosLayout.Margin = new BorderDouble(0, 0, 0, 6);
                tuningRatiosLayout.AnchorAll();
                tuningRatiosLayout.Padding = new BorderDouble(3, 5, 3, 0);
                TextWidget feedRateDescription;
                {
                    FlowLayoutWidget feedRateLeftToRight;
                    {
                        feedRateValue = new NumberEdit(1, allowDecimals: true, minValue: minFeedRateRatio, maxValue: maxFeedRateRatio, pixelWidth: 40);

                        feedRateLeftToRight = new FlowLayoutWidget();

						feedRateDescription = new TextWidget(new LocalizedString("Speed Multiplier").Translated);
                        feedRateDescription.TextColor = RGBA_Bytes.White;
                        feedRateLeftToRight.AddChild(feedRateDescription);
                        feedRateRatioSlider = new Slider(new Vector2(), 300, minFeedRateRatio, maxFeedRateRatio);
                        feedRateRatioSlider.Margin = new BorderDouble(5, 0);
                        feedRateRatioSlider.Value = PrinterCommunication.Instance.FeedRateRatio;
                        feedRateRatioSlider.View.BackgroundColor = new RGBA_Bytes();
                        feedRateRatioSlider.ValueChanged += (sender, e) =>
                        {
                            PrinterCommunication.Instance.FeedRateRatio = feedRateRatioSlider.Value;
                        };
                        PrinterCommunication.Instance.FeedRateRatioChanged.RegisterEvent(FeedRateRatioChanged_Event, ref unregisterEvents);
                        feedRateValue.EditComplete += (sender, e) =>
                        {
                            feedRateRatioSlider.Value = feedRateValue.Value;
                        };
                        feedRateLeftToRight.AddChild(feedRateRatioSlider);
                        tuningRatiosLayout.AddChild(feedRateLeftToRight);

                        feedRateLeftToRight.AddChild(feedRateValue);
                        feedRateValue.Margin = new BorderDouble(0, 0, 5, 0);
                        textImageButtonFactory.FixedHeight = (int)feedRateValue.Height + 1;
						feedRateLeftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated));
                    }

                    TextWidget extrusionDescription;
                    {
                        extrusionValue = new NumberEdit(1, allowDecimals: true, minValue: minExtrutionRatio, maxValue: maxExtrusionRatio, pixelWidth: 40);

                        FlowLayoutWidget leftToRight = new FlowLayoutWidget();

						extrusionDescription = new TextWidget(new LocalizedString("Extrusion Multiplier").Translated);
                        extrusionDescription.TextColor = RGBA_Bytes.White;
                        leftToRight.AddChild(extrusionDescription);
                        extrusionRatioSlider = new Slider(new Vector2(), 300, minExtrutionRatio, maxExtrusionRatio);
                        extrusionRatioSlider.Margin = new BorderDouble(5, 0);
                        extrusionRatioSlider.Value = PrinterCommunication.Instance.ExtrusionRatio;
                        extrusionRatioSlider.View.BackgroundColor = new RGBA_Bytes();
                        extrusionRatioSlider.ValueChanged += (sender, e) =>
                        {
                            PrinterCommunication.Instance.ExtrusionRatio = extrusionRatioSlider.Value;
                        };
                        PrinterCommunication.Instance.ExtrusionRatioChanged.RegisterEvent(ExtrusionRatioChanged_Event, ref unregisterEvents);
                        extrusionValue.EditComplete += (sender, e) =>
                        {
                            extrusionRatioSlider.Value = extrusionValue.Value;
                        };
                        leftToRight.AddChild(extrusionRatioSlider);
                        tuningRatiosLayout.AddChild(leftToRight);
                        leftToRight.AddChild(extrusionValue);
                        extrusionValue.Margin = new BorderDouble(0, 0, 5, 0);
                        textImageButtonFactory.FixedHeight = (int)extrusionValue.Height + 1;
						leftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated));
                    }

                    feedRateDescription.Width = extrusionDescription.Width;
                    feedRateDescription.MinimumSize = new Vector2(extrusionDescription.Width, feedRateDescription.MinimumSize.y);
                    feedRateLeftToRight.HAnchor = HAnchor.FitToChildren;
                    feedRateLeftToRight.VAnchor = VAnchor.FitToChildren;
                }

                adjustmentControlsGroupBox.AddChild(tuningRatiosLayout);
            }

            tuningAdjustmentControlsContainer = new DisableableWidget();
            tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox);
            controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer);
        }
        private void AddTemperatureControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            FlowLayoutWidget temperatureControlContainer = new FlowLayoutWidget();
            temperatureControlContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
			temperatureControlContainer.Margin = new BorderDouble (top: 10);

            extruderTemperatureControlWidget = new DisableableWidget();
            extruderTemperatureControlWidget.AddChild(new ExtruderTemperatureControlWidget());
            temperatureControlContainer.AddChild(extruderTemperatureControlWidget);

            bedTemperatureControlWidget = new DisableableWidget();
            bedTemperatureControlWidget.AddChild(new BedTemperatureControlWidget());

            if (ActivePrinterProfile.Instance.ActivePrinter == null
                || ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasHeatedBed())
            {
                temperatureControlContainer.AddChild(bedTemperatureControlWidget);
            }

            controlsTopToBottomLayout.AddChild(temperatureControlContainer);
        }
        private void AddMovementControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            Button editButton;
			GroupBox movementControlsGroupBox = new GroupBox(textImageButtonFactory.GenerateGroupBoxLableWithEdit(new LocalizedString("Movement Controls").Translated, out editButton));
            editButton.Click += (sender, e) =>
            {
                if (editSettingsWindow == null)
                {
                    editSettingsWindow = new EditManualMovementSpeedsWindow("Movement Speeds", GetMovementSpeedsString(), SetMovementSpeeds);
                    editSettingsWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editSettingsWindow = null; };
                }
                else
                {
                    editSettingsWindow.BringToFront();
                }
            };

            movementControlsGroupBox.Margin = new BorderDouble(0);
            movementControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            movementControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            movementControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            movementControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;

            {
                FlowLayoutWidget manualControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                manualControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                manualControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
                manualControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
                {
                    manualControlsLayout.AddChild(GetHomeButtonBar());
                    manualControlsLayout.AddChild(CreateSeparatorLine());
                    manualControlsLayout.AddChild(new JogControls(new XYZColors()));
                    manualControlsLayout.AddChild(CreateSeparatorLine());
                    //manualControlsLayout.AddChild(GetManualMoveBar());
                }

                movementControlsGroupBox.AddChild(manualControlsLayout);
            }

            movementControlsContainer = new DisableableWidget();
            movementControlsContainer.AddChild(movementControlsGroupBox);
            controlsTopToBottomLayout.AddChild(movementControlsContainer);
        }
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox eePromControlsGroupBox = new GroupBox(new LocalizedString("EEProm Settings").Translated);

			eePromControlsGroupBox.Margin = new BorderDouble(0);
            eePromControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
			eePromControlsGroupBox.Height = 68;

            {
				FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
				eePromControlsLayout.HAnchor |= HAnchor.ParentLeftRight;
				eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
				eePromControlsLayout.Margin = new BorderDouble(3, 0, 3, 6);
				eePromControlsLayout.Padding = new BorderDouble(0);
                {
					Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
					ImageBMPIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
					ImageWidget eePromIcon = new ImageWidget(eePromImage);
					eePromIcon.Margin = new BorderDouble (right: 6);

					Button openEePromWindow = textImageButtonFactory.Generate(new LocalizedString("CONFIGURE").Translated);
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
						switch(PrinterCommunication.Instance.FirmwareType)
                        {
                            case PrinterCommunication.FirmwareTypes.Repetier:
                                new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
                            break;

                            case PrinterCommunication.FirmwareTypes.Marlin:
                                new MatterHackers.MatterControl.EeProm.EePromMarlinWidget();
                            break;

                            default:
                                UiThread.RunOnIdle((state) => 
                                {
									string message = new LocalizedString("Oops! There is no eeprom mapping for your printer's firmware.").Translated;
                                    StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK);
                                }
                                );
                            break;
                        }
#endif
                    };
					//eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
        private void AddFanControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
			GroupBox fanControlsGroupBox = new GroupBox(new LocalizedString("Fan Controls").Translated);

            fanControlsGroupBox.Margin = new BorderDouble(0);
            fanControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            fanControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            fanControlsGroupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;

            {
                FlowLayoutWidget fanControlsLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                fanControlsLayout.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                fanControlsLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
                fanControlsLayout.Padding = new BorderDouble(3, 5, 3, 0);
                {
                    fanControlsLayout.AddChild(CreateFanControls());
                }

                fanControlsGroupBox.AddChild(fanControlsLayout);
            }

            fanControlsContainer = new DisableableWidget();
            fanControlsContainer.AddChild(fanControlsGroupBox);

            if (ActivePrinterProfile.Instance.ActivePrinter == null
                || ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasFan())
            {
                controlsTopToBottomLayout.AddChild(fanControlsContainer);
            }
        }
        public ManualPrinterControls()
        {
            SetDisplayAttributes();

            HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            VAnchor = Agg.UI.VAnchor.FitToChildren;

            FlowLayoutWidget controlsTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
            controlsTopToBottomLayout.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            controlsTopToBottomLayout.VAnchor = Agg.UI.VAnchor.FitToChildren;
            controlsTopToBottomLayout.Name = "ManualPrinterControls.ControlsContainer";

            controlsTopToBottomLayout.Padding = new BorderDouble(3, 0);

            AddTemperatureControls(controlsTopToBottomLayout);

            FlowLayoutWidget centerControlsContainer = new FlowLayoutWidget();
            centerControlsContainer.HAnchor = HAnchor.ParentLeftRight;

            AddMovementControls(centerControlsContainer);

            // put in the terminal communications
            {
                terminalCommunicationsContainer = new DisableableWidget();
                terminalCommunicationsContainer.AddChild(CreateTerminalControlsContainer());

                FlowLayoutWidget rightColumnContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                rightColumnContainer.AddChild(terminalCommunicationsContainer);
                rightColumnContainer.Width = 180;
                rightColumnContainer.VAnchor |= VAnchor.ParentTop;

                AddFanControls(rightColumnContainer);
                AddEePromControls(rightColumnContainer);

                centerControlsContainer.AddChild(rightColumnContainer);
            }

            controlsTopToBottomLayout.AddChild(centerControlsContainer);

            sdCardManagerContainer = new DisableableWidget();
            sdCardManagerContainer.AddChild(CreateSdCardManagerContainer());
            if (false)// || ActivePrinterProfile.Instance.ActivePrinter == null || ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasSdCard())
            {
                controlsTopToBottomLayout.AddChild(sdCardManagerContainer);
            }

            macroControls = new DisableableWidget();
            macroControls.AddChild(new MacroControls());
            controlsTopToBottomLayout.AddChild(macroControls);

            AddAdjustmentControls(controlsTopToBottomLayout);

            printLevelContainer = new DisableableWidget();
            printLevelContainer.AddChild(CreatePrintLevelingControlsContainer());
            controlsTopToBottomLayout.AddChild(printLevelContainer);

            this.AddChild(controlsTopToBottomLayout);
            AddHandlers();
            SetVisibleControls();
        }