コード例 #1
0
        public EditableNumberDisplay(double startingValue, string largestPossibleValue, Color textColor)
            : base(FlowDirection.LeftToRight)
        {
            this.Margin  = new BorderDouble(3, 0);
            this.VAnchor = VAnchor.Center;

            clickableValueContainer = new ClickWidget
            {
                VAnchor     = VAnchor.Stretch,
                Cursor      = Cursors.Hand,
                BorderWidth = 1,
                BorderColor = BorderColor
            };

            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new Color(BorderColor, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new Color(BorderColor, 140);
            };

            valueDisplay = new TextWidget(largestPossibleValue, pointSize: 12)
            {
                TextColor = textColor,
                VAnchor   = VAnchor.Center,
                HAnchor   = HAnchor.Left,
                Margin    = new BorderDouble(6),
            };

            clickableValueContainer.Click += editField_Click;

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();

            numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(left: 6),
                Visible = false
            };

            // This is a hack to make sure the control is tall enough.
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new Vector2(0, numberInputField.Height);

            numberInputField.ActuallNumberEdit.EnterPressed += (s, e) => UpdateDisplayString();
            numberInputField.ContainsFocusChanged           += (s1, e1) =>
            {
                if (!numberInputField.ContainsFocus)
                {
                    UpdateDisplayString();
                }
            };

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible        = false;
                }
            };

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);

            Value       = startingValue + 1;
            Value       = startingValue;
            BorderColor = TextColor;
        }
コード例 #2
0
        public EditManualMovementSpeedsWindow(string windowTitle, string movementSpeedsString, EventHandler functionToCallOnSave)
            : base(260, 300)
        {
            AlwaysOnTopOfMain = true;
            Title             = LocalizedString.Get(windowTitle);

            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     movementSpeedsLabel = LocalizedString.Get("Movement Speeds Presets".Localize());
                TextWidget elementHeader       = new TextWidget(string.Format("{0}:", movementSpeedsLabel), 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);

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

            topToBottom.AddChild(presetsFormContainer);

            this.functionToCallOnSave = functionToCallOnSave;
            BackgroundColor           = ActiveTheme.Instance.PrimaryBackgroundColor;

            double oldHeight = textImageButtonFactory.FixedHeight;

            textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;

            TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);

            tempTypeLabel.Margin  = new BorderDouble(3);
            tempTypeLabel.HAnchor = HAnchor.ParentLeft;
            presetsFormContainer.AddChild(tempTypeLabel);

            FlowLayoutWidget leftRightLabels = new FlowLayoutWidget();

            leftRightLabels.Padding  = new BorderDouble(3, 6);
            leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

            GuiWidget hLabelSpacer = new GuiWidget();

            hLabelSpacer.HAnchor = HAnchor.ParentLeftRight;

            GuiWidget tempLabelContainer = new GuiWidget();

            tempLabelContainer.Width  = 76;
            tempLabelContainer.Height = 16;
            tempLabelContainer.Margin = new BorderDouble(3, 0);

            TextWidget tempLabel = new TextWidget(string.Format("mm / minute"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);

            tempLabel.HAnchor = HAnchor.ParentLeft;
            tempLabel.VAnchor = VAnchor.ParentCenter;

            tempLabelContainer.AddChild(tempLabel);

            leftRightLabels.AddChild(hLabelSpacer);
            leftRightLabels.AddChild(tempLabelContainer);

            presetsFormContainer.AddChild(leftRightLabels);

            // put in the movement edit controls
            string[] settingsArray = movementSpeedsString.Split(',');
            int      preset_count  = 1;
            int      tab_index     = 0;

            for (int i = 0; i < settingsArray.Count() - 1; i += 2)
            {
                FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
                leftRightEdit.Padding  = new BorderDouble(3);
                leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
                TextWidget axisLabel;
                if (settingsArray[i].StartsWith("e"))
                {
                    int    extruderIndex    = (int)double.Parse(settingsArray[i].Substring(1)) + 1;
                    string extruderLabelTxt = LocalizedString.Get("Extruder");
                    axisLabel = new TextWidget(string.Format("{0} {1}", extruderLabelTxt, extruderIndex), textColor: ActiveTheme.Instance.PrimaryTextColor);
                }
                else
                {
                    string axisLabelText = LocalizedString.Get("Axis");
                    axisLabel = new TextWidget(string.Format("{0} {1}", axisLabelText, settingsArray[i]), textColor: ActiveTheme.Instance.PrimaryTextColor);
                }
                axisLabel.VAnchor = VAnchor.ParentCenter;
                leftRightEdit.AddChild(axisLabel);

                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                leftRightEdit.AddChild(hSpacer);

                // we add this to the listWithValues to make sure we build the string correctly on save.
                TextWidget typeEdit = new TextWidget(settingsArray[i]);
                listWithValues.Add(typeEdit);

                double movementSpeed = 0;
                double.TryParse(settingsArray[i + 1], out movementSpeed);
                MHNumberEdit valueEdit = new MHNumberEdit(movementSpeed, minValue: 0, pixelWidth: 60, tabIndex: tab_index++);
                valueEdit.Margin = new BorderDouble(3);
                leftRightEdit.AddChild(valueEdit);
                listWithValues.Add(valueEdit);

                //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete"));
                presetsFormContainer.AddChild(leftRightEdit);
                preset_count += 1;
            }

            textImageButtonFactory.FixedHeight = oldHeight;

            ShowAsSystemWindow();
            MinimumSize = new Vector2(260, 300);

            Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));

            savePresetsButton.Click += new EventHandler(save_Click);

            Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));

            cancelPresetsButton.Click += (sender, e) => {
                UiThread.RunOnIdle((state) =>
                {
                    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(savePresetsButton);
            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
コード例 #3
0
		public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave)
			: base(360, 300)
		{
			AlwaysOnTopOfMain = true;
			Title = LocalizedString.Get(windowTitle);

			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 tempShortcutPresetLabel = LocalizedString.Get("Temperature Shortcut Presets");
				string tempShortcutPresetLabelFull = string.Format("{0}:", tempShortcutPresetLabel);
				TextWidget elementHeader = new TextWidget(tempShortcutPresetLabelFull, 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);
			//ListBox printerListContainer = new ListBox();
			{
				presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
				presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
				presetsFormContainer.Padding = new BorderDouble(3);
				presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			topToBottom.AddChild(presetsFormContainer);

			this.functionToCallOnSave = functionToCallOnSave;
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			double oldHeight = textImageButtonFactory.FixedHeight;
			textImageButtonFactory.FixedHeight = 30 * GuiWidget.DeviceScale;

			TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempTypeLabel.Margin = new BorderDouble(3);
			tempTypeLabel.HAnchor = HAnchor.ParentLeft;
			presetsFormContainer.AddChild(tempTypeLabel);

			FlowLayoutWidget leftRightLabels = new FlowLayoutWidget();
			leftRightLabels.Padding = new BorderDouble(3, 6);
			leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

			GuiWidget hLabelSpacer = new GuiWidget();
			hLabelSpacer.HAnchor = HAnchor.ParentLeftRight;

			GuiWidget labelLabelContainer = new GuiWidget();
			labelLabelContainer.Width = 66;
			labelLabelContainer.Height = 16;
			labelLabelContainer.Margin = new BorderDouble(3, 0);

			string labelLabelTxt = LocalizedString.Get("Label");
			TextWidget labelLabel = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			labelLabel.HAnchor = HAnchor.ParentLeft;
			labelLabel.VAnchor = VAnchor.ParentCenter;

			labelLabelContainer.AddChild(labelLabel);

			GuiWidget tempLabelContainer = new GuiWidget();
			tempLabelContainer.Width = 66;
			tempLabelContainer.Height = 16;
			tempLabelContainer.Margin = new BorderDouble(3, 0);

			TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempLabel.HAnchor = HAnchor.ParentLeft;
			tempLabel.VAnchor = VAnchor.ParentCenter;

			tempLabelContainer.AddChild(tempLabel);

			leftRightLabels.AddChild(hLabelSpacer);
			leftRightLabels.AddChild(labelLabelContainer);
			leftRightLabels.AddChild(tempLabelContainer);

			presetsFormContainer.AddChild(leftRightLabels);

			// put in the temperature edit controls
			string[] settingsArray = temperatureSettings.Split(',');
			int preset_count = 1;
			int tab_index = 0;
			for (int i = 0; i < settingsArray.Count() - 1; i += 2)
			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
				string presetLabelTxt = LocalizedString.Get("Preset");
				TextWidget label = new TextWidget(string.Format("{1} {0}", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor);
				label.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(label);

				leftRightEdit.AddChild(new HorizontalSpacer());

				MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++);

				typeEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(typeEdit);
				listWithValues.Add(typeEdit);

				double temperatureValue = 0;
				double.TryParse(settingsArray[i + 1], out temperatureValue);
				MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, minValue: 0, pixelWidth: 60, tabIndex: tab_index++);
				valueEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(valueEdit);
				listWithValues.Add(valueEdit);

				//leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete"));
				presetsFormContainer.AddChild(leftRightEdit);
				preset_count += 1;
			}

			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

				TextWidget maxWidgetLabel = new TextWidget(LocalizedString.Get("Max Temp"), textColor: ActiveTheme.Instance.PrimaryTextColor);
				maxWidgetLabel.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(maxWidgetLabel);
				leftRightEdit.AddChild(new HorizontalSpacer());

				double maxTemperature = 0;
				double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature);
				MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index);
				valueEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(valueEdit);
				listWithValues.Add(valueEdit);

				presetsFormContainer.AddChild(leftRightEdit);
			}

			textImageButtonFactory.FixedHeight = oldHeight;

			ShowAsSystemWindow();
			MinimumSize = new Vector2(360, 300);

			Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
			savePresetsButton.Click += new EventHandler(save_Click);

			Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
			cancelPresetsButton.Click += (sender, e) => { CloseOnIdle(); };

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

			GuiWidget hButtonSpacer = new GuiWidget();
			hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

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

			topToBottom.AddChild(buttonRow);

			AddChild(topToBottom);
		}
