private GuiWidget CreateXYGridControl(XYZColors colors, double distanceBetweenControls, double buttonSeparationDistance) { GuiWidget xyGrid = new GuiWidget(); { FlowLayoutWidget xButtons = new FlowLayoutWidget(); { moveButtonFactory.normalFillColor = XYZColors.xColor; xButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; xButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; xMinusControl = moveButtonFactory.Generate("X-", PrinterConnectionAndCommunication.Axis.X, MovementControls.XSpeed); xMinusControl.ToolTipText = "Move X negative"; xButtons.AddChild(xMinusControl); GuiWidget spacer = new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 2); spacer.VAnchor = Agg.UI.VAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.xColor; xButtons.AddChild(spacer); xPlusControl = moveButtonFactory.Generate("X+", PrinterConnectionAndCommunication.Axis.X, MovementControls.XSpeed); xPlusControl.ToolTipText = "Move X positive"; xButtons.AddChild(xPlusControl); } xyGrid.AddChild(xButtons); FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom); { moveButtonFactory.normalFillColor = XYZColors.yColor; yButtons.HAnchor |= Agg.UI.HAnchor.ParentCenter; yButtons.VAnchor |= Agg.UI.VAnchor.ParentCenter; yPlusControl = moveButtonFactory.Generate("Y+", PrinterConnectionAndCommunication.Axis.Y, MovementControls.YSpeed); yPlusControl.ToolTipText = "Move Y positive"; yButtons.AddChild(yPlusControl); GuiWidget spacer = new GuiWidget(2, buttonSeparationDistance); spacer.HAnchor = Agg.UI.HAnchor.ParentCenter; spacer.BackgroundColor = XYZColors.yColor; yButtons.AddChild(spacer); yMinusControl = moveButtonFactory.Generate("Y-", PrinterConnectionAndCommunication.Axis.Y, MovementControls.YSpeed); yMinusControl.ToolTipText = "Move Y negative"; yButtons.AddChild(yMinusControl); } xyGrid.AddChild(yButtons); } xyGrid.HAnchor = HAnchor.FitToChildren; xyGrid.VAnchor = VAnchor.FitToChildren; xyGrid.VAnchor = Agg.UI.VAnchor.ParentBottom; xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5); return xyGrid; }
public JogControls(XYZColors colors) { moveButtonFactory.normalTextColor = RGBA_Bytes.Black; double distanceBetweenControls = 12; double buttonSeparationDistance = 10; FlowLayoutWidget allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); allControlsTopToBottom.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget allControlsLeftToRight = new FlowLayoutWidget(); FlowLayoutWidget xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget xYZControls = new FlowLayoutWidget(); { GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance); xYZControls.AddChild(xyGrid); FlowLayoutWidget zButtons = CreateZButtons(XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl); zButtons.VAnchor = Agg.UI.VAnchor.ParentBottom; xYZControls.AddChild(zButtons); xYZWithDistance.AddChild(xYZControls); } this.KeyDown += (sender, e) => { double moveAmountPositive = AxisMoveAmount; double moveAmountNegative = -AxisMoveAmount; int eMoveAmountPositive = EAxisMoveAmount; int eMoveAmountNegative = -EAxisMoveAmount; if (e.KeyCode == Keys.Home && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.XYZ); } else if (e.KeyCode == Keys.Z && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Z); } else if (e.KeyCode == Keys.Y && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.Y); } else if (e.KeyCode == Keys.X && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.HomeAxis(PrinterConnectionAndCommunication.Axis.X); } else if (e.KeyCode == Keys.Left && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountNegative, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Right && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.X, moveAmountPositive, MovementControls.XSpeed); } else if (e.KeyCode == Keys.Up && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountPositive, MovementControls.YSpeed); } else if (e.KeyCode == Keys.Down && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Y, moveAmountNegative, MovementControls.YSpeed); } else if (e.KeyCode == Keys.PageUp && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountPositive, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.PageDown && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, moveAmountNegative, MovementControls.ZSpeed); } else if (e.KeyCode == Keys.E && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountPositive, MovementControls.EFeedRate(0)); } else if (e.KeyCode == Keys.R && hotKeysEnabled) { PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.E, eMoveAmountNegative, MovementControls.EFeedRate(0)); } }; // 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 pointOneButton = buttonFactory.GenerateRadioButton("0.1"); pointOneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; pointOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(.1); }; moveRadioButtons.AddChild(pointOneButton); RadioButton oneButton = buttonFactory.GenerateRadioButton("1"); oneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(1); }; moveRadioButtons.AddChild(oneButton); RadioButton tenButton = buttonFactory.GenerateRadioButton("10"); tenButton.VAnchor = Agg.UI.VAnchor.ParentCenter; tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(10); }; moveRadioButtons.AddChild(tenButton); RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100"); oneHundredButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(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; xYZWithDistance.AddChild(setMoveDistanceControl); } allControlsLeftToRight.AddChild(xYZWithDistance); #if !__ANDROID__ allControlsLeftToRight.AddChild(GetHotkeyControlContainer()); #endif GuiWidget barBetweenZAndE = new GuiWidget(2, 2); barBetweenZAndE.VAnchor = Agg.UI.VAnchor.ParentBottomTop; barBetweenZAndE.BackgroundColor = RGBA_Bytes.White; barBetweenZAndE.Margin = new BorderDouble(distanceBetweenControls, 5); allControlsLeftToRight.AddChild(barBetweenZAndE); //moveButtonFactory.normalFillColor = XYZColors.eColor; FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance); eButtons.VAnchor |= Agg.UI.VAnchor.ParentTop; allControlsLeftToRight.AddChild(eButtons); allControlsTopToBottom.AddChild(allControlsLeftToRight); } this.AddChild(allControlsTopToBottom); this.HAnchor = HAnchor.FitToChildren; this.VAnchor = VAnchor.FitToChildren; Margin = new BorderDouble(3); // this.HAnchor |= HAnchor.ParentLeftRight; }
public JogControls(XYZColors colors) { moveButtonFactory.normalTextColor = RGBA_Bytes.Black; double distanceBetweenControls = 12; double buttonSeparationDistance = 10; FlowLayoutWidget allControlsTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom); allControlsTopToBottom.HAnchor |= Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget allControlsLeftToRight = new FlowLayoutWidget(); FlowLayoutWidget xYZWithDistance = new FlowLayoutWidget(FlowDirection.TopToBottom); { FlowLayoutWidget xYZControls = new FlowLayoutWidget(); { GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance); xYZControls.AddChild(xyGrid); FlowLayoutWidget zButtons = CreateZButtons(XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl); zButtons.VAnchor = Agg.UI.VAnchor.ParentBottom; xYZControls.AddChild(zButtons); xYZWithDistance.AddChild(xYZControls); } // 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 pointOneButton = buttonFactory.GenerateRadioButton("0.1"); pointOneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; pointOneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(.1); }; moveRadioButtons.AddChild(pointOneButton); RadioButton oneButton = buttonFactory.GenerateRadioButton("1"); oneButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(1); }; moveRadioButtons.AddChild(oneButton); RadioButton tenButton = buttonFactory.GenerateRadioButton("10"); tenButton.VAnchor = Agg.UI.VAnchor.ParentCenter; tenButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(10); }; moveRadioButtons.AddChild(tenButton); RadioButton oneHundredButton = buttonFactory.GenerateRadioButton("100"); oneHundredButton.VAnchor = Agg.UI.VAnchor.ParentCenter; oneHundredButton.CheckedStateChanged += (sender, e) => { if (((RadioButton)sender).Checked) SetXYZMoveAmount(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; xYZWithDistance.AddChild(setMoveDistanceControl); } allControlsLeftToRight.AddChild(xYZWithDistance); GuiWidget barBetweenZAndE = new GuiWidget(2, 2); barBetweenZAndE.VAnchor = Agg.UI.VAnchor.ParentBottomTop; barBetweenZAndE.BackgroundColor = RGBA_Bytes.White; barBetweenZAndE.Margin = new BorderDouble(distanceBetweenControls, 5); allControlsLeftToRight.AddChild(barBetweenZAndE); moveButtonFactory.normalFillColor = XYZColors.eColor; FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance); eButtons.VAnchor |= Agg.UI.VAnchor.ParentTop; allControlsLeftToRight.AddChild(eButtons); allControlsTopToBottom.AddChild(allControlsLeftToRight); } this.AddChild(allControlsTopToBottom); HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; Margin = new BorderDouble(3); this.HAnchor |= HAnchor.ParentLeftRight; }