Пример #1
0
		public CompactSlidePanel(QueueDataView queueDataView) : base(2)
		{
			this.queueDataView = queueDataView;

			// do the front panel stuff
			{
				// first add the print progress bar
				this.LeftPanel.AddChild(new PrintProgressBar());

				// construct the main controls tab control
				mainControlsTabControl = new FirstPanelTabView(queueDataView);

				var advancedControlsButtonFactory = new TextImageButtonFactory()
				{
					normalTextColor = ActiveTheme.Instance.PrimaryTextColor,
					hoverTextColor = ActiveTheme.Instance.PrimaryTextColor,
					pressedTextColor = ActiveTheme.Instance.PrimaryTextColor,
					fontSize = 10,

					disabledTextColor = RGBA_Bytes.LightGray,
					disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor,
					disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor,

					invertImageLocation = true
				};

				Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Settings\n& Controls"), "icon_arrow_right_32x32.png");
				advancedControlsLinkButton.Name = "SettingsAndControls";
				advancedControlsLinkButton.ToolTipText = "Switch to Settings, Controls and Options".Localize();
				advancedControlsLinkButton.Margin = new BorderDouble(right: 3);
				advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom;
				advancedControlsLinkButton.Cursor = Cursors.Hand;
				advancedControlsLinkButton.Click += ToggleActivePanel_Click;

				mainControlsTabControl.TabBar.AddChild(new HorizontalSpacer());
				mainControlsTabControl.TabBar.AddChild(advancedControlsLinkButton);
				mainControlsTabControl.TabBar.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;
				mainControlsTabControl.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;

				this.LeftPanel.AddChild(mainControlsTabControl);
			}

			// Right panel
			this.RightPanel.AddChild(new PrintProgressBar());

			var advancedControlsPanel = new AdvancedControlsPanel()
			{
				Name = "For - CompactSlidePanel"
			};
			advancedControlsPanel.BackClicked += ToggleActivePanel_Click;

			this.RightPanel.AddChild(advancedControlsPanel);

			WidescreenPanel.PreChangePanels.RegisterEvent(SaveCurrentPanelIndex, ref unregisterEvents);

			SetPanelIndexImmediate(lastPanelIndexBeforeReload);
		}
Пример #2
0
		public CompactSlidePanel(QueueDataView queueDataView)
			: base(2)
		{
			this.queueDataView = queueDataView;

			// do the front panel stuff
			{
				// first add the print progress bar
				this.LeftPanel.AddChild(new PrintProgressBar());

				// construct the main controls tab control
				mainControlsTabControl = new FirstPanelTabView(queueDataView);

				TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
				advancedControlsButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
				advancedControlsButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
				advancedControlsButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
				advancedControlsButtonFactory.fontSize = 10;

				advancedControlsButtonFactory.disabledTextColor = RGBA_Bytes.LightGray;
				advancedControlsButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				advancedControlsButtonFactory.disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor;

				advancedControlsButtonFactory.invertImageLocation = true;
				Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Settings\n& Controls"), "icon_arrow_right_32x32.png");
                advancedControlsLinkButton.Name = "SettingsAndControls";
                advancedControlsLinkButton.ToolTipText = "Switch to Settings, Controls and Options".Localize();
                advancedControlsLinkButton.Margin = new BorderDouble(right: 3);
				advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom;
				advancedControlsLinkButton.Cursor = Cursors.Hand;
				advancedControlsLinkButton.Click += new EventHandler(AdvancedControlsButton_Click);
				advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsAdvancedControlsLink);
				advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsAdvancedControlsLink);

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

				mainControlsTabControl.TabBar.AddChild(hSpacer);
				mainControlsTabControl.TabBar.AddChild(advancedControlsLinkButton);
				mainControlsTabControl.TabBar.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;
				mainControlsTabControl.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;

				this.LeftPanel.AddChild(mainControlsTabControl);
			}

			// do the right panel
			{
				this.RightPanel.AddChild(new PrintProgressBar());
				ThirdPanelTabView thirdPanelTabView = new ThirdPanelTabView(AdvancedControlsButton_Click, onMouseEnterBoundsPrintQueueLink, onMouseLeaveBoundsPrintQueueLink);
				thirdPanelTabView.Name = "For - CompactSlidePanel";
				this.RightPanel.AddChild(thirdPanelTabView);
			}

			WidescreenPanel.PreChangePanels.RegisterEvent(SaveCurrentPanelIndex, ref unregisterEvents);

			SetPanelIndexImediate(lastPanelIndexBeforeReload);
		}
Пример #3
0
		private Button CreateDefaultButton(string buttonText)
		{
			TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
			buttonFactory.FixedHeight = 30 * TextWidget.GlobalPointSizeScaleRatio;
			buttonFactory.normalFillColor = RGBA_Bytes.White;
			buttonFactory.normalTextColor = RGBA_Bytes.Black;
			buttonFactory.hoverTextColor = RGBA_Bytes.Black;
			buttonFactory.hoverFillColor = new RGBA_Bytes(255, 255, 255, 200);
			buttonFactory.borderWidth = 1;
			buttonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
			buttonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);

			return buttonFactory.Generate(buttonText, centerText: true);
		}
		private Button CreateButton(Tuple<string, Func<bool>> buttonInfo)
		{
			TextImageButtonFactory buttonFactory = new TextImageButtonFactory();

			buttonFactory.FixedHeight = this.FixedHeight;
			buttonFactory.normalFillColor = this.normalFillColor;
			buttonFactory.normalTextColor = this.normalTextColor;
			buttonFactory.hoverTextColor = this.hoverTextColor;
			buttonFactory.hoverFillColor = this.hoverFillColor;
			buttonFactory.borderWidth = 1;
			buttonFactory.normalBorderColor = this.normalBorderColor;
			buttonFactory.hoverBorderColor = this.hoverBorderColor;

			Button button = buttonFactory.Generate(buttonInfo.Item1, normalImageName: imageName, centerText: true);

			button.Click += (object sender, EventArgs e) =>
			{
				buttonInfo.Item2();
			};

			return button;
		}
		public EnterCodesView(TextImageButtonFactory textImageButtonFactory) : base("")
		{
			this.textImageButtonFactory = textImageButtonFactory;
			FlowLayoutWidget buttonContainer = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.ParentLeftRight,
				Margin = new BorderDouble(0, 14)
			};
			mainContainer.AddChild(buttonContainer);

			if (UserSettings.Instance.IsTouchScreen)
			{
				// the redeem design code button
				Button redeemPurchaseButton = textImageButtonFactory.Generate("Redeem Purchase".Localize());
				redeemPurchaseButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it.
				redeemPurchaseButton.Name = "Redeem Code Button";
				redeemPurchaseButton.Margin = new BorderDouble(0, 0, 10, 0);
				redeemPurchaseButton.Click += (sender, e) =>
				{
					RedeemDesignCode?.Invoke(this, null);
				};
				buttonContainer.AddChild(redeemPurchaseButton);

				// the redeem a share code button
				Button redeemShareButton = textImageButtonFactory.Generate("Enter Share Code".Localize());
				redeemShareButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it.
				redeemShareButton.Name = "Enter Share Code";
				redeemShareButton.Margin = new BorderDouble(0, 0, 3, 0);
				redeemShareButton.Click += (sender, e) =>
				{
					EnterShareCode?.Invoke(this, null);
				};

				buttonContainer.AddChild(redeemShareButton);
			}
		}
		private TabControl CreateAdvancedControlsTab()
		{
			TabControl advancedControls = new TabControl();

			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
			advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
			advancedControls.TabBar.Margin = new BorderDouble(0, 0);
			advancedControls.TabBar.Padding = new BorderDouble(0, 2);

			int textSize = 16;

			// this means we are in compact view and so we will make the tabs text a bit smaller
			textSize = 14;
			TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
			advancedControlsButtonFactory.fontSize = 14;
			advancedControlsButtonFactory.invertImageLocation = false;
			backButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), StaticData.Instance.LoadIcon("icon_arrow_left_32x32.png", 32,32));
			backButton.ToolTipText = "Switch to Queue, Library and History".Localize();
			backButton.Margin = new BorderDouble(right: 3);
			backButton.VAnchor = VAnchor.ParentBottom;
			backButton.Cursor = Cursors.Hand;
			backButton.Click += (s, e) => BackClicked?.Invoke(this, null);

			advancedControls.TabBar.AddChild(backButton);

			advancedControls.TabBar.AddChild(new HorizontalSpacer());

			GuiWidget manualPrinterControls = new ManualPrinterControls();

			ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);
			manualPrinterControlsScrollArea.ScrollArea.HAnchor |= HAnchor.ParentLeftRight;
			manualPrinterControlsScrollArea.AnchorAll();
			manualPrinterControlsScrollArea.AddChild(manualPrinterControls);

			RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

			if (ActiveSliceSettings.Instance.PrinterSelected)
			{
				sliceSettingsWidget = new SliceSettingsWidget();
			}
			else
			{
				sliceSettingsWidget = new NoSettingsWidget();
			}

			var sliceSettingsTabPage = new TabPage(sliceSettingsWidget, "Settings".Localize().ToUpper());
			var sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize);
			advancedControls.AddTab(sliceSettingPopOut);
			
			var controlsTabPage = new TabPage(manualPrinterControlsScrollArea, "Controls".Localize().ToUpper());
			var controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize);
			advancedControls.AddTab(controlsPopOut);

#if !__ANDROID__
			MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut;
			MenuOptionSettings.controlsPopOut = controlsPopOut;
#endif

			var optionsControls = new PrinterConfigurationScrollWidget();
			advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, "Options".Localize().ToUpper()), "Options Tab", textSize,
						ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

			// Make sure we are on the right tab when we create this view
			{
				string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab);
				advancedControls.SelectTab(selectedTab);

				advancedControls.TabBar.TabIndexChanged += (sender, e) =>
				{
					string selectedTabName = advancedControls.TabBar.SelectedTabName;
					if (!string.IsNullOrEmpty(selectedTabName))
					{
						UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, selectedTabName);
					}
				};
			}

			return advancedControls;
		}
        private TabControl CreateAdvancedControlsTab()
        {
            TabControl advancedControls = new TabControl();

            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
            advancedControls.TabBar.Margin      = new BorderDouble(0, 0);
            advancedControls.TabBar.Padding     = new BorderDouble(0, 2);

            int textSize = 16;

            // this means we are in compact view and so we will make the tabs text a bit smaller
            textSize = 14;
            TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();

            advancedControlsButtonFactory.fontSize            = 14;
            advancedControlsButtonFactory.invertImageLocation = false;
            backButton             = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), StaticData.Instance.LoadIcon("icon_arrow_left_32x32.png", 32, 32));
            backButton.ToolTipText = "Switch to Queue, Library and History".Localize();
            backButton.Margin      = new BorderDouble(right: 3);
            backButton.VAnchor     = VAnchor.ParentBottom;
            backButton.Cursor      = Cursors.Hand;
            backButton.Click      += (s, e) => BackClicked?.Invoke(this, null);

            advancedControls.TabBar.AddChild(backButton);

            advancedControls.TabBar.AddChild(new HorizontalSpacer());

            GuiWidget manualPrinterControls = new ManualPrinterControls();

            ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);

            manualPrinterControlsScrollArea.ScrollArea.HAnchor |= HAnchor.ParentLeftRight;
            manualPrinterControlsScrollArea.AnchorAll();
            manualPrinterControlsScrollArea.AddChild(manualPrinterControls);

            RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

            if (ActiveSliceSettings.Instance.PrinterSelected)
            {
                sliceSettingsWidget = new SliceSettingsWidget();
            }
            else
            {
                sliceSettingsWidget = new NoSettingsWidget();
            }

            var sliceSettingsTabPage = new TabPage(sliceSettingsWidget, "Settings".Localize().ToUpper());
            var sliceSettingPopOut   = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize);

            advancedControls.AddTab(sliceSettingPopOut);

            var controlsTabPage = new TabPage(manualPrinterControlsScrollArea, "Controls".Localize().ToUpper());
            var controlsPopOut  = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize);

            advancedControls.AddTab(controlsPopOut);

#if !__ANDROID__
            MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut;
            MenuOptionSettings.controlsPopOut      = controlsPopOut;
#endif

            var optionsControls = new PrinterConfigurationScrollWidget();
            advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(optionsControls, "Options".Localize().ToUpper()), "Options Tab", textSize,
                                                            ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

            // Make sure we are on the right tab when we create this view
            {
                string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab);
                advancedControls.SelectTab(selectedTab);

                advancedControls.TabBar.TabIndexChanged += (sender, e) =>
                {
                    string selectedTabName = advancedControls.TabBar.SelectedTabName;
                    if (!string.IsNullOrEmpty(selectedTabName))
                    {
                        UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, selectedTabName);
                    }
                };
            }

            return(advancedControls);
        }
        public EditableNumberDisplay(TextImageButtonFactory textImageButtonFactory, string startingValue, string largestPossibleValue)
            : base(Agg.UI.FlowDirection.LeftToRight)
        {
            this.Margin  = new BorderDouble(3, 0);
            this.VAnchor = VAnchor.ParentCenter;

            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);
        }
        public EditManualMovementSpeedsWindow(string windowTitle, string movementSpeedsString, EventHandler functionToCallOnSave)
            : base(260, 300)
        {
            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 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);
        }