コード例 #4
0
        public EditTemperaturePresetsWindow(string windowTitle, string temperatureSettings, EventHandler functionToCallOnSave)
            : base(360, 300)
        {
            Title = new LocalizedString(windowTitle).Translated;

            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     tempShortcutPresetLbl     = new LocalizedString("Temperature Shortcut Presets").Translated;
                string     tempShortcutPresetLblFull = string.Format("{0}:", tempShortcutPresetLbl);
                TextWidget elementHeader             = new TextWidget(tempShortcutPresetLblFull, 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);

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

            topToBottom.AddChild(presetsFormContainer);

            this.functionToCallOnSave = functionToCallOnSave;
            BackgroundColor           = ActiveTheme.Instance.PrimaryBackgroundColor;

            int oldHeight = textImageButtonFactory.FixedHeight;

            textImageButtonFactory.FixedHeight = 30;

            TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);

            tempTypeLabel.Margin  = new BorderDouble(3);
            tempTypeLabel.HAnchor = HAnchor.ParentLeft;
            presetsFormContainer.AddChild(tempTypeLabel);

            FlowLayoutWidget leftRightLabels = new FlowLayoutWidget();

            leftRightLabels.Padding  = new BorderDouble(3, 6);
            leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

            GuiWidget hLabelSpacer = new GuiWidget();

            hLabelSpacer.HAnchor = HAnchor.ParentLeftRight;

            GuiWidget labelLabelContainer = new GuiWidget();

            labelLabelContainer.Width  = 66;
            labelLabelContainer.Height = 16;
            labelLabelContainer.Margin = new BorderDouble(3, 0);

            string     labelLabelTxt = new LocalizedString("Label").Translated;
            TextWidget labelLabel    = new TextWidget(string.Format(labelLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);

            labelLabel.HAnchor = HAnchor.ParentLeft;
            labelLabel.VAnchor = VAnchor.ParentCenter;


            labelLabelContainer.AddChild(labelLabel);

            GuiWidget tempLabelContainer = new GuiWidget();

            tempLabelContainer.Width  = 66;
            tempLabelContainer.Height = 16;
            tempLabelContainer.Margin = new BorderDouble(3, 0);

            TextWidget tempLabel = new TextWidget(string.Format("Temp (C)"), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);

            tempLabel.HAnchor = HAnchor.ParentLeft;
            tempLabel.VAnchor = VAnchor.ParentCenter;

            tempLabelContainer.AddChild(tempLabel);

            leftRightLabels.AddChild(hLabelSpacer);
            leftRightLabels.AddChild(labelLabelContainer);
            leftRightLabels.AddChild(tempLabelContainer);

            presetsFormContainer.AddChild(leftRightLabels);

            // put in the temperature edit controls
            string[] settingsArray = temperatureSettings.Split(',');
            int      preset_count  = 1;
            int      tab_index     = 0;

            for (int i = 0; i < settingsArray.Count() - 1; i += 2)
            {
                FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
                leftRightEdit.Padding  = new BorderDouble(3);
                leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
                string     presetLabelTxt = new LocalizedString("Preset").Translated;
                TextWidget label          = new TextWidget(string.Format("{1} {0}.", preset_count, presetLabelTxt), textColor: ActiveTheme.Instance.PrimaryTextColor);
                label.VAnchor = VAnchor.ParentCenter;
                leftRightEdit.AddChild(label);

                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                leftRightEdit.AddChild(hSpacer);

                MHTextEditWidget typeEdit = new MHTextEditWidget(settingsArray[i], pixelWidth: 60, tabIndex: tab_index++);

                typeEdit.Margin = new BorderDouble(3);
                leftRightEdit.AddChild(typeEdit);
                listWithValues.Add(typeEdit);

                double temperatureValue = 0;
                double.TryParse(settingsArray[i + 1], out temperatureValue);
                MHNumberEdit valueEdit = new MHNumberEdit(temperatureValue, minValue: 0, pixelWidth: 60, tabIndex: tab_index++);
                valueEdit.Margin = new BorderDouble(3);
                leftRightEdit.AddChild(valueEdit);
                listWithValues.Add(valueEdit);

                //leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete"));
                presetsFormContainer.AddChild(leftRightEdit);
                preset_count += 1;
            }

            {
                FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
                leftRightEdit.Padding  = new BorderDouble(3);
                leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

                GuiWidget hSpacer = new GuiWidget();
                hSpacer.HAnchor = HAnchor.ParentLeftRight;

                TextWidget maxWidgetLabel = new TextWidget(new LocalizedString("Max Temp.").Translated, textColor: ActiveTheme.Instance.PrimaryTextColor);
                maxWidgetLabel.VAnchor = VAnchor.ParentCenter;
                leftRightEdit.AddChild(maxWidgetLabel);
                leftRightEdit.AddChild(hSpacer);

                double maxTemperature = 0;
                double.TryParse(settingsArray[settingsArray.Count() - 1], out maxTemperature);
                MHNumberEdit valueEdit = new MHNumberEdit(maxTemperature, minValue: 0, pixelWidth: 60, tabIndex: tab_index);
                valueEdit.Margin = new BorderDouble(3);
                leftRightEdit.AddChild(valueEdit);
                listWithValues.Add(valueEdit);

                presetsFormContainer.AddChild(leftRightEdit);
            }

            textImageButtonFactory.FixedHeight = oldHeight;

            ShowAsSystemWindow();

            Button savePresetsButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated);

            savePresetsButton.Click += new ButtonBase.ButtonEventHandler(save_Click);

            Button cancelPresetsButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);

            cancelPresetsButton.Click += (sender, e) => { CloseOnIdle(); };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

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

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

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

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
コード例 #5
0
        public MovementSpeedsPage(PrinterConfig printer)
        {
            this.AlwaysOnTopOfMain = true;
            this.WindowTitle       = "Movement Speeds".Localize();
            this.HeaderText        = "Movement Speeds Presets".Localize();

            this.WindowSize = new Vector2(500 * GuiWidget.DeviceScale, 320 * GuiWidget.DeviceScale);

            var rightLabel = new TextWidget("mm/s".Localize(), textColor: theme.TextColor, pointSize: theme.FontSize10)
            {
                VAnchor = VAnchor.Center,
                Margin  = new BorderDouble(right: 20)
            };

            var headerBar = new Toolbar(theme.TabbarPadding, rightLabel)
            {
                Height  = theme.ButtonHeight,
                Padding = theme.ToolbarPadding,
                HAnchor = HAnchor.Stretch
            };

            headerBar.AddChild(new TextWidget(this.WindowTitle, textColor: theme.TextColor, pointSize: theme.FontSize10));

            contentRow.AddChild(headerBar);

            // put in the movement edit controls
            string[] settingsArray = printer.Settings.Helpers.GetMovementSpeedsString().Split(',');
            int      preset_count  = 1;
            int      tab_index     = 0;

            for (int i = 0; i < settingsArray.Count() - 1; i += 2)
            {
                var row = new FlowLayoutWidget
                {
                    Padding = 3,
                    HAnchor = HAnchor.Stretch
                };

                TextWidget axisLabel;

                if (settingsArray[i].StartsWith("e"))
                {
                    axisLabel = new TextWidget(string.Format("{0}(s)", "Extruder".Localize()), textColor: theme.TextColor);
                }
                else
                {
                    axisLabel = new TextWidget(string.Format("{0} {1}", "Axis".Localize(), settingsArray[i].ToUpper()), textColor: theme.TextColor);
                }
                axisLabel.VAnchor = VAnchor.Center;
                row.AddChild(axisLabel);

                row.AddChild(new HorizontalSpacer());

                axisLabels.Add(settingsArray[i]);

                if (double.TryParse(settingsArray[i + 1], out double movementSpeed))
                {
                    movementSpeed = movementSpeed / 60.0;                       // Convert from mm/min to mm/s
                }

                var valueEdit = new MHNumberEdit(movementSpeed, theme, minValue: 0, pixelWidth: 60 * GuiWidget.DeviceScale, tabIndex: tab_index++, allowDecimals: true)
                {
                    Margin = 3
                };
                row.AddChild(valueEdit);
                valueEditors.Add(valueEdit);

                contentRow.AddChild(row);
                preset_count += 1;
            }

            var savePresetsButton = theme.CreateDialogButton("Save".Localize());

            savePresetsButton.Click += (s, e) =>
            {
                bool first         = true;
                var  settingString = new StringBuilder();

                for (int i = 0; i < valueEditors.Count(); i++)
                {
                    if (!first)
                    {
                        settingString.Append(",");
                    }

                    first = false;

                    settingString.Append(axisLabels[i]);
                    settingString.Append(",");

                    double movementSpeed = 0;
                    double.TryParse(valueEditors[i].Text, out movementSpeed);
                    movementSpeed = movementSpeed * 60;                     // Convert to mm/min

                    settingString.Append(movementSpeed.ToString());
                }

                string speedString = settingString.ToString();
                if (!string.IsNullOrEmpty(speedString))
                {
                    printer.Settings.SetValue(SettingsKey.manual_movement_speeds, speedString);
                    printer.Bed.GCodeRenderer?.Clear3DGCode();
                }

                this.DialogWindow.CloseOnIdle();
            };

            this.AddPageAction(savePresetsButton);
        }
