public ThemedNumberEdit(double startingValue, ThemeConfig theme, char singleCharLabel = char.MaxValue, string unitsLabel = "", double pixelWidth = 0, double pixelHeight = 0, bool allowNegatives = false, bool allowDecimals = false, double minValue = int.MinValue, double maxValue = int.MaxValue, double increment = 1, int tabIndex = 0) { using (this.LayoutLock()) { this.Padding = 3; this.HAnchor = HAnchor.Fit; this.VAnchor = VAnchor.Fit; this.Border = 1; this.theme = theme; this.ActuallNumberEdit = new NumberEdit(startingValue, 0, 0, theme.DefaultFontSize, pixelWidth, pixelHeight, allowNegatives, allowDecimals, minValue, maxValue, increment, tabIndex) { VAnchor = VAnchor.Bottom, }; TextWidget labelWidget = null; if (singleCharLabel != char.MaxValue) { labelWidget = new TextWidget(singleCharLabel.ToString(), pointSize: theme.DefaultFontSize - 2, textColor: theme.PrimaryAccentColor) { Margin = new BorderDouble(left: 2), HAnchor = HAnchor.Left, VAnchor = VAnchor.Center, Selectable = false }; this.AddChild(labelWidget); var labelWidth = labelWidget.Width + labelWidget.Margin.Left; ActuallNumberEdit.Margin = ActuallNumberEdit.Margin.Clone(left: labelWidth + 2); } var internalWidget = this.ActuallNumberEdit.InternalTextEditWidget; internalWidget.TextColor = theme.EditFieldColors.Inactive.TextColor; internalWidget.FocusChanged += (s, e) => { internalWidget.TextColor = (internalWidget.Focused) ? theme.EditFieldColors.Focused.TextColor : theme.EditFieldColors.Inactive.TextColor; if (labelWidget != null) { var labelDetailsColor = theme.PrimaryAccentColor.WithContrast(theme.EditFieldColors.Focused.BackgroundColor, 3).ToColor(); labelWidget.TextColor = (internalWidget.Focused) ? labelDetailsColor : theme.PrimaryAccentColor; } }; this.ActuallNumberEdit.InternalNumberEdit.MaxDecimalsPlaces = 5; this.AddChild(this.ActuallNumberEdit); } this.PerformLayout(); }
public GCodeViewerApplication(string gCodeToLoad = "") : base(800, 600) { MinimumSize = new VectorMath.Vector2(200, 200); Title = "MatterHackers GCodeVisualizer"; gCodeViewWidget = new GCodeViewWidget(new Vector2(), new Vector2(100, 100)); AddChild(gCodeViewWidget); FlowLayoutWidget keepOnTop = new FlowLayoutWidget(); prevLayerButton = new Button("<<", 0, 0); prevLayerButton.Click += new Button.ButtonEventHandler(prevLayer_ButtonClick); keepOnTop.AddChild(prevLayerButton); currentLayerIndex = new NumberEdit(1, pixelWidth: 40); keepOnTop.AddChild(currentLayerIndex); currentLayerIndex.EditComplete += new EventHandler(layerCountTextWidget_EditComplete); layerCountTextWidget = new TextWidget("/1____", 12); keepOnTop.AddChild(layerCountTextWidget); nextLayerButton = new Button(">>", 0, 0); nextLayerButton.Click += new Button.ButtonEventHandler(nextLayer_ButtonClick); keepOnTop.AddChild(nextLayerButton); if (gCodeToLoad != "") { gCodeViewWidget.Load(gCodeToLoad); } else { openFileButton = new Button("Open GCode", 0, 0); openFileButton.Click += new Button.ButtonEventHandler(openFileButton_ButtonClick); keepOnTop.AddChild(openFileButton); } AddChild(keepOnTop); AnchorAll(); currentLayerIndex.Focus(); }
public SetLayerWidget(ViewGcodeWidget gcodeViewWidget) : base(FlowDirection.LeftToRight) { this.gcodeViewWidget = gcodeViewWidget; textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor; textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor; editCurrentLayerIndex = new NumberEdit(1, pixelWidth: 40); editCurrentLayerIndex.VAnchor = VAnchor.ParentCenter; editCurrentLayerIndex.Margin = new BorderDouble(5, 0); editCurrentLayerIndex.EditComplete += new EventHandler(editCurrentLayerIndex_EditComplete); this.AddChild(editCurrentLayerIndex); gcodeViewWidget.ActiveLayerChanged += new EventHandler(gcodeViewWidget_ActiveLayerChanged); setLayerButton = textImageButtonFactory.Generate(LocalizedString.Get("Go")); setLayerButton.VAnchor = Agg.UI.VAnchor.ParentCenter; setLayerButton.Click += new EventHandler(layerCountTextWidget_EditComplete); this.AddChild(setLayerButton); }
protected override void AddChildElements() { AltGroupBox adjustmentControlsGroupBox = new AltGroupBox(new TextWidget("Tuning Adjustment".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor)); adjustmentControlsGroupBox.Margin = new BorderDouble(0); adjustmentControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; adjustmentControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight; { FlowLayoutWidget tuningRatiosLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); tuningRatiosLayout.Margin = new BorderDouble(0, 0, 0, 0); tuningRatiosLayout.HAnchor = HAnchor.ParentLeftRight; tuningRatiosLayout.Padding = new BorderDouble(3, 0, 3, 0); double sliderWidth = 300 * GuiWidget.DeviceScale; double sliderThumbWidth = 10 * GuiWidget.DeviceScale; if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen) { sliderThumbWidth = 15 * GuiWidget.DeviceScale; } TextWidget subheader = new TextWidget("", pointSize: 4, textColor: ActiveTheme.Instance.PrimaryTextColor); subheader.Margin = new BorderDouble(bottom: 6); tuningRatiosLayout.AddChild(subheader); TextWidget feedRateDescription; { FlowLayoutWidget feedRateLeftToRight; { feedRateValue = new NumberEdit(0, allowDecimals: true, minValue: minFeedRateRatio, maxValue: maxFeedRateRatio, pixelWidth: 40 * GuiWidget.DeviceScale); feedRateValue.Value = ((int)(PrinterConnectionAndCommunication.Instance.FeedRateRatio * 100 + .5)) / 100.0; feedRateLeftToRight = new FlowLayoutWidget(); feedRateLeftToRight.HAnchor = HAnchor.ParentLeftRight; feedRateDescription = new TextWidget(LocalizedString.Get("Speed Multiplier")); feedRateDescription.MinimumSize = new Vector2(140, 0) * GuiWidget.DeviceScale; feedRateDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor; feedRateDescription.VAnchor = VAnchor.ParentCenter; feedRateLeftToRight.AddChild(feedRateDescription); feedRateRatioSlider = new SolidSlider(new Vector2(), sliderThumbWidth, minFeedRateRatio, maxFeedRateRatio); feedRateRatioSlider.Margin = new BorderDouble(5, 0); feedRateRatioSlider.Value = PrinterConnectionAndCommunication.Instance.FeedRateRatio; feedRateRatioSlider.TotalWidthInPixels = sliderWidth; feedRateRatioSlider.View.BackgroundColor = new RGBA_Bytes(); feedRateRatioSlider.ValueChanged += (sender, e) => { PrinterConnectionAndCommunication.Instance.FeedRateRatio = feedRateRatioSlider.Value; }; PrinterConnectionAndCommunication.Instance.FeedRateRatioChanged.RegisterEvent(FeedRateRatioChanged_Event, ref unregisterEvents); feedRateValue.EditComplete += (sender, e) => { feedRateRatioSlider.Value = feedRateValue.Value; }; feedRateLeftToRight.AddChild(feedRateRatioSlider); tuningRatiosLayout.AddChild(feedRateLeftToRight); feedRateLeftToRight.AddChild(feedRateValue); feedRateValue.Margin = new BorderDouble(0, 0, 5, 0); feedRateValue.VAnchor = VAnchor.ParentCenter; textImageButtonFactory.FixedHeight = (int)feedRateValue.Height + 1; textImageButtonFactory.borderWidth = 1; textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200); Button setFeedRateButton = textImageButtonFactory.Generate(LocalizedString.Get("Set")); setFeedRateButton.VAnchor = VAnchor.ParentCenter; feedRateLeftToRight.AddChild(setFeedRateButton); } TextWidget extrusionDescription; { extrusionValue = new NumberEdit(0, allowDecimals: true, minValue: minExtrutionRatio, maxValue: maxExtrusionRatio, pixelWidth: 40 * GuiWidget.DeviceScale); extrusionValue.Value = ((int)(PrinterConnectionAndCommunication.Instance.ExtrusionRatio * 100 + .5)) / 100.0; FlowLayoutWidget leftToRight = new FlowLayoutWidget(); leftToRight.HAnchor = HAnchor.ParentLeftRight; leftToRight.Margin = new BorderDouble(top: 10); extrusionDescription = new TextWidget(LocalizedString.Get("Extrusion Multiplier")); extrusionDescription.MinimumSize = new Vector2(140, 0) * GuiWidget.DeviceScale; extrusionDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor; extrusionDescription.VAnchor = VAnchor.ParentCenter; leftToRight.AddChild(extrusionDescription); extrusionRatioSlider = new SolidSlider(new Vector2(), sliderThumbWidth, minExtrutionRatio, maxExtrusionRatio, Orientation.Horizontal); extrusionRatioSlider.TotalWidthInPixels = sliderWidth; extrusionRatioSlider.Margin = new BorderDouble(5, 0); extrusionRatioSlider.Value = PrinterConnectionAndCommunication.Instance.ExtrusionRatio; extrusionRatioSlider.View.BackgroundColor = new RGBA_Bytes(); extrusionRatioSlider.ValueChanged += (sender, e) => { PrinterConnectionAndCommunication.Instance.ExtrusionRatio = extrusionRatioSlider.Value; }; PrinterConnectionAndCommunication.Instance.ExtrusionRatioChanged.RegisterEvent(ExtrusionRatioChanged_Event, ref unregisterEvents); extrusionValue.EditComplete += (sender, e) => { extrusionRatioSlider.Value = extrusionValue.Value; }; leftToRight.AddChild(extrusionRatioSlider); tuningRatiosLayout.AddChild(leftToRight); leftToRight.AddChild(extrusionValue); extrusionValue.Margin = new BorderDouble(0, 0, 5, 0); extrusionValue.VAnchor = VAnchor.ParentCenter; textImageButtonFactory.FixedHeight = (int)extrusionValue.Height + 1; Button setExtrusionButton = textImageButtonFactory.Generate(LocalizedString.Get("Set")); setExtrusionButton.VAnchor = VAnchor.ParentCenter; leftToRight.AddChild(setExtrusionButton); } feedRateLeftToRight.VAnchor = VAnchor.FitToChildren; } adjustmentControlsGroupBox.AddChild(tuningRatiosLayout); } this.AddChild(adjustmentControlsGroupBox); }
private void AddAdjustmentControls(FlowLayoutWidget controlsTopToBottomLayout) { GroupBox adjustmentControlsGroupBox = new GroupBox(new LocalizedString("Tuning Adjustment (while printing)").Translated); adjustmentControlsGroupBox.Margin = new BorderDouble(0); adjustmentControlsGroupBox.TextColor = ActiveTheme.Instance.PrimaryTextColor; adjustmentControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor; adjustmentControlsGroupBox.HAnchor = Agg.UI.HAnchor.ParentLeftRight; adjustmentControlsGroupBox.Height = 93; { FlowLayoutWidget tuningRatiosLayout = new FlowLayoutWidget(FlowDirection.TopToBottom); tuningRatiosLayout.Margin = new BorderDouble(0, 0, 0, 6); tuningRatiosLayout.AnchorAll(); tuningRatiosLayout.Padding = new BorderDouble(3, 5, 3, 0); TextWidget feedRateDescription; { FlowLayoutWidget feedRateLeftToRight; { feedRateValue = new NumberEdit(1, allowDecimals: true, minValue: minFeedRateRatio, maxValue: maxFeedRateRatio, pixelWidth: 40); feedRateLeftToRight = new FlowLayoutWidget(); feedRateDescription = new TextWidget(new LocalizedString("Speed Multiplier").Translated); feedRateDescription.TextColor = RGBA_Bytes.White; feedRateLeftToRight.AddChild(feedRateDescription); feedRateRatioSlider = new Slider(new Vector2(), 300, minFeedRateRatio, maxFeedRateRatio); feedRateRatioSlider.Margin = new BorderDouble(5, 0); feedRateRatioSlider.Value = PrinterCommunication.Instance.FeedRateRatio; feedRateRatioSlider.View.BackgroundColor = new RGBA_Bytes(); feedRateRatioSlider.ValueChanged += (sender, e) => { PrinterCommunication.Instance.FeedRateRatio = feedRateRatioSlider.Value; }; PrinterCommunication.Instance.FeedRateRatioChanged.RegisterEvent(FeedRateRatioChanged_Event, ref unregisterEvents); feedRateValue.EditComplete += (sender, e) => { feedRateRatioSlider.Value = feedRateValue.Value; }; feedRateLeftToRight.AddChild(feedRateRatioSlider); tuningRatiosLayout.AddChild(feedRateLeftToRight); feedRateLeftToRight.AddChild(feedRateValue); feedRateValue.Margin = new BorderDouble(0, 0, 5, 0); textImageButtonFactory.FixedHeight = (int)feedRateValue.Height + 1; feedRateLeftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated)); } TextWidget extrusionDescription; { extrusionValue = new NumberEdit(1, allowDecimals: true, minValue: minExtrutionRatio, maxValue: maxExtrusionRatio, pixelWidth: 40); FlowLayoutWidget leftToRight = new FlowLayoutWidget(); extrusionDescription = new TextWidget(new LocalizedString("Extrusion Multiplier").Translated); extrusionDescription.TextColor = RGBA_Bytes.White; leftToRight.AddChild(extrusionDescription); extrusionRatioSlider = new Slider(new Vector2(), 300, minExtrutionRatio, maxExtrusionRatio); extrusionRatioSlider.Margin = new BorderDouble(5, 0); extrusionRatioSlider.Value = PrinterCommunication.Instance.ExtrusionRatio; extrusionRatioSlider.View.BackgroundColor = new RGBA_Bytes(); extrusionRatioSlider.ValueChanged += (sender, e) => { PrinterCommunication.Instance.ExtrusionRatio = extrusionRatioSlider.Value; }; PrinterCommunication.Instance.ExtrusionRatioChanged.RegisterEvent(ExtrusionRatioChanged_Event, ref unregisterEvents); extrusionValue.EditComplete += (sender, e) => { extrusionRatioSlider.Value = extrusionValue.Value; }; leftToRight.AddChild(extrusionRatioSlider); tuningRatiosLayout.AddChild(leftToRight); leftToRight.AddChild(extrusionValue); extrusionValue.Margin = new BorderDouble(0, 0, 5, 0); textImageButtonFactory.FixedHeight = (int)extrusionValue.Height + 1; leftToRight.AddChild(textImageButtonFactory.Generate(new LocalizedString("Set").Translated)); } feedRateDescription.Width = extrusionDescription.Width; feedRateDescription.MinimumSize = new Vector2(extrusionDescription.Width, feedRateDescription.MinimumSize.y); feedRateLeftToRight.HAnchor = HAnchor.FitToChildren; feedRateLeftToRight.VAnchor = VAnchor.FitToChildren; } adjustmentControlsGroupBox.AddChild(tuningRatiosLayout); } tuningAdjustmentControlsContainer = new DisableableWidget(); tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox); controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer); }
public MHNumberEdit(double startingValue, double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool allowNegatives = false, bool allowDecimals = false, double minValue = int.MinValue, double maxValue = int.MaxValue, double increment = 1, int tabIndex = 0) { Padding = new BorderDouble(3); actuallNumberEdit = new NumberEdit(startingValue, x, y, pointSize, pixelWidth, pixelHeight, allowNegatives, allowDecimals, minValue, maxValue, increment, tabIndex); actuallNumberEdit.VAnchor = Agg.UI.VAnchor.ParentBottom; AddChild(actuallNumberEdit); BackgroundColor = RGBA_Bytes.White; HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; }
public MHNumberEdit(double startingValue, double x = 0, double y = 0, double pointSize = 12, double pixelWidth = 0, double pixelHeight = 0, bool allowNegatives = false, bool allowDecimals = false, double minValue = int.MinValue, double maxValue = int.MaxValue, double increment = 1, int tabIndex = 0) { Padding = new BorderDouble(3); actuallNumberEdit = new NumberEdit(startingValue, x, y, pointSize, pixelWidth, pixelHeight, allowNegatives, allowDecimals, minValue, maxValue, increment, tabIndex); actuallNumberEdit.VAnchor = Agg.UI.VAnchor.ParentBottom; AddChild(actuallNumberEdit); BackgroundColor = RGBA_Bytes.White; HAnchor = HAnchor.FitToChildren; VAnchor = VAnchor.FitToChildren; actuallNumberEdit.TextChanged += new EventHandler(internalNumberEdit_TextChanged); actuallNumberEdit.InternalTextEditWidget.EditComplete += new EventHandler(InternalTextEditWidget_EditComplete); UiThread.RunOnIdle(OnIdle); }