Пример #10
0
        public void doLayout()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget       topToBottom            = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.Padding = new BorderDouble(10);
            topToBottom.AnchorAll();

            string     exportLblTxt     = new LocalizedString("File export options").Translated;
            string     exportLblTxtFull = string.Format("{0}:", exportLblTxt);
            TextWidget exportLabel      = new TextWidget(exportLblTxtFull);

            exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            topToBottom.AddChild(exportLabel);

            GuiWidget dividerLine = new GuiWidget();

            dividerLine.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            dividerLine.Height          = 1;
            dividerLine.Margin          = new BorderDouble(0, 3);
            dividerLine.BackgroundColor = RGBA_Bytes.White;
            topToBottom.AddChild(dividerLine);

            if (!partIsGCode)
            {
                string exportStlTxt     = new LocalizedString("Export as").Translated;
                string exportStlTxtFull = string.Format("{0} STL", exportStlTxt);

                Button exportSTL = textImageButtonFactory.Generate(exportStlTxtFull);
                exportSTL.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click);
                //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter;
                topToBottom.AddChild(exportSTL);
            }

            bool showExportGCodeButton = PrinterCommunication.Instance.ActivePrinter != null || partIsGCode;

            if (showExportGCodeButton)
            {
                Button exportGCode = textImageButtonFactory.Generate("Export as GCode");
                //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter;
                exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click);
                topToBottom.AddChild(exportGCode);
            }

            GuiWidget vSpacer = new GuiWidget();

            vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
            topToBottom.AddChild(vSpacer);

            if (!showExportGCodeButton)
            {
                string     noGCodeMessageTxtBeg  = new LocalizedString("Note").Translated;
                string     noGCodeMessageTxtEnd  = new LocalizedString("To enable GCode export, select a printer profile.").Translated;
                string     noGCodeMessageTxtFull = string.Format("{0}: {1}", noGCodeMessageTxtBeg, noGCodeMessageTxtEnd);
                TextWidget noGCodeMessage        = new TextWidget(noGCodeMessageTxtFull, textColor: RGBA_Bytes.White, pointSize: 10);
                topToBottom.AddChild(noGCodeMessage);
            }

            // TODO: make this work on the mac and then delete this if
            if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows)
            {
                showInFolderAfterSave        = new CheckBox(new LocalizedString("Show file in folder after save").Translated, RGBA_Bytes.White, 10);
                showInFolderAfterSave.Margin = new BorderDouble(top: 10);
                topToBottom.AddChild(showInFolderAfterSave);
            }

            this.AddChild(topToBottom);
        }
        public StyledMessageBox(String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height)
            : base(width, height)
        {
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            textImageButtonFactory.FixedWidth = 50;

            FlowLayoutWidget topToBottomFlow = new FlowLayoutWidget(FlowDirection.TopToBottom);
            //topToBottomFlow.DebugShowBounds = true;
            TextWidget messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor);

            messageContainer.HAnchor = Agg.UI.HAnchor.ParentCenter;
            topToBottomFlow.AddChild(messageContainer);

            if (extraWidgetsToAdd != null)
            {
                foreach (GuiWidget widget in extraWidgetsToAdd)
                {
                    topToBottomFlow.AddChild(widget);
                }
            }

            Title = windowTitle;

            // add a spacer
            GuiWidget spacer = new GuiWidget(10, 10);

            spacer.HAnchor |= Agg.UI.HAnchor.ParentCenter;
            //spacer.DebugShowBounds = true;
            topToBottomFlow.AddChild(spacer);
            topToBottomFlow.HAnchor = Agg.UI.HAnchor.ParentCenter | Agg.UI.HAnchor.FitToChildren;
            topToBottomFlow.VAnchor = Agg.UI.VAnchor.ParentCenter | Agg.UI.VAnchor.FitToChildren;

            switch (messageType)
            {
            case MessageType.YES_NO:
            {
                FlowLayoutWidget yesNoButtonsFlow = new FlowLayoutWidget();
                yesNoButtonsFlow.HAnchor |= HAnchor.ParentCenter;

                Button yesButton = textImageButtonFactory.Generate(new LocalizedString("Yes").Translated, centerText: true);
                yesButton.Click += new ButtonBase.ButtonEventHandler(okButton_Click);
                yesNoButtonsFlow.AddChild(yesButton);

                GuiWidget buttonSpacer = new GuiWidget(10, 10);
                yesNoButtonsFlow.AddChild(buttonSpacer);

                Button noButton = textImageButtonFactory.Generate(new LocalizedString("No").Translated, centerText: true);
                noButton.Click += new ButtonBase.ButtonEventHandler(noButton_Click);
                yesNoButtonsFlow.AddChild(noButton);

                topToBottomFlow.AddChild(yesNoButtonsFlow);
            }
            break;

            case MessageType.OK:
            {
                Button okButton = textImageButtonFactory.Generate(new LocalizedString("Ok").Translated, centerText: true);
                //okButton.DebugShowBounds = true;
                okButton.Click  += new ButtonBase.ButtonEventHandler(okButton_Click);
                okButton.HAnchor = HAnchor.ParentCenter;
                topToBottomFlow.AddChild(okButton);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            AddChild(topToBottomFlow);

            IsModal = true;
        }
Пример #12
0
        public void CreateWindowContent()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget       topToBottom            = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
            topToBottom.AnchorAll();

            // Creates Header
            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);
            BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;

            //Creates Text and adds into header
            {
                TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
                topToBottom.AddChild(headerRow);
            }

            // Creates container in the middle of window
            FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                middleRowContainer.HAnchor         = HAnchor.ParentLeftRight;
                middleRowContainer.VAnchor         = VAnchor.ParentBottomTop;
                middleRowContainer.Padding         = new BorderDouble(5);
                middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            if (!partIsGCode)
            {
                string exportStlText     = LocalizedString.Get("Export as");
                string exportStlTextFull = string.Format("{0} STL", exportStlText);

                Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
                exportAsStlButton.HAnchor = HAnchor.ParentLeft;
                exportAsStlButton.Cursor  = Cursors.Hand;
                exportAsStlButton.Click  += new EventHandler(exportSTL_Click);
                middleRowContainer.AddChild(exportAsStlButton);
            }

            if (!partIsGCode)
            {
                string exportAmfText     = LocalizedString.Get("Export as");
                string exportAmfTextFull = string.Format("{0} AMF", exportAmfText);

                Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull);
                exportAsAmfButton.HAnchor = HAnchor.ParentLeft;
                exportAsAmfButton.Cursor  = Cursors.Hand;
                exportAsAmfButton.Click  += new EventHandler(exportAMF_Click);
                middleRowContainer.AddChild(exportAsAmfButton);
            }

            bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;

            if (showExportGCodeButton)
            {
                string exportGCodeText     = LocalizedString.Get("Export as");
                string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText);
                Button exportGCode         = textImageButtonFactory.Generate(exportGCodeTextFull);
                exportGCode.HAnchor = HAnchor.ParentLeft;
                exportGCode.Cursor  = Cursors.Hand;
                exportGCode.Click  += new EventHandler((object sender, EventArgs e) =>
                {
                    UiThread.RunOnIdle(ExportGCode_Click);
                });
                middleRowContainer.AddChild(exportGCode);

                bool showExportX3GButton = ActiveSliceSettings.Instance.IsMakerbotGCodeFlavor();
                if (showExportX3GButton)
                {
                    string exportAsX3GText = "Export as X3G".Localize();
                    Button exportAsX3G     = textImageButtonFactory.Generate(exportAsX3GText);
                    exportAsX3G.HAnchor = HAnchor.ParentLeft;
                    exportAsX3G.Cursor  = Cursors.Hand;
                    exportAsX3G.Click  += new EventHandler((object sender, EventArgs e) =>
                    {
                        UiThread.RunOnIdle(ExportX3G_Click);
                    });
                    middleRowContainer.AddChild(exportAsX3G);
                }
            }

            middleRowContainer.AddChild(new VerticalSpacer());

            // If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
            if (showExportGCodeButton && ActivePrinterProfile.Instance.DoPrintLeveling)
            {
                applyLeveling         = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
                applyLeveling.Checked = true;
                applyLeveling.HAnchor = HAnchor.ParentLeft;
                applyLeveling.Cursor  = Cursors.Hand;
                //applyLeveling.Margin = new BorderDouble(top: 10);
                middleRowContainer.AddChild(applyLeveling);
            }

            // TODO: make this work on the mac and then delete this if
            if (OsInformation.OperatingSystem == OSType.Windows ||
                OsInformation.OperatingSystem == OSType.X11)
            {
                showInFolderAfterSave         = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
                showInFolderAfterSave.HAnchor = HAnchor.ParentLeft;
                showInFolderAfterSave.Cursor  = Cursors.Hand;
                //showInFolderAfterSave.Margin = new BorderDouble(top: 10);
                middleRowContainer.AddChild(showInFolderAfterSave);
            }

            if (!showExportGCodeButton)
            {
                string     noGCodeMessageTextBeg  = LocalizedString.Get("Note");
                string     noGCodeMessageTextEnd  = LocalizedString.Get("To enable GCode export, select a printer profile.");
                string     noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
                TextWidget noGCodeMessage         = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
                noGCodeMessage.HAnchor = HAnchor.ParentLeft;
                middleRowContainer.AddChild(noGCodeMessage);
            }

            //Creates button container on the bottom of window
            FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
            {
                BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                buttonRow.HAnchor = HAnchor.ParentLeftRight;
                buttonRow.Padding = new BorderDouble(0, 3);
            }

            Button cancelButton = textImageButtonFactory.Generate("Cancel");

            cancelButton.Cursor = Cursors.Hand;
            cancelButton.Click += (sender, e) =>
            {
                CloseOnIdle();
            };

            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(cancelButton);
            topToBottom.AddChild(middleRowContainer);
            topToBottom.AddChild(buttonRow);

            this.AddChild(topToBottom);
        }
Пример #13
0
        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 DisablablableWidget();
            tuningAdjustmentControlsContainer.AddChild(adjustmentControlsGroupBox);
            controlsTopToBottomLayout.AddChild(tuningAdjustmentControlsContainer);
        }
Пример #14
0
        private void AddEePromControls(FlowLayoutWidget controlsTopToBottomLayout)
        {
            GroupBox eePromControlsGroupBox = new GroupBox(LocalizedString.Get("EEProm Settings"));

            eePromControlsGroupBox.Margin      = new BorderDouble(0);
            eePromControlsGroupBox.TextColor   = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
            eePromControlsGroupBox.HAnchor    |= Agg.UI.HAnchor.ParentLeftRight;
            eePromControlsGroupBox.VAnchor     = Agg.UI.VAnchor.FitToChildren;
            eePromControlsGroupBox.Height      = 68;

            {
                FlowLayoutWidget eePromControlsLayout = new FlowLayoutWidget();
                eePromControlsLayout.HAnchor |= HAnchor.ParentLeftRight;
                eePromControlsLayout.VAnchor |= Agg.UI.VAnchor.ParentCenter;
                eePromControlsLayout.Margin   = new BorderDouble(3, 0, 3, 6);
                eePromControlsLayout.Padding  = new BorderDouble(0);
                {
                    Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
                    ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
                    ImageWidget eePromIcon = new ImageWidget(eePromImage);
                    eePromIcon.Margin = new BorderDouble(right: 6);

                    Button openEePromWindow = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
                    openEePromWindow.Click += (sender, e) =>
                    {
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
                        new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
#else
                        switch (PrinterCommunication.Instance.FirmwareType)
                        {
                        case PrinterCommunication.FirmwareTypes.Repetier:
                            new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
                            break;

                        case PrinterCommunication.FirmwareTypes.Marlin:
                            new MatterHackers.MatterControl.EeProm.EePromMarlinWidget();
                            break;

                        default:
                            UiThread.RunOnIdle((state) =>
                            {
                                string message = LocalizedString.Get("Oops! There is no eeprom mapping for your printer's firmware.");
                                StyledMessageBox.ShowMessageBox(message, "Warning no eeprom mapping", StyledMessageBox.MessageType.OK);
                            }
                                               );
                            break;
                        }
#endif
                    };
                    //eePromControlsLayout.AddChild(eePromIcon);
                    eePromControlsLayout.AddChild(openEePromWindow);
                }

                eePromControlsGroupBox.AddChild(eePromControlsLayout);
            }

            eePromControlsContainer = new DisableableWidget();
            eePromControlsContainer.AddChild(eePromControlsGroupBox);

            controlsTopToBottomLayout.AddChild(eePromControlsContainer);
        }