コード例 #6
0
		public EditLevelingSettingsWindow()
			: base(400, 370)
		{
			Title = LocalizedString.Get("Leveling Settings".Localize());

			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 movementSpeedsLabel = LocalizedString.Get("Sampled Positions".Localize());
				TextWidget elementHeader = new TextWidget(string.Format("{0}:", movementSpeedsLabel), 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);
			//ListBox printerListContainer = new ListBox();
			{
				presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
				presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
				presetsFormContainer.Padding = new BorderDouble(3);
				presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			topToBottom.AddChild(presetsFormContainer);

			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			double oldHeight = textImageButtonFactory.FixedHeight;
			textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;

			// put in the movement edit controls
			PrintLevelingData levelingData = PrintLevelingData.GetForPrinter(ActivePrinterProfile.Instance.ActivePrinter);
			if (EditSamplePositionList(levelingData))
			{
				for (int i = 0; i < levelingData.SampledPositions.Count; i++)
				{
					positions.Add(levelingData.SampledPositions[i]);
				}
			}
			else
			{
				positions.Add(levelingData.SampledPosition0);
				positions.Add(levelingData.SampledPosition1);
				positions.Add(levelingData.SampledPosition2);
			}

			int tab_index = 0;
			for (int row = 0; row < positions.Count; row++)
			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
				TextWidget positionLabel;

				string whichPositionText = LocalizedString.Get("Position");
				positionLabel = new TextWidget("{0} {1,-5}".FormatWith(whichPositionText, row + 1), textColor: ActiveTheme.Instance.PrimaryTextColor);

				positionLabel.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(positionLabel);

				for (int axis = 0; axis < 3; axis++)
				{
					GuiWidget hSpacer = new GuiWidget();
					hSpacer.HAnchor = HAnchor.ParentLeftRight;

					leftRightEdit.AddChild(hSpacer);

					string axisName = "x";
					if (axis == 1) axisName = "y";
					else if (axis == 2) axisName = "z";

					TextWidget typeEdit = new TextWidget("  {0}: ".FormatWith(axisName), textColor: ActiveTheme.Instance.PrimaryTextColor);
					typeEdit.VAnchor = VAnchor.ParentCenter;
					leftRightEdit.AddChild(typeEdit);

					int linkCompatibleRow = row;
					int linkCompatibleAxis = axis;
					double minValue = double.MinValue;
					if (axis == 2 && ActiveSliceSettings.Instance.GetActiveValue("z_can_be_negative") == "0")
					{
						minValue = 0;
					}
					MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, minValue: minValue, pixelWidth: 60, tabIndex: tab_index++);
					valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) =>
					{
						Vector3 position = positions[linkCompatibleRow];
						position[linkCompatibleAxis] = valueEdit.ActuallNumberEdit.Value;
						positions[linkCompatibleRow] = position;
					};

					valueEdit.Margin = new BorderDouble(3);
					leftRightEdit.AddChild(valueEdit);
				}

				presetsFormContainer.AddChild(leftRightEdit);

				presetsFormContainer.AddChild(new CustomWidgets.HorizontalLine());
			}

			textImageButtonFactory.FixedHeight = oldHeight;

			ShowAsSystemWindow();
			MinimumSize = new Vector2(Width, Height);

			Button savePresetsButton = textImageButtonFactory.Generate("Save".Localize());
			savePresetsButton.Click += new EventHandler(save_Click);

			Button cancelPresetsButton = textImageButtonFactory.Generate("Cancel".Localize());
			cancelPresetsButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(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(savePresetsButton);
			buttonRow.AddChild(hButtonSpacer);
			buttonRow.AddChild(cancelPresetsButton);

			topToBottom.AddChild(buttonRow);

			AddChild(topToBottom);
		}
