Exemple #1
0
        private FlowLayoutWidget createMacroNameContainer()
        {
            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);

            container.Margin = new BorderDouble(0, 5);
            BorderDouble elementMargin = new BorderDouble(top: 3);

            string     macroNameLabelTxt     = LocalizedString.Get("Macro Name");
            string     macroNameLabelTxtFull = string.Format("{0}:", macroNameLabelTxt);
            TextWidget macroNameLabel        = new TextWidget(macroNameLabelTxtFull, 0, 0, 12);

            macroNameLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            macroNameLabel.HAnchor   = HAnchor.ParentLeftRight;
            macroNameLabel.Margin    = new BorderDouble(0, 0, 0, 1);

            macroNameInput         = new MHTextEditWidget(MacroControls.FixMacroName(windowController.ActiveMacro.Name));
            macroNameInput.HAnchor = HAnchor.ParentLeftRight;

            string giveMacroANameLabel     = LocalizedString.Get("Give the macro a name");
            string giveMacroANameLabelFull = string.Format("{0}.", giveMacroANameLabel);

            macroNameError           = new TextWidget(giveMacroANameLabelFull, 0, 0, 10);
            macroNameError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            macroNameError.HAnchor   = HAnchor.ParentLeftRight;
            macroNameError.Margin    = elementMargin;

            container.AddChild(macroNameLabel);
            container.AddChild(macroNameInput);
            container.AddChild(macroNameError);
            container.HAnchor = HAnchor.ParentLeftRight;
            return(container);
        }
        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();
        }
Exemple #3
0
        public MacroListWidget(EditMacrosWindow windowController)
        {
            this.windowController = windowController;

            linkButtonFactory.fontSize = 10;
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.HAnchor = HAnchor.ParentLeftRight;
            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);

            {
                string     macroPresetsLabel     = LocalizedString.Get("Macro Presets");
                string     macroPresetsLabelFull = string.Format("{0}:", macroPresetsLabel);
                TextWidget elementHeader         = new TextWidget(macroPresetsLabelFull, pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;
                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

            FlowLayoutWidget presetsFormContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                presetsFormContainer.HAnchor         = HAnchor.ParentLeftRight;
                presetsFormContainer.VAnchor         = VAnchor.ParentBottomTop;
                presetsFormContainer.Padding         = new BorderDouble(3);
                presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            topToBottom.AddChild(presetsFormContainer);

            if (ActiveSliceSettings.Instance?.Macros != null)
            {
                foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
                {
                    FlowLayoutWidget macroRow = new FlowLayoutWidget();
                    macroRow.Margin          = new BorderDouble(3, 0, 3, 3);
                    macroRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                    macroRow.Padding         = new BorderDouble(3);
                    macroRow.BackgroundColor = RGBA_Bytes.White;

                    TextWidget buttonLabel = new TextWidget(MacroControls.FixMacroName(macro.Name));
                    macroRow.AddChild(buttonLabel);

                    macroRow.AddChild(new HorizontalSpacer());

                    // You can't pass a foreach variable into a link function or it wall always be the last item.
                    // So we make a local variable copy of it and pass that. This will get the right one.
                    var localMacroReference = macro;

                    Button editLink = linkButtonFactory.Generate("edit".Localize());
                    editLink.Margin = new BorderDouble(right: 5);
                    editLink.Click += (sender, e) =>
                    {
                        windowController.ChangeToMacroDetail(localMacroReference);
                    };
                    macroRow.AddChild(editLink);

                    Button removeLink = linkButtonFactory.Generate("remove".Localize());
                    removeLink.Click += (sender, e) =>
                    {
                        ActiveSliceSettings.Instance.Macros.Remove(localMacroReference);
                        windowController.FunctionToCallOnSave(this, null);
                        windowController.ChangeToMacroList();
                    };
                    macroRow.AddChild(removeLink);

                    presetsFormContainer.AddChild(macroRow);
                }
            }

            Button addMacroButton = textImageButtonFactory.Generate("Add".Localize(), "icon_circle_plus.png");

            addMacroButton.ToolTipText = "Add a new Macro".Localize();
            addMacroButton.Click      += (s, e) =>
            {
                windowController.ChangeToMacroDetail(new GCodeMacro()
                {
                    Name  = "Home All",
                    GCode = "G28 ; Home All Axes"
                });
            };

            Button cancelPresetsButton = textImageButtonFactory.Generate("Close".Localize());

            cancelPresetsButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(() => this.windowController.Close());
            };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

            buttonRow.HAnchor = HAnchor.ParentLeftRight;
            buttonRow.Padding = new BorderDouble(0, 3);

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

            buttonRow.AddChild(addMacroButton);
            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);
            AddChild(topToBottom);
            this.AnchorAll();
        }