public ManualPrinterControls(PrinterConfig printer, ThemeConfig theme)
        {
            this.theme               = theme;
            this.printer             = printer;
            this.ScrollArea.HAnchor |= HAnchor.Stretch;
            this.AnchorAll();
            this.AutoScroll = true;
            this.HAnchor    = HAnchor.Stretch;
            this.VAnchor    = VAnchor.Stretch;
            this.Name       = "ManualPrinterControls";

            int headingPointSize = theme.H1PointSize;

            column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.MaxFitOrStretch,
                VAnchor = VAnchor.Fit,
                Name    = "ManualPrinterControls.ControlsContainer",
                Margin  = new BorderDouble(0)
            };
            this.AddChild(column);

            movementControlsContainer = this.AddPluginWidget(MovementControls.CreateSection(printer, theme)) as MovementControls;

            if (!printer.Settings.GetValue <bool>(SettingsKey.has_hardware_leveling))
            {
                calibrationControlsContainer = this.AddPluginWidget(CalibrationControls.CreateSection(printer, theme));
            }

            if (!printer.Settings.GetValue <bool>(SettingsKey.sla_printer))
            {
                temperatureControlsContainer = this.AddPluginWidget(TemperatureControls.CreateSection(printer, theme));
            }

            macroControlsContainer = this.AddPluginWidget(MacroControls.CreateSection(printer, theme));

            if (printer.Settings.GetValue <bool>(SettingsKey.has_fan))
            {
                fanControlsContainer = this.AddPluginWidget(FanControls.CreateSection(printer, theme));
            }

#if !__ANDROID__
            this.AddPluginWidget(PowerControls.CreateSection(printer, theme));
#endif

            tuningAdjustmentControlsContainer = this.AddPluginWidget(AdjustmentControls.CreateSection(printer, theme));

            // HACK: this is a hack to make the layout engine fire again for this control
            UiThread.RunOnIdle(() => tuningAdjustmentControlsContainer.Width = tuningAdjustmentControlsContainer.Width + 1);

            // Register listeners
            printer.Connection.CommunicationStateChanged    += Printer_StatusChanged;
            printer.Connection.DetailedPrintingStateChanged += Printer_StatusChanged;

            SetVisibleControls();
        }
 private void AddTemperatureControls(FlowLayoutWidget controlsTopToBottomLayout)
 {
     temperatureControlsContainer = new TemperatureControls();
     controlsTopToBottomLayout.AddChild(temperatureControlsContainer);
 }
        public ManualPrinterControlsTouchScreen()
            : base(Orientation.Vertical)
        {
            RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

            this.TabBar.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay;
            this.TabBar.BorderColor     = new RGBA_Bytes(0, 0, 0, 0);
            this.TabBar.Margin          = new BorderDouble(0);
            this.TabBar.Padding         = new BorderDouble(4, 4);

            this.AnchorAll();
            this.VAnchor |= VAnchor.FitToChildren;

            this.Margin      = new BorderDouble(0);
            this.TabTextSize = 13;

            // add action tab
            {
                GuiWidget actionContainerContainer = new GuiWidget();
                actionContainerContainer.Padding = new BorderDouble(6);
                actionContainerContainer.AnchorAll();

                actionControlsContainer         = new ActionControls();
                actionControlsContainer.VAnchor = VAnchor.ParentTop;
                if (ActiveSliceSettings.Instance.ActionMacros().Any())
                {
                    actionContainerContainer.AddChild(actionControlsContainer);
                }

                if (ActiveSliceSettings.Instance.ActionMacros().Any())
                {
                    TabPage actionTabPage = new TabPage(actionContainerContainer, "Actions".Localize().ToUpper());
                    this.AddTab(new SimpleTextTabWidget(actionTabPage, "Actions Tab", TabTextSize,
                                                        ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
                }
            }

            // add temperature tab
            {
                GuiWidget temperatureContainerContainer = new GuiWidget();
                temperatureContainerContainer.Padding = new BorderDouble(6);
                temperatureContainerContainer.AnchorAll();

                temperatureControlsContainer          = new TemperatureControls();
                temperatureControlsContainer.VAnchor |= VAnchor.ParentTop;

                temperatureContainerContainer.AddChild(temperatureControlsContainer);

                TabPage temperatureTabPage = new TabPage(temperatureContainerContainer, "Temperature".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(temperatureTabPage, "Temperature Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add movement tab
            {
                GuiWidget movementContainerContainer = new GuiWidget();
                movementContainerContainer.Padding = new BorderDouble(6);
                movementContainerContainer.AnchorAll();

                movementControlsContainer         = new MovementControls();
                movementControlsContainer.VAnchor = VAnchor.ParentTop;

                movementContainerContainer.AddChild(movementControlsContainer);

                TabPage movementTabPage = new TabPage(movementContainerContainer, "Movement".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(movementTabPage, "Movement Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add macro tab
            {
                GuiWidget macrosContainerContainer = new GuiWidget();
                macrosContainerContainer.Padding = new BorderDouble(6);
                macrosContainerContainer.AnchorAll();

                macroControlsContainer          = new MacroControls();
                macroControlsContainer.VAnchor |= VAnchor.ParentTop;
                macrosContainerContainer.AddChild(macroControlsContainer);


                TabPage macrosTabPage = new TabPage(macrosContainerContainer, "Macros".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(macrosTabPage, "Macros Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            if (ActiveSliceSettings.Instance.GetValue <bool>("has_fan"))
            {
                // add fan tab
                GuiWidget fanContainerContainer = new GuiWidget();
                fanContainerContainer.Padding = new BorderDouble(6);
                fanContainerContainer.AnchorAll();

                fanControlsContainer         = new FanControls();
                fanControlsContainer.VAnchor = VAnchor.ParentTop;

                fanContainerContainer.AddChild(fanControlsContainer);

                TabPage fanTabPage = new TabPage(fanContainerContainer, "Fan Controls".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(fanTabPage, "Fan Controls Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add tunning tab
            {
                GuiWidget tuningContainerContainer = new GuiWidget();
                tuningContainerContainer.Padding = new BorderDouble(6);
                tuningContainerContainer.AnchorAll();

                tuningAdjustmentControlsContainer         = new AdjustmentControls();
                tuningAdjustmentControlsContainer.VAnchor = VAnchor.ParentTop;

                tuningContainerContainer.AddChild(tuningAdjustmentControlsContainer);

                TabPage tuningTabPage = new TabPage(tuningContainerContainer, "Tuning Adjust".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(tuningTabPage, "Tuning Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            // add terminal tab
            {
                GuiWidget terminalContainerContainer = new GuiWidget();
                terminalContainerContainer.Padding = new BorderDouble(6);
                terminalContainerContainer.AnchorAll();

                terminalControlsContainer          = new TerminalControls();
                terminalControlsContainer.VAnchor |= VAnchor.ParentBottomTop;

                terminalContainerContainer.AddChild(terminalControlsContainer);

                TabPage terminalTabPage = new TabPage(terminalContainerContainer, "Terminal".Localize().ToUpper());
                this.AddTab(new SimpleTextTabWidget(terminalTabPage, "Terminal Tab", TabTextSize,
                                                    ActiveTheme.Instance.SecondaryAccentColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
            }

            PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
            PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

            SetVisibleControls();
        }