コード例 #7
0
        public EditLevelingSettingsPage(PrinterConfig printer, ThemeConfig theme)
        {
            this.printer = printer;

            this.WindowTitle = "Leveling Settings".Localize();
            this.HeaderText  = "Sampled Positions".Localize();

            var scrollableWidget = new ScrollableWidget()
            {
                AutoScroll = true,
                HAnchor    = HAnchor.Stretch,
                VAnchor    = VAnchor.Stretch,
            };

            scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch;
            contentRow.AddChild(scrollableWidget);

            // No right padding removes unexpected spacing to the right of scrollbar
            contentRow.Padding = contentRow.Padding.Clone(right: 0);

            var column = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
                Padding = new BorderDouble(right: theme.DefaultContainerPadding + 4)
            };

            scrollableWidget.AddChild(column);

            var positions = new List <Vector3>();

            PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();

            for (int i = 0; i < levelingData.SampledPositions.Count; i++)
            {
                positions.Add(levelingData.SampledPositions[i]);
            }

            int tab_index = 0;

            for (int row = 0; row < positions.Count; row++)
            {
                var leftRightEdit = new FlowLayoutWidget
                {
                    Padding = new BorderDouble(3),
                    HAnchor = HAnchor.Stretch
                };

                var positionLabel = new TextWidget("{0} {1,-5}".FormatWith("Position".Localize(), row + 1), textColor: theme.TextColor);

                positionLabel.VAnchor = VAnchor.Center;
                leftRightEdit.AddChild(positionLabel);

                for (int axis = 0; axis < 3; axis++)
                {
                    leftRightEdit.AddChild(new HorizontalSpacer());

                    string axisName = "x";
                    if (axis == 1)
                    {
                        axisName = "y";
                    }
                    else if (axis == 2)
                    {
                        axisName = "z";
                    }

                    leftRightEdit.AddChild(
                        new TextWidget($"  {axisName}: ", textColor: theme.TextColor)
                    {
                        VAnchor = VAnchor.Center
                    });

                    int linkCompatibleRow  = row;
                    int linkCompatibleAxis = axis;

                    MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], theme, allowNegatives: true, allowDecimals: true, pixelWidth: 60, tabIndex: tab_index++)
                    {
                        Name = $"{axisName} Position {row}"
                    };
                    valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) =>
                    {
                        Vector3 position = positions[linkCompatibleRow];
                        position[linkCompatibleAxis] = valueEdit.ActuallNumberEdit.Value;
                        positions[linkCompatibleRow] = position;
                    };

                    valueEdit.Margin = new BorderDouble(3);
                    leftRightEdit.AddChild(valueEdit);
                }

                column.AddChild(leftRightEdit);
            }

            var savePresetsButton = theme.CreateDialogButton("Save".Localize());

            savePresetsButton.Name   = "Save Leveling Button";
            savePresetsButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                PrintLevelingData newLevelingData = printer.Settings.Helpers.GetPrintLevelingData();

                for (int i = 0; i < newLevelingData.SampledPositions.Count; i++)
                {
                    newLevelingData.SampledPositions[i] = positions[i];
                }

                printer.Settings.Helpers.SetPrintLevelingData(newLevelingData);
                this.DialogWindow.Close();
            });
            this.AddPageAction(savePresetsButton);

            var exportButton = theme.CreateDialogButton("Export".Localize());

            exportButton.Click += (s, e) => {
                UiThread.RunOnIdle(this.ExportSettings, .1);
            };
            this.AddPageAction(exportButton);
        }
コード例 #8
0
        public EditLevelingSettingsWindow()
            : base(400, 370)
        {
            AlwaysOnTopOfMain = true;
            Title             = LocalizedString.Get("Leveling Settings".Localize());

            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     movementSpeedsLabel = LocalizedString.Get("Sampled Positions".Localize());
                TextWidget elementHeader       = new TextWidget(string.Format("{0}:", movementSpeedsLabel), 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);

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

            topToBottom.AddChild(presetsFormContainer);

            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            double oldHeight = textImageButtonFactory.FixedHeight;

            textImageButtonFactory.FixedHeight = 30 * GuiWidget.DeviceScale;

            // put in the movement edit controls
            PrintLevelingData levelingData = ActiveSliceSettings.Instance.GetPrintLevelingData();

            if (EditSamplePositionList(levelingData))
            {
                for (int i = 0; i < levelingData.SampledPositions.Count; i++)
                {
                    positions.Add(levelingData.SampledPositions[i]);
                }
            }
            else
            {
                positions.Add(levelingData.SampledPosition0);
                positions.Add(levelingData.SampledPosition1);
                positions.Add(levelingData.SampledPosition2);
            }

            int tab_index = 0;

            for (int row = 0; row < positions.Count; row++)
            {
                FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
                leftRightEdit.Padding  = new BorderDouble(3);
                leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
                TextWidget positionLabel;

                string whichPositionText = LocalizedString.Get("Position");
                positionLabel = new TextWidget("{0} {1,-5}".FormatWith(whichPositionText, row + 1), textColor: ActiveTheme.Instance.PrimaryTextColor);

                positionLabel.VAnchor = VAnchor.ParentCenter;
                leftRightEdit.AddChild(positionLabel);

                for (int axis = 0; axis < 3; axis++)
                {
                    leftRightEdit.AddChild(new HorizontalSpacer());

                    string axisName = "x";
                    if (axis == 1)
                    {
                        axisName = "y";
                    }
                    else if (axis == 2)
                    {
                        axisName = "z";
                    }

                    TextWidget typeEdit = new TextWidget("  {0}: ".FormatWith(axisName), textColor: ActiveTheme.Instance.PrimaryTextColor);
                    typeEdit.VAnchor = VAnchor.ParentCenter;
                    leftRightEdit.AddChild(typeEdit);

                    int    linkCompatibleRow  = row;
                    int    linkCompatibleAxis = axis;
                    double minValue           = double.MinValue;
                    if (axis == 2 && ActiveSliceSettings.Instance.ActiveValue("z_can_be_negative") == "0")
                    {
                        minValue = 0;
                    }
                    MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, minValue: minValue, pixelWidth: 60, tabIndex: tab_index++);
                    valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) =>
                    {
                        Vector3 position = positions[linkCompatibleRow];
                        position[linkCompatibleAxis] = valueEdit.ActuallNumberEdit.Value;
                        positions[linkCompatibleRow] = position;
                    };

                    valueEdit.Margin = new BorderDouble(3);
                    leftRightEdit.AddChild(valueEdit);
                }

                presetsFormContainer.AddChild(leftRightEdit);

                presetsFormContainer.AddChild(new CustomWidgets.HorizontalLine());
            }

            textImageButtonFactory.FixedHeight = oldHeight;

            ShowAsSystemWindow();
            MinimumSize = new Vector2(Width, Height);

            Button savePresetsButton = textImageButtonFactory.Generate("Save".Localize());

            savePresetsButton.Click += new EventHandler(save_Click);

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

            cancelPresetsButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(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(savePresetsButton);
            buttonRow.AddChild(hButtonSpacer);
            buttonRow.AddChild(cancelPresetsButton);

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
コード例 #9
0
        public EditableNumberDisplay(TextImageButtonFactory textImageButtonFactory, string startingValue, string largestPossibleValue)
            : base(Agg.UI.FlowDirection.LeftToRight)
        {
            this.Margin   = new BorderDouble(3, 0);
            this.VAnchor |= VAnchor.ParentBottomTop;

            clickableValueContainer             = new ClickWidget();
            clickableValueContainer.VAnchor     = VAnchor.ParentBottomTop;
            clickableValueContainer.Cursor      = Cursors.Hand;
            clickableValueContainer.BorderWidth = 1;
            clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);


            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);
            };

            valueDisplay           = new TextWidget(largestPossibleValue, pointSize: 12);
            valueDisplay.VAnchor   = VAnchor.ParentCenter;
            valueDisplay.HAnchor   = HAnchor.ParentLeft;
            valueDisplay.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            valueDisplay.Margin    = new BorderDouble(6);

            clickableValueContainer.Click += new EventHandler(editField_Click);

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();
            valueDisplay.Text = startingValue;

            numberInputField         = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true);
            numberInputField.VAnchor = VAnchor.ParentCenter;
            numberInputField.Margin  = new BorderDouble(left: 6);
            numberInputField.Visible = false;

            // This is a hack to make sure the control is tall enough.
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new VectorMath.Vector2(0, numberInputField.Height);

            setButton         = textImageButtonFactory.Generate("SET");
            setButton.VAnchor = VAnchor.ParentCenter;
            setButton.Margin  = new BorderDouble(left: 6);
            setButton.Visible = false;

            numberInputField.ActuallNumberEdit.EnterPressed += new KeyEventHandler(ActuallNumberEdit_EnterPressed);

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible        = false;
                    setButton.Visible = false;
                }
            };

            setButton.Click += new EventHandler(setButton_Click);

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);
            this.AddChild(setButton);
        }
