Ejemplo n.º 1
0
        private FlowLayoutWidget CreateZButtons()
        {
            FlowLayoutWidget zButtons = JogControls.CreateZButtons(RGBA_Bytes.White, 4, out zPlusControl, out zMinusControl);

            // set these to 0 so the button does not do any movements by default (we will handle the movement on our click callback)
            zPlusControl.MoveAmount  = 0;
            zMinusControl.MoveAmount = 0;
            zPlusControl.Click      += new ButtonBase.ButtonEventHandler(zPlusControl_Click);
            zMinusControl.Click     += new ButtonBase.ButtonEventHandler(zMinusControl_Click);
            return(zButtons);
        }
Ejemplo n.º 2
0
        public JogControls(PrinterConfig printer, XYZColors colors, ThemeConfig theme)
        {
            this.theme   = theme;
            this.printer = printer;

            double distanceBetweenControls  = 12;
            double buttonSeparationDistance = 10;

            var allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch
            };

            var allControlsLeftToRight = new FlowLayoutWidget();

            using (allControlsLeftToRight.LayoutLock())
            {
                var xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom);
                {
                    var xYZControls = new FlowLayoutWidget();
                    xYZControls.AddChild(this.CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance));

                    FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, buttonSeparationDistance, out zPlusControl, out zMinusControl, colors, theme);
                    zButtons.VAnchor = VAnchor.Bottom;
                    xYZControls.AddChild(zButtons);
                    xYZWithDistance.AddChild(xYZControls);

                    // add in some movement radio buttons
                    var setMoveDistanceControl = new FlowLayoutWidget
                    {
                        HAnchor = HAnchor.Left | HAnchor.Fit,
                        VAnchor = VAnchor.Fit
                    };

                    {
                        var moveRadioButtons = new FlowLayoutWidget();
                        var radioList        = new List <GuiWidget>();

                        movePointZeroTwoMmButton = theme.CreateMicroRadioButton("0.02", radioList);
                        movePointZeroTwoMmButton.CheckedStateChanged += (s, e) =>
                        {
                            if (movePointZeroTwoMmButton.Checked)
                            {
                                SetXYZMoveAmount(.02);
                            }
                        };
                        moveRadioButtons.AddChild(movePointZeroTwoMmButton);

                        var pointOneButton = theme.CreateMicroRadioButton("0.1", radioList);
                        pointOneButton.CheckedStateChanged += (s, e) =>
                        {
                            if (pointOneButton.Checked)
                            {
                                SetXYZMoveAmount(.1);
                            }
                        };
                        moveRadioButtons.AddChild(pointOneButton);

                        moveOneMmButton = theme.CreateMicroRadioButton("1", radioList);
                        moveOneMmButton.CheckedStateChanged += (s, e) =>
                        {
                            if (moveOneMmButton.Checked)
                            {
                                SetXYZMoveAmount(1);
                            }
                        };
                        moveRadioButtons.AddChild(moveOneMmButton);

                        tenButton = theme.CreateMicroRadioButton("10", radioList);
                        tenButton.CheckedStateChanged += (s, e) =>
                        {
                            if (tenButton.Checked)
                            {
                                SetXYZMoveAmount(10);
                            }
                        };
                        moveRadioButtons.AddChild(tenButton);

                        oneHundredButton = theme.CreateMicroRadioButton("100", radioList);
                        oneHundredButton.CheckedStateChanged += (s, e) =>
                        {
                            if (oneHundredButton.Checked)
                            {
                                SetXYZMoveAmount(100);
                            }
                        };
                        moveRadioButtons.AddChild(oneHundredButton);

                        tenButton.Checked = true;
                        SetXYZMoveAmount(10);
                        moveRadioButtons.Margin = new BorderDouble(0, 3);
                        setMoveDistanceControl.AddChild(moveRadioButtons);

                        moveRadioButtons.AddChild(new TextWidget("mm", textColor: theme.TextColor, pointSize: 8)
                        {
                            Margin  = new BorderDouble(left: 10),
                            VAnchor = VAnchor.Center
                        });
                    }

                    xYZWithDistance.AddChild(setMoveDistanceControl);
                }

                allControlsLeftToRight.AddChild(xYZWithDistance);

#if !__ANDROID__
                allControlsLeftToRight.AddChild(GetHotkeyControlContainer());
#endif
                // Bar between Z And E
                allControlsLeftToRight.AddChild(new GuiWidget(1, 1)
                {
                    VAnchor         = VAnchor.Stretch,
                    BackgroundColor = colors.ZColor,
                    Margin          = new BorderDouble(distanceBetweenControls, 5)
                });

                // EButtons
                disableableEButtons         = CreateEButtons(buttonSeparationDistance, colors);
                disableableEButtons.Name    = "disableableEButtons";
                disableableEButtons.HAnchor = HAnchor.Fit;
                disableableEButtons.VAnchor = VAnchor.Fit | VAnchor.Top;

                allControlsLeftToRight.AddChild(disableableEButtons);
                allControlsTopToBottom.AddChild(allControlsLeftToRight);
            }
            allControlsLeftToRight.PerformLayout();

            using (this.LayoutLock())
            {
                this.AddChild(allControlsTopToBottom);
                this.HAnchor = HAnchor.Fit;
                this.VAnchor = VAnchor.Fit;
                Margin       = new BorderDouble(3);
            }

            this.PerformLayout();

            // Register listeners
            printer.Settings.SettingChanged += Printer_SettingChanged;
        }