Esempio n. 1
0
            void moveAxis_Click(object sender, EventArgs mouseEvent)
            {
                ExtrudeButton moveButton = (ExtrudeButton)sender;

                //Add more fancy movement here
                PrinterConnectionAndCommunication.Instance.MoveExtruderRelative(MoveAmount, movementFeedRate, ExtruderNumber);
            }
Esempio n. 2
0
            public ExtrudeButton Generate(string label, double movementFeedRate, int extruderNumber = 0)
            {
                //Create button based on view container widget
                ButtonViewStates buttonViewWidget = GetButtonView(label);
                ExtrudeButton    textImageButton  = new ExtrudeButton(0, 0, buttonViewWidget, movementFeedRate, extruderNumber);

                textImageButton.Margin  = new BorderDouble(0);
                textImageButton.Padding = new BorderDouble(0);
                return(textImageButton);
            }
Esempio n. 3
0
        private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance, XYZColors colors)
        {
            int extruderCount = printer.Settings.GetValue <int>(SettingsKey.extruder_count);

            FlowLayoutWidget eButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                FlowLayoutWidget eMinusButtonAndText = new FlowLayoutWidget();
                BorderDouble     extrusionMargin     = new BorderDouble(4, 0, 4, 0);

                if (extruderCount == 1)
                {
                    ExtrudeButton eMinusControl = theme.CreateExtrudeButton(printer, "E-", printer.Settings.EFeedRate(0), 0);
                    eMinusControl.MoveAmount  = -eMinusControl.MoveAmount;
                    eMinusControl.Margin      = extrusionMargin;
                    eMinusControl.ToolTipText = "Retract filament".Localize();
                    eMinusButtonAndText.AddChild(eMinusControl);
                    eMinusButtons.Add(eMinusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton eMinusControl = theme.CreateExtrudeButton(printer, $"E{i + 1}-", printer.Settings.EFeedRate(0), i);
                        eMinusControl.MoveAmount  = -eMinusControl.MoveAmount;
                        eMinusControl.ToolTipText = "Retract filament".Localize();
                        eMinusControl.Margin      = extrusionMargin;
                        eMinusButtonAndText.AddChild(eMinusControl);
                        eMinusButtons.Add(eMinusControl);
                    }
                }

                TextWidget eMinusControlLabel = new TextWidget("Retract".Localize(), pointSize: 11)
                {
                    TextColor = theme.TextColor,
                    VAnchor   = VAnchor.Center
                };
                eMinusButtonAndText.AddChild(eMinusControlLabel);
                eButtons.AddChild(eMinusButtonAndText);

                eMinusButtonAndText.HAnchor = HAnchor.Fit;
                eMinusButtonAndText.VAnchor = VAnchor.Fit;

                FlowLayoutWidget buttonSpacerContainer = new FlowLayoutWidget();
                for (int i = 0; i < extruderCount; i++)
                {
                    double buttonWidth = eMinusButtons[i].Width + 6;

                    var eSpacer = new GuiWidget(1, buttonSeparationDistance)
                    {
                        Margin          = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0),
                        BackgroundColor = colors.EColor
                    };
                    buttonSpacerContainer.AddChild(eSpacer);
                }

                eButtons.AddChild(buttonSpacerContainer);

                buttonSpacerContainer.HAnchor = HAnchor.Fit;
                buttonSpacerContainer.VAnchor = VAnchor.Fit;

                FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget();
                if (extruderCount == 1)
                {
                    ExtrudeButton ePlusControl = theme.CreateExtrudeButton(printer, "E+", printer.Settings.EFeedRate(0), 0);
                    ePlusControl.Margin      = extrusionMargin;
                    ePlusControl.ToolTipText = "Extrude filament".Localize();
                    ePlusButtonAndText.AddChild(ePlusControl);
                    ePlusButtons.Add(ePlusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton ePlusControl = theme.CreateExtrudeButton(printer, $"E{i + 1}+", printer.Settings.EFeedRate(0), i);
                        ePlusControl.Margin      = extrusionMargin;
                        ePlusControl.ToolTipText = "Extrude filament".Localize();
                        ePlusButtonAndText.AddChild(ePlusControl);
                        ePlusButtons.Add(ePlusControl);
                    }
                }

                TextWidget ePlusControlLabel = new TextWidget("Extrude".Localize(), pointSize: 11);
                ePlusControlLabel.TextColor = theme.TextColor;
                ePlusControlLabel.VAnchor   = VAnchor.Center;
                ePlusButtonAndText.AddChild(ePlusControlLabel);
                eButtons.AddChild(ePlusButtonAndText);
                ePlusButtonAndText.HAnchor = HAnchor.Fit;
                ePlusButtonAndText.VAnchor = VAnchor.Fit;
            }

            eButtons.AddChild(new GuiWidget(10, 6));

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

            {
                var moveRadioButtons = new FlowLayoutWidget
                {
                    Margin = new BorderDouble(0, 3)
                };

                var oneButton = theme.CreateMicroRadioButton("1");
                oneButton.CheckedStateChanged += (s, e) =>
                {
                    if (oneButton.Checked)
                    {
                        SetEMoveAmount(1);
                    }
                };
                moveRadioButtons.AddChild(oneButton);

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

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

                tenButton.Checked = true;
                setMoveDistanceControl.AddChild(moveRadioButtons);
            }

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

            eButtons.AddChild(setMoveDistanceControl);

            eButtons.HAnchor = HAnchor.Fit;
            eButtons.VAnchor = VAnchor.Fit | VAnchor.Bottom;

            return(eButtons);
        }