コード例 #10
0
		public EditManualMovementSpeedsWindow(string windowTitle, string movementSpeedsString, EventHandler functionToCallOnSave)
			: base(260, 300)
		{
			AlwaysOnTopOfMain = true;
			Title = LocalizedString.Get(windowTitle);

			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 movementSpeedsLabel = LocalizedString.Get("Movement Speeds Presets".Localize());
				TextWidget elementHeader = new TextWidget(string.Format("{0}:", movementSpeedsLabel), 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);
			//ListBox printerListContainer = new ListBox();
			{
				presetsFormContainer.HAnchor = HAnchor.ParentLeftRight;
				presetsFormContainer.VAnchor = VAnchor.ParentBottomTop;
				presetsFormContainer.Padding = new BorderDouble(3);
				presetsFormContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			topToBottom.AddChild(presetsFormContainer);

			this.functionToCallOnSave = functionToCallOnSave;
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			double oldHeight = textImageButtonFactory.FixedHeight;
			textImageButtonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;

			TextWidget tempTypeLabel = new TextWidget(windowTitle, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempTypeLabel.Margin = new BorderDouble(3);
			tempTypeLabel.HAnchor = HAnchor.ParentLeft;
			presetsFormContainer.AddChild(tempTypeLabel);

			FlowLayoutWidget leftRightLabels = new FlowLayoutWidget();
			leftRightLabels.Padding = new BorderDouble(3, 6);
			leftRightLabels.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;

			GuiWidget hLabelSpacer = new GuiWidget();
			hLabelSpacer.HAnchor = HAnchor.ParentLeftRight;

			GuiWidget tempLabelContainer = new GuiWidget();
			tempLabelContainer.Width = 76;
			tempLabelContainer.Height = 16;
			tempLabelContainer.Margin = new BorderDouble(3, 0);

			TextWidget tempLabel = new TextWidget("mm / minute".Localize(), textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
			tempLabel.HAnchor = HAnchor.ParentLeft;
			tempLabel.VAnchor = VAnchor.ParentCenter;

			tempLabelContainer.AddChild(tempLabel);

			leftRightLabels.AddChild(hLabelSpacer);
			leftRightLabels.AddChild(tempLabelContainer);

			presetsFormContainer.AddChild(leftRightLabels);

			// put in the movement edit controls
			string[] settingsArray = movementSpeedsString.Split(',');
			int preset_count = 1;
			int tab_index = 0;
			for (int i = 0; i < settingsArray.Count() - 1; i += 2)
			{
				FlowLayoutWidget leftRightEdit = new FlowLayoutWidget();
				leftRightEdit.Padding = new BorderDouble(3);
				leftRightEdit.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
				TextWidget axisLabel;
				if (settingsArray[i].StartsWith("e"))
				{
					axisLabel = new TextWidget(string.Format("{0}(s)", "Extruder".Localize()), textColor: ActiveTheme.Instance.PrimaryTextColor);
				}
				else
				{
					axisLabel = new TextWidget(string.Format("{0} {1}", "Axis".Localize(), settingsArray[i].ToUpper()), textColor: ActiveTheme.Instance.PrimaryTextColor);
				}
				axisLabel.VAnchor = VAnchor.ParentCenter;
				leftRightEdit.AddChild(axisLabel);

				leftRightEdit.AddChild(new HorizontalSpacer());

				// we add this to the listWithValues to make sure we build the string correctly on save.
				TextWidget typeEdit = new TextWidget(settingsArray[i]);
				listWithValues.Add(typeEdit);

				double movementSpeed = 0;
				double.TryParse(settingsArray[i + 1], out movementSpeed);
				MHNumberEdit valueEdit = new MHNumberEdit(movementSpeed, minValue: 0, pixelWidth: 60, tabIndex: tab_index++);
				valueEdit.Margin = new BorderDouble(3);
				leftRightEdit.AddChild(valueEdit);
				listWithValues.Add(valueEdit);

				//leftRightEdit.AddChild(textImageButtonFactory.Generate("Delete"));
				presetsFormContainer.AddChild(leftRightEdit);
				preset_count += 1;
			}

			textImageButtonFactory.FixedHeight = oldHeight;

			ShowAsSystemWindow();
			MinimumSize = new Vector2(260, 300);

			Button savePresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
			savePresetsButton.Click += new EventHandler(save_Click);

			Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
			cancelPresetsButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(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(savePresetsButton);
			buttonRow.AddChild(hButtonSpacer);
			buttonRow.AddChild(cancelPresetsButton);

			topToBottom.AddChild(buttonRow);

			AddChild(topToBottom);
		}
コード例 #11
0
        private void AddRotateControls(FlowLayoutWidget buttonPanel)
        {
            List<GuiWidget> rotateControls = new List<GuiWidget>();
			transformControls.Add(new LocalizedString("Rotate").Translated, rotateControls);

            textImageButtonFactory.FixedWidth = 44;

            FlowLayoutWidget degreesContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            degreesContainer.HAnchor = HAnchor.ParentLeftRight;
            degreesContainer.Padding = new BorderDouble(5);

            GuiWidget horizontalSpacer = new GuiWidget();
            horizontalSpacer.HAnchor = HAnchor.ParentLeftRight;

			string degreesLabelTxt = new LocalizedString("Degrees").Translated;
			string degreesLabelTxtFull = string.Format("{0}:", degreesLabelTxt);
			TextWidget degreesLabel = new TextWidget(degreesLabelTxt, textColor: RGBA_Bytes.White);
            degreesContainer.AddChild(degreesLabel);
            degreesContainer.AddChild(horizontalSpacer);

            MHNumberEdit degreesControl = new MHNumberEdit(45, pixelWidth: 40, allowNegatives: true, increment: 5, minValue: -360, maxValue: 360);
            degreesControl.VAnchor = Agg.UI.VAnchor.ParentTop;
            degreesContainer.AddChild(degreesControl);
            rotateControls.Add(degreesControl);

            buttonPanel.AddChild(degreesContainer);

            FlowLayoutWidget rotateButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            rotateButtonContainer.HAnchor = HAnchor.ParentLeftRight;

            Button rotateXButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredX = new TextWidget("X", pointSize: 10, textColor: RGBA_Bytes.White); centeredX.Margin = new BorderDouble(3, 0, 0, 0); centeredX.AnchorCenter(); rotateXButton.AddChild(centeredX);
            rotateButtonContainer.AddChild(rotateXButton);
            rotateControls.Add(rotateXButton);
            rotateXButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationX(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                PlatingHelper.PlaceMeshOnBed(Meshes, MeshTransforms, SelectedMeshIndex, false);
                saveButton.Visible = true;
                Invalidate();
            };

            Button rotateYButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredY = new TextWidget("Y", pointSize: 10, textColor: RGBA_Bytes.White); centeredY.Margin = new BorderDouble(3, 0, 0, 0); centeredY.AnchorCenter(); rotateYButton.AddChild(centeredY);
            rotateButtonContainer.AddChild(rotateYButton);
            rotateControls.Add(rotateYButton);
            rotateYButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationY(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                PlatingHelper.PlaceMeshOnBed(Meshes, MeshTransforms, SelectedMeshIndex, false);
                saveButton.Visible = true;
                Invalidate();
            };

            Button rotateZButton = textImageButtonFactory.Generate("", "icon_rotate_32x32.png");
            TextWidget centeredZ = new TextWidget("Z", pointSize: 10, textColor: RGBA_Bytes.White); centeredZ.Margin = new BorderDouble(3, 0, 0, 0); centeredZ.AnchorCenter(); rotateZButton.AddChild(centeredZ);
            rotateButtonContainer.AddChild(rotateZButton);
            rotateControls.Add(rotateZButton);
            rotateZButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                double radians = MathHelper.DegreesToRadians(degreesControl.ActuallNumberEdit.Value);
                AxisAlignedBoundingBox bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                Vector3 startingCenter = bounds.Center;
                // move it to the origin so it rotates about it's center
                Matrix4X4 totalTransfrom = Matrix4X4.CreateTranslation(-startingCenter);
                // rotate it
                totalTransfrom *= Matrix4X4.CreateRotationZ(radians);
                SelectedMeshTransform *= totalTransfrom;
                // find the new center
                bounds = SelectedMesh.GetAxisAlignedBoundingBox(SelectedMeshTransform);
                // and shift it back so the new center is where the old center was
                SelectedMeshTransform *= Matrix4X4.CreateTranslation(startingCenter - bounds.Center);
                saveButton.Visible = true;
                Invalidate();
            };

            buttonPanel.AddChild(rotateButtonContainer);

			Button layFlatButton = whiteButtonFactory.Generate(new LocalizedString("Align to Bed").Translated, centerText: true);
            layFlatButton.Cursor = Cursors.Hand;
            buttonPanel.AddChild(layFlatButton);

            layFlatButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                MakeLowestFaceFlat(SelectedMeshIndex);

                saveButton.Visible = true;
                Invalidate();
            };

            buttonPanel.AddChild(generateHorizontalRule());
            textImageButtonFactory.FixedWidth = 0;
        }
コード例 #12
0
        private void AddScaleControls(FlowLayoutWidget buttonPanel)
        {
            List<GuiWidget> scaleControls = new List<GuiWidget>();
            transformControls.Add("Scale", scaleControls);

            FlowLayoutWidget scaleRatioContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            scaleRatioContainer.HAnchor = HAnchor.ParentLeftRight;
            scaleRatioContainer.Padding = new BorderDouble(5);

			string scaleRatioLblTxt = new LocalizedString("Ratio").Translated;
			string scaleRatioLblTxtFull = string.Format("{0}:", scaleRatioLblTxt);
			TextWidget scaleRatioLabel = new TextWidget(scaleRatioLblTxtFull, textColor: RGBA_Bytes.White);
            scaleRatioLabel.VAnchor = VAnchor.ParentCenter;
            scaleRatioContainer.AddChild(scaleRatioLabel);

            GuiWidget horizontalSpacer = new GuiWidget();
            horizontalSpacer.HAnchor = HAnchor.ParentLeftRight;
            scaleRatioContainer.AddChild(horizontalSpacer);

            scaleRatioControl = new MHNumberEdit(1, pixelWidth: 50, allowDecimals: true, increment: .05);
            scaleRatioContainer.AddChild(scaleRatioControl);
            scaleRatioControl.ActuallNumberEdit.KeyPressed += (sender, e) =>
            {
                double scale = scaleRatioControl.ActuallNumberEdit.Value;
                if (scale != MeshExtraData[SelectedMeshIndex].currentScale)
                {
                    applyScaleButton.Visible = true;
                }
                else
                {
                    applyScaleButton.Visible = false;
                }
            };

            buttonPanel.AddChild(scaleRatioContainer);

            scaleControls.Add(scaleRatioControl);
            scaleRatioControl.ActuallNumberEdit.EnterPressed += (object sender, KeyEventArgs keyEvent) =>
            {
                ApplyScaleFromEditField();
            };

			DropDownMenu presetScaleMenu = new DropDownMenu(new LocalizedString("Conversions").Translated, Direction.Down);
            RectangleDouble presetBounds = presetScaleMenu.LocalBounds;
            presetBounds.Inflate(new BorderDouble(5, 10, 10, 10));
            presetScaleMenu.LocalBounds = presetBounds;
            presetScaleMenu.MenuAsWideAsItems = false;
            presetScaleMenu.HAnchor |= HAnchor.ParentLeftRight;

            presetScaleMenu.AddItem("mm to in (.03937)");
            presetScaleMenu.AddItem("in to mm (25.4)");
            presetScaleMenu.AddItem("mm to cm (.1)");
            presetScaleMenu.AddItem("cm to mm (10)");
			string resetLbl = new LocalizedString ("reset").Translated;
			string resetLblFull = string.Format("{0} (1)",resetLbl);
			presetScaleMenu.AddItem(resetLblFull);


            presetScaleMenu.SelectionChanged += (sender, e) =>
            {
                double scale = 1;
                switch (presetScaleMenu.SelectedIndex)
                {
                    case 0:
                        scale = 1.0 / 25.4;
                        break;
                    case 1:
                        scale = 25.4;
                        break;
                    case 2:
                        scale = .1;
                        break;
                    case 3:
                        scale = 10;
                        break;
                    case 4:
                        scale = 1;
                        break;
                }

                scaleRatioControl.ActuallNumberEdit.Value = scale;
                ApplyScaleFromEditField();
            };

            buttonPanel.AddChild(presetScaleMenu);

			applyScaleButton = whiteButtonFactory.Generate(new LocalizedString("Apply Scale").Translated, centerText: true);
            applyScaleButton.Visible = false;
            applyScaleButton.Cursor = Cursors.Hand;
            buttonPanel.AddChild(applyScaleButton);

            scaleControls.Add(applyScaleButton);
            applyScaleButton.Click += (object sender, MouseEventArgs mouseEvent) =>
            {
                ApplyScaleFromEditField();
            };

            buttonPanel.AddChild(generateHorizontalRule());
        }
コード例 #13
0
        public EditableNumberDisplay(TextImageButtonFactory textImageButtonFactory, string startingValue, string largestPossibleValue)
            : base(Agg.UI.FlowDirection.LeftToRight)
        {
            this.Margin = new BorderDouble(3, 0);
            this.VAnchor |= VAnchor.ParentBottomTop;

            clickableValueContainer = new ClickWidget();
            clickableValueContainer.VAnchor = VAnchor.ParentBottomTop;
            clickableValueContainer.Cursor = Cursors.Hand;
            clickableValueContainer.BorderWidth = 1;
            clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);


            clickableValueContainer.MouseEnterBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 2;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 255);
            };

            clickableValueContainer.MouseLeaveBounds += (sender, e) =>
            {
                clickableValueContainer.BorderWidth = 1;
                clickableValueContainer.BorderColor = new RGBA_Bytes(255, 255, 255, 140);
            };

            valueDisplay = new TextWidget(largestPossibleValue, pointSize: 12);
            valueDisplay.VAnchor = VAnchor.ParentCenter;
            valueDisplay.HAnchor = HAnchor.ParentLeft;
            valueDisplay.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            valueDisplay.Margin = new BorderDouble(6);

            clickableValueContainer.Click += new ClickWidget.ButtonEventHandler(editField_Click);

            clickableValueContainer.AddChild(valueDisplay);
            clickableValueContainer.SetBoundsToEncloseChildren();
            valueDisplay.Text = startingValue;

            numberInputField = new MHNumberEdit(0, pixelWidth: 40, allowDecimals: true);
            numberInputField.VAnchor = VAnchor.ParentCenter;
            numberInputField.Margin = new BorderDouble(left: 6);
            numberInputField.Visible = false;

            // This is a hack to make sure the control is tall enough. 
            // TODO: This hack needs a unit test and then pass and then remove this line.
            this.MinimumSize = new VectorMath.Vector2(0, numberInputField.Height);

			setButton = textImageButtonFactory.Generate("SET");
            setButton.VAnchor = VAnchor.ParentCenter;
            setButton.Margin = new BorderDouble(left: 6);
            setButton.Visible = false;

            numberInputField.ActuallNumberEdit.EnterPressed += new KeyEventHandler(ActuallNumberEdit_EnterPressed);

            numberInputField.KeyDown += (sender, e) =>
            {
                if (e.KeyCode == Keys.Escape)
                {
                    clickableValueContainer.Visible = true;
                    numberInputField.Visible = false;
                    setButton.Visible = false;
                }
            };

            setButton.Click += new ButtonBase.ButtonEventHandler(setButton_Click);

            this.AddChild(clickableValueContainer);
            this.AddChild(numberInputField);
            this.AddChild(setButton);
        }