Пример #15
0
        public TerminalWidget(bool showInWindow)
        {
            this.BackgroundColor = backgroundColor;
            this.Padding         = new BorderDouble(5, 0);
            FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget();

            topLeftToRightLayout.AnchorAll();

            {
                FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop;
                manualEntryTopToBottomLayout.Padding  = new BorderDouble(top: 8);

                {
                    FlowLayoutWidget topBarControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
                    topBarControls.HAnchor |= HAnchor.ParentLeft;

                    {
                        string filterOutputChkTxt = LocalizedString.Get("Filter Output");

                        filterOutput                      = new CheckBox(filterOutputChkTxt);
                        filterOutput.Margin               = new BorderDouble(5, 5, 5, 2);
                        filterOutput.TextColor            = this.textColor;
                        filterOutput.CheckedStateChanged += (object sender, EventArgs e) =>
                        {
                            if (filterOutput.Checked)
                            {
                                textScrollWidget.SetLineStartFilter(new string[] { "<-wait", "<-ok", "->M105", "<-T" });
                            }
                            else
                            {
                                textScrollWidget.SetLineStartFilter(null);
                            }

                            UserSettings.Instance.Fields.SetBool(TerminalFilterOutputKey, filterOutput.Checked);
                        };

                        filterOutput.VAnchor = Agg.UI.VAnchor.ParentBottom;
                        topBarControls.AddChild(filterOutput);
                    }

                    {
                        string autoUpperCaseChkTxt = LocalizedString.Get("Auto Uppercase");

                        autoUppercase           = new CheckBox(autoUpperCaseChkTxt);
                        autoUppercase.Margin    = new BorderDouble(5, 5, 5, 2);
                        autoUppercase.Checked   = UserSettings.Instance.Fields.GetBool(TerminalAutoUppercaseKey, true);
                        autoUppercase.TextColor = this.textColor;
                        autoUppercase.VAnchor   = Agg.UI.VAnchor.ParentBottom;
                        topBarControls.AddChild(autoUppercase);
                        autoUppercase.CheckedStateChanged += (sender, e) =>
                        {
                            UserSettings.Instance.Fields.SetBool(TerminalAutoUppercaseKey, autoUppercase.Checked);
                        };
                        manualEntryTopToBottomLayout.AddChild(topBarControls);
                    }
                }

                {
                    FlowLayoutWidget leftToRight = new FlowLayoutWidget();
                    leftToRight.AnchorAll();

                    textScrollWidget = new TextScrollWidget(PrinterOutputCache.Instance.PrinterLines);
                    //outputScrollWidget.Height = 100;
                    textScrollWidget.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                    textScrollWidget.TextColor       = ActiveTheme.Instance.PrimaryTextColor;
                    textScrollWidget.HAnchor         = HAnchor.ParentLeftRight;
                    textScrollWidget.VAnchor         = VAnchor.ParentBottomTop;
                    textScrollWidget.Margin          = new BorderDouble(0, 5);
                    textScrollWidget.Padding         = new BorderDouble(3, 0);

                    leftToRight.AddChild(textScrollWidget);

                    TextScrollBar textScrollBar = new TextScrollBar(textScrollWidget, 15);
                    leftToRight.AddChild(textScrollBar);

                    manualEntryTopToBottomLayout.AddChild(leftToRight);
                }

                FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight);
                manualEntryLayout.BackgroundColor = this.backgroundColor;
                manualEntryLayout.HAnchor         = HAnchor.ParentLeftRight;
                {
                    manualCommandTextEdit = new MHTextEditWidget("");
                    //manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White;
                    manualCommandTextEdit.Margin  = new BorderDouble(right: 3);
                    manualCommandTextEdit.HAnchor = HAnchor.ParentLeftRight;
                    manualCommandTextEdit.VAnchor = VAnchor.ParentBottom;
                    manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed);
                    manualCommandTextEdit.ActualTextEditWidget.KeyDown      += new KeyEventHandler(manualCommandTextEdit_KeyDown);
                    manualEntryLayout.AddChild(manualCommandTextEdit);
                }

                manualEntryTopToBottomLayout.AddChild(manualEntryLayout);

                Button clearConsoleButton = controlButtonFactory.Generate(LocalizedString.Get("Clear"));
                clearConsoleButton.Margin = new BorderDouble(0);
                clearConsoleButton.Click += (sender, e) =>
                {
                    PrinterOutputCache.Instance.Clear();
                };

                //Output Console text to screen
                Button exportConsoleTextButton = controlButtonFactory.Generate(LocalizedString.Get("Export..."));
                exportConsoleTextButton.Click += (sender, mouseEvent) =>
                {
                    UiThread.RunOnIdle(DoExportExportLog_Click);
                };

                Button closeButton = controlButtonFactory.Generate(LocalizedString.Get("Close"));
                closeButton.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(CloseWindow);
                };

                sendCommand        = controlButtonFactory.Generate(LocalizedString.Get("Send"));
                sendCommand.Click += new EventHandler(sendManualCommandToPrinter_Click);

                FlowLayoutWidget bottomRowContainer = new FlowLayoutWidget();
                bottomRowContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                bottomRowContainer.Margin  = new BorderDouble(0, 3);

                bottomRowContainer.AddChild(sendCommand);
                bottomRowContainer.AddChild(clearConsoleButton);
                bottomRowContainer.AddChild(exportConsoleTextButton);
                bottomRowContainer.AddChild(new HorizontalSpacer());

                if (showInWindow)
                {
                    bottomRowContainer.AddChild(closeButton);
                }

                manualEntryTopToBottomLayout.AddChild(bottomRowContainer);
                manualEntryTopToBottomLayout.AnchorAll();

                topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout);
            }

            AddChild(topLeftToRightLayout);
            this.AnchorAll();
        }
        private TabControl CreateNewAdvancedControls(ButtonBase.ButtonEventHandler AdvancedControlsButton_Click, EventHandler onMouseEnterBoundsPrintQueueLink, EventHandler onMouseLeaveBoundsPrintQueueLink)
        {
            TabControl advancedControls = new TabControl();

            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
            advancedControls.TabBar.Margin = new BorderDouble(0, 0);
            advancedControls.TabBar.Padding = new BorderDouble(0, 2);

            int textSize = 16;

            if (AdvancedControlsButton_Click != null)
            {
                // this means we are in compact view and so we will make the tabs text a bit smaller
                textSize = 14;
                TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
                advancedControlsButtonFactory.invertImageLocation = false;
                advancedControlsLinkButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Print\nQueue"), "icon_arrow_left_32x32.png");
                advancedControlsLinkButton.Margin = new BorderDouble(right: 3);
                advancedControlsLinkButton.VAnchor = VAnchor.ParentBottom;
                advancedControlsLinkButton.Cursor = Cursors.Hand;
                advancedControlsLinkButton.Click += new ButtonBase.ButtonEventHandler(AdvancedControlsButton_Click);
                advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsPrintQueueLink);
                advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsPrintQueueLink);

                advancedControls.TabBar.AddChild(advancedControlsLinkButton);
            }

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

            advancedControls.TabBar.AddChild(hSpacer);

            GuiWidget manualPrinterControls = new ManualPrinterControls();
            ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);
            manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            manualPrinterControlsScrollArea.AnchorAll();
            manualPrinterControlsScrollArea.AddChild(manualPrinterControls);

            RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

            //Add the tab contents for 'Advanced Controls'
            string printerControlsLabel = LocalizedString.Get("Controls").ToUpper();
            advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), "Controls Tab", textSize,
            ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

            string sliceSettingsLabel = LocalizedString.Get("Slice Settings").ToUpper();
            sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState);
            advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), "Slice Settings Tab", textSize,
                        ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

            string configurationLabel = LocalizedString.Get("Configuration").ToUpper();
            ScrollableWidget configurationControls = new PrinterConfigurationPage();
            advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", textSize,
                        ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

            advancedControls.SelectedTabIndex = lastAdvanceControlsIndex;

            return advancedControls;
        }
Пример #17
0
        public MainSlidePanel()
            : base(2)
        {
            ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);

            // do the front panel stuff
            {
                // first add the print progress bar
                this.LeftPanel.AddChild(new PrintProgressBar());

                // construct the main controls tab control
                mainControlsTabControl = new TabControl();
                mainControlsTabControl.TabBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
                mainControlsTabControl.TabBar.BorderColor     = new RGBA_Bytes(0, 0, 0, 0);
                mainControlsTabControl.TabBar.Margin          = new BorderDouble(0, 0);
                mainControlsTabControl.TabBar.Padding         = new BorderDouble(0, 2);

                QueueTabPage = new TabPage(new QueueControlsWidget(), "Queue");
                NumQueueItemsChanged(this, null);

                mainControlsTabControl.AddTab(new SimpleTextTabWidget(QueueTabPage, 18,
                                                                      ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));
                //mainControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(new GuiWidget(), "History"), 18,
                //        ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

                string libraryTabLabel = new LocalizedString("Library").Translated;

                mainControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(new PrintLibraryWidget(), libraryTabLabel), 18,
                                                                      ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

                //mainControlsTabControl.AddTab(new SimpleTextTabWidget(new TabPage(new ToolsWidget(), "Tools"), 18,
                //ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

                AboutTabPage = new TabPage(new AboutPage(), new LocalizedString("About").Translated);
                aboutTabView = new SimpleTextTabWidget(AboutTabPage, 18,
                                                       ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes());
                mainControlsTabControl.AddTab(aboutTabView);


                advancedControlsButtonFactory.normalTextColor  = RGBA_Bytes.White;
                advancedControlsButtonFactory.hoverTextColor   = RGBA_Bytes.White;
                advancedControlsButtonFactory.pressedTextColor = RGBA_Bytes.White;
                advancedControlsButtonFactory.fontSize         = 10;

                advancedControlsButtonFactory.disabledTextColor   = RGBA_Bytes.LightGray;
                advancedControlsButtonFactory.disabledFillColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                advancedControlsButtonFactory.disabledBorderColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                advancedControlsButtonFactory.invertImageLocation = true;
                Button advancedControlsLinkButton = advancedControlsButtonFactory.Generate(new LocalizedString("Advanced\nControls").Translated, "icon_arrow_right_32x32.png");
                advancedControlsLinkButton.Margin            = new BorderDouble(right: 3);
                advancedControlsLinkButton.VAnchor           = VAnchor.ParentBottom;
                advancedControlsLinkButton.Cursor            = Cursors.Hand;
                advancedControlsLinkButton.Click            += new ButtonBase.ButtonEventHandler(AdvancedControlsButton_Click);
                advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsAdvancedControlsLink);
                advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsAdvancedControlsLink);

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

                mainControlsTabControl.TabBar.AddChild(hSpacer);
                mainControlsTabControl.TabBar.AddChild(advancedControlsLinkButton);
                // and add it
                this.LeftPanel.AddChild(mainControlsTabControl);

                SetUpdateNotification(this, null);
            }

            // do the back panel
            {
                advancedControlsTabControl = CreateNewAdvancedControlsTab(new SliceSettingsWidget.UiState());
                this.RightPanel.AddChild(advancedControlsTabControl);
                this.RightPanel.AddChild(new PrintProgressBar());
            }
            AddHandlers();
        }
        public SetupAccountView(TextImageButtonFactory textImageButtonFactory)
            : base("My Account")
        {
            this.textImageButtonFactory = textImageButtonFactory;

            bool   signedIn = true;
            string username = AuthenticationData.Instance.ActiveSessionUsername;

            if (username == null)
            {
                signedIn = false;
                username = "******";
            }

            FlowLayoutWidget nameAndStatus = new FlowLayoutWidget();

            nameAndStatus.AddChild(new TextWidget(username, pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor));

            connectionStatus = new TextWidget(AuthenticationString, pointSize: 8, textColor: ActiveTheme.Instance.SecondaryTextColor)
            {
                Margin = new BorderDouble(5, 0, 0, 0),
                AutoExpandBoundsToText = true,
            };

            if (signedIn)
            {
                nameAndStatus.AddChild(connectionStatus);
            }


            mainContainer.AddChild(nameAndStatus);

            RefreshStatus();

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget();

            buttonContainer.HAnchor = HAnchor.ParentLeftRight;
            buttonContainer.Margin  = new BorderDouble(0, 14);

            signInButton         = textImageButtonFactory.Generate("Sign In".Localize());
            signInButton.Margin  = new BorderDouble(left: 0);
            signInButton.VAnchor = VAnchor.ParentCenter;
            signInButton.Visible = !signedIn;
            signInButton.Click  += (s, e) =>
            {
#if __ANDROID__
                if (MatterControlApplication.Instance.IsNetworkConnected() &&
                    AuthenticationData.Instance.IsConnected)
                {
                    UiThread.RunOnIdle(ApplicationController.Instance.StartSignIn);
                }
                else
                {
                    WizardWindow.Show <NetworkTroubleshooting>("/networktroubleshooting", "Network Troubleshooting");
                }
#else
                UiThread.RunOnIdle(ApplicationController.Instance.StartSignIn);
#endif
            };
            buttonContainer.AddChild(signInButton);

            signOutButton         = textImageButtonFactory.Generate("Sign Out".Localize());
            signOutButton.Margin  = new BorderDouble(left: 0);
            signOutButton.VAnchor = VAnchor.ParentCenter;
            signOutButton.Visible = signedIn;
            signOutButton.Click  += (s, e) => UiThread.RunOnIdle(ApplicationController.Instance.StartSignOut);
            buttonContainer.AddChild(signOutButton);

            buttonContainer.AddChild(new HorizontalSpacer());

            // the redeem design code button
            textImageButtonFactory.disabledTextColor = new RGBA_Bytes(textImageButtonFactory.normalTextColor, 100);
            Button redeemPurchaseButton = textImageButtonFactory.Generate("Redeem Purchase".Localize());
            redeemPurchaseButton.Enabled = true;             // The library selector (the first library selected) is protected so we can't add to it.
            redeemPurchaseButton.Name    = "Redeem Code Button";
            redeemPurchaseButton.Margin  = new BorderDouble(0, 0, 10, 0);
            redeemPurchaseButton.Click  += (sender, e) =>
            {
                ApplicationController.Instance.RedeemDesignCode?.Invoke();
            };
            buttonContainer.AddChild(redeemPurchaseButton);

            // the redeem a share code button
            Button redeemShareButton = textImageButtonFactory.Generate("Enter Share Code".Localize());
            redeemShareButton.Enabled = true;             // The library selector (the first library selected) is protected so we can't add to it.
            redeemShareButton.Name    = "Enter Share Code";
            redeemShareButton.Margin  = new BorderDouble(0, 0, 10, 0);
            redeemShareButton.Click  += (sender, e) =>
            {
                ApplicationController.Instance.EnterShareCode?.Invoke();
            };

            if (!signedIn)
            {
                redeemPurchaseButton.Enabled = false;
                redeemShareButton.Enabled    = false;
            }

            buttonContainer.AddChild(redeemShareButton);

            statusMessage         = new TextWidget("Please wait...", pointSize: 12, textColor: ActiveTheme.Instance.SecondaryAccentColor);
            statusMessage.Visible = false;
            buttonContainer.AddChild(statusMessage);

            mainContainer.AddChild(buttonContainer);

            ApplicationController.Instance.DoneReloadingAll.RegisterEvent(RemoveAndNewControl, ref unregisterEvents);
        }
Пример #19
0
        public MacroDetailWidget(EditMacrosWindow windowController)
        {
            this.windowController = windowController;
            if (this.windowController.ActiveMacro == null)
            {
                initMacro();
            }


            linkButtonFactory.fontSize = 10;

            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     editMacroLabel     = LocalizedString.Get("Edit Macro");
                string     editMacroLabelFull = string.Format("{0}:", editMacroLabel);
                TextWidget elementHeader      = new TextWidget(editMacroLabelFull, 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);

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

            topToBottom.AddChild(presetsFormContainer);

            presetsFormContainer.AddChild(createMacroNameContainer());
            presetsFormContainer.AddChild(createMacroCommandContainer());


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

            addMacroButton.Click += new EventHandler(saveMacro_Click);

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

            cancelPresetsButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle((state) =>
                {
                    windowController.ChangeToMacroList();
                });
            };

            FlowLayoutWidget buttonRow = new FlowLayoutWidget();

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

            GuiWidget hButtonSpacer = new GuiWidget();

            hButtonSpacer.HAnchor = HAnchor.ParentLeftRight;

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

            topToBottom.AddChild(buttonRow);
            AddChild(topToBottom);
            this.AnchorAll();
        }