Esempio n. 4
0
        private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance)
        {
            int extruderCount = ActiveSliceSettings.Instance.ExtruderCount;

            FlowLayoutWidget eButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                FlowLayoutWidget eMinusButtonAndText = new FlowLayoutWidget();
                BorderDouble     extrusionMargin     = new BorderDouble(4, 0, 4, 0);

                if (extruderCount == 1)
                {
                    ExtrudeButton eMinusControl = moveButtonFactory.Generate("E-", MovementControls.EFeedRate(0), 0);
                    eMinusControl.Margin = extrusionMargin;
                    eMinusButtonAndText.AddChild(eMinusControl);
                    eMinusButtons.Add(eMinusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton eMinusControl = moveButtonFactory.Generate(string.Format("E{0}-", i + 1), MovementControls.EFeedRate(0), i);
                        eMinusControl.Margin = extrusionMargin;
                        eMinusButtonAndText.AddChild(eMinusControl);
                        eMinusButtons.Add(eMinusControl);
                    }
                }

                TextWidget eMinusControlLabel = new TextWidget(LocalizedString.Get("Retract"), pointSize: 11);
                eMinusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                eMinusControlLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                eMinusButtonAndText.AddChild(eMinusControlLabel);
                eMinusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(eMinusButtonAndText);

                eMinusButtonAndText.HAnchor = HAnchor.FitToChildren;
                eMinusButtonAndText.VAnchor = VAnchor.FitToChildren;


                FlowLayoutWidget buttonSpacerContainer = new FlowLayoutWidget();
                for (int i = 0; i < extruderCount; i++)
                {
                    GuiWidget eSpacer     = new GuiWidget(2, buttonSeparationDistance);
                    double    buttonWidth = eMinusButtons[i].Width + 6;

                    eSpacer.Margin          = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0);
                    eSpacer.BackgroundColor = XYZColors.eColor;
                    buttonSpacerContainer.AddChild(eSpacer);
                }
                buttonSpacerContainer.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(buttonSpacerContainer);

                buttonSpacerContainer.HAnchor = HAnchor.FitToChildren;
                buttonSpacerContainer.VAnchor = VAnchor.FitToChildren;

                FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget();
                if (extruderCount == 1)
                {
                    ExtrudeButton ePlusControl = moveButtonFactory.Generate("E+", MovementControls.EFeedRate(0), 0);
                    ePlusControl.Margin = extrusionMargin;
                    ePlusButtonAndText.AddChild(ePlusControl);
                    ePlusButtons.Add(ePlusControl);
                }
                else
                {
                    for (int i = 0; i < extruderCount; i++)
                    {
                        ExtrudeButton ePlusControl = moveButtonFactory.Generate(string.Format("E{0}+", i + 1), MovementControls.EFeedRate(0), i);
                        ePlusControl.Margin = extrusionMargin;
                        ePlusButtonAndText.AddChild(ePlusControl);
                        ePlusButtons.Add(ePlusControl);
                    }
                }

                TextWidget ePlusControlLabel = new TextWidget(LocalizedString.Get("Extrude"), pointSize: 11);
                ePlusControlLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                ePlusControlLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                ePlusButtonAndText.AddChild(ePlusControlLabel);
                ePlusButtonAndText.HAnchor = Agg.UI.HAnchor.ParentLeft;
                eButtons.AddChild(ePlusButtonAndText);
                ePlusButtonAndText.HAnchor = HAnchor.FitToChildren;
                ePlusButtonAndText.VAnchor = VAnchor.FitToChildren;
            }

            eButtons.AddChild(new GuiWidget(10, 6));

            // add in some movement radio buttons
            FlowLayoutWidget setMoveDistanceControl = new FlowLayoutWidget();
            TextWidget       buttonsLabel           = new TextWidget("Distance:", textColor: RGBA_Bytes.White);

            buttonsLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
            //setMoveDistanceControl.AddChild(buttonsLabel);

            {
                TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
                buttonFactory.FixedHeight        = 20 * TextWidget.GlobalPointSizeScaleRatio;
                buttonFactory.FixedWidth         = 30 * TextWidget.GlobalPointSizeScaleRatio;
                buttonFactory.fontSize           = 8;
                buttonFactory.Margin             = new BorderDouble(0);
                buttonFactory.checkedBorderColor = ActiveTheme.Instance.PrimaryTextColor;

                FlowLayoutWidget moveRadioButtons = new FlowLayoutWidget();
                RadioButton      oneButton        = buttonFactory.GenerateRadioButton("1");
                oneButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                  {
                                                                      SetEMoveAmount(1);
                                                                  }
                };
                moveRadioButtons.AddChild(oneButton);
                RadioButton tenButton = buttonFactory.GenerateRadioButton("10");
                tenButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                  {
                                                                      SetEMoveAmount(10);
                                                                  }
                };
                moveRadioButtons.AddChild(tenButton);
                RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100");
                oneHundredButton.VAnchor              = Agg.UI.VAnchor.ParentCenter;
                oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked)
                                                                         {
                                                                             SetEMoveAmount(100);
                                                                         }
                };
                moveRadioButtons.AddChild(oneHundredButton);
                tenButton.Checked       = true;
                moveRadioButtons.Margin = new BorderDouble(0, 3);
                setMoveDistanceControl.AddChild(moveRadioButtons);
            }

            TextWidget mmLabel = new TextWidget("mm", textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 8);

            mmLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
            setMoveDistanceControl.AddChild(mmLabel);
            setMoveDistanceControl.HAnchor = Agg.UI.HAnchor.ParentLeft;
            eButtons.AddChild(setMoveDistanceControl);

            eButtons.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;
            eButtons.VAnchor = VAnchor.FitToChildren | VAnchor.ParentBottom;

            return(eButtons);
        }
			public ExtrudeButton Generate(string label, double movementFeedRate, int extruderNumber = 0)
			{
				//Create button based on view container widget
				ButtonViewStates buttonViewWidget = GetButtonView(label);
				ExtrudeButton textImageButton = new ExtrudeButton(0, 0, buttonViewWidget, movementFeedRate, extruderNumber);
				textImageButton.Margin = new BorderDouble(0);
				textImageButton.Padding = new BorderDouble(0);
				return textImageButton;
			}