コード例 #14
0
        public EditLevelingSettingsPage(PrinterConfig printer)
        {
            var theme = ApplicationController.Instance.Theme;

            this.WindowTitle = "Leveling Settings".Localize();
            this.HeaderText  = "Sampled Positions".Localize();

            var scrollableWidget = new ScrollableWidget()
            {
                AutoScroll = true,
                HAnchor    = HAnchor.Stretch,
                VAnchor    = VAnchor.Stretch,
            };

            scrollableWidget.ScrollArea.HAnchor = HAnchor.Stretch;
            contentRow.AddChild(scrollableWidget);
            var scrollArrea = new FlowLayoutWidget(FlowDirection.TopToBottom)
            {
                HAnchor = HAnchor.Stretch,
            };

            scrollableWidget.AddChild(scrollArrea);

            var positions = new List <Vector3>();

            PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();

            for (int i = 0; i < levelingData.SampledPositions.Count; i++)
            {
                positions.Add(levelingData.SampledPositions[i]);
            }

            int tab_index = 0;

            for (int row = 0; row < positions.Count; row++)
            {
                var leftRightEdit = new FlowLayoutWidget
                {
                    Padding = new BorderDouble(3),
                    HAnchor = HAnchor.Stretch
                };

                var positionLabel = new TextWidget("{0} {1,-5}".FormatWith("Position".Localize(), row + 1), textColor: ActiveTheme.Instance.PrimaryTextColor);

                positionLabel.VAnchor = VAnchor.Center;
                leftRightEdit.AddChild(positionLabel);

                for (int axis = 0; axis < 3; axis++)
                {
                    leftRightEdit.AddChild(new HorizontalSpacer());

                    string axisName = "x";
                    if (axis == 1)
                    {
                        axisName = "y";
                    }
                    else if (axis == 2)
                    {
                        axisName = "z";
                    }

                    leftRightEdit.AddChild(
                        new TextWidget($"  {axisName}: ", textColor: ActiveTheme.Instance.PrimaryTextColor)
                    {
                        VAnchor = VAnchor.Center
                    });

                    int linkCompatibleRow  = row;
                    int linkCompatibleAxis = axis;

                    MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, pixelWidth: 60, tabIndex: tab_index++);
                    valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) =>
                    {
                        Vector3 position = positions[linkCompatibleRow];
                        position[linkCompatibleAxis] = valueEdit.ActuallNumberEdit.Value;
                        positions[linkCompatibleRow] = position;
                    };

                    valueEdit.Margin = new BorderDouble(3);
                    leftRightEdit.AddChild(valueEdit);
                }

                scrollArrea.AddChild(leftRightEdit);
            }

            var savePresetsButton = theme.CreateDialogButton("Save".Localize());

            savePresetsButton.Click += (s, e) => UiThread.RunOnIdle(() =>
            {
                PrintLevelingData newLevelingData = printer.Settings.Helpers.GetPrintLevelingData();

                for (int i = 0; i < newLevelingData.SampledPositions.Count; i++)
                {
                    newLevelingData.SampledPositions[i] = positions[i];
                }

                printer.Settings.Helpers.SetPrintLevelingData(newLevelingData, false);
                this.DialogWindow.Close();
            });

            this.AddPageAction(savePresetsButton);
        }