Пример #20
0
		private TabControl CreateNewAdvancedControls(EventHandler AdvancedControlsButton_Click)
		{
			TabControl advancedControls = new TabControl();

			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
			advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
			advancedControls.TabBar.Margin = new BorderDouble(0, 0);
			advancedControls.TabBar.Padding = new BorderDouble(0, 2);

			int textSize = 16;

			if (AdvancedControlsButton_Click != null)
			{
				// this means we are in compact view and so we will make the tabs text a bit smaller
				textSize = 14;
				TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
				advancedControlsButtonFactory.fontSize = 14;
				advancedControlsButtonFactory.invertImageLocation = false;
				advancedControlsBackButton = advancedControlsButtonFactory.Generate(LocalizedString.Get("Back"), "icon_arrow_left_32x32.png");
				advancedControlsBackButton.ToolTipText = "Switch to Queue, Library and History".Localize();
				advancedControlsBackButton.Margin = new BorderDouble(right: 3);
				advancedControlsBackButton.VAnchor = VAnchor.ParentBottom;
				advancedControlsBackButton.Cursor = Cursors.Hand;
				advancedControlsBackButton.Click += new EventHandler(AdvancedControlsButton_Click);

				advancedControls.TabBar.AddChild(advancedControlsBackButton);
			}

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

			advancedControls.TabBar.AddChild(hSpacer);

			GuiWidget manualPrinterControls = new ManualPrinterControls();
			ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);
			manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
			manualPrinterControlsScrollArea.AnchorAll();
			manualPrinterControlsScrollArea.AddChild(manualPrinterControls);

			RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

			//Add the tab contents for 'Advanced Controls'
			string sliceSettingsLabel = LocalizedString.Get("Settings").ToUpper();
			string printerControlsLabel = LocalizedString.Get("Controls").ToUpper();
			sliceSettingsWidget = new SliceSettingsWidget();

			TabPage sliceSettingsTabPage = new TabPage(sliceSettingsWidget, sliceSettingsLabel);
			PopOutTextTabWidget sliceSettingPopOut = new PopOutTextTabWidget(sliceSettingsTabPage, SliceSettingsTabName, new Vector2(590, 400), textSize);
			advancedControls.AddTab(sliceSettingPopOut);
			
			TabPage controlsTabPage = new TabPage(manualPrinterControlsScrollArea, printerControlsLabel);
			PopOutTextTabWidget controlsPopOut = new PopOutTextTabWidget(controlsTabPage, ControlsTabName, new Vector2(400, 300), textSize);
			advancedControls.AddTab(controlsPopOut);

#if !__ANDROID__
			MenuOptionSettings.sliceSettingsPopOut = sliceSettingPopOut;
			MenuOptionSettings.controlsPopOut = controlsPopOut;
#endif

			string optionsLabel = LocalizedString.Get("Options").ToUpper();
			ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget();
			advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, optionsLabel), "Configuration Tab", textSize,
						ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

			// Make sure we are on the right tab when we create this view
			{
				string selectedTab = UserSettings.Instance.get(ThirdPanelTabView_AdvancedControls_CurrentTab);
				advancedControls.SelectTab(selectedTab);

				advancedControls.TabBar.TabIndexChanged += (object sender, EventArgs e) =>
				{
					UserSettings.Instance.set(ThirdPanelTabView_AdvancedControls_CurrentTab, advancedControls.TabBar.SelectedTabName);
				};
			}

			return advancedControls;
		}
Пример #21
0
        public MacroListWidget(EditMacrosWindow windowController)
        {
            this.windowController = windowController;

            linkButtonFactory.fontSize = 10;
            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     macroPresetsLabel     = LocalizedString.Get("Macro Presets");
                string     macroPresetsLabelFull = string.Format("{0}:", macroPresetsLabel);
                TextWidget elementHeader         = new TextWidget(macroPresetsLabelFull, 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);

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

            topToBottom.AddChild(presetsFormContainer);

            IEnumerable <DataStorage.CustomCommands> macroList = GetMacros();

            foreach (DataStorage.CustomCommands currentCommand in macroList)
            {
                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.Margin          = new BorderDouble(3, 0, 3, 3);
                macroRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.Padding         = new BorderDouble(3);
                macroRow.BackgroundColor = RGBA_Bytes.White;

                TextWidget buttonLabel = new TextWidget(currentCommand.Name);
                macroRow.AddChild(buttonLabel);

                FlowLayoutWidget hSpacer = new FlowLayoutWidget();
                hSpacer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                macroRow.AddChild(hSpacer);

                Button editLink = linkButtonFactory.Generate(LocalizedString.Get("edit"));
                editLink.Margin = new BorderDouble(right: 5);
                // You can't pass a foreach variable into a link function or it wall always be the last item.
                // So we make a local variable copy of it and pass that. This will get the right one.
                DataStorage.CustomCommands currentCommandForLinkFunction = currentCommand;
                editLink.Click += (sender, e) =>
                {
                    windowController.ChangeToMacroDetail(currentCommandForLinkFunction);
                };
                macroRow.AddChild(editLink);

                Button removeLink = linkButtonFactory.Generate(LocalizedString.Get("remove"));
                removeLink.Click += (sender, e) =>
                {
                    currentCommandForLinkFunction.Delete();
                    windowController.functionToCallOnSave(this, null);
                    windowController.ChangeToMacroList();
                };
                macroRow.AddChild(removeLink);

                presetsFormContainer.AddChild(macroRow);
            }


            Button addMacroButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");

            addMacroButton.Click += new EventHandler(addMacro_Click);

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

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

            topToBottom.AddChild(buttonRow);
            AddChild(topToBottom);
            this.AnchorAll();
        }
Пример #22
0
        private void AddContent(HtmlParser htmlParser, string htmlContent)
        {
            ElementState elementState = htmlParser.CurrentElementState;
            string       decodedHtml  = HtmlParser.UrlDecode(htmlContent);

            switch (elementState.TypeName)
            {
            case "a":
            {
                Button         linkButton      = linkButtonFactory.Generate(decodedHtml);
                StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                double         descentInPixels = styled.DescentInPixels;
                linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels);
                linkButton.Click += (sender, mouseEvent) =>
                {
                    System.Diagnostics.Process.Start(elementState.Href);
                };
                currentRow.AddChild(linkButton);
            }
            break;

            case "table":
                break;

            case "td":
            case "span":
                GuiWidget widgetToAdd;

                if (elementState.Classes.Contains("translate"))
                {
                    decodedHtml = decodedHtml.Localize();
                }
                if (elementState.Classes.Contains("toUpper"))
                {
                    decodedHtml = decodedHtml.ToUpper();
                }
                if (elementState.Classes.Contains("versionNumber"))
                {
                    decodedHtml = VersionInfo.Instance.ReleaseVersion;
                }
                if (elementState.Classes.Contains("buildNumber"))
                {
                    decodedHtml = VersionInfo.Instance.BuildVersion;
                }

                Button createdButton = null;
                if (elementState.Classes.Contains("centeredButton"))
                {
                    createdButton = textImageButtonFactory.Generate(decodedHtml);
                    widgetToAdd   = createdButton;
                }
                else if (elementState.Classes.Contains("linkButton"))
                {
                    double oldFontSize = linkButtonFactory.fontSize;
                    linkButtonFactory.fontSize = elementState.PointSize;
                    createdButton = linkButtonFactory.Generate(decodedHtml);
                    StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                    double         descentInPixels = styled.DescentInPixels;
                    createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels);
                    widgetToAdd = createdButton;
                    linkButtonFactory.fontSize = oldFontSize;
                }
                else
                {
                    TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    widgetToAdd = content;
                }

                if (createdButton != null)
                {
                    if (elementState.Id == "sendFeedback")
                    {
                        createdButton.Click += (sender, mouseEvent) => { ContactFormWindow.Open(); };
                    }
                    else if (elementState.Id == "clearCache")
                    {
                        createdButton.Click += (sender, mouseEvent) => { DeleteCacheData(); };
                    }
                }

                if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top)
                {
                    widgetToAdd.VAnchor = VAnchor.ParentTop;
                }

                currentRow.AddChild(widgetToAdd);
                break;

            case "tr":
                currentRow = new FlowLayoutWidget();
                if (elementState.HeightPercent == 100)
                {
                    currentRow.VAnchor = VAnchor.ParentBottomTop;
                }
                if (elementState.Alignment == ElementState.AlignType.center)
                {
                    currentRow.HAnchor |= HAnchor.ParentCenter;
                }
                break;

            default:
                throw new NotImplementedException("Don't know what to do with {0}".FormatWith(elementState.TypeName));
            }
        }
Пример #23
0
        private TabControl CreateNewAdvancedControls(EventHandler AdvancedControlsButton_Click, EventHandler onMouseEnterBoundsPrintQueueLink, EventHandler onMouseLeaveBoundsPrintQueueLink)
        {
            TabControl advancedControls = new TabControl();

            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            advancedControls.TabBar.BorderColor = ActiveTheme.Instance.SecondaryTextColor;
            advancedControls.TabBar.Margin      = new BorderDouble(0, 0);
            advancedControls.TabBar.Padding     = new BorderDouble(0, 2);

            int textSize = 16;

            if (AdvancedControlsButton_Click != null)
            {
                // this means we are in compact view and so we will make the tabs text a bit smaller
                textSize = 14;
                TextImageButtonFactory advancedControlsButtonFactory = new TextImageButtonFactory();
                advancedControlsButtonFactory.invertImageLocation = false;
                advancedControlsLinkButton                   = advancedControlsButtonFactory.Generate(LocalizedString.Get("Print\nQueue"), "icon_arrow_left_32x32.png");
                advancedControlsLinkButton.Margin            = new BorderDouble(right: 3);
                advancedControlsLinkButton.VAnchor           = VAnchor.ParentBottom;
                advancedControlsLinkButton.Cursor            = Cursors.Hand;
                advancedControlsLinkButton.Click            += new EventHandler(AdvancedControlsButton_Click);
                advancedControlsLinkButton.MouseEnterBounds += new EventHandler(onMouseEnterBoundsPrintQueueLink);
                advancedControlsLinkButton.MouseLeaveBounds += new EventHandler(onMouseLeaveBoundsPrintQueueLink);

                advancedControls.TabBar.AddChild(advancedControlsLinkButton);
            }

            GuiWidget hSpacer = new GuiWidget();

            hSpacer.HAnchor = HAnchor.ParentLeftRight;

            advancedControls.TabBar.AddChild(hSpacer);

            GuiWidget        manualPrinterControls           = new ManualPrinterControls();
            ScrollableWidget manualPrinterControlsScrollArea = new ScrollableWidget(true);

            manualPrinterControlsScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
            manualPrinterControlsScrollArea.AnchorAll();
            manualPrinterControlsScrollArea.AddChild(manualPrinterControls);

            RGBA_Bytes unselectedTextColor = ActiveTheme.Instance.TabLabelUnselected;

            //Add the tab contents for 'Advanced Controls'
            string sliceSettingsLabel   = LocalizedString.Get("Settings").ToUpper();
            string printerControlsLabel = LocalizedString.Get("Controls").ToUpper();

            sliceSettingsWidget = new SliceSettingsWidget(sliceSettingsUiState);

            advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(sliceSettingsWidget, sliceSettingsLabel), SliceSettingsTabName, new Vector2(590, 400), textSize));
            advancedControls.AddTab(new PopOutTextTabWidget(new TabPage(manualPrinterControlsScrollArea, printerControlsLabel), ControlsTabName, new Vector2(400, 300), textSize));

            string           configurationLabel    = LocalizedString.Get("Configuration").ToUpper();
            ScrollableWidget configurationControls = new PrinterConfigurationScrollWidget();

            advancedControls.AddTab(new SimpleTextTabWidget(new TabPage(configurationControls, configurationLabel), "Configuration Tab", textSize,
                                                            ActiveTheme.Instance.PrimaryTextColor, new RGBA_Bytes(), unselectedTextColor, new RGBA_Bytes()));

            advancedControls.SelectedTabIndex = lastAdvanceControlsIndex;

            return(advancedControls);
        }
Пример #24
0
        public WizardControl()
        {
            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 titleString = LocalizedString.Get("Title Stuff".Localize());
                stepDescriptionWidget = new TextWidget(titleString, pointSize: 14);
                stepDescriptionWidget.AutoExpandBoundsToText = true;
                stepDescriptionWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                stepDescriptionWidget.HAnchor   = HAnchor.ParentLeftRight;
                stepDescriptionWidget.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(stepDescriptionWidget);
            }

            topToBottom.AddChild(headerRow);

            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = new RGBA_Bytes(200, 200, 200);
            textImageButtonFactory.disabledFillColor = new RGBA_Bytes(0, 0, 0, 0);
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;

            AnchorAll();
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            bottomToTopLayout = new FlowLayoutWidget(FlowDirection.BottomToTop);
            bottomToTopLayout.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            bottomToTopLayout.Padding         = new BorderDouble(3);

            topToBottom.AddChild(bottomToTopLayout);

            {
                FlowLayoutWidget buttonBar = new FlowLayoutWidget();
                buttonBar.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
                buttonBar.Padding = new BorderDouble(0, 3);

                textImageButtonFactory.FixedWidth = 60 * TextWidget.GlobalPointSizeScaleRatio;
                backButton        = textImageButtonFactory.Generate(LocalizedString.Get("Back"), centerText: true);
                backButton.Click += new EventHandler(back_Click);

                nextButton        = textImageButtonFactory.Generate(LocalizedString.Get("Next"), centerText: true);
                nextButton.Click += new EventHandler(next_Click);

                doneButton        = textImageButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true);
                doneButton.Click += done_Click;

                cancelButton        = textImageButtonFactory.Generate("Cancel".Localize(), centerText: true);
                cancelButton.Click += done_Click;

                buttonBar.AddChild(backButton);
                buttonBar.AddChild(nextButton);
                buttonBar.AddChild(new HorizontalSpacer());
                buttonBar.AddChild(doneButton);
                buttonBar.AddChild(cancelButton);

                topToBottom.AddChild(buttonBar);
            }

            bottomToTopLayout.AnchorAll();

            AddChild(topToBottom);
        }
Пример #25
0
        // private as you can't make one
        private OutputScrollWindow()
            : base(400, 300)
        {
            this.BackgroundColor = backgroundColor;
            this.Padding         = new BorderDouble(5);

            FlowLayoutWidget topLeftToRightLayout = new FlowLayoutWidget();

            topLeftToRightLayout.AnchorAll();

            {
                FlowLayoutWidget manualEntryTopToBottomLayout = new FlowLayoutWidget(FlowDirection.TopToBottom);
                manualEntryTopToBottomLayout.VAnchor |= Agg.UI.VAnchor.ParentTop;
                manualEntryTopToBottomLayout.Padding  = new BorderDouble(5);

                {
                    FlowLayoutWidget OutputWindowsLayout = new FlowLayoutWidget(FlowDirection.LeftToRight);
                    OutputWindowsLayout.HAnchor |= HAnchor.ParentLeft;

                    string filterOutputChkTxt = new LocalizedString("Filter Output").Translated;

                    filterOutput                      = new CheckBox(filterOutputChkTxt);
                    filterOutput.Margin               = new BorderDouble(5, 5, 5, 2);
                    filterOutput.Checked              = false;
                    filterOutput.TextColor            = this.textColor;
                    filterOutput.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(SetCorrectFilterOutputBehavior);
                    OutputWindowsLayout.AddChild(filterOutput);

                    string autoUpperCaseChkTxt = new LocalizedString("Auto Uppercase").Translated;

                    autoUppercase           = new CheckBox(autoUpperCaseChkTxt);
                    autoUppercase.Margin    = new BorderDouble(5, 5, 5, 2);
                    autoUppercase.Checked   = true;
                    autoUppercase.TextColor = this.textColor;
                    OutputWindowsLayout.AddChild(autoUppercase);

                    monitorPrinterTemperature                      = new CheckBox("Monitor Temperature");
                    monitorPrinterTemperature.Margin               = new BorderDouble(5, 5, 5, 2);
                    monitorPrinterTemperature.Checked              = PrinterCommunication.Instance.MonitorPrinterTemperature;
                    monitorPrinterTemperature.TextColor            = this.textColor;
                    monitorPrinterTemperature.CheckedStateChanged += new CheckBox.CheckedStateChangedEventHandler(monitorPrinterTemperature_CheckedStateChanged);

                    manualEntryTopToBottomLayout.AddChild(OutputWindowsLayout);
                }

                {
                    FlowLayoutWidget OutputWindowsLayout = new FlowLayoutWidget(FlowDirection.LeftToRight);
                    OutputWindowsLayout.VAnchor = VAnchor.ParentBottomTop;

                    outputScrollWidget                 = new OutputScroll();
                    outputScrollWidget.Height          = 100;
                    outputScrollWidget.BackgroundColor = RGBA_Bytes.White;
                    outputScrollWidget.HAnchor         = HAnchor.ParentLeftRight;
                    outputScrollWidget.VAnchor         = VAnchor.ParentBottomTop;
                    outputScrollWidget.Margin          = new BorderDouble(0, 5);

                    OutputWindowsLayout.AddChild(outputScrollWidget);

                    manualEntryTopToBottomLayout.AddChild(outputScrollWidget);
                }

                FlowLayoutWidget manualEntryLayout = new FlowLayoutWidget(FlowDirection.LeftToRight);
                manualEntryLayout.BackgroundColor = this.backgroundColor;
                manualEntryLayout.HAnchor         = HAnchor.ParentLeftRight;
                {
                    manualCommandTextEdit = new MHTextEditWidget("");
                    manualCommandTextEdit.BackgroundColor = RGBA_Bytes.White;
                    manualCommandTextEdit.HAnchor         = HAnchor.ParentLeftRight;
                    manualCommandTextEdit.VAnchor         = VAnchor.ParentCenter;
                    manualCommandTextEdit.ActualTextEditWidget.EnterPressed += new KeyEventHandler(manualCommandTextEdit_EnterPressed);
                    manualCommandTextEdit.ActualTextEditWidget.KeyDown      += new KeyEventHandler(manualCommandTextEdit_KeyDown);
                    manualEntryLayout.AddChild(manualCommandTextEdit);

                    sendCommand        = controlButtonFactory.Generate(new LocalizedString("Send").Translated);
                    sendCommand.Margin = new BorderDouble(5, 0);
                    sendCommand.Click += new ButtonBase.ButtonEventHandler(sendManualCommandToPrinter_Click);
                    manualEntryLayout.AddChild(sendCommand);
                }

                manualEntryTopToBottomLayout.AddChild(manualEntryLayout);
                manualEntryTopToBottomLayout.AnchorAll();

                topLeftToRightLayout.AddChild(manualEntryTopToBottomLayout);
            }

            AddHandlers();

            AddChild(topLeftToRightLayout);
            SetCorrectFilterOutputBehavior(this, null);
            this.AnchorAll();

            Title = new LocalizedString("MatterControl - Terminal").Translated;
            this.ShowAsSystemWindow();
            MinimumSize = new Vector2(Width, Height);
        }
Пример #26
0
        public void CreateWindowContent()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget       topToBottom            = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
            topToBottom.AnchorAll();

            // Creates Header
            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);
            BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;

            //Creates Text and adds into header
            {
                TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
                topToBottom.AddChild(headerRow);
            }

            // Creates container in the middle of window
            FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                middleRowContainer.HAnchor         = HAnchor.ParentLeftRight;
                middleRowContainer.VAnchor         = VAnchor.ParentBottomTop;
                middleRowContainer.Padding         = new BorderDouble(5);
                middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            if (!partIsGCode)
            {
                string exportStlText     = LocalizedString.Get("Export as");
                string exportStlTextFull = string.Format("{0} STL", exportStlText);

                Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
                exportAsStlButton.HAnchor = HAnchor.ParentLeft;
                exportAsStlButton.Cursor  = Cursors.Hand;
                exportAsStlButton.Click  += new EventHandler(exportSTL_Click);
                middleRowContainer.AddChild(exportAsStlButton);
            }

            if (!partIsGCode)
            {
                string exportAmfText     = LocalizedString.Get("Export as");
                string exportAmfTextFull = string.Format("{0} AMF", exportAmfText);

                Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull);
                exportAsAmfButton.HAnchor = HAnchor.ParentLeft;
                exportAsAmfButton.Cursor  = Cursors.Hand;
                exportAsAmfButton.Click  += new EventHandler(exportAMF_Click);
                middleRowContainer.AddChild(exportAsAmfButton);
            }

            bool showExportGCodeButton = ActiveSliceSettings.Instance != null || partIsGCode;

            if (showExportGCodeButton)
            {
                string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize());
                Button exportGCode         = textImageButtonFactory.Generate(exportGCodeTextFull);
                exportGCode.Name    = "Export as GCode Button";
                exportGCode.HAnchor = HAnchor.ParentLeft;
                exportGCode.Cursor  = Cursors.Hand;
                exportGCode.Click  += new EventHandler((object sender, EventArgs e) =>
                {
                    UiThread.RunOnIdle(ExportGCode_Click);
                });
                middleRowContainer.AddChild(exportGCode);

                PluginFinder <ExportGcodePlugin> exportPluginFinder = new PluginFinder <ExportGcodePlugin>();

                foreach (ExportGcodePlugin plugin in exportPluginFinder.Plugins)
                {
                    //Create export button for each Plugin found

                    string exportButtonText = plugin.GetButtonText().Localize();

                    Button exportButton = textImageButtonFactory.Generate(exportButtonText);
                    exportButton.HAnchor = HAnchor.ParentLeft;
                    exportButton.Cursor  = Cursors.Hand;
                    exportButton.Click  += (object sender, EventArgs e) =>
                    {
                        UiThread.RunOnIdle(() =>
                        {
                            // Close the export window
                            Close();

                            // Open a SaveFileDialog. If Save is clicked, slice the part if needed and pass the plugin the
                            // path to the gcode file and the target save path
                            FileDialog.SaveFileDialog(
                                new SaveFileDialogParams(plugin.GetExtensionFilter())
                            {
                                Title             = "MatterControl: Export File",
                                FileName          = printItemWrapper.Name,
                                ActionButtonLabel = "Export"
                            },
                                (SaveFileDialogParams saveParam) =>
                            {
                                string extension = Path.GetExtension(saveParam.FileName);
                                if (extension == "")
                                {
                                    saveParam.FileName += plugin.GetFileExtension();
                                }

                                if (partIsGCode)
                                {
                                    plugin.Generate(printItemWrapper.FileLocation, saveParam.FileName);
                                }
                                else
                                {
                                    SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);

                                    printItemWrapper.SlicingDone += (printItem, eventArgs) =>
                                    {
                                        PrintItemWrapper sliceItem = (PrintItemWrapper)printItem;
                                        if (File.Exists(sliceItem.GetGCodePathAndFileName()))
                                        {
                                            plugin.Generate(sliceItem.GetGCodePathAndFileName(), saveParam.FileName);
                                        }
                                    };
                                }
                            });
                        });
                    };                     // End exportButton Click handler

                    middleRowContainer.AddChild(exportButton);
                }
            }

            middleRowContainer.AddChild(new VerticalSpacer());

            // If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
            if (showExportGCodeButton && ActiveSliceSettings.Instance.DoPrintLeveling())
            {
                applyLeveling         = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
                applyLeveling.Checked = true;
                applyLeveling.HAnchor = HAnchor.ParentLeft;
                applyLeveling.Cursor  = Cursors.Hand;
                //applyLeveling.Margin = new BorderDouble(top: 10);
                middleRowContainer.AddChild(applyLeveling);
            }

            // TODO: make this work on the mac and then delete this if
            if (OsInformation.OperatingSystem == OSType.Windows ||
                OsInformation.OperatingSystem == OSType.X11)
            {
                showInFolderAfterSave         = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
                showInFolderAfterSave.HAnchor = HAnchor.ParentLeft;
                showInFolderAfterSave.Cursor  = Cursors.Hand;
                //showInFolderAfterSave.Margin = new BorderDouble(top: 10);
                middleRowContainer.AddChild(showInFolderAfterSave);
            }

            if (!showExportGCodeButton)
            {
                string     noGCodeMessageTextBeg  = LocalizedString.Get("Note");
                string     noGCodeMessageTextEnd  = LocalizedString.Get("To enable GCode export, select a printer profile.");
                string     noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
                TextWidget noGCodeMessage         = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
                noGCodeMessage.HAnchor = HAnchor.ParentLeft;
                middleRowContainer.AddChild(noGCodeMessage);
            }

            //Creates button container on the bottom of window
            FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
            {
                BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                buttonRow.HAnchor = HAnchor.ParentLeftRight;
                buttonRow.Padding = new BorderDouble(0, 3);
            }

            Button cancelButton = textImageButtonFactory.Generate("Cancel");

            cancelButton.Name   = "Export Item Window Cancel Button";
            cancelButton.Cursor = Cursors.Hand;
            cancelButton.Click += (sender, e) =>
            {
                CloseOnIdle();
            };

            buttonRow.AddChild(new HorizontalSpacer());
            buttonRow.AddChild(cancelButton);
            topToBottom.AddChild(middleRowContainer);
            topToBottom.AddChild(buttonRow);

            this.AddChild(topToBottom);
        }
Пример #27
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);
        }
		public SetupAccountView(TextImageButtonFactory textImageButtonFactory)
			: base("My Account")
		{
			this.textImageButtonFactory = textImageButtonFactory;

			bool signedIn = true;
			string username = AuthenticationData.Instance.ActiveSessionUsername;
			if (username == null)
			{
				signedIn = false;
				username = "******";
			}

			FlowLayoutWidget nameAndStatus = new FlowLayoutWidget();
			nameAndStatus.AddChild(new TextWidget(username, pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor));

			connectionStatus = new TextWidget(AuthenticationString, pointSize: 8, textColor: ActiveTheme.Instance.SecondaryTextColor)
			{
				Margin = new BorderDouble(5, 0, 0, 0),
				AutoExpandBoundsToText = true,
			};

			if (signedIn)
			{
				nameAndStatus.AddChild(connectionStatus);
			}


			mainContainer.AddChild(nameAndStatus);

			RefreshStatus();

			FlowLayoutWidget buttonContainer = new FlowLayoutWidget();
			buttonContainer.HAnchor = HAnchor.ParentLeftRight;
			buttonContainer.Margin = new BorderDouble(0, 14);

			signInButton = textImageButtonFactory.Generate("Sign In");
			signInButton.Margin = new BorderDouble(left: 0);
			signInButton.VAnchor = VAnchor.ParentCenter;
			signInButton.Visible = !signedIn;
			signInButton.Click += (s, e) => UiThread.RunOnIdle(() =>
			{
				signInButton.Visible = false;
				signOutButton.Visible = false;
				statusMessage.Visible = true;
				ApplicationController.Instance.StartSignIn();
			});
			buttonContainer.AddChild(signInButton);

			signOutButton = textImageButtonFactory.Generate("Sign Out");
			signOutButton.Margin = new BorderDouble(left: 0);
			signOutButton.VAnchor = VAnchor.ParentCenter;
			signOutButton.Visible = signedIn;
			signOutButton.Click += (s, e) => UiThread.RunOnIdle(() =>
			{
				signInButton.Visible = false;
				signOutButton.Visible = false;
				statusMessage.Visible = true;
				ApplicationController.Instance.StartSignOut();
			});
			buttonContainer.AddChild(signOutButton);

			buttonContainer.AddChild(new HorizontalSpacer());

			// the redeem design code button
			textImageButtonFactory.disabledTextColor = new RGBA_Bytes(textImageButtonFactory.normalTextColor, 100);
			Button redeemPurchaseButton = textImageButtonFactory.Generate("Redeem Purchase".Localize());
			redeemPurchaseButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it.
			redeemPurchaseButton.Name = "Redeem Code Button";
			redeemPurchaseButton.Margin = new BorderDouble(0, 0, 10, 0);
			redeemPurchaseButton.Click += (sender, e) =>
			{
				ApplicationController.Instance.RedeemDesignCode?.Invoke();
			};
			buttonContainer.AddChild(redeemPurchaseButton);

			// the redeem a share code button
			Button redeemShareButton = textImageButtonFactory.Generate("Enter Share Code".Localize());
			redeemShareButton.Enabled = true; // The library selector (the first library selected) is protected so we can't add to it.
			redeemShareButton.Name = "Enter Share Code";
			redeemShareButton.Margin = new BorderDouble(0, 0, 10, 0);
			redeemShareButton.Click += (sender, e) =>
			{
				ApplicationController.Instance.EnterShareCode?.Invoke();
			};

			if (!signedIn)
			{
				redeemPurchaseButton.Enabled = false;
				redeemShareButton.Enabled = false;
			}

			buttonContainer.AddChild(redeemShareButton);

			statusMessage = new TextWidget("Please wait...", pointSize: 12, textColor: ActiveTheme.Instance.SecondaryAccentColor);
			statusMessage.Visible = false;
			buttonContainer.AddChild(statusMessage);

			mainContainer.AddChild(buttonContainer);

			ApplicationController.Instance.DoneReloadingAll.RegisterEvent(RemoveAndNewControl, ref unregisterEvents);
		}
			public CriteriaRow (string itemText, string fixitText, string errorText, bool succeeded, Action fixAction) :base(FlowDirection.LeftToRight, HAnchor.ParentLeftRight, VAnchor.AbsolutePosition)
			{
				TextImageButtonFactory buttonFactory = new TextImageButtonFactory();

				ErrorText = errorText;

				base.Height = 40;

				base.AddChild(new TextWidget (string.Format("  {0}. {1}", criteriaCount + 1, itemText)){
					TextColor = stillSuccessful ? RGBA_Bytes.White : disabledTextColor,
					VAnchor = VAnchor.ParentCenter
				});

				if(stillSuccessful && !succeeded)
				{
					ActiveErrorItem = this;
				}

				base.AddChild(new HorizontalSpacer());

				if(stillSuccessful) {
					if(succeeded)
					{
						// Add checkmark image
						AddSuccessIcon();
					} else {
						// Add Fix button
						Button button  = buttonFactory.Generate(LocalizedString.Get(fixitText),centerText:true);
						button.VAnchor = VAnchor.ParentCenter;
						button.Padding = new BorderDouble(3, 8);
						button.Click += (sender, e) => fixAction();
						base.AddChild(button);
					}
				}

				if(stillSuccessful) 
				{
					this.BackgroundColor = (criteriaCount % 2 == 0) ? RGBA_Bytes.Gray : toggleColor;
				}
				else
				{
					this.BackgroundColor = disabledBackColor;
				}

				stillSuccessful &= succeeded;

				criteriaCount++;
			}
		public SetupPrinterView(TextImageButtonFactory textImageButtonFactory)
			: base("Printer Profile")
		{
			this.textImageButtonFactory = textImageButtonFactory;

			var buttonContainer = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.ParentLeftRight,
				Margin = new BorderDouble (0, 14)
			};
			mainContainer.AddChild(buttonContainer);

			var printerSelectorAndEditButton = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.ParentLeftRight,
			};
			buttonContainer.AddChild(printerSelectorAndEditButton);

			var printerSelector = new PrinterSelector();
			printerSelector.AddPrinter += (s, e) => WizardPage.WizardWindow.ChangeToSetupPrinterForm(true);
			printerSelectorAndEditButton.AddChild(printerSelector);

			var editButton = TextImageButtonFactory.GetThemedEditButton();
			editButton.ToolTipText = "Edit Selected Setting".Localize();
			editButton.VAnchor = VAnchor.ParentCenter;
			editButton.Click += UiNavigation.OpenEditPrinterWizard_Click;
			printerSelectorAndEditButton.AddChild(editButton);

			disconnectButton = textImageButtonFactory.Generate("Disconnect");
			disconnectButton.Margin = new BorderDouble(left: 12);
			disconnectButton.VAnchor = VAnchor.ParentCenter;
			disconnectButton.Click += (sender, e) =>
			{
				PrinterConnectionAndCommunication.Instance.Disable();
				UiThread.RunOnIdle(WizardPage.WizardWindow.ChangeToPage<SetupOptionsPage>);
			};
			buttonContainer.AddChild(disconnectButton);

			connectionStatus = new TextWidget("Status:", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor)
			{
				HAnchor = HAnchor.ParentLeftRight
			};
			mainContainer.AddChild(connectionStatus);

			PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(updateConnectedState, ref unregisterEvents);
			updateConnectedState(null, null);
		}
Пример #31
0
        private void AddContent(HtmlParser htmlParser, string htmlContent)
        {
            ElementState elementState = htmlParser.CurrentElementState;

            htmlContent = replaceMultipleWhiteSpacesWithSingleWhitespaceRegex.Replace(htmlContent, " ");
            string decodedHtml = HtmlParser.UrlDecode(htmlContent);

            switch (elementState.TypeName)
            {
            case "a":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "a";

                if (decodedHtml != null && decodedHtml != "")
                {
                    Button         linkButton      = linkButtonFactory.Generate(decodedHtml.Replace("\r\n", "\n"));
                    StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                    double         descentInPixels = styled.DescentInPixels;
                    linkButton.OriginRelativeParent = new VectorMath.Vector2(linkButton.OriginRelativeParent.x, linkButton.OriginRelativeParent.y + descentInPixels);
                    linkButton.Click += (sender, mouseEvent) =>
                    {
                        MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
                    };
                    elementsUnderConstruction.Peek().AddChild(linkButton);
                }
            }
            break;

            case "h1":
            case "p":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name    = "p";
                elementsUnderConstruction.Peek().HAnchor = HAnchor.ParentLeftRight;

                if (decodedHtml != null && decodedHtml != "")
                {
                    WrappingTextWidget content = new WrappingTextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    //content.VAnchor = VAnchor.ParentTop;
                    elementsUnderConstruction.Peek().AddChild(content);
                }
            }
            break;

            case "div":
            {
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "div";

                if (decodedHtml != null && decodedHtml != "")
                {
                    TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    elementsUnderConstruction.Peek().AddChild(content);
                }
            }
            break;

            case "!DOCTYPE":
                break;

            case "body":
                break;

            case "html":
                break;

            case "img":
            {
                ImageBuffer image       = new ImageBuffer(Math.Max(elementState.SizeFixed.x, 1), Math.Max(elementState.SizeFixed.y, 1));
                ImageWidget imageWidget = new ImageWidget(image);
                imageWidget.Load += (s, e) => StaticData.DownloadToImageAsync(image, elementState.src, elementState.SizeFixed.x == 0 ? true : false);
                // put the image into the widget when it is done downloading.

                if (elementsUnderConstruction.Peek().Name == "a")
                {
                    Button linkButton = new Button(0, 0, imageWidget);
                    linkButton.Cursor = Cursors.Hand;
                    linkButton.Click += (sender, mouseEvent) =>
                    {
                        MatterControlApplication.Instance.LaunchBrowser(elementState.Href);
                    };
                    elementsUnderConstruction.Peek().AddChild(linkButton);
                }
                else
                {
                    elementsUnderConstruction.Peek().AddChild(imageWidget);
                }
            }
            break;

            case "input":
                break;

            case "table":
                break;

            case "td":
            case "span":
                GuiWidget widgetToAdd;

                if (elementState.Classes.Contains("translate"))
                {
                    decodedHtml = decodedHtml.Localize();
                }
                if (elementState.Classes.Contains("toUpper"))
                {
                    decodedHtml = decodedHtml.ToUpper();
                }
                if (elementState.Classes.Contains("versionNumber"))
                {
                    decodedHtml = VersionInfo.Instance.ReleaseVersion;
                }
                if (elementState.Classes.Contains("buildNumber"))
                {
                    decodedHtml = VersionInfo.Instance.BuildVersion;
                }

                Button createdButton = null;
                if (elementState.Classes.Contains("centeredButton"))
                {
                    createdButton = textImageButtonFactory.Generate(decodedHtml);
                    widgetToAdd   = createdButton;
                }
                else if (elementState.Classes.Contains("linkButton"))
                {
                    double oldFontSize = linkButtonFactory.fontSize;
                    linkButtonFactory.fontSize = elementState.PointSize;
                    createdButton = linkButtonFactory.Generate(decodedHtml);
                    StyledTypeFace styled          = new StyledTypeFace(LiberationSansFont.Instance, elementState.PointSize);
                    double         descentInPixels = styled.DescentInPixels;
                    createdButton.OriginRelativeParent = new VectorMath.Vector2(createdButton.OriginRelativeParent.x, createdButton.OriginRelativeParent.y + descentInPixels);
                    widgetToAdd = createdButton;
                    linkButtonFactory.fontSize = oldFontSize;
                }
                else
                {
                    TextWidget content = new TextWidget(decodedHtml, pointSize: elementState.PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor);
                    widgetToAdd = content;
                }

                if (createdButton != null)
                {
                    if (elementState.Id == "sendFeedback")
                    {
                        createdButton.Click += (s, e) => ContactFormWindow.Open();
                    }
                    else if (elementState.Id == "clearCache")
                    {
                        createdButton.Click += (s, e) => AboutWidget.DeleteCacheData(0);
                    }
                }

                if (elementState.VerticalAlignment == ElementState.VerticalAlignType.top)
                {
                    widgetToAdd.VAnchor = VAnchor.ParentTop;
                }

                elementsUnderConstruction.Peek().AddChild(widgetToAdd);
                break;

            case "tr":
                elementsUnderConstruction.Push(new FlowLayoutWidget());
                elementsUnderConstruction.Peek().Name = "tr";
                if (elementState.SizePercent.y == 100)
                {
                    elementsUnderConstruction.Peek().VAnchor = VAnchor.ParentBottomTop;
                }
                if (elementState.Alignment == ElementState.AlignType.center)
                {
                    elementsUnderConstruction.Peek().HAnchor |= HAnchor.ParentCenter;
                }
                break;

            default:
                throw new NotImplementedException("Don't know what to do with '{0}'".FormatWith(elementState.TypeName));
            }
        }
Пример #32
0
        public MacroListWidget(EditMacrosWindow windowController)
        {
            this.windowController = windowController;

            linkButtonFactory.fontSize = 10;
            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     macroPresetsLabel     = LocalizedString.Get("Macro Presets");
                string     macroPresetsLabelFull = string.Format("{0}:", macroPresetsLabel);
                TextWidget elementHeader         = new TextWidget(macroPresetsLabelFull, 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);

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

            topToBottom.AddChild(presetsFormContainer);

            if (ActiveSliceSettings.Instance?.Macros != null)
            {
                foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
                {
                    FlowLayoutWidget macroRow = new FlowLayoutWidget();
                    macroRow.Margin          = new BorderDouble(3, 0, 3, 3);
                    macroRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                    macroRow.Padding         = new BorderDouble(3);
                    macroRow.BackgroundColor = RGBA_Bytes.White;

                    TextWidget buttonLabel = new TextWidget(macro.Name);
                    macroRow.AddChild(buttonLabel);

                    macroRow.AddChild(new HorizontalSpacer());

                    // You can't pass a foreach variable into a link function or it wall always be the last item.
                    // So we make a local variable copy of it and pass that. This will get the right one.
                    var localMacroReference = macro;

                    Button editLink = linkButtonFactory.Generate("edit".Localize());
                    editLink.Margin = new BorderDouble(right: 5);
                    editLink.Click += (sender, e) =>
                    {
                        windowController.ChangeToMacroDetail(localMacroReference);
                    };
                    macroRow.AddChild(editLink);

                    Button removeLink = linkButtonFactory.Generate("remove".Localize());
                    removeLink.Click += (sender, e) =>
                    {
                        ActiveSliceSettings.Instance.Macros.Remove(localMacroReference);
                        windowController.functionToCallOnSave(this, null);
                        windowController.ChangeToMacroList();
                    };
                    macroRow.AddChild(removeLink);

                    presetsFormContainer.AddChild(macroRow);
                }
            }

            Button addMacroButton = textImageButtonFactory.Generate("Add".Localize(), "icon_circle_plus.png");

            addMacroButton.ToolTipText = "Add a new Macro".Localize();
            addMacroButton.Click      += (s, e) =>
            {
                windowController.ChangeToMacroDetail(new GCodeMacro()
                {
                    Name  = "Home All",
                    GCode = "G28 ; Home All Axes"
                });
            };

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

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

            topToBottom.AddChild(buttonRow);
            AddChild(topToBottom);
            this.AnchorAll();
        }
        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);
        }
Пример #34
0
		public void CreateWindowContent()
		{
			this.RemoveAllChildren();
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
			topToBottom.AnchorAll();

			// Creates Header
			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);
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			//Creates Text and adds into header
			{
				TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14);
				elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				elementHeader.HAnchor = HAnchor.ParentLeftRight;
				elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

				headerRow.AddChild(elementHeader);
				topToBottom.AddChild(headerRow);
			}

			// Creates container in the middle of window
			FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
				middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
				middleRowContainer.Padding = new BorderDouble(5);
				middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			if (!partIsGCode)
			{
				string exportStlText = LocalizedString.Get("Export as");
				string exportStlTextFull = string.Format("{0} STL", exportStlText);

				Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
				exportAsStlButton.HAnchor = HAnchor.ParentLeft;
				exportAsStlButton.Cursor = Cursors.Hand;
				exportAsStlButton.Click += new EventHandler(exportSTL_Click);
				middleRowContainer.AddChild(exportAsStlButton);
			}

			if (!partIsGCode)
			{
				string exportAmfText = LocalizedString.Get("Export as");
				string exportAmfTextFull = string.Format("{0} AMF", exportAmfText);

				Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull);
				exportAsAmfButton.HAnchor = HAnchor.ParentLeft;
				exportAsAmfButton.Cursor = Cursors.Hand;
				exportAsAmfButton.Click += new EventHandler(exportAMF_Click);
				middleRowContainer.AddChild(exportAsAmfButton);
			}

			bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;

			if (showExportGCodeButton)
			{
				string exportGCodeText = LocalizedString.Get("Export as");
				string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText);
				Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
				exportGCode.HAnchor = HAnchor.ParentLeft;
				exportGCode.Cursor = Cursors.Hand;
				exportGCode.Click += new EventHandler((object sender, EventArgs e) =>
				{
					UiThread.RunOnIdle(ExportGCode_Click);
				});
				middleRowContainer.AddChild(exportGCode);

				bool showExportX3GButton = ActiveSliceSettings.Instance.IsMakerbotGCodeFlavor();
				if (showExportX3GButton)
				{
					string exportAsX3GText = "Export as X3G".Localize();
					Button exportAsX3G = textImageButtonFactory.Generate(exportAsX3GText);
					exportAsX3G.HAnchor = HAnchor.ParentLeft;
					exportAsX3G.Cursor = Cursors.Hand;
					exportAsX3G.Click += new EventHandler((object sender, EventArgs e) =>
						{
							UiThread.RunOnIdle(ExportX3G_Click);
						});
					middleRowContainer.AddChild(exportAsX3G);
				}
			}

			middleRowContainer.AddChild(new VerticalSpacer());

			// If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
			if (showExportGCodeButton && ActivePrinterProfile.Instance.DoPrintLeveling)
			{
				applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
				applyLeveling.Checked = true;
				applyLeveling.HAnchor = HAnchor.ParentLeft;
				applyLeveling.Cursor = Cursors.Hand;
				//applyLeveling.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(applyLeveling);
			}

			// TODO: make this work on the mac and then delete this if
			if (OsInformation.OperatingSystem == OSType.Windows
				|| OsInformation.OperatingSystem == OSType.X11)
			{
				showInFolderAfterSave = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
				showInFolderAfterSave.HAnchor = HAnchor.ParentLeft;
				showInFolderAfterSave.Cursor = Cursors.Hand;
				//showInFolderAfterSave.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(showInFolderAfterSave);
			}

			if (!showExportGCodeButton)
			{
				string noGCodeMessageTextBeg = LocalizedString.Get("Note");
				string noGCodeMessageTextEnd = LocalizedString.Get("To enable GCode export, select a printer profile.");
				string noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
				TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
				noGCodeMessage.HAnchor = HAnchor.ParentLeft;
				middleRowContainer.AddChild(noGCodeMessage);
			}

			//Creates button container on the bottom of window
			FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			{
				BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				buttonRow.HAnchor = HAnchor.ParentLeftRight;
				buttonRow.Padding = new BorderDouble(0, 3);
			}

			Button cancelButton = textImageButtonFactory.Generate("Cancel");
			cancelButton.Cursor = Cursors.Hand;
			cancelButton.Click += (sender, e) =>
			{
				CloseOnIdle();
			};

			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(cancelButton);
			topToBottom.AddChild(middleRowContainer);
			topToBottom.AddChild(buttonRow);

			this.AddChild(topToBottom);
		}
		public void CreateWindowContent()
		{
			this.RemoveAllChildren();
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
			FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
			topToBottom.AnchorAll();

			// Creates Header
			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);
			BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			//Creates Text and adds into header
			{
				TextWidget elementHeader = new TextWidget("File export options:".Localize(), pointSize: 14);
				elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
				elementHeader.HAnchor = HAnchor.ParentLeftRight;
				elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;

				headerRow.AddChild(elementHeader);
				topToBottom.AddChild(headerRow);
			}

			// Creates container in the middle of window
			FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			{
				middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
				middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
				middleRowContainer.Padding = new BorderDouble(5);
				middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			}

			if (!partIsGCode)
			{
				string exportStlText = LocalizedString.Get("Export as");
				string exportStlTextFull = string.Format("{0} STL", exportStlText);

				Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
				exportAsStlButton.HAnchor = HAnchor.ParentLeft;
				exportAsStlButton.Cursor = Cursors.Hand;
				exportAsStlButton.Click += new EventHandler(exportSTL_Click);
				middleRowContainer.AddChild(exportAsStlButton);
			}

			if (!partIsGCode)
			{
				string exportAmfText = LocalizedString.Get("Export as");
				string exportAmfTextFull = string.Format("{0} AMF", exportAmfText);

				Button exportAsAmfButton = textImageButtonFactory.Generate(exportAmfTextFull);
				exportAsAmfButton.HAnchor = HAnchor.ParentLeft;
				exportAsAmfButton.Cursor = Cursors.Hand;
				exportAsAmfButton.Click += new EventHandler(exportAMF_Click);
				middleRowContainer.AddChild(exportAsAmfButton);
			}

			bool showExportGCodeButton = ActiveSliceSettings.Instance != null || partIsGCode;
			if (showExportGCodeButton)
			{
				string exportGCodeTextFull = string.Format("{0} G-Code", "Export as".Localize());
				Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
				exportGCode.Name = "Export as GCode Button";
				exportGCode.HAnchor = HAnchor.ParentLeft;
				exportGCode.Cursor = Cursors.Hand;
				exportGCode.Click += new EventHandler((object sender, EventArgs e) =>
				{
					UiThread.RunOnIdle(ExportGCode_Click);
				});
				middleRowContainer.AddChild(exportGCode);

				PluginFinder<ExportGcodePlugin> exportPluginFinder = new PluginFinder<ExportGcodePlugin>();

				foreach (ExportGcodePlugin plugin in exportPluginFinder.Plugins)
				{
					//Create export button for each Plugin found

					string exportButtonText = plugin.GetButtonText().Localize();

					Button exportButton = textImageButtonFactory.Generate(exportButtonText);
					exportButton.HAnchor = HAnchor.ParentLeft;
					exportButton.Cursor = Cursors.Hand;
					exportButton.Click += (object sender, EventArgs e) =>
					{
						UiThread.RunOnIdle(() =>
						{
							// Close the export window
							Close();

							// Open a SaveFileDialog. If Save is clicked, slice the part if needed and pass the plugin the 
							// path to the gcode file and the target save path
							FileDialog.SaveFileDialog(
								new SaveFileDialogParams(plugin.GetExtensionFilter())
								{
									Title = "MatterControl: Export File",
									FileName = printItemWrapper.Name,
									ActionButtonLabel = "Export"
								},
								(SaveFileDialogParams saveParam) =>
								{
									string extension = Path.GetExtension(saveParam.FileName);
									if (extension == "")
									{
										saveParam.FileName += plugin.GetFileExtension();
									}

									if (partIsGCode)
									{
										plugin.Generate(printItemWrapper.FileLocation, saveParam.FileName);
									}
									else
									{
										SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);

										printItemWrapper.SlicingDone += (printItem, eventArgs) =>
										{
											PrintItemWrapper sliceItem = (PrintItemWrapper)printItem;
											if (File.Exists(sliceItem.GetGCodePathAndFileName()))
											{
												plugin.Generate(sliceItem.GetGCodePathAndFileName(), saveParam.FileName);
											}
										};
									}
								});
						});
					}; // End exportButton Click handler

					middleRowContainer.AddChild(exportButton);
				}
			}

			middleRowContainer.AddChild(new VerticalSpacer());

			// If print leveling is enabled then add in a check box 'Apply Leveling During Export' and default checked.
			if (showExportGCodeButton && ActiveSliceSettings.Instance.DoPrintLeveling)
			{
				applyLeveling = new CheckBox(LocalizedString.Get(applyLevelingDuringExportString), ActiveTheme.Instance.PrimaryTextColor, 10);
				applyLeveling.Checked = true;
				applyLeveling.HAnchor = HAnchor.ParentLeft;
				applyLeveling.Cursor = Cursors.Hand;
				//applyLeveling.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(applyLeveling);
			}

			// TODO: make this work on the mac and then delete this if
			if (OsInformation.OperatingSystem == OSType.Windows
				|| OsInformation.OperatingSystem == OSType.X11)
			{
				showInFolderAfterSave = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
				showInFolderAfterSave.HAnchor = HAnchor.ParentLeft;
				showInFolderAfterSave.Cursor = Cursors.Hand;
				//showInFolderAfterSave.Margin = new BorderDouble(top: 10);
				middleRowContainer.AddChild(showInFolderAfterSave);
			}

			if (!showExportGCodeButton)
			{
				string noGCodeMessageTextBeg = LocalizedString.Get("Note");
				string noGCodeMessageTextEnd = LocalizedString.Get("To enable GCode export, select a printer profile.");
				string noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
				TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
				noGCodeMessage.HAnchor = HAnchor.ParentLeft;
				middleRowContainer.AddChild(noGCodeMessage);
			}

			//Creates button container on the bottom of window
			FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			{
				BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
				buttonRow.HAnchor = HAnchor.ParentLeftRight;
				buttonRow.Padding = new BorderDouble(0, 3);
			}

			Button cancelButton = textImageButtonFactory.Generate("Cancel");
			cancelButton.Name = "Export Item Window Cancel Button";
			cancelButton.Cursor = Cursors.Hand;
			cancelButton.Click += (sender, e) =>
			{
				CloseOnIdle();
			};

			buttonRow.AddChild(new HorizontalSpacer());
			buttonRow.AddChild(cancelButton);
			topToBottom.AddChild(middleRowContainer);
			topToBottom.AddChild(buttonRow);

			this.AddChild(topToBottom);
		}
		public SetupAccountView(TextImageButtonFactory textImageButtonFactory)
			: base("My Account")
		{
			this.textImageButtonFactory = textImageButtonFactory;

			bool signedIn = true;
			string username = AuthenticationData.Instance.ActiveSessionUsername;
			if (username == null)
			{
				signedIn = false;
				username = "******";
			}

			mainContainer.AddChild(new TextWidget(username, pointSize: 16, textColor: ActiveTheme.Instance.PrimaryTextColor));

			FlowLayoutWidget buttonContainer = new FlowLayoutWidget();
			buttonContainer.HAnchor = HAnchor.ParentLeftRight;
			buttonContainer.Margin = new BorderDouble(0, 14);

			signInButton = textImageButtonFactory.Generate("Sign In");
			signInButton.Margin = new BorderDouble(left: 0);
			signInButton.VAnchor = VAnchor.ParentCenter;
			signInButton.Visible = !signedIn;
			signInButton.Click +=  (s, e) => UiThread.RunOnIdle(() =>
			{
				signInButton.Visible = false;
				signOutButton.Visible = false;
				statusMessage.Visible = true;
				ApplicationController.Instance.StartSignIn();
			});
			buttonContainer.AddChild(signInButton);

			signOutButton = textImageButtonFactory.Generate("Sign Out");
			signOutButton.Margin = new BorderDouble(left: 0);
			signOutButton.VAnchor = VAnchor.ParentCenter;
			signOutButton.Visible = signedIn;
			signOutButton.Click += (s, e) => UiThread.RunOnIdle(() =>
			{
				signInButton.Visible = false;
				signOutButton.Visible = false;
				statusMessage.Visible = true;
				ApplicationController.Instance.StartSignOut();
			});
			buttonContainer.AddChild(signOutButton);

			statusMessage = new TextWidget("Please wait...", pointSize: 12, textColor: ActiveTheme.Instance.SecondaryAccentColor);
			statusMessage.Visible = false;
			buttonContainer.AddChild(statusMessage);

			mainContainer.AddChild(buttonContainer);

			ApplicationController.Instance.DoneReloadingAll.RegisterEvent(RemoveAndNewControl, ref unregisterEvents);
		}
Пример #37
0
        public void doLayout()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget       topToBottom            = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
            topToBottom.AnchorAll();

            FlowLayoutWidget headerContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerContainer.HAnchor         = HAnchor.ParentLeftRight;
            headerContainer.Padding         = new BorderDouble(0, 3, 0, 3);
            headerContainer.Margin          = new BorderDouble(0, 3, 0, 0);
            headerContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            string     exportLabelText     = LocalizedString.Get("File export options");
            string     exportLabelTextFull = string.Format("{0}:", exportLabelText);
            TextWidget exportLabel         = new TextWidget(exportLabelTextFull);

            exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            headerContainer.AddChild(exportLabel);
            topToBottom.AddChild(headerContainer);

            FlowLayoutWidget exportSTLGCodeButtonsContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            exportSTLGCodeButtonsContainer.HAnchor         = HAnchor.ParentLeftRight;
            exportSTLGCodeButtonsContainer.VAnchor         = VAnchor.ParentBottomTop;
            exportSTLGCodeButtonsContainer.Padding         = new BorderDouble(5);
            exportSTLGCodeButtonsContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

            Button cancelButton = textImageButtonFactory.Generate("Cancel");

            cancelButton.Padding = new BorderDouble(0);
            cancelButton.Click  += (sender, e) => {
                CloseOnIdle();
            };

            GuiWidget gDSpacer = new GuiWidget();

            gDSpacer.HAnchor = HAnchor.ParentLeftRight;

            if (!partIsGCode)
            {
                string exportStlText     = LocalizedString.Get("Export as");
                string exportStlTextFull = string.Format("{0} STL", exportStlText);

                Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTextFull);
                exportAsStlButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click);
                exportSTLGCodeButtonsContainer.AddChild(exportAsStlButton);
            }

            bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;

            if (showExportGCodeButton)
            {
                string exportGCodeText     = LocalizedString.Get("Export as");
                string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText);

                Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);
                exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click);
                exportSTLGCodeButtonsContainer.AddChild(exportGCode);
            }

            GuiWidget vSpacer = new GuiWidget();

            vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
            exportSTLGCodeButtonsContainer.AddChild(vSpacer);

            if (!showExportGCodeButton)
            {
                string     noGCodeMessageTextBeg  = LocalizedString.Get("Note");
                string     noGCodeMessageTextEnd  = LocalizedString.Get("To enable GCode export, select a printer profile.");
                string     noGCodeMessageTextFull = string.Format("{0}: {1}", noGCodeMessageTextBeg, noGCodeMessageTextEnd);
                TextWidget noGCodeMessage         = new TextWidget(noGCodeMessageTextFull, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 10);
                exportSTLGCodeButtonsContainer.AddChild(noGCodeMessage);
            }

            FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonRow.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            buttonRow.HAnchor         = HAnchor.ParentLeftRight;
            buttonRow.Padding         = new BorderDouble(0);

            // TODO: make this work on the mac and then delete this if
            if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows)
            {
                showInFolderAfterSave        = new CheckBox(LocalizedString.Get("Show file in folder after save"), ActiveTheme.Instance.PrimaryTextColor, 10);
                showInFolderAfterSave.Margin = new BorderDouble(top: 10);
                exportSTLGCodeButtonsContainer.AddChild(showInFolderAfterSave);
                buttonRow.AddChild(gDSpacer);
                buttonRow.AddChild(cancelButton);
                topToBottom.AddChild(exportSTLGCodeButtonsContainer);
                topToBottom.AddChild(buttonRow);
            }

            this.AddChild(topToBottom);
        }
        public StyledMessageBox(Action <bool> callback, String message, string windowTitle, MessageType messageType, GuiWidget[] extraWidgetsToAdd, double width, double height, string yesOk, string no)
            : base(width, height)
        {
            if (UserSettings.Instance.IsTouchScreen)
            {
                extraTextScaling = 1.33333;
            }

            textImageButtonFactory.fontSize = extraTextScaling * textImageButtonFactory.fontSize;
            if (yesOk == "")
            {
                if (messageType == MessageType.OK)
                {
                    yesOk = "Ok".Localize();
                }
                else
                {
                    yesOk = "Yes".Localize();
                }
            }
            if (no == "")
            {
                no = "No".Localize();
            }

            responseCallback = callback;
            unwrappedMessage = message;
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            if (UserSettings.Instance.IsTouchScreen)
            {
                topToBottom.Padding = new BorderDouble(12, 12, 13, 8);
            }
            else
            {
                topToBottom.Padding = new BorderDouble(3, 0, 3, 5);
            }

            // Creates Header
            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);
            BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;

            //Creates Text and adds into header
            {
                TextWidget elementHeader = new TextWidget(windowTitle, pointSize: 14 * extraTextScaling);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
                topToBottom.AddChild(headerRow);
            }

            // Creates container in the middle of window
            middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            {
                middleRowContainer.HAnchor = HAnchor.ParentLeftRight;
                middleRowContainer.VAnchor = VAnchor.ParentBottomTop;
                // normally the padding for the middle container should be just (5) all around. The has extra top space
                middleRowContainer.Padding         = new BorderDouble(5, 5, 5, 15);
                middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            messageContainer = new TextWidget(message, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: 12 * extraTextScaling);
            messageContainer.AutoExpandBoundsToText = true;
            messageContainer.HAnchor = Agg.UI.HAnchor.ParentLeft;
            middleRowContainer.AddChild(messageContainer);

            if (extraWidgetsToAdd != null)
            {
                foreach (GuiWidget widget in extraWidgetsToAdd)
                {
                    middleRowContainer.AddChild(widget);
                }
            }

            topToBottom.AddChild(middleRowContainer);

            //Creates button container on the bottom of window
            FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            {
                BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                buttonRow.HAnchor = HAnchor.ParentLeftRight;
                buttonRow.Padding = new BorderDouble(0, 3);
            }


            switch (messageType)
            {
            case MessageType.YES_NO:
            {
                Title = "MatterControl - " + "Please Confirm".Localize();
                Button yesButton = textImageButtonFactory.Generate(yesOk, centerText: true);
                yesButton.Click += new EventHandler(okButton_Click);
                yesButton.Cursor = Cursors.Hand;
                buttonRow.AddChild(yesButton);

                buttonRow.AddChild(new HorizontalSpacer());

                Button noButton = textImageButtonFactory.Generate(no, centerText: true);
                noButton.Click += new EventHandler(noButton_Click);
                noButton.Cursor = Cursors.Hand;
                buttonRow.AddChild(noButton);
            }
            break;

            case MessageType.OK:
            {
                Title = "MatterControl - " + "Alert".Localize();
                Button okButton = textImageButtonFactory.Generate(LocalizedString.Get("Ok"), centerText: true);
                okButton.Name   = "Ok Button";
                okButton.Cursor = Cursors.Hand;
                okButton.Click += new EventHandler(okButton_Click);
                buttonRow.AddChild(okButton);
            }
            break;

            default:
                throw new NotImplementedException();
            }

            topToBottom.AddChild(buttonRow);
            this.AddChild(topToBottom);

            IsModal = true;
            AdjustTextWrap();
        }
Пример #39
0
		private GuiWidget CreateContentForEmptyControl()
		{
			GuiWidget allContent = new GuiWidget(HAnchor.ParentLeftRight, VAnchor.ParentBottomTop);
			allContent.Padding = new BorderDouble(5, 10, 5, 10);

			FlowLayoutWidget flowWidget = new FlowLayoutWidget();
			flowWidget.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
			flowWidget.HAnchor = HAnchor.ParentLeftRight;
			flowWidget.VAnchor = VAnchor.ParentTop;
			flowWidget.Padding = new BorderDouble(10, 0);
			flowWidget.Height = 60;

			TextImageButtonFactory bringBackButtonFactory = new TextImageButtonFactory();
			bringBackButtonFactory.normalFillColor = RGBA_Bytes.Gray;
			bringBackButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;

			Button bringBackToTabButton = bringBackButtonFactory.Generate(LocalizedString.Get("Restore"));
			bringBackToTabButton.ToolTipText = "Bring the Window back into this Tab".Localize();
			bringBackToTabButton.VAnchor = VAnchor.ParentCenter;
			bringBackToTabButton.Cursor = Cursors.Hand;
			bringBackToTabButton.Click += (sender, e) =>
			{
				UiThread.RunOnIdle(() =>
				{
					SaveWindowShouldStartClosed();
					SystemWindow temp = systemWindowWithPopContent;
					SystemWindow_Closing(null, null);
					temp.Close();
				});
			};

			TextWidget windowedModeMessage = new TextWidget(LocalizedString.Get("WINDOWED MODE: This tab has been moved to a separate window."),
				pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor);
			windowedModeMessage.VAnchor = VAnchor.ParentCenter;

			flowWidget.AddChild(windowedModeMessage);
			flowWidget.AddChild(new HorizontalSpacer());
			flowWidget.AddChild(bringBackToTabButton);

			allContent.AddChild(flowWidget);

			return allContent;
		}
Пример #40
0
        public SaveAsWindow(SetPrintItemWrapperAndSave functionToCallOnSaveAs)
            : base(480, 250)
        {
            Title = "MatterControl - Save As";

            this.functionToCallOnSaveAs = functionToCallOnSaveAs;

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.Padding = new BorderDouble(3, 0, 3, 5);

            // Creates Header
            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);
            BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;

            //Creates Text and adds into header
            {
                string     saveAsLabel   = "Save New Design to Queue:";
                TextWidget elementHeader = new TextWidget(saveAsLabel, pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
                topToBottom.AddChild(headerRow);
                this.AddChild(topToBottom);
            }

            //Creates container in the middle of window
            FlowLayoutWidget middleRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
            {
                middleRowContainer.HAnchor         = HAnchor.ParentLeftRight;
                middleRowContainer.VAnchor         = VAnchor.ParentBottomTop;
                middleRowContainer.Padding         = new BorderDouble(5);
                middleRowContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            }

            string     fileNameLabel = "Design Name";
            TextWidget textBoxHeader = new TextWidget(fileNameLabel, pointSize: 12);

            textBoxHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            textBoxHeader.Margin    = new BorderDouble(5);
            textBoxHeader.HAnchor   = HAnchor.ParentLeft;

            string     fileNameLabelFull = "Enter the name of your design.";
            TextWidget textBoxHeaderFull = new TextWidget(fileNameLabelFull, pointSize: 9);

            textBoxHeaderFull.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            textBoxHeaderFull.Margin    = new BorderDouble(5);
            textBoxHeaderFull.HAnchor   = HAnchor.ParentLeftRight;

            //Adds text box and check box to the above container
            textToAddWidget         = new MHTextEditWidget("", pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a Design Name Here");
            textToAddWidget.HAnchor = HAnchor.ParentLeftRight;
            textToAddWidget.Margin  = new BorderDouble(5);

            addToLibraryOption         = new CheckBox("Also save to Library", ActiveTheme.Instance.PrimaryTextColor);
            addToLibraryOption.Margin  = new BorderDouble(5);
            addToLibraryOption.HAnchor = HAnchor.ParentLeftRight;

            middleRowContainer.AddChild(textBoxHeader);
            middleRowContainer.AddChild(textBoxHeaderFull);
            middleRowContainer.AddChild(textToAddWidget);
            middleRowContainer.AddChild(new HorizontalSpacer());
            middleRowContainer.AddChild(addToLibraryOption);
            topToBottom.AddChild(middleRowContainer);

            //Creates button container on the bottom of window
            FlowLayoutWidget buttonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
            {
                BackgroundColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
                buttonRow.HAnchor = HAnchor.ParentLeftRight;
                buttonRow.Padding = new BorderDouble(0, 3);
            }

            Button saveAsButton = textImageButtonFactory.Generate("Save As".Localize(), centerText: true);

            saveAsButton.Visible = true;
            saveAsButton.Cursor  = Cursors.Hand;
            buttonRow.AddChild(saveAsButton);

            saveAsButton.Click += new EventHandler(saveAsButton_Click);
            textToAddWidget.ActualTextEditWidget.EnterPressed += new KeyEventHandler(ActualTextEditWidget_EnterPressed);

            //Adds SaveAs and Close Button to button container
            buttonRow.AddChild(new HorizontalSpacer());

            Button cancelButton = textImageButtonFactory.Generate("Cancel", centerText: true);

            cancelButton.Visible = true;
            cancelButton.Cursor  = Cursors.Hand;
            buttonRow.AddChild(cancelButton);
            cancelButton.Click += (sender, e) =>
            {
                CloseOnIdle();
            };

            topToBottom.AddChild(buttonRow);

            ShowAsSystemWindow();
        }
Пример #41
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 * 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 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);

                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(LocalizedString.Get("Max Temp."), 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();
            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);
        }
        public void doLayout()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            topToBottom.Padding = new BorderDouble(10);
            topToBottom.AnchorAll();

			string exportLblTxt = new LocalizedString ("File export options").Translated;
			string exportLblTxtFull = string.Format ("{0}:", exportLblTxt);
			TextWidget exportLabel = new TextWidget(exportLblTxtFull);
            exportLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            topToBottom.AddChild(exportLabel);

            GuiWidget dividerLine = new GuiWidget();
            dividerLine.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            dividerLine.Height = 1;
            dividerLine.Margin = new BorderDouble(0, 3);
            dividerLine.BackgroundColor = RGBA_Bytes.White;
            topToBottom.AddChild(dividerLine);

            if (!partIsGCode)
            {
				string exportStlTxt = new LocalizedString("Export as").Translated;
				string exportStlTxtFull = string.Format("{0} STL", exportStlTxt);

				Button exportAsStlButton = textImageButtonFactory.Generate(exportStlTxtFull);
                exportAsStlButton.Click += new ButtonBase.ButtonEventHandler(exportSTL_Click);
                //exportSTL.HAnchor = Agg.UI.HAnchor.ParentCenter;
                topToBottom.AddChild(exportAsStlButton);
            }

            bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;

            if(showExportGCodeButton)
            {
				string exportGCodeText = new LocalizedString("Export as").Translated;
				string exportGCodeTextFull = string.Format("{0} GCode", exportGCodeText);

				Button exportGCode = textImageButtonFactory.Generate(exportGCodeTextFull);

                //exportGCode.HAnchor = Agg.UI.HAnchor.ParentCenter;
				exportGCode.Click += new ButtonBase.ButtonEventHandler(exportGCode_Click);
				topToBottom.AddChild(exportGCode);
            }

            GuiWidget vSpacer = new GuiWidget();
            vSpacer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
            topToBottom.AddChild(vSpacer);

            if (!showExportGCodeButton)
            {
				string noGCodeMessageTxtBeg = new LocalizedString("Note").Translated;
				string noGCodeMessageTxtEnd = new LocalizedString ("To enable GCode export, select a printer profile.").Translated;
				string noGCodeMessageTxtFull = string.Format ("{0}: {1}", noGCodeMessageTxtBeg, noGCodeMessageTxtEnd);
				TextWidget noGCodeMessage = new TextWidget(noGCodeMessageTxtFull, textColor: RGBA_Bytes.White, pointSize: 10);
                topToBottom.AddChild(noGCodeMessage);
			}

            // TODO: make this work on the mac and then delete this if
           	if (MatterHackers.Agg.UI.WindowsFormsAbstract.GetOSType() == WindowsFormsAbstract.OSType.Windows)
            {
				showInFolderAfterSave = new CheckBox(new LocalizedString("Show file in folder after save").Translated, RGBA_Bytes.White, 10);
                showInFolderAfterSave.Margin = new BorderDouble(top: 10);
                topToBottom.AddChild(showInFolderAfterSave);
            }

            this.AddChild(topToBottom);
        }