コード例 #15
0
        private GuiWidget CreateSettingInfoUIControls(OrganizerSettingsData settingData, double minSettingNameWidth)
        {
            FlowLayoutWidget leftToRightLayout = new FlowLayoutWidget();

            if (ActiveSliceSettings.Instance.Contains(settingData.SlicerConfigName))
            {
                int intEditWidth        = 60;
                int doubleEditWidth     = 60;
                int vectorXYEditWidth   = 60;
                int multiLineEditHeight = 60;

                string sliceSettingValue = ActiveSliceSettings.Instance.GetActiveValue(settingData.SlicerConfigName);
                leftToRightLayout.Margin   = new BorderDouble(0, 5);
                leftToRightLayout.HAnchor |= Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                if (settingData.DataEditType != OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT)
                {
                    string convertedNewLines = settingData.PresentationName.Replace("\\n ", "\n");
                    convertedNewLines = convertedNewLines.Replace("\\n", "\n");
                    convertedNewLines = new LocalizedString(convertedNewLines).Translated;
                    TextWidget settingName = new TextWidget(convertedNewLines);
                    settingName.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                    settingName.Width     = minSettingNameWidth;
                    //settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y);
                    leftToRightLayout.AddChild(settingName);
                }

                switch (settingData.DataEditType)
                {
                case OrganizerSettingsData.DataEditTypes.INT:
                {
                    int currentValue = 0;
                    int.TryParse(sliceSettingValue, out currentValue);
                    MHNumberEdit intEditWidget = new MHNumberEdit(currentValue, pixelWidth: intEditWidth, tabIndex: tabIndexForItem++);
                    intEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
                    leftToRightLayout.AddChild(intEditWidget);
                    leftToRightLayout.AddChild(getSettingInfoData(settingData));
                }
                break;

                case OrganizerSettingsData.DataEditTypes.DOUBLE:
                {
                    double currentValue = 0;
                    double.TryParse(sliceSettingValue, out currentValue);
                    MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowNegatives: true, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
                    doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
                    leftToRightLayout.AddChild(doubleEditWidget);
                    leftToRightLayout.AddChild(getSettingInfoData(settingData));
                }
                break;

                case OrganizerSettingsData.DataEditTypes.POSITVE_DOUBLE:
                {
                    double currentValue = 0;
                    double.TryParse(sliceSettingValue, out currentValue);
                    MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
                    doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
                    leftToRightLayout.AddChild(doubleEditWidget);
                    leftToRightLayout.AddChild(getSettingInfoData(settingData));
                }
                break;

                case OrganizerSettingsData.DataEditTypes.OFFSET:
                {
                    double currentValue = 0;
                    double.TryParse(sliceSettingValue, out currentValue);
                    MHNumberEdit doubleEditWidget = new MHNumberEdit(currentValue, allowDecimals: true, allowNegatives: true, pixelWidth: doubleEditWidth, tabIndex: tabIndexForItem++);
                    doubleEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((NumberEdit)sender).Value.ToString()); };
                    leftToRightLayout.AddChild(doubleEditWidget);
                    leftToRightLayout.AddChild(getSettingInfoData(settingData));
                }
                break;

                case OrganizerSettingsData.DataEditTypes.DOUBLE_OR_PERCENT:
                {
                    MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 60, tabIndex: tabIndexForItem++);
                    stringEdit.ActualTextEditWidget.EditComplete += (sender, e) =>
                    {
                        TextEditWidget textEditWidget = (TextEditWidget)sender;
                        string         text           = textEditWidget.Text;
                        text = text.Trim();
                        bool isPercent = text.Contains("%");
                        if (isPercent)
                        {
                            text = text.Substring(0, text.IndexOf("%"));
                        }
                        double result;
                        double.TryParse(text, out result);
                        text = result.ToString();
                        if (isPercent)
                        {
                            text += "%";
                        }
                        textEditWidget.Text = text;
                        SaveSetting(settingData.SlicerConfigName, textEditWidget.Text);
                    };

                    leftToRightLayout.AddChild(stringEdit);
                    leftToRightLayout.AddChild(getSettingInfoData(settingData));
                }
                break;

                case OrganizerSettingsData.DataEditTypes.CHECK_BOX:
                {
                    CheckBox checkBoxWidget = new CheckBox("");
                    checkBoxWidget.VAnchor              = Agg.UI.VAnchor.ParentBottom;
                    checkBoxWidget.TextColor            = ActiveTheme.Instance.PrimaryTextColor;
                    checkBoxWidget.Checked              = (sliceSettingValue == "1");
                    checkBoxWidget.CheckedStateChanged += (sender, e) =>
                    {
                        if (((CheckBox)sender).Checked)
                        {
                            SaveSetting(settingData.SlicerConfigName, "1");
                        }
                        else
                        {
                            SaveSetting(settingData.SlicerConfigName, "0");
                        }
                    };
                    leftToRightLayout.AddChild(checkBoxWidget);
                }
                break;

                case OrganizerSettingsData.DataEditTypes.STRING:
                {
                    MHTextEditWidget stringEdit = new MHTextEditWidget(sliceSettingValue, pixelWidth: 120, tabIndex: tabIndexForItem++);
                    stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text); };
                    leftToRightLayout.AddChild(stringEdit);
                }
                break;

                case OrganizerSettingsData.DataEditTypes.MULTI_LINE_TEXT:
                {
                    string           convertedNewLines = sliceSettingValue.Replace("\\n", "\n");
                    MHTextEditWidget stringEdit        = new MHTextEditWidget(convertedNewLines, pixelWidth: 320, pixelHeight: multiLineEditHeight, multiLine: true, tabIndex: tabIndexForItem++);
                    stringEdit.ActualTextEditWidget.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, ((TextEditWidget)sender).Text.Replace("\n", "\\n")); };
                    leftToRightLayout.AddChild(stringEdit);
                }
                break;

                case OrganizerSettingsData.DataEditTypes.LIST:
                {
                    StyledDropDownList selectableOptions = new StyledDropDownList("None", Direction.Up);
                    selectableOptions.Margin = new BorderDouble();

                    string[] listItems = settingData.ExtraSettings.Split(',');
                    foreach (string listItem in listItems)
                    {
                        MenuItem newItem = selectableOptions.AddItem(listItem);
                        if (newItem.Text == sliceSettingValue)
                        {
                            selectableOptions.SelectedValue = sliceSettingValue;
                        }

                        newItem.Selected += (sender, e) =>
                        {
                            MenuItem menuItem = ((MenuItem)sender);
                            SaveSetting(settingData.SlicerConfigName, menuItem.Text);
                        };
                    }
                    leftToRightLayout.AddChild(selectableOptions);
                }
                break;

                case OrganizerSettingsData.DataEditTypes.VECTOR2:
                {
                    string[] xyValueStrings = sliceSettingValue.Split(',');
                    if (xyValueStrings.Length != 2)
                    {
                        xyValueStrings = new string[] { "0", "0" };
                    }
                    double currentXValue = 0;
                    double.TryParse(xyValueStrings[0], out currentXValue);
                    MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);

                    double currentYValue = 0;
                    double.TryParse(xyValueStrings[1], out currentYValue);
                    MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
                    {
                        xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); };
                        leftToRightLayout.AddChild(xEditWidget);
                        TextWidget xText = new TextWidget("x");
                        xText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        xText.Margin    = new BorderDouble(5, 0);
                        leftToRightLayout.AddChild(xText);
                    }
                    {
                        yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "," + yEditWidget.ActuallNumberEdit.Value.ToString()); };
                        leftToRightLayout.AddChild(yEditWidget);
                        TextWidget yText = new TextWidget("y");
                        yText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        yText.Margin    = new BorderDouble(5, 0);
                        leftToRightLayout.AddChild(yText);
                    }
                }
                break;

                case OrganizerSettingsData.DataEditTypes.OFFSET2:
                {
                    string[] xyValueStrings = sliceSettingValue.Split('x');
                    if (xyValueStrings.Length != 2)
                    {
                        xyValueStrings = new string[] { "0", "0" };
                    }
                    double currentXValue = 0;
                    double.TryParse(xyValueStrings[0], out currentXValue);
                    MHNumberEdit xEditWidget = new MHNumberEdit(currentXValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);

                    double currentYValue = 0;
                    double.TryParse(xyValueStrings[1], out currentYValue);
                    MHNumberEdit yEditWidget = new MHNumberEdit(currentYValue, allowDecimals: true, allowNegatives: true, pixelWidth: vectorXYEditWidth, tabIndex: tabIndexForItem++);
                    {
                        xEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); };
                        leftToRightLayout.AddChild(xEditWidget);
                        TextWidget xText = new TextWidget("x");
                        xText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        xText.Margin    = new BorderDouble(5, 0);
                        leftToRightLayout.AddChild(xText);
                    }
                    {
                        yEditWidget.ActuallNumberEdit.EditComplete += (sender, e) => { SaveSetting(settingData.SlicerConfigName, xEditWidget.ActuallNumberEdit.Value.ToString() + "x" + yEditWidget.ActuallNumberEdit.Value.ToString()); };
                        leftToRightLayout.AddChild(yEditWidget);
                        TextWidget yText = new TextWidget("y");
                        yText.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                        yText.Margin    = new BorderDouble(5, 0);
                        leftToRightLayout.AddChild(yText);
                    }
                }
                break;

                default:
                    TextWidget missingSetting = new TextWidget(String.Format("Missing the setting for '{0}'.", settingData.DataEditType.ToString()));
                    missingSetting.TextColor       = ActiveTheme.Instance.PrimaryTextColor;
                    missingSetting.BackgroundColor = RGBA_Bytes.Red;
                    leftToRightLayout.AddChild(missingSetting);
                    break;
                }
            }
            else // the setting we think we are adding is not in the config.ini it may have been depricated
            {
                TextWidget settingName = new TextWidget(String.Format("Setting '{0}' not found in config.ini", settingData.SlicerConfigName));
                settingName.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
                settingName.MinimumSize = new Vector2(minSettingNameWidth, settingName.MinimumSize.y);
                leftToRightLayout.AddChild(settingName);
                leftToRightLayout.BackgroundColor = RGBA_Bytes.Red;
            }

            return(leftToRightLayout);
        }