public ViewControls2D()
		{
			if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
			{
				buttonHeight = 40;
			}
			else
			{
				buttonHeight = 0;
			}

			TextImageButtonFactory iconTextImageButtonFactory = new TextImageButtonFactory();
			iconTextImageButtonFactory.AllowThemeToAdjustImage = false;
			iconTextImageButtonFactory.checkedBorderColor = RGBA_Bytes.White;

			BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);
			iconTextImageButtonFactory.FixedHeight = buttonHeight;
			iconTextImageButtonFactory.FixedWidth = buttonHeight;

			string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png");
			resetViewButton = iconTextImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath,32,32).InvertLightness());
			resetViewButton.ToolTipText = "Reset View".Localize();
			AddChild(resetViewButton);
			resetViewButton.Click += (sender, e) =>
			{
				ResetView?.Invoke(this, null);
			};

			string translateIconPath = Path.Combine("ViewTransformControls", "translate.png");
			translateButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath,32,32));
            translateButton.ToolTipText = "Move".Localize();
            translateButton.Margin = new BorderDouble(3);
			AddChild(translateButton);

			string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png");
			scaleButton = iconTextImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath,32,32));
            scaleButton.ToolTipText = "Zoom".Localize();
            scaleButton.Margin = new BorderDouble(3);
			AddChild(scaleButton);

			Margin = new BorderDouble(5);
			HAnchor |= Agg.UI.HAnchor.ParentLeft;
			VAnchor = Agg.UI.VAnchor.ParentTop;
			translateButton.Checked = true;
		}
		public ViewControls3D(MeshViewerWidget meshViewerWidget)
		{
			if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
			{
				buttonHeight = 40;
			}
			else
			{
				buttonHeight = 0;
			}

			this.meshViewerWidget = meshViewerWidget;
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();

			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;

			BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);
			textImageButtonFactory.FixedHeight = buttonHeight;
			textImageButtonFactory.FixedWidth = buttonHeight;
			textImageButtonFactory.AllowThemeToAdjustImage = false;
			textImageButtonFactory.checkedBorderColor = RGBA_Bytes.White;

            string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png");
			resetViewButton = textImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath, 32,32).InvertLightness());
			resetViewButton.ToolTipText = "Reset View".Localize();
			AddChild(resetViewButton);
			resetViewButton.Click += (sender, e) =>
			{
				ResetView?.Invoke(this, null);
            };

			string rotateIconPath = Path.Combine("ViewTransformControls", "rotate.png");
			rotateButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(rotateIconPath,32,32));
			rotateButton.ToolTipText = "Rotate (Alt + Left Mouse)".Localize();
            rotateButton.Margin = new BorderDouble(3);
			AddChild(rotateButton);
			rotateButton.Click += (sender, e) =>
			{
				this.ActiveButton = ViewControls3DButtons.Rotate;
			};

			string translateIconPath = Path.Combine("ViewTransformControls", "translate.png");
			translateButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath,32,32));
			translateButton.ToolTipText = "Move (Shift + Left Mouse)".Localize();
            translateButton.Margin = new BorderDouble(3);
			AddChild(translateButton);
			translateButton.Click += (sender, e) =>
			{
				this.ActiveButton = ViewControls3DButtons.Translate;
			};

			string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png");
			scaleButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath,32,32));
			scaleButton.ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize();
            scaleButton.Margin = new BorderDouble(3);
			AddChild(scaleButton);
			scaleButton.Click += (sender, e) =>
			{
				this.ActiveButton = ViewControls3DButtons.Scale;
			};

			partSelectSeparator = new GuiWidget(2, 32);
			partSelectSeparator.BackgroundColor = RGBA_Bytes.White;
			partSelectSeparator.Margin = new BorderDouble(3);
			AddChild(partSelectSeparator);

			string partSelectIconPath = Path.Combine("ViewTransformControls", "partSelect.png");
			partSelectButton = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(partSelectIconPath,32,32));
            partSelectButton.ToolTipText = "Select Part".Localize();
            partSelectButton.Margin = new BorderDouble(3);
			AddChild(partSelectButton);
			partSelectButton.Click += (sender, e) =>
			{
				this.ActiveButton = ViewControls3DButtons.PartSelect;
			};

			Margin = new BorderDouble(5);
			HAnchor |= Agg.UI.HAnchor.ParentLeft;
			VAnchor = Agg.UI.VAnchor.ParentTop;
			rotateButton.Checked = true;

			SetMeshViewerDisplayTheme();
			partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme;

			ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
		}
        public PrintLibraryWidget()
        {
            currentPrintLibraryWidget = this;
            SetDisplayAttributes();

            textImageButtonFactory.borderWidth = 0;

            editButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
            editButtonFactory.disabledFillColor = new RGBA_Bytes();
            editButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            editButtonFactory.borderWidth       = 0;
            editButtonFactory.Margin            = new BorderDouble(10, 0);

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                enterEditModeButton        = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                enterEditModeButton.Click += enterEditModeButtonClick;

                leaveEditModeButton        = editButtonFactory.Generate("Done".Localize(), centerText: true);
                leaveEditModeButton.Click += leaveEditModeButtonClick;

                // make sure the buttons are the same size even when localized
                if (leaveEditModeButton.Width < enterEditModeButton.Width)
                {
                    editButtonFactory.FixedWidth = enterEditModeButton.Width;
                    leaveEditModeButton          = editButtonFactory.Generate("Done".Localize(), centerText: true);
                    leaveEditModeButton.Click   += leaveEditModeButtonClick;
                }
                else
                {
                    editButtonFactory.FixedWidth = leaveEditModeButton.Width;
                    enterEditModeButton          = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                    enterEditModeButton.Click   += enterEditModeButtonClick;
                }

                enterEditModeButton.Name = "Library Edit Button";

                leaveEditModeButton.Visible = false;

                FlowLayoutWidget navigationPanel = new FlowLayoutWidget();
                navigationPanel.HAnchor         = HAnchor.ParentLeftRight;
                navigationPanel.Padding         = new BorderDouble(0);
                navigationPanel.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay;

                navigationLabel           = new TextWidget("My Library".Localize(), pointSize: 14);
                navigationLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                navigationLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                navigationPanel.AddChild(new GuiWidget(50, 0));                 //Add this as temporary balance to edit buttons
                navigationPanel.AddChild(new HorizontalSpacer());
                navigationPanel.AddChild(navigationLabel);
                navigationPanel.AddChild(new HorizontalSpacer());

                buttonPanel             = new FlowLayoutWidget();
                buttonPanel.HAnchor     = HAnchor.ParentLeftRight;
                buttonPanel.Padding     = new BorderDouble(0, 3);
                buttonPanel.MinimumSize = new Vector2(0, 46);

                AddLibraryButtonElements();

                //allControls.AddChild(navigationPanel);
                searchPanel = CreateSearchPannel();
                allControls.AddChild(searchPanel);

                libraryDataView  = new LibraryDataView();
                breadCrumbWidget = new FolderBreadCrumbWidget(libraryDataView.SetCurrentLibraryProvider, libraryDataView.CurrentLibraryProvider);
                libraryDataView.ChangedCurrentLibraryProvider += breadCrumbWidget.SetBreadCrumbs;

                libraryDataView.ChangedCurrentLibraryProvider += LibraryProviderChanged;
                breadCrumbAndActionBar = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.ParentLeftRight,
                };

                breadCrumbAndActionBar.AddChild(breadCrumbWidget);
                breadCrumbAndActionBar.AddChild(CreateActionsMenu());

                allControls.AddChild(breadCrumbAndActionBar);

                allControls.AddChild(libraryDataView);
                allControls.AddChild(buttonPanel);
            }

            allControls.AnchorAll();

            this.AddChild(allControls);

            AddHandlers();
        }
Пример #4
0
        public PrintLibraryWidget()
        {
            SetDisplayAttributes();

            textImageButtonFactory.borderWidth = 0;

            searchButtonFactory.normalTextColor   = RGBA_Bytes.White;
            searchButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            searchButtonFactory.disabledTextColor = RGBA_Bytes.White;
            searchButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            searchButtonFactory.borderWidth       = 0;
            searchButtonFactory.FixedWidth        = 80;

            editButtonFactory.normalTextColor   = ActiveTheme.Instance.SecondaryAccentColor;
            editButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
            editButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            editButtonFactory.borderWidth       = 0;
            editButtonFactory.FixedWidth        = 70;

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                enterEditModeButton         = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                leaveEditModeButton         = editButtonFactory.Generate("Done".Localize(), centerText: true);
                leaveEditModeButton.Visible = false;

                FlowLayoutWidget searchPanel = new FlowLayoutWidget();
                searchPanel.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                searchPanel.HAnchor         = HAnchor.ParentLeftRight;
                searchPanel.Padding         = new BorderDouble(0);
                {
                    searchInput         = new MHTextEditWidget(messageWhenEmptyAndNotSelected: "Search Library".Localize());
                    searchInput.Margin  = new BorderDouble(0, 3, 0, 0);
                    searchInput.HAnchor = HAnchor.ParentLeftRight;
                    searchInput.VAnchor = VAnchor.ParentCenter;


                    searchButton = searchButtonFactory.Generate(LocalizedString.Get("Search"), centerText: true);

                    searchPanel.AddChild(enterEditModeButton);
                    searchPanel.AddChild(leaveEditModeButton);

                    searchPanel.AddChild(searchInput);
                    searchPanel.AddChild(searchButton);
                }

                FlowLayoutWidget navigationPanel = new FlowLayoutWidget();
                navigationPanel.HAnchor         = HAnchor.ParentLeftRight;
                navigationPanel.Padding         = new BorderDouble(0);
                navigationPanel.BackgroundColor = ActiveTheme.Instance.TransparentLightOverlay;

                navigationLabel           = new TextWidget("My Library".Localize(), pointSize: 14);
                navigationLabel.VAnchor   = Agg.UI.VAnchor.ParentCenter;
                navigationLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;



                navigationPanel.AddChild(new GuiWidget(50, 0)); //Add this as temporary balance to edit buttons
                navigationPanel.AddChild(new HorizontalSpacer());
                navigationPanel.AddChild(navigationLabel);
                navigationPanel.AddChild(new HorizontalSpacer());
                //navigationPanel.AddChild(enterEditModeButton);
                //navigationPanel.AddChild(leaveEditModeButton);



                FlowLayoutWidget buttonPanel = new FlowLayoutWidget();
                buttonPanel.HAnchor     = HAnchor.ParentLeftRight;
                buttonPanel.Padding     = new BorderDouble(0, 3);
                buttonPanel.MinimumSize = new Vector2(0, 46);
                {
                    addToLibraryButton = textImageButtonFactory.Generate(LocalizedString.Get("Import"), "icon_import_white_32x32.png");
                    buttonPanel.AddChild(addToLibraryButton);
                    addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0);
                    addToLibraryButton.Click += new EventHandler(importToLibraryloadFile_Click);

                    addToQueueButton         = textImageButtonFactory.Generate("Add to Queue".Localize());
                    addToQueueButton.Margin  = new BorderDouble(3, 0);
                    addToQueueButton.Click  += new EventHandler(addToQueueButton_Click);
                    addToQueueButton.Visible = false;
                    buttonPanel.AddChild(addToQueueButton);

                    exportItemButton         = textImageButtonFactory.Generate("Export".Localize());
                    exportItemButton.Margin  = new BorderDouble(3, 0);
                    exportItemButton.Click  += new EventHandler(exportButton_Click);
                    exportItemButton.Visible = false;
                    buttonPanel.AddChild(exportItemButton);

                    editItemButton         = textImageButtonFactory.Generate("Edit".Localize());
                    editItemButton.Margin  = new BorderDouble(3, 0);
                    editItemButton.Click  += new EventHandler(editButton_Click);
                    editItemButton.Visible = false;
                    buttonPanel.AddChild(editItemButton);

                    removeFromLibraryButton         = textImageButtonFactory.Generate("Remove".Localize());
                    removeFromLibraryButton.Margin  = new BorderDouble(3, 0);
                    removeFromLibraryButton.Click  += new EventHandler(deleteFromQueueButton_Click);
                    removeFromLibraryButton.Visible = false;
                    buttonPanel.AddChild(removeFromLibraryButton);

                    GuiWidget spacer = new GuiWidget();
                    spacer.HAnchor = HAnchor.ParentLeftRight;
                    buttonPanel.AddChild(spacer);
                }
                //allControls.AddChild(navigationPanel);
                allControls.AddChild(searchPanel);
                libraryDataView = new LibraryDataView();
                allControls.AddChild(libraryDataView);
                allControls.AddChild(buttonPanel);
            }
            allControls.AnchorAll();

            this.AddChild(allControls);

            AddHandlers();
        }
Пример #5
0
        void AddChildElements()
        {
            EnhancedSettingsControlBar topRow    = new EnhancedSettingsControlBar();
            FlowLayoutWidget           bottomRow = new FlowLayoutWidget();

            bottomRow.HAnchor = HAnchor.ParentLeftRight;
            bottomRow.Margin  = new BorderDouble(bottom: 4);

            FlowLayoutWidget settingsStatusLabelContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            settingsStatusLabelContainer.VAnchor |= VAnchor.ParentTop;
            settingsStatusLabelContainer.Margin   = new BorderDouble(0);
            {
                string activeSettingsLabelText     = LocalizedString.Get("Active Settings").ToUpper();
                string activeSettingsLabelTextFull = string.Format("{0}:", activeSettingsLabelText);

                TextWidget settingsStatusLabel = new TextWidget(string.Format(activeSettingsLabelTextFull), pointSize: 10);
                settingsStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                settingsStatusDescription        = new TextWidget("", pointSize: 14);
                settingsStatusDescription.Margin = new BorderDouble(top: 4);
                settingsStatusDescription.AutoExpandBoundsToText = true;
                settingsStatusDescription.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                string unsavedChangesTxtBeg  = LocalizedString.Get("unsaved changes");
                string unsavedChangesTxtFull = string.Format("({0})", unsavedChangesTxtBeg);
                unsavedChangesIndicator = new TextWidget(unsavedChangesTxtFull, pointSize: 10);
                unsavedChangesIndicator.AutoExpandBoundsToText = true;
                unsavedChangesIndicator.Visible   = false;
                unsavedChangesIndicator.Margin    = new BorderDouble(left: 4);
                unsavedChangesIndicator.TextColor = ActiveTheme.Instance.PrimaryTextColor;

                settingsStatusLabelContainer.AddChild(settingsStatusLabel);
                settingsStatusLabelContainer.AddChild(settingsStatusDescription);
                settingsStatusLabelContainer.AddChild(unsavedChangesIndicator);
            }

            saveButton         = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
            saveButton.VAnchor = VAnchor.ParentCenter;
            saveButton.Visible = false;
            saveButton.Margin  = new BorderDouble(0, 0, 0, 10);
            saveButton.Click  += new EventHandler(saveButton_Click);

            revertbutton         = textImageButtonFactory.Generate(LocalizedString.Get("Revert"));
            revertbutton.VAnchor = VAnchor.ParentCenter;
            revertbutton.Visible = false;
            revertbutton.Margin  = new BorderDouble(0, 0, 0, 10);
            revertbutton.Click  += new EventHandler(revertbutton_Click);

            bottomRow.AddChild(settingsStatusLabelContainer);

            GuiWidget spacer = new GuiWidget(HAnchor.ParentLeftRight);

            bottomRow.AddChild(spacer);

            bottomRow.AddChild(saveButton);
            bottomRow.AddChild(revertbutton);
            bottomRow.AddChild(GetSliceOptionsMenuDropList());

            this.AddChild(bottomRow);
            this.AddChild(topRow);

            SetStatusDisplay();
        }
Пример #6
0
        public ViewControls3D(MeshViewerWidget meshViewerWidget)
        {
            if (UserSettings.Instance.DisplayMode == ApplicationDisplayType.Touchscreen)
            {
                buttonHeight = 40;
            }
            else
            {
                buttonHeight = 0;
            }

            this.meshViewerWidget = meshViewerWidget;
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();

            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;

            BackgroundColor = new RGBA_Bytes(0, 0, 0, 120);
            textImageButtonFactory.FixedHeight             = buttonHeight * GuiWidget.DeviceScale;
            textImageButtonFactory.FixedWidth              = buttonHeight * GuiWidget.DeviceScale;
            textImageButtonFactory.AllowThemeToAdjustImage = false;
            textImageButtonFactory.checkedBorderColor      = RGBA_Bytes.White;

            string resetViewIconPath = Path.Combine("ViewTransformControls", "reset.png");

            resetViewButton             = textImageButtonFactory.Generate("", StaticData.Instance.LoadIcon(resetViewIconPath, 32, 32).InvertLightness());
            resetViewButton.ToolTipText = "Reset View".Localize();
            AddChild(resetViewButton);
            resetViewButton.Click += (sender, e) =>
            {
                ResetView?.Invoke(this, null);
            };

            string rotateIconPath = Path.Combine("ViewTransformControls", "rotate.png");

            rotateButton             = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(rotateIconPath, 32, 32));
            rotateButton.ToolTipText = "Rotate (Alt + Left Mouse)".Localize();
            rotateButton.Margin      = new BorderDouble(3);
            AddChild(rotateButton);
            rotateButton.Click += (sender, e) =>
            {
                this.ActiveButton = ViewControls3DButtons.Rotate;
            };

            string translateIconPath = Path.Combine("ViewTransformControls", "translate.png");

            translateButton             = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(translateIconPath, 32, 32));
            translateButton.ToolTipText = "Move (Shift + Left Mouse)".Localize();
            translateButton.Margin      = new BorderDouble(3);
            AddChild(translateButton);
            translateButton.Click += (sender, e) =>
            {
                this.ActiveButton = ViewControls3DButtons.Translate;
            };

            string scaleIconPath = Path.Combine("ViewTransformControls", "scale.png");

            scaleButton             = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(scaleIconPath, 32, 32));
            scaleButton.ToolTipText = "Zoom (Ctrl + Left Mouse)".Localize();
            scaleButton.Margin      = new BorderDouble(3);
            AddChild(scaleButton);
            scaleButton.Click += (sender, e) =>
            {
                this.ActiveButton = ViewControls3DButtons.Scale;
            };

            partSelectSeparator = new GuiWidget(2, 32);
            partSelectSeparator.BackgroundColor = RGBA_Bytes.White;
            partSelectSeparator.Margin          = new BorderDouble(3);
            AddChild(partSelectSeparator);

            string partSelectIconPath = Path.Combine("ViewTransformControls", "partSelect.png");

            partSelectButton             = textImageButtonFactory.GenerateRadioButton("", StaticData.Instance.LoadIcon(partSelectIconPath, 32, 32));
            partSelectButton.ToolTipText = "Select Part".Localize();
            partSelectButton.Margin      = new BorderDouble(3);
            AddChild(partSelectButton);
            partSelectButton.Click += (sender, e) =>
            {
                this.ActiveButton = ViewControls3DButtons.PartSelect;
            };

            Margin   = new BorderDouble(5);
            HAnchor |= Agg.UI.HAnchor.ParentLeft;
            VAnchor  = Agg.UI.VAnchor.ParentTop;
            rotateButton.Checked = true;

            SetMeshViewerDisplayTheme();
            partSelectButton.CheckedStateChanged += SetMeshViewerDisplayTheme;

            ActiveTheme.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
        }
        public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
            : base(windowController, container)
        {
            {
                this.editMode = editMode;

                textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
                textImageButtonFactory.borderWidth       = 0;

                editButtonFactory.normalTextColor   = ActiveTheme.Instance.SecondaryAccentColor;
                editButtonFactory.hoverTextColor    = RGBA_Bytes.White;
                editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
                editButtonFactory.pressedTextColor  = RGBA_Bytes.White;
                editButtonFactory.borderWidth       = 0;
                editButtonFactory.FixedWidth        = 60 * TextWidget.GlobalPointSizeScaleRatio;

                this.AnchorAll();
                this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                this.Padding         = new BorderDouble(0);         //To be re-enabled once native borders are turned off


                GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                mainContainer.AnchorAll();
                mainContainer.Padding         = new BorderDouble(3, 0, 3, 5);
                mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                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, 0);

                {
                    string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration");
                    string chooseThreeDPrinterConfigFull  = string.Format("{0}:", chooseThreeDPrinterConfigLabel);

                    TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
                    elementHeader.TextColor = this.defaultTextColor;
                    elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                    elementHeader.VAnchor   = Agg.UI.VAnchor.ParentCenter;

                    headerRow.AddChild(elementHeader);
                }

                FlowLayoutWidget editButtonRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
                editButtonRow.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                editButtonRow.HAnchor         = HAnchor.ParentLeftRight;
                editButtonRow.Margin          = new BorderDouble(0, 3, 0, 0);
                editButtonRow.Padding         = new BorderDouble(0, 3, 0, 0);

                Button enterLeaveEditModeButton;
                if (!this.editMode)
                {
                    enterLeaveEditModeButton        = editButtonFactory.Generate(LocalizedString.Get("Edit"), centerText: true);
                    enterLeaveEditModeButton.Click += EditModeOnLink_Click;
                }
                else
                {
                    enterLeaveEditModeButton        = editButtonFactory.Generate(LocalizedString.Get("Done"), centerText: true);
                    enterLeaveEditModeButton.Click += EditModeOffLink_Click;
                }

                editButtonRow.AddChild(enterLeaveEditModeButton);

                //To do - replace with scrollable widget
                FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                //ListBox printerListContainer = new ListBox();
                {
                    printerListContainer.HAnchor         = HAnchor.ParentLeftRight;
                    printerListContainer.VAnchor         = VAnchor.FitToChildren;
                    printerListContainer.Padding         = new BorderDouble(3);
                    printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;


                    //Get a list of printer records and add them to radio button list
                    foreach (Printer printer in GetAllPrinters())
                    {
                        PrinterListItem printerListItem;
                        if (this.editMode)
                        {
                            printerListItem = new PrinterListItemEdit(printer, this.windowController);
                        }
                        else
                        {
                            printerListItem = new PrinterListItemView(printer, this.windowController);
                        }

                        printerListContainer.AddChild(printerListItem);
                    }
                }

                FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
                buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
                buttonContainer.Margin  = new BorderDouble(0, 3);
                {
                    closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));

                    Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    addPrinterButton.Name        = "Add new printer button";
                    addPrinterButton.ToolTipText = "Add a new Printer Profile".Localize();
                    addPrinterButton.Click      += new EventHandler(AddConnectionLink_Click);

                    Button refreshListButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
                    refreshListButton.Click += new EventHandler(EditModeOffLink_Click);

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

                    //Add buttons to ButtonContainer
                    buttonContainer.AddChild(addPrinterButton);

                    if (!this.editMode)
                    {
                        buttonContainer.AddChild(refreshListButton);
                    }

                    buttonContainer.AddChild(spacer);
                    buttonContainer.AddChild(closeButton);
                }

                ScrollableWidget printerListScrollArea = new ScrollableWidget(true);
                printerListScrollArea.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
                printerListScrollArea.AnchorAll();
                printerListScrollArea.AddChild(printerListContainer);

                FlowLayoutWidget printerListScrollContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                printerListScrollContainer.HAnchor         = HAnchor.ParentLeftRight;
                printerListScrollContainer.VAnchor         = VAnchor.ParentBottomTop;
                printerListScrollContainer.Padding         = new BorderDouble(3);
                printerListScrollContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

                mainContainer.AddChild(headerRow);
                mainContainer.AddChild(editButtonRow);
                mainContainer.AddChild(printerListScrollContainer);
                printerListScrollContainer.AddChild(printerListScrollArea);
                mainContainer.AddChild(buttonContainer);

                this.AddChild(mainContainer);

                BindCloseButtonClick();
            }
        }
Пример #8
0
        public void SetBreadCrumbs(LibraryProvider previousLibraryProvider, LibraryProvider currentLibraryProvider)
        {
            LibraryProvider displayingProvider = currentLibraryProvider;

            this.CloseAndRemoveAllChildren();

            List <LibraryProvider> parentProviderList = new List <LibraryProvider>();

            while (currentLibraryProvider != null)
            {
                parentProviderList.Add(currentLibraryProvider);
                currentLibraryProvider = currentLibraryProvider.ParentLibraryProvider;
            }

            bool haveFilterRunning = displayingProvider.KeywordFilter != null && displayingProvider.KeywordFilter != "";

            bool first = true;

            for (int i = parentProviderList.Count - 1; i >= 0; i--)
            {
                LibraryProvider parentLibraryProvider = parentProviderList[i];
                if (!first)
                {
                    GuiWidget separator = new TextWidget(">", textColor: ActiveTheme.Instance.PrimaryTextColor);
                    separator.VAnchor = VAnchor.ParentCenter;
                    separator.Margin  = new BorderDouble(0);
                    this.AddChild(separator);
                }

                Button gotoProviderButton = navigationButtonFactory.Generate(parentLibraryProvider.Name);
                gotoProviderButton.Name = "Bread Crumb Button " + parentLibraryProvider.Name;
                if (first)
                {
                    gotoProviderButton.Margin = new BorderDouble(0, 0, 3, 0);
                }
                else
                {
                    gotoProviderButton.Margin = new BorderDouble(3, 0);
                }
                gotoProviderButton.Click += (sender2, e2) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        SwitchToLibraryProvider(parentLibraryProvider);
                    });
                };
                this.AddChild(gotoProviderButton);
                first = false;
            }

            if (haveFilterRunning)
            {
                GuiWidget separator = new TextWidget(">", textColor: ActiveTheme.Instance.PrimaryTextColor);
                separator.VAnchor = VAnchor.ParentCenter;
                separator.Margin  = new BorderDouble(0);
                this.AddChild(separator);

                Button searchResultsButton = navigationButtonFactory.Generate("Search Results".Localize(), "icon_search_24x24.png");
                searchResultsButton.Name   = "Bread Crumb Button " + "Search Results";
                searchResultsButton.Margin = new BorderDouble(3, 0);
                this.AddChild(searchResultsButton);
            }

            // while all the buttons don't fit in the control
            if (this.Parent != null &&
                this.Parent.Width > 0 &&
                this.Children.Count > 4 &&
                this.GetChildrenBoundsIncludingMargins().Width > this.Parent.Width)
            {
                // lets take out the > and put in a ...
                this.RemoveChild(1);
                GuiWidget separator = new TextWidget("...", textColor: ActiveTheme.Instance.PrimaryTextColor);
                separator.VAnchor = VAnchor.ParentCenter;
                separator.Margin  = new BorderDouble(3, 0);
                this.AddChild(separator, 1);

                while (this.GetChildrenBoundsIncludingMargins().Width > this.Parent.Width &&
                       this.Children.Count > 4)
                {
                    this.RemoveChild(3);
                    this.RemoveChild(2);
                }
            }
        }
        public void AddElements()
        {
            Title = LocalizedString.Get("Design Add-ons");

            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     elementHeaderLabelBeg  = LocalizedString.Get("Select a Design Tool");
                string     elementHeaderLabelFull = string.Format("{0}:", elementHeaderLabelBeg);
                string     elementHeaderLabel     = elementHeaderLabelFull;
                TextWidget elementHeader          = new TextWidget(string.Format(elementHeaderLabel), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

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

            FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            pluginRowContainer.AnchorAll();
            presetsFormContainer.AddChild(pluginRowContainer);

            unlockButtonFactory.Margin = new BorderDouble(10, 0);
            if (ActiveTheme.Instance.IsDarkTheme)
            {
                unlockButtonFactory.normalFillColor   = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.hoverFillColor    = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.hoverBorderColor  = new RGBA_Bytes(0, 0, 0, 50);
            }
            else
            {
                unlockButtonFactory.normalFillColor   = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.normalBorderColor = new RGBA_Bytes(0, 0, 0, 50);
                unlockButtonFactory.hoverFillColor    = new RGBA_Bytes(0, 0, 0, 100);
                unlockButtonFactory.hoverBorderColor  = new RGBA_Bytes(0, 0, 0, 100);
            }

            foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
            {
                FlowLayoutWidget pluginListingContainer = new FlowLayoutWidget();
                pluginListingContainer.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                pluginListingContainer.BackgroundColor = RGBA_Bytes.White;
                pluginListingContainer.Padding         = new BorderDouble(0);
                pluginListingContainer.Margin          = new BorderDouble(6, 0, 6, 6);

                ClickWidget pluginRow = new ClickWidget();
                pluginRow.Margin  = new BorderDouble(6, 0, 6, 0);
                pluginRow.Height  = 38;
                pluginRow.HAnchor = Agg.UI.HAnchor.ParentLeftRight;

                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.AnchorAll();
                macroRow.BackgroundColor = RGBA_Bytes.White;

                if (creatorInfo.iconPath != "")
                {
                    ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
                    ImageWidget imageWidget = new ImageWidget(imageBuffer);
                    imageWidget.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    macroRow.AddChild(imageWidget);
                }

                bool userHasPermission;
                if (!creatorInfo.paidAddOnFlag)
                {
                    userHasPermission = true;
                }
                else
                {
                    userHasPermission = creatorInfo.permissionFunction();
                }

                string addOnDescription;
                addOnDescription = creatorInfo.description;
                TextWidget buttonLabel = new TextWidget(addOnDescription, pointSize: 14);
                buttonLabel.Margin  = new BorderDouble(left: 10);
                buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                macroRow.AddChild(buttonLabel);

                if (!userHasPermission)
                {
                    TextWidget demoLabel = new TextWidget("(demo)", pointSize: 10);

                    demoLabel.Margin  = new BorderDouble(left: 4);
                    demoLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                    macroRow.AddChild(demoLabel);
                }

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

                CreatorInformation callCorrectFunctionHold = creatorInfo;
                pluginRow.Click += (sender, e) =>
                {
                    if (RegisteredCreators.Instance.Creators.Count > 0)
                    {
                        UiThread.RunOnIdle(CloseOnIdle, callCorrectFunctionHold);
                    }
                    else
                    {
                        UiThread.RunOnIdle(CloseOnIdle);
                    }
                };

                pluginRow.Cursor    = Cursors.Hand;
                macroRow.Selectable = false;
                pluginRow.AddChild(macroRow);

                pluginListingContainer.AddChild(pluginRow);

                if (!userHasPermission)
                {
                    Button unlockButton = unlockButtonFactory.Generate("Unlock");
                    unlockButton.Margin = new BorderDouble(0);
                    unlockButton.Cursor = Cursors.Hand;
                    unlockButton.Click += (sender, e) =>
                    {
                        callCorrectFunctionHold.unlockFunction();
                    };
                    pluginListingContainer.AddChild(unlockButton);
                }

                pluginRowContainer.AddChild(pluginListingContainer);
                if (callCorrectFunctionHold.unlockRegisterFunction != null)
                {
                    callCorrectFunctionHold.unlockRegisterFunction(TriggerReload, ref unregisterEvents);
                }
            }

            topToBottom.AddChild(presetsFormContainer);
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

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

            cancelPresetsButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(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(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     fileExportLabelTxt = new LocalizedString("File export options").Translated;
            TextWidget exportLabel        = new TextWidget(string.Format("{0}:", fileExportLabelTxt));

            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     noGCodeMessageText     = new LocalizedString("Note").Translated;
                string     noGCodeMessageTextFull = new LocalizedString("To enable GCode export, select a printer profile").Translated;
                TextWidget noGCodeMessage         = new TextWidget(string.Format("{0}: {1}.", noGCodeMessageText, noGCodeMessageTextFull), 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);
        }
Пример #11
0
        private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory)
        {
            var container = new FlowLayoutWidget()
            {
                HAnchor = HAnchor.ParentLeftRight,
                Margin  = new BorderDouble(top: 3)
            };

            Button duplicateButton = buttonFactory.Generate("Duplicate".Localize());

            duplicateButton.Click += (s, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    string sanitizedName  = numberMatch.Replace(presetNameInput.Text, "").Trim();
                    string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault("MatterControl.LayerName")));

                    var clonedLayer  = presetsContext.PersistenceLayer.Clone();
                    clonedLayer.Name = newProfileName;
                    presetsContext.PresetLayers.Add(clonedLayer);

                    presetsContext.SetAsActive(clonedLayer.ID);
                    presetsContext.PersistenceLayer = clonedLayer;

                    middleRow.CloseAllChildren();
                    middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer));

                    presetNameInput.Text = newProfileName;
                });
            };

            Button importButton = buttonFactory.Generate("Import".Localize());

            importButton.Click += (s, e) =>
            {
                throw new NotImplementedException();
            };

            Button exportButton = buttonFactory.Generate("Export".Localize());

            exportButton.Click += (s, e) => UiThread.RunOnIdle(SaveAs);

            Button closeButton = buttonFactory.Generate("Close".Localize());

            closeButton.Click += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    if (initialPresetName != presetsContext.PersistenceLayer.Name)
                    {
                        // TODO: If we get to the point where we refresh rather than reload, we need
                        // to rebuild the target droplist to display the new name
                        ApplicationController.Instance.ReloadAdvancedControlsPanel();
                    }
                    this.Close();
                });
            };

            container.AddChild(duplicateButton);

            //Only show duplicate/import/export buttons if setting has been saved.
            if (false)
            {
                container.AddChild(importButton);
                container.AddChild(exportButton);
            }

            container.AddChild(new HorizontalSpacer());
            container.AddChild(closeButton);

            return(container);
        }
        public void SetBreadCrumbs(LibraryProvider previousLibraryProvider, LibraryProvider currentLibraryProvider)
        {
            navigationButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            navigationButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            navigationButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            navigationButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            navigationButtonFactory.Margin            = new BorderDouble(10, 0);

            this.CloseAndRemoveAllChildren();

            List <LibraryProvider> parentProviderList = new List <LibraryProvider>();

            while (currentLibraryProvider != null)
            {
                parentProviderList.Add(currentLibraryProvider);
                currentLibraryProvider = currentLibraryProvider.ParentLibraryProvider;
            }

            bool first = true;

            for (int i = parentProviderList.Count - 1; i >= 0; i--)
            {
                LibraryProvider parentLibraryProvider = parentProviderList[i];
                if (!first)
                {
                    GuiWidget separator = new TextWidget(">", textColor: ActiveTheme.Instance.PrimaryTextColor);
                    separator.VAnchor = VAnchor.ParentCenter;
                    separator.Margin  = new BorderDouble(0);
                    this.AddChild(separator);
                }

                Button gotoProviderButton = navigationButtonFactory.Generate(parentLibraryProvider.Name);
                gotoProviderButton.Margin = new BorderDouble(3, 0);
                gotoProviderButton.Click += (sender2, e2) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        SwitchToLibraryProvider(parentLibraryProvider);
                    });
                };
                this.AddChild(gotoProviderButton);
                first = false;
            }

            // while all the buttons don't fit in the control
            if (this.Parent.Width > 0 &&
                this.Children.Count > 4 &&
                this.GetChildrenBoundsIncludingMargins().Width > this.Parent.Width)
            {
                // lets take out the > and put in a ...
                this.RemoveChild(1);
                GuiWidget separator = new TextWidget("...", textColor: ActiveTheme.Instance.PrimaryTextColor);
                separator.VAnchor = VAnchor.ParentCenter;
                separator.Margin  = new BorderDouble(3, 0);
                this.AddChild(separator, 1);

                while (this.GetChildrenBoundsIncludingMargins().Width > this.Parent.Width &&
                       this.Children.Count > 4)
                {
                    this.RemoveChild(3);
                    this.RemoveChild(2);
                }
            }
        }
Пример #13
0
        public QueueDataWidget(QueueDataView queueDataView)
        {
            this.queueDataView = queueDataView;

            SetDisplayAttributes();

            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.borderWidth       = 0;


            editButtonFactory.normalTextColor   = ActiveTheme.Instance.SecondaryAccentColor;
            editButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
            editButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            editButtonFactory.borderWidth       = 0;
            editButtonFactory.FixedWidth        = 70;

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                enterEditModeButton         = editButtonFactory.Generate("Edit".Localize(), centerText: true);
                leaveEditModeButton         = editButtonFactory.Generate("Done".Localize(), centerText: true);
                leaveEditModeButton.Visible = false;

                FlowLayoutWidget searchPanel = new FlowLayoutWidget();
                searchPanel.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                searchPanel.HAnchor         = HAnchor.ParentLeftRight;
                searchPanel.Padding         = new BorderDouble(0);

                searchPanel.AddChild(enterEditModeButton);
                searchPanel.AddChild(leaveEditModeButton);

                searchPanel.AddChild(new HorizontalSpacer());

                allControls.AddChild(searchPanel);

                {
                    // Ensure the form opens with no rows selected.
                    //ActiveQueueList.Instance.ClearSelected();

                    allControls.AddChild(queueDataView);
                }

                FlowLayoutWidget buttonPanel1 = new FlowLayoutWidget();
                buttonPanel1.HAnchor     = HAnchor.ParentLeftRight;
                buttonPanel1.Padding     = new BorderDouble(0, 3);
                buttonPanel1.MinimumSize = new Vector2(0, 46);
                {
                    addToQueueButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    buttonPanel1.AddChild(addToQueueButton);
                    addToQueueButton.Margin = new BorderDouble(0, 0, 3, 0);
                    addToQueueButton.Click += new EventHandler(addToQueueButton_Click);

                    // put in the creator button
                    {
                        createButton = textImageButtonFactory.Generate(LocalizedString.Get("Create"), "icon_creator_white_32x32.png");
                        buttonPanel1.AddChild(createButton);
                        createButton.Margin = new BorderDouble(0, 0, 3, 0);
                        createButton.Click += (sender, e) =>
                        {
                            OpenPluginChooserWindow();
                        };
                    }

                    exportItemButton         = textImageButtonFactory.Generate("Export".Localize());
                    exportItemButton.Margin  = new BorderDouble(3, 0);
                    exportItemButton.Click  += new EventHandler(exportButton_Click);
                    exportItemButton.Visible = false;
                    buttonPanel1.AddChild(exportItemButton);

                    copyItemButton         = textImageButtonFactory.Generate("Copy".Localize());
                    copyItemButton.Margin  = new BorderDouble(3, 0);
                    copyItemButton.Click  += new EventHandler(copy_Button_Click);
                    copyItemButton.Visible = false;
                    buttonPanel1.AddChild(copyItemButton);

                    removeItemButton         = textImageButtonFactory.Generate("Remove".Localize());
                    removeItemButton.Margin  = new BorderDouble(3, 0);
                    removeItemButton.Click  += new EventHandler(removeButton_Click);
                    removeItemButton.Visible = false;
                    buttonPanel1.AddChild(removeItemButton);

                    if (OemSettings.Instance.ShowShopButton)
                    {
                        shopButton = textImageButtonFactory.Generate(LocalizedString.Get("Buy Materials"), "icon_shopping_cart_32x32.png");
                        buttonPanel1.AddChild(shopButton);
                        shopButton.Margin = new BorderDouble(0, 0, 3, 0);
                        shopButton.Click += (sender, e) =>
                        {
                            double activeFilamentDiameter = 0;
                            if (ActivePrinterProfile.Instance.ActivePrinter != null)
                            {
                                activeFilamentDiameter = 3;
                                if (ActiveSliceSettings.Instance.FilamentDiameter < 2)
                                {
                                    activeFilamentDiameter = 1.75;
                                }
                            }

                            System.Diagnostics.Process.Start("http://www.matterhackers.com/mc/store/redirect?d={0}&clk=mcs&a={1}".FormatWith(activeFilamentDiameter, OemSettings.Instance.AffiliateCode));
                        };
                    }

                    Button deleteAllFromQueueButton = textImageButtonFactory.Generate(LocalizedString.Get("Remove All"));
                    deleteAllFromQueueButton.Margin = new BorderDouble(3, 0);
                    deleteAllFromQueueButton.Click += new EventHandler(deleteAllFromQueueButton_Click);
                    //buttonPanel1.AddChild(deleteAllFromQueueButton);

                    buttonPanel1.AddChild(new HorizontalSpacer());

                    queueMenuContainer         = new FlowLayoutWidget();
                    queueMenuContainer.VAnchor = Agg.UI.VAnchor.ParentBottomTop;
                    queueMenu = new QueueOptionsMenu();
                    queueMenuContainer.AddChild(queueMenu.MenuDropList);
                    buttonPanel1.AddChild(queueMenuContainer);

                    ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent((object sender, EventArgs e) =>
                    {
                        queueMenuContainer.RemoveAllChildren();
                        // the printer changed reload the queueMenue
                        queueMenu = new QueueOptionsMenu();
                        queueMenuContainer.AddChild(queueMenu.MenuDropList);
                    }, ref unregisterEvents);
                }
                allControls.AddChild(buttonPanel1);
            }
            allControls.AnchorAll();

            this.AddChild(allControls);
            AddHandlers();
        }
		private AnchoredDropDownList CreateDropdown()
		{
			AnchoredDropDownList dropDownList = new AnchoredDropDownList("- default -", maxHeight: 300);
			dropDownList.Margin = new BorderDouble(0, 3);
			dropDownList.MinimumSize = new Vector2(dropDownList.LocalBounds.Width, dropDownList.LocalBounds.Height);

			MenuItem defaultMenuItem = dropDownList.AddItem("- default -", "0");
			defaultMenuItem.Selected += new EventHandler(onItemSelect);

			var listSource = (filterTag == "material") ? ActiveSliceSettings.Instance.AllMaterialKeys() : ActiveSliceSettings.Instance.AllQualityKeys();
			foreach (var presetName in listSource)
			{
				MenuItem menuItem = dropDownList.AddItem(presetName, presetName);
				menuItem.Selected += onItemSelect;
			}

			// put in a small bottom region
			{
				FlowLayoutWidget container = new FlowLayoutWidget();
				container.HAnchor = HAnchor.ParentLeftRight;

				TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
				buttonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
				buttonFactory.borderWidth = 0;

				Button addPresetButton = buttonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
				addPresetButton.ToolTipText = "Add a new Settings Preset".Localize();
				addPresetButton.Click += (sender, e) =>
				{
					onNewItemSelect(sender, e);
				};
				container.AddChild(addPresetButton);

				Button importPresetButton = buttonFactory.Generate(LocalizedString.Get("Import"));
				importPresetButton.ToolTipText = "Import an existing Settings Preset".Localize();
				importPresetButton.Click += (sender, e) =>
				{
				};
				container.AddChild(importPresetButton);

				dropDownList.MenuItems.Add(new MenuItem(container));
			}

			try
			{
				string settingsKey;

				if (filterTag == "material")
				{
					settingsKey = ActiveSliceSettings.Instance.GetMaterialPresetKey(extruderIndex);
				}
				else
				{
					settingsKey = ActiveSliceSettings.Instance.ActiveQualityKey;
				}

				if (!string.IsNullOrEmpty(settingsKey))
				{
					dropDownList.SelectedValue = settingsKey;
				}
			}
			catch (Exception ex)
			{
				GuiWidget.BreakInDebugger(ex.Message);
			}
		
			return dropDownList;
		}
Пример #15
0
        public PrintLibraryWidget()
        {
            SetDisplayAttributes();

            textImageButtonFactory.borderWidth = 0;

            searchButtonFactory.normalTextColor   = RGBA_Bytes.White;
            searchButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            searchButtonFactory.disabledTextColor = RGBA_Bytes.White;
            searchButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            searchButtonFactory.borderWidth       = 0;
            searchButtonFactory.FixedWidth        = 80;

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                FlowLayoutWidget searchPanel = new FlowLayoutWidget();
                searchPanel.BackgroundColor = ActiveTheme.Instance.TransparentDarkOverlay;
                searchPanel.HAnchor         = HAnchor.ParentLeftRight;
                searchPanel.Padding         = new BorderDouble(0);
                {
                    searchInput         = new MHTextEditWidget();
                    searchInput.Margin  = new BorderDouble(6, 3, 0, 0);
                    searchInput.HAnchor = HAnchor.ParentLeftRight;
                    searchInput.VAnchor = VAnchor.ParentCenter;

                    searchButton = searchButtonFactory.Generate(LocalizedString.Get("Search"), centerText: true);

                    searchPanel.AddChild(searchInput);
                    searchPanel.AddChild(searchButton);
                }

                FlowLayoutWidget buttonPanel = new FlowLayoutWidget();
                buttonPanel.HAnchor = HAnchor.ParentLeftRight;
                buttonPanel.Padding = new BorderDouble(0, 3);
                {
                    Button addToLibrary = textImageButtonFactory.Generate(LocalizedString.Get("Import"), "icon_import_white_32x32.png");
                    buttonPanel.AddChild(addToLibrary);
                    addToLibrary.Margin = new BorderDouble(0, 0, 3, 0);
                    addToLibrary.Click += new ButtonBase.ButtonEventHandler(loadFile_Click);

                    addToQueueButton         = textImageButtonFactory.Generate("Add to Queue");
                    addToQueueButton.Margin  = new BorderDouble(3, 0);
                    addToQueueButton.Click  += new ButtonBase.ButtonEventHandler(addToQueueButton_Click);
                    addToQueueButton.Visible = false;
                    buttonPanel.AddChild(addToQueueButton);

                    deleteFromLibraryButton         = textImageButtonFactory.Generate("Remove");
                    deleteFromLibraryButton.Margin  = new BorderDouble(3, 0);
                    deleteFromLibraryButton.Click  += new ButtonBase.ButtonEventHandler(deleteFromQueueButton_Click);
                    deleteFromLibraryButton.Visible = false;
                    buttonPanel.AddChild(deleteFromLibraryButton);

                    GuiWidget spacer = new GuiWidget();
                    spacer.HAnchor = HAnchor.ParentLeftRight;
                    buttonPanel.AddChild(spacer);
                }

                allControls.AddChild(searchPanel);
                libraryDataView = new LibraryDataView();
                allControls.AddChild(libraryDataView);
                allControls.AddChild(buttonPanel);
            }
            allControls.AnchorAll();

            this.AddChild(allControls);

            AddHandlers();
        }
        public CheckForUpdateWindow()
            : base(540, 350)
        {
            linkButtonFactory.fontSize  = 10;
            linkButtonFactory.textColor = ActiveTheme.Instance.SecondaryAccentColor;

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.AnchorAll();
            topToBottom.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            Padding = new BorderDouble(left: 5, right: 5);

            FlowLayoutWidget mainLabelContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            mainLabelContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            mainLabelContainer.VAnchor         = VAnchor.FitToChildren;
            mainLabelContainer.HAnchor         = HAnchor.ParentLeftRight;

            FlowLayoutWidget currentFeedAndDropDownContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            currentFeedAndDropDownContainer.VAnchor         = VAnchor.FitToChildren;
            currentFeedAndDropDownContainer.HAnchor         = HAnchor.ParentLeftRight;
            currentFeedAndDropDownContainer.Margin          = new BorderDouble(0, 5, 0, 0);
            currentFeedAndDropDownContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

            TextWidget checkUpdateLabel = new TextWidget("Check for Update".Localize(), pointSize: 20);

            checkUpdateLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            checkUpdateLabel.Margin    = new BorderDouble(2, 10, 10, 5);

            UpdateControlView updateStatusWidget = new UpdateControlView();

            String     fullCurrentFeedLabel = "Update Channel".Localize();
            TextWidget feedLabel            = new TextWidget(fullCurrentFeedLabel, pointSize: 12);

            feedLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            feedLabel.VAnchor   = VAnchor.ParentCenter;
            feedLabel.Margin    = new BorderDouble(left: 5);

            releaseOptionsDropList         = new DropDownList("Development", maxHeight: 200);
            releaseOptionsDropList.HAnchor = HAnchor.ParentLeftRight;

            MenuItem releaseOptionsDropDownItem = releaseOptionsDropList.AddItem("Stable".Localize(), "release");

            releaseOptionsDropDownItem.Selected += new EventHandler(FixTabDot);

            MenuItem preReleaseDropDownItem = releaseOptionsDropList.AddItem("Beta".Localize(), "pre-release");

            preReleaseDropDownItem.Selected += new EventHandler(FixTabDot);

            MenuItem developmentDropDownItem = releaseOptionsDropList.AddItem("Alpha".Localize(), "development");

            developmentDropDownItem.Selected += new EventHandler(FixTabDot);

            List <string> acceptableUpdateFeedTypeValues = new List <string>()
            {
                "release", "pre-release", "development"
            };
            string currentUpdateFeedType = UserSettings.Instance.get("UpdateFeedType");

            if (acceptableUpdateFeedTypeValues.IndexOf(currentUpdateFeedType) == -1)
            {
                UserSettings.Instance.set("UpdateFeedType", "release");
            }

            releaseOptionsDropList.SelectedValue     = UserSettings.Instance.get("UpdateFeedType");
            releaseOptionsDropList.SelectionChanged += new EventHandler(ReleaseOptionsDropList_SelectionChanged);

            string currentBuildNo        = VersionInfo.Instance.BuildVersion;
            string currentBuildInfoLabel = String.Format("Current Build : {0}", currentBuildNo);

            currentBuildInfo           = new TextWidget(currentBuildInfoLabel.Localize());
            currentBuildInfo.HAnchor   = HAnchor.ParentLeftRight;
            currentBuildInfo.Margin    = new BorderDouble(left: 5, bottom: 15, top: 20);
            currentBuildInfo.TextColor = ActiveTheme.Instance.PrimaryTextColor;


            FlowLayoutWidget additionalInfoContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            additionalInfoContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            additionalInfoContainer.HAnchor         = HAnchor.ParentLeftRight;
            additionalInfoContainer.Padding         = new BorderDouble(left: 6, top: 6);

            string aboutUpdateChannel = "Changing your update channel will change the version of MatterControl  \nthat you receive when updating:";

            updateChannelLabel           = new TextWidget(aboutUpdateChannel);
            updateChannelLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            updateChannelLabel.HAnchor   = HAnchor.ParentLeftRight;
            updateChannelLabel.Margin    = new BorderDouble(bottom: 20);
            additionalInfoContainer.AddChild(updateChannelLabel);


            string stableFeedInfoText = "Stable: The current release version of MatterControl (recommended).".Localize();

            stableInfoLabel           = new TextWidget(stableFeedInfoText);
            stableInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            stableInfoLabel.HAnchor   = HAnchor.ParentLeftRight;
            stableInfoLabel.Margin    = new BorderDouble(bottom: 10);
            additionalInfoContainer.AddChild(stableInfoLabel);

            string betaFeedInfoText = "Beta: The release candidate version of MatterControl.".Localize();

            betaInfoLabel           = new TextWidget(betaFeedInfoText);
            betaInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            betaInfoLabel.HAnchor   = HAnchor.ParentLeftRight;
            betaInfoLabel.Margin    = new BorderDouble(bottom: 10);
            additionalInfoContainer.AddChild(betaInfoLabel);

            string alphaFeedInfoText = "Alpha: The in development version of MatterControl.".Localize();

            alphaInfoLabel           = new TextWidget(alphaFeedInfoText);
            alphaInfoLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
            alphaInfoLabel.HAnchor   = HAnchor.ParentLeftRight;
            alphaInfoLabel.Margin    = new BorderDouble(bottom: 10);
            additionalInfoContainer.AddChild(alphaInfoLabel);

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonContainer.HAnchor         = HAnchor.ParentLeftRight;
            buttonContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            Button closeButton = textImageButtonFactory.Generate("Close".Localize(), centerText: true);

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

            Button whatsThisLink = linkButtonFactory.Generate("What's this?".Localize());

            whatsThisLink.VAnchor = VAnchor.ParentCenter;
            whatsThisLink.Margin  = new BorderDouble(left: 6);
            whatsThisLink.Click  += (sender, e) =>
            {
                UiThread.RunOnIdle(() =>
                {
                    if (!additionalInfoContainer.Visible)
                    {
                        additionalInfoContainer.Visible = true;
                    }
                    else
                    {
                        additionalInfoContainer.Visible = false;
                    }
                });
            };


            mainLabelContainer.AddChild(checkUpdateLabel);
            topToBottom.AddChild(mainLabelContainer);
            topToBottom.AddChild(updateStatusWidget);
            topToBottom.AddChild(currentBuildInfo);
            currentFeedAndDropDownContainer.AddChild(feedLabel);
            currentFeedAndDropDownContainer.AddChild(whatsThisLink);
            currentFeedAndDropDownContainer.AddChild(new HorizontalSpacer());
            currentFeedAndDropDownContainer.AddChild(releaseOptionsDropList);
            topToBottom.AddChild(currentFeedAndDropDownContainer);

            topToBottom.AddChild(additionalInfoContainer);
            buttonContainer.AddChild(new HorizontalSpacer());
            buttonContainer.AddChild(closeButton);
            topToBottom.AddChild(new VerticalSpacer());
            topToBottom.AddChild(buttonContainer);
            this.AddChild(topToBottom);

            additionalInfoContainer.Visible = false;
            this.Title           = "Check for Update".Localize();
            this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            this.ShowAsSystemWindow();
            this.AlwaysOnTopOfMain = true;
        }
        public EditConnectionWidget(ConnectionWindow windowController, GuiWidget containerWindowToClose, Printer activePrinter = null, object state = null)
            : base(windowController, containerWindowToClose)
        {
            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.borderWidth       = 0;

            linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
            linkButtonFactory.fontSize  = 8;

            this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            this.AnchorAll();
            this.Padding = new BorderDouble(0);             //To be re-enabled once native borders are turned off

            GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.AnchorAll();
            mainContainer.Padding         = new BorderDouble(3, 3, 3, 5);
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            string headerTitle;

            if (activePrinter == null)
            {
                headerTitle                 = string.Format("Add a Printer");
                this.addNewPrinterFlag      = true;
                this.ActivePrinter          = new Printer();
                this.ActivePrinter.Name     = "Default Printer";
                this.ActivePrinter.BaudRate = "250000";
                try
                {
                    this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
                }
                catch (Exception e)
                {
                    Debug.Print(e.Message);
                    GuiWidget.BreakInDebugger();
                    //No active COM ports
                }
            }
            else
            {
                this.ActivePrinter = activePrinter;
                string editHeaderTitleTxt = LocalizedString.Get("Edit Printer");
                headerTitle = string.Format("{1} - {0}", this.ActivePrinter.Name, editHeaderTitleTxt);
                if (this.ActivePrinter.BaudRate == null)
                {
                    this.ActivePrinter.BaudRate = "250000";
                }
                if (this.ActivePrinter.ComPort == null)
                {
                    try
                    {
                        this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
                    }
                    catch (Exception e)
                    {
                        Debug.Print(e.Message);
                        GuiWidget.BreakInDebugger();
                        //No active COM ports
                    }
                }
            }

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);
            headerRow.HAnchor = HAnchor.ParentLeftRight;
            {
                TextWidget headerLabel = new TextWidget(headerTitle, pointSize: 14);
                headerLabel.TextColor = this.defaultTextColor;

                headerRow.AddChild(headerLabel);
            }

            ConnectionControlContainer                 = new FlowLayoutWidget(FlowDirection.TopToBottom);
            ConnectionControlContainer.Padding         = new BorderDouble(5);
            ConnectionControlContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            ConnectionControlContainer.HAnchor         = HAnchor.ParentLeftRight;
            {
                TextWidget printerNameLabel = new TextWidget(LocalizedString.Get("Name"), 0, 0, 10);
                printerNameLabel.TextColor = this.defaultTextColor;
                printerNameLabel.HAnchor   = HAnchor.ParentLeftRight;
                printerNameLabel.Margin    = new BorderDouble(0, 0, 0, 1);

                printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name);

                printerNameInput.HAnchor |= HAnchor.ParentLeftRight;

                comPortLabelWidget = new FlowLayoutWidget();

                Button refreshComPorts = linkButtonFactory.Generate(LocalizedString.Get("(refresh)"));
                refreshComPorts.Margin  = new BorderDouble(left: 5);
                refreshComPorts.VAnchor = VAnchor.ParentBottom;
                refreshComPorts.Click  += new EventHandler(RefreshComPorts);

                FlowLayoutWidget comPortContainer = null;

#if !__ANDROID__
                TextWidget comPortLabel = new TextWidget(LocalizedString.Get("Serial Port"), 0, 0, 10);
                comPortLabel.TextColor = this.defaultTextColor;

                comPortLabelWidget.AddChild(comPortLabel);
                comPortLabelWidget.AddChild(refreshComPorts);
                comPortLabelWidget.Margin  = new BorderDouble(0, 0, 0, 10);
                comPortLabelWidget.HAnchor = HAnchor.ParentLeftRight;

                comPortContainer         = new FlowLayoutWidget(FlowDirection.TopToBottom);
                comPortContainer.Margin  = new BorderDouble(0);
                comPortContainer.HAnchor = HAnchor.ParentLeftRight;

                CreateSerialPortControls(comPortContainer, this.ActivePrinter.ComPort);
#endif

                TextWidget baudRateLabel = new TextWidget(LocalizedString.Get("Baud Rate"), 0, 0, 10);
                baudRateLabel.TextColor = this.defaultTextColor;
                baudRateLabel.Margin    = new BorderDouble(0, 0, 0, 10);
                baudRateLabel.HAnchor   = HAnchor.ParentLeftRight;

                baudRateWidget         = GetBaudRateWidget();
                baudRateWidget.HAnchor = HAnchor.ParentLeftRight;

                FlowLayoutWidget printerMakeContainer  = createPrinterMakeContainer();
                FlowLayoutWidget printerModelContainer = createPrinterModelContainer();

                enableAutoconnect           = new CheckBox(LocalizedString.Get("Auto Connect"));
                enableAutoconnect.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                enableAutoconnect.Margin    = new BorderDouble(top: 10);
                enableAutoconnect.HAnchor   = HAnchor.ParentLeft;
                if (this.ActivePrinter.AutoConnectFlag)
                {
                    enableAutoconnect.Checked = true;
                }

                if (state as StateBeforeRefresh != null)
                {
                    enableAutoconnect.Checked = ((StateBeforeRefresh)state).autoConnect;
                }

                SerialPortControl serialPortScroll = new SerialPortControl();

                if (comPortContainer != null)
                {
                    serialPortScroll.AddChild(comPortContainer);
                }

                ConnectionControlContainer.VAnchor = VAnchor.ParentBottomTop;
                ConnectionControlContainer.AddChild(printerNameLabel);
                ConnectionControlContainer.AddChild(printerNameInput);
                ConnectionControlContainer.AddChild(printerMakeContainer);
                ConnectionControlContainer.AddChild(printerModelContainer);
                ConnectionControlContainer.AddChild(comPortLabelWidget);
                ConnectionControlContainer.AddChild(serialPortScroll);
                ConnectionControlContainer.AddChild(baudRateLabel);
                ConnectionControlContainer.AddChild(baudRateWidget);
#if !__ANDROID__
                ConnectionControlContainer.AddChild(enableAutoconnect);
#endif
            }

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
            buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
            //buttonContainer.VAnchor = VAnchor.BottomTop;
            buttonContainer.Margin = new BorderDouble(0, 5, 0, 3);
            {
                //Construct buttons
                saveButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
                //saveButton.VAnchor = VAnchor.Bottom;

                cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
                //cancelButton.VAnchor = VAnchor.Bottom;
                cancelButton.Click += new EventHandler(CancelButton_Click);

                //Add buttons to buttonContainer
                buttonContainer.AddChild(saveButton);
                buttonContainer.AddChild(new HorizontalSpacer());
                buttonContainer.AddChild(cancelButton);
            }

            //mainContainer.AddChild(new PrinterChooser());

            mainContainer.AddChild(headerRow);
            mainContainer.AddChild(ConnectionControlContainer);
            mainContainer.AddChild(buttonContainer);

#if __ANDROID__
            this.AddChild(new SoftKeyboardContentOffset(mainContainer));
#else
            this.AddChild(mainContainer);
#endif

            BindSaveButtonHandlers();
            BindBaudRateHandlers();
        }
        private FlowLayoutWidget CreateSaveButtons()
        {
            TextImageButtonFactory saveButtonFactory = new TextImageButtonFactory();
            saveButtonFactory.FixedWidth = 56;
            saveButtonFactory.FixedHeight = 40;
            saveButtonFactory.normalFillColor = RGBA_Bytes.White;
            saveButtonFactory.normalTextColor = RGBA_Bytes.Black;
            saveButtonFactory.hoverTextColor = RGBA_Bytes.Black;
            saveButtonFactory.hoverFillColor = new RGBA_Bytes(255, 255, 255, 200);

            FlowLayoutWidget saveButtons = new FlowLayoutWidget();

            //Create Save Button
            Button saveButton = saveButtonFactory.Generate(LocalizedString.Get("Save"), centerText: true);
            saveButton.Cursor = Cursors.Hand;
            saveButtons.AddChild(saveButton);
            saveButton.Click += (sender, e) =>
            {
                MergeAndSavePartsToStl();
            };

            //Create Save As Button 	
            saveButtonFactory.FixedWidth = SideBarButtonWidth - saveButtonFactory.FixedWidth - 2;
            Button saveAsButton = saveButtonFactory.Generate("Save As".Localize(), centerText: true);
            saveAsButton.Cursor = Cursors.Hand;
            saveButtons.AddChild(saveAsButton);
            saveAsButton.Click += (sender, e) =>
            {
				if(saveAsWindowIsOpen == false)
				{
				saveAsWindow = new SaveAsWindow(MergeAndSavePartsToStl);
				this.saveAsWindowIsOpen = true;
				saveAsWindow.Closed += new EventHandler(SaveAsWindow_Closed);
				}
				else
				{
					if(saveAsWindowIsOpen != null)
					{
						saveAsWindow.BringToFront();
					}
				}
            };

            saveButtons.Visible = false;

            return saveButtons;
        }
Пример #19
0
        public EePromRepetierWindow()
            : base(540, 480)
        {
            AlwaysOnTopOfMain = true;
            BackgroundColor   = ActiveTheme.Instance.SecondaryBackgroundColor;

            currentEePromSettings = new EePromRepetierStorage();

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            topToBottom.Padding         = new BorderDouble(3, 0);

            FlowLayoutWidget row = new FlowLayoutWidget();

            row.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            GuiWidget descriptionWidget = AddDescription(LocalizedString.Get("Description"));

            descriptionWidget.Margin = new BorderDouble(left: 3);
            row.AddChild(descriptionWidget);

            CreateSpacer(row);

            GuiWidget valueText = new TextWidget(LocalizedString.Get("Value"), textColor: ActiveTheme.Instance.PrimaryTextColor);

            valueText.VAnchor = Agg.UI.VAnchor.ParentCenter;
            valueText.Margin  = new BorderDouble(left: 5, right: 60);
            row.AddChild(valueText);
            topToBottom.AddChild(row);

            {
                ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true);
                settingsAreaScrollBox.ScrollArea.HAnchor |= HAnchor.ParentLeftRight;
                settingsAreaScrollBox.AnchorAll();
                settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                topToBottom.AddChild(settingsAreaScrollBox);

                settingsColmun         = new FlowLayoutWidget(FlowDirection.TopToBottom);
                settingsColmun.HAnchor = HAnchor.Max_FitToChildren_ParentWidth;

                settingsAreaScrollBox.AddChild(settingsColmun);
            }

            FlowLayoutWidget buttonBar = new FlowLayoutWidget();

            buttonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            // put in the save button
            {
                Button buttonSave = textImageButtonFactory.Generate("Save To EEPROM".Localize());
                buttonSave.Margin = new BorderDouble(0, 3);
                buttonSave.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        currentEePromSettings.Save();
                        currentEePromSettings.Clear();
                        currentEePromSettings.eventAdded -= NewSettingReadFromPrinter;
                        Close();
                    });
                };

                buttonBar.AddChild(buttonSave);
            }

            CreateSpacer(buttonBar);

            // put in the import button
            {
                Button buttonImport = textImageButtonFactory.Generate("Import".Localize() + "...");
                buttonImport.Margin = new BorderDouble(0, 3);
                buttonImport.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        FileDialog.OpenFileDialog(
                            new OpenFileDialogParams("EEPROM Settings" + "|*.ini")
                        {
                            ActionButtonLabel = "Import EEPROM Settings".Localize(),
                            Title             = "Import EEPROM".Localize(),
                        },
                            (openParams) =>
                        {
                            if (!string.IsNullOrEmpty(openParams.FileName))
                            {
                                currentEePromSettings.Import(openParams.FileName);
                                RebuildUi();
                            }
                        });
                    });
                };
                buttonBar.AddChild(buttonImport);
            }

            // put in the export button
            {
                Button buttonExport = textImageButtonFactory.Generate("Export".Localize() + "...");
                buttonExport.Margin = new BorderDouble(0, 3);
                buttonExport.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        FileDialog.SaveFileDialog(
                            new SaveFileDialogParams("EEPROM Settings" + "|*.ini")
                        {
                            ActionButtonLabel = "Export EEPROM Settings".Localize(),
                            Title             = "Export EEPROM".Localize(),
                            FileName          = "eeprom_settings.ini"
                        },
                            (saveParams) =>
                        {
                            if (!string.IsNullOrEmpty(saveParams.FileName))
                            {
                                currentEePromSettings.Export(saveParams.FileName);
                            }
                        });
                    });
                };
                buttonBar.AddChild(buttonExport);
            }

            // put in the cancel button
            {
                Button buttonCancel = textImageButtonFactory.Generate("Close".Localize());
                buttonCancel.Margin = new BorderDouble(10, 3, 0, 3);
                buttonCancel.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        currentEePromSettings.Clear();
                        currentEePromSettings.eventAdded -= NewSettingReadFromPrinter;
                        Close();
                    });
                };
                buttonBar.AddChild(buttonCancel);
            }

            topToBottom.AddChild(buttonBar);

#if __ANDROID__
            TerminalWidget terminalWidget = new TerminalWidget(true);
            this.AddChild(new SoftKeyboardContentOffset(topToBottom));
            //topToBottom.Closed += (sender, e) => { Close(); };
#else
            this.AddChild(topToBottom);
#endif

            Title = LocalizedString.Get("Firmware EEPROM Settings");

            ShowAsSystemWindow();

            currentEePromSettings.Clear();
            PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
            currentEePromSettings.eventAdded += NewSettingReadFromPrinter;
            currentEePromSettings.AskPrinterForSettings();

#if SIMULATE_CONNECTION
            UiThread.RunOnIdle(AddSimulatedItems);
#endif
        }
Пример #20
0
        public EePromRepetierWidget()
            : base(540, 480)
        {
            BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

            currentEePromSettings = new EePromRepetierStorage();

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

            topToBottom.VAnchor         = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;
            topToBottom.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            topToBottom.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            topToBottom.Padding         = new BorderDouble(3, 0);

            FlowLayoutWidget row = new FlowLayoutWidget();

            row.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
            row.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            GuiWidget descriptionWidget = AddDescription(LocalizedString.Get("Description"));

            descriptionWidget.Margin = new BorderDouble(left: 3);
            row.AddChild(descriptionWidget);

            CreateSpacer(row);

            GuiWidget valueText = new TextWidget(LocalizedString.Get("Value"), textColor: ActiveTheme.Instance.PrimaryTextColor);

            valueText.VAnchor = Agg.UI.VAnchor.ParentCenter;
            valueText.Margin  = new BorderDouble(left: 5, right: 60);
            row.AddChild(valueText);
            topToBottom.AddChild(row);

            {
                ScrollableWidget settingsAreaScrollBox = new ScrollableWidget(true);
                settingsAreaScrollBox.ScrollArea.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
                settingsAreaScrollBox.AnchorAll();
                settingsAreaScrollBox.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                topToBottom.AddChild(settingsAreaScrollBox);

                settingsColmun         = new FlowLayoutWidget(FlowDirection.TopToBottom);
                settingsColmun.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;

                settingsAreaScrollBox.AddChild(settingsColmun);
            }

            FlowLayoutWidget buttonBar = new FlowLayoutWidget();

            buttonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
            buttonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            buttonSave        = textImageButtonFactory.Generate(LocalizedString.Get("Save To EEPROM"));
            buttonSave.Margin = new BorderDouble(0, 3);
            buttonBar.AddChild(buttonSave);

            CreateSpacer(buttonBar);

            buttonCancel        = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
            buttonCancel.Margin = new BorderDouble(3);
            buttonBar.AddChild(buttonCancel);

            topToBottom.AddChild(buttonBar);

            this.AddChild(topToBottom);

            translate();
            //MatterControlApplication.Instance.LanguageChanged += translate;

            ShowAsSystemWindow();

            currentEePromSettings.Clear();
            PrinterCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);
            currentEePromSettings.eventAdded += NewSettingReadFromPrinter;
            currentEePromSettings.AskPrinterForSettings();

#if SIMULATE_CONNECTION
            UiThread.RunOnIdle(AddSimulatedItems);
#endif
        }
Пример #21
0
        public EditConnectionWidget(ConnectionWindow windowController, GuiWidget containerWindowToClose, Printer activePrinter = null)
            : base(windowController, containerWindowToClose)
        {
            textImageButtonFactory.normalTextColor   = RGBA_Bytes.White;
            textImageButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            textImageButtonFactory.disabledTextColor = RGBA_Bytes.White;
            textImageButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            textImageButtonFactory.borderWidth       = 0;

            linkButtonFactory.textColor = RGBA_Bytes.White;
            linkButtonFactory.fontSize  = 8;

            this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            this.AnchorAll();
            this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off

            GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            mainContainer.AnchorAll();
            mainContainer.Padding         = new BorderDouble(3, 0, 3, 5);
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            string headerTitle;

            if (activePrinter == null)
            {
                headerTitle                 = string.Format("Add a Printer");
                this.addNewPrinterFlag      = true;
                this.ActivePrinter          = new Printer();
                this.ActivePrinter.Name     = "Default Printer";
                this.ActivePrinter.BaudRate = "250000";
                try
                {
                    this.ActivePrinter.ComPort = SerialPort.GetPortNames()[0];
                }
                catch
                {
                    //No active COM ports
                }
            }
            else
            {
                this.ActivePrinter = activePrinter;
                string editHeaderTitleTxt = new LocalizedString("Edit").Translated;
                headerTitle = string.Format("{1} - {0}", this.ActivePrinter.Name, editHeaderTitleTxt);
                if (this.ActivePrinter.BaudRate == null)
                {
                    this.ActivePrinter.BaudRate = "250000";
                }
                if (this.ActivePrinter.ComPort == null)
                {
                    try
                    {
                        this.ActivePrinter.ComPort = SerialPort.GetPortNames()[0];
                    }
                    catch
                    {
                        //No active COM ports
                    }
                }
            }

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

            headerRow.Margin  = new BorderDouble(0, 3, 0, 0);
            headerRow.Padding = new BorderDouble(0, 3, 0, 3);
            headerRow.HAnchor = HAnchor.ParentLeftRight;
            {
                TextWidget headerLabel = new TextWidget(headerTitle, pointSize: 14);
                headerLabel.TextColor = this.defaultTextColor;

                headerRow.AddChild(headerLabel);
            }

            ConnectionControlContainer                 = new FlowLayoutWidget(FlowDirection.TopToBottom);
            ConnectionControlContainer.Padding         = new BorderDouble(5);
            ConnectionControlContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            ConnectionControlContainer.HAnchor         = HAnchor.ParentLeftRight;
            {
                TextWidget printerNameLabel = new TextWidget(new LocalizedString("Printer Name").Translated, 0, 0, 10);
                printerNameLabel.TextColor = this.defaultTextColor;
                printerNameLabel.HAnchor   = HAnchor.ParentLeftRight;
                printerNameLabel.Margin    = new BorderDouble(0, 0, 0, 1);

                printerNameInput = new MHTextEditWidget(this.ActivePrinter.Name);

                printerNameInput.HAnchor |= HAnchor.ParentLeftRight;

                comPortLabelWidget = new FlowLayoutWidget();

                Button refreshComPorts = linkButtonFactory.Generate(new LocalizedString("(refresh)").Translated);
                refreshComPorts.Margin  = new BorderDouble(left: 5);
                refreshComPorts.VAnchor = VAnchor.ParentBottom;
                refreshComPorts.Click  += new ButtonBase.ButtonEventHandler(RefreshComPorts);

                TextWidget comPortLabel = new TextWidget(new LocalizedString("Serial Port").Translated, 0, 0, 10);
                comPortLabel.TextColor = this.defaultTextColor;

                comPortLabelWidget.AddChild(comPortLabel);
                comPortLabelWidget.AddChild(refreshComPorts);
                comPortLabelWidget.Margin  = new BorderDouble(0, 0, 0, 10);
                comPortLabelWidget.HAnchor = HAnchor.ParentLeftRight;

                FlowLayoutWidget comPortContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                comPortContainer.Margin  = new BorderDouble(0);
                comPortContainer.HAnchor = HAnchor.ParentLeftRight;


                int portIndex = 0;
                foreach (string serialPort in SerialPort.GetPortNames())
                {
                    //Filter com port list based on usb type (applies to Mac mostly)
                    bool looks_like_mac = serialPort.StartsWith("/dev/tty.");
                    bool looks_like_pc  = serialPort.StartsWith("COM");
                    if (looks_like_mac || looks_like_pc)
                    {
                        SerialPortIndexRadioButton comPortOption = createComPortOption(serialPort);
                        comPortContainer.AddChild(comPortOption);
                        portIndex++;
                    }
                }

                //If there are no com ports in the filtered list assume we are missing something and show the unfiltered list
                if (portIndex == 0)
                {
                    foreach (string serialPort in SerialPort.GetPortNames())
                    {
                        SerialPortIndexRadioButton comPortOption = createComPortOption(serialPort);
                        comPortContainer.AddChild(comPortOption);
                        portIndex++;
                    }
                }

                if (!printerComPortIsAvailable && this.ActivePrinter.ComPort != null)
                {
                    SerialPortIndexRadioButton comPortOption = createComPortOption(this.ActivePrinter.ComPort);
                    comPortOption.Enabled = false;
                    comPortContainer.AddChild(comPortOption);
                    portIndex++;
                }

                //If there are still no com ports show a message to that effect
                if (portIndex == 0)
                {
                    TextWidget comPortOption = new TextWidget(new LocalizedString("No COM ports available").Translated);
                    comPortOption.Margin    = new BorderDouble(3, 6, 5, 6);
                    comPortOption.TextColor = this.subContainerTextColor;
                    comPortContainer.AddChild(comPortOption);
                }


                TextWidget baudRateLabel = new TextWidget(new LocalizedString("Baud Rate").Translated, 0, 0, 10);
                baudRateLabel.TextColor = this.defaultTextColor;
                baudRateLabel.Margin    = new BorderDouble(0, 0, 0, 10);
                baudRateLabel.HAnchor   = HAnchor.ParentLeftRight;

                baudRateWidget         = GetBaudRateWidget();
                baudRateWidget.HAnchor = HAnchor.ParentLeftRight;

                FlowLayoutWidget printerMakeContainer  = createPrinterMakeContainer();
                FlowLayoutWidget printerModelContainer = createPrinterModelContainer();

                enableAutoconnect           = new CheckBox(new LocalizedString("Auto Connect").Translated);
                enableAutoconnect.TextColor = RGBA_Bytes.White;
                enableAutoconnect.Margin    = new BorderDouble(top: 10);
                enableAutoconnect.HAnchor   = HAnchor.ParentLeft;
                if (this.ActivePrinter.AutoConnectFlag)
                {
                    enableAutoconnect.Checked = true;
                }

                ConnectionControlContainer.VAnchor = VAnchor.ParentBottomTop;
                ConnectionControlContainer.AddChild(printerNameLabel);
                ConnectionControlContainer.AddChild(printerNameInput);
                ConnectionControlContainer.AddChild(printerMakeContainer);
                ConnectionControlContainer.AddChild(printerModelContainer);
                ConnectionControlContainer.AddChild(comPortLabelWidget);
                ConnectionControlContainer.AddChild(comPortContainer);
                ConnectionControlContainer.AddChild(baudRateLabel);
                ConnectionControlContainer.AddChild(baudRateWidget);
                ConnectionControlContainer.AddChild(enableAutoconnect);
            }

            FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);

            buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
            //buttonContainer.VAnchor = VAnchor.BottomTop;
            buttonContainer.Margin = new BorderDouble(0, 3);
            {
                //Construct buttons
                saveButton = textImageButtonFactory.Generate(new LocalizedString("Save").Translated);
                //saveButton.VAnchor = VAnchor.Bottom;

                cancelButton = textImageButtonFactory.Generate(new LocalizedString("Cancel").Translated);
                //cancelButton.VAnchor = VAnchor.Bottom;
                cancelButton.Click += new ButtonBase.ButtonEventHandler(CancelButton_Click);

                //Add buttons to buttonContainer
                buttonContainer.AddChild(saveButton);
                buttonContainer.AddChild(cancelButton);
            }

            //mainContainer.AddChild(new PrinterChooser());

            mainContainer.AddChild(headerRow);
            mainContainer.AddChild(ConnectionControlContainer);
            mainContainer.AddChild(buttonContainer);

            this.AddChild(mainContainer);

            BindSaveButtonHandlers();
            BindBaudRateHandlers();
        }
Пример #22
0
        public TemperatureWidgetBase(string textValue)
            : base(52, 52)
        {
            whiteButtonFactory.FixedHeight     = 18;
            whiteButtonFactory.fontSize        = 7;
            whiteButtonFactory.normalFillColor = RGBA_Bytes.White;
            whiteButtonFactory.normalTextColor = RGBA_Bytes.DarkGray;

            FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);

            container.AnchorAll();

            this.BackgroundColor = new RGBA_Bytes(255, 255, 255, 200);
            this.Margin          = new BorderDouble(0, 2);

            GuiWidget labelContainer = new GuiWidget();

            labelContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            labelContainer.Height  = 18;

            labelTextWidget = new TextWidget("", pointSize: 8);
            labelTextWidget.AutoExpandBoundsToText = true;
            labelTextWidget.HAnchor   = HAnchor.ParentCenter;
            labelTextWidget.VAnchor   = VAnchor.ParentCenter;
            labelTextWidget.TextColor = ActiveTheme.Instance.SecondaryAccentColor;
            labelTextWidget.Visible   = false;

            labelContainer.AddChild(labelTextWidget);

            GuiWidget indicatorContainer = new GuiWidget();

            indicatorContainer.AnchorAll();

            indicatorTextWidget           = new TextWidget(textValue, pointSize: 11);
            indicatorTextWidget.TextColor = ActiveTheme.Instance.PrimaryAccentColor;
            indicatorTextWidget.HAnchor   = HAnchor.ParentCenter;
            indicatorTextWidget.VAnchor   = VAnchor.ParentCenter;
            indicatorTextWidget.AutoExpandBoundsToText = true;

            indicatorContainer.AddChild(indicatorTextWidget);

            GuiWidget buttonContainer = new GuiWidget();

            buttonContainer.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
            buttonContainer.Height  = 18;

            preheatButton         = whiteButtonFactory.Generate("PREHEAT");
            preheatButton.Cursor  = Cursors.Hand;
            preheatButton.Visible = false;

            buttonContainer.AddChild(preheatButton);

            container.AddChild(labelContainer);
            container.AddChild(indicatorContainer);
            container.AddChild(buttonContainer);


            this.AddChild(container);
            ActiveTheme.Instance.ThemeChanged.RegisterEvent(onThemeChanged, ref unregisterEvents);

            this.MouseEnterBounds    += onEnterBounds;
            this.MouseLeaveBounds    += onLeaveBounds;
            this.preheatButton.Click += onPreheatButtonClick;
        }
Пример #23
0
        public PluginChooserWindow()
            : base(360, 300)
        {
            Title = new LocalizedString("Installed Plugins").Translated;

            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);

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

            FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);

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

            {
                string     elementHeaderLblBeg  = new LocalizedString("Select a Design Tool").Translated;
                string     elementHeaderLblFull = string.Format("{0}:", elementHeaderLblBeg);
                string     elementHeaderLbl     = elementHeaderLblFull;
                TextWidget elementHeader        = new TextWidget(string.Format(elementHeaderLbl), pointSize: 14);
                elementHeader.TextColor = ActiveTheme.Instance.PrimaryTextColor;
                elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                headerRow.AddChild(elementHeader);
            }

            topToBottom.AddChild(headerRow);

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

            FlowLayoutWidget pluginRowContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

            pluginRowContainer.AnchorAll();
            presetsFormContainer.AddChild(pluginRowContainer);

            foreach (CreatorInformation creatorInfo in RegisteredCreators.Instance.Creators)
            {
                ClickWidget pluginRow = new ClickWidget();
                pluginRow.HAnchor         = Agg.UI.HAnchor.ParentLeftRight;
                pluginRow.Height          = 38;
                pluginRow.BackgroundColor = RGBA_Bytes.White;
                pluginRow.Padding         = new BorderDouble(3);
                pluginRow.Margin          = new BorderDouble(6, 0, 6, 6);

                GuiWidget overlay = new GuiWidget();
                overlay.AnchorAll();
                overlay.Cursor = Cursors.Hand;

                FlowLayoutWidget macroRow = new FlowLayoutWidget();
                macroRow.AnchorAll();
                macroRow.BackgroundColor = RGBA_Bytes.White;

                if (creatorInfo.iconPath != "")
                {
                    ImageBuffer imageBuffer = LoadImage(creatorInfo.iconPath);
                    ImageWidget imageWidget = new ImageWidget(imageBuffer);
                    macroRow.AddChild(imageWidget);
                }

                TextWidget buttonLabel = new TextWidget(creatorInfo.description, pointSize: 14);

                buttonLabel.Margin  = new BorderDouble(left: 10);
                buttonLabel.VAnchor = Agg.UI.VAnchor.ParentCenter;
                macroRow.AddChild(buttonLabel);

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

                CreatorInformation callCorrectFunctionHold = creatorInfo;
                pluginRow.Click += (sender, e) =>
                {
                    if (RegisteredCreators.Instance.Creators.Count > 0)
                    {
                        callCorrectFunctionHold.functionToLaunchCreator(null, null);
                    }
                    UiThread.RunOnIdle(CloseOnIdle);
                };
                pluginRow.AddChild(macroRow);
                pluginRow.AddChild(overlay);
                pluginRowContainer.AddChild(pluginRow);
            }

            topToBottom.AddChild(presetsFormContainer);
            BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

            //ShowAsSystemWindow();

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

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

            topToBottom.AddChild(buttonRow);

            AddChild(topToBottom);
        }
        public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
            : base(windowController, container)
        {
            {
                this.editMode = editMode;

                textImageButtonFactory.normalTextColor   = RGBA_Bytes.White;
                textImageButtonFactory.hoverTextColor    = RGBA_Bytes.White;
                textImageButtonFactory.disabledTextColor = RGBA_Bytes.White;
                textImageButtonFactory.pressedTextColor  = RGBA_Bytes.White;
                textImageButtonFactory.borderWidth       = 0;

                this.AnchorAll();
                this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
                this.Padding         = new BorderDouble(0); //To be re-enabled once native borders are turned off

                GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                mainContainer.AnchorAll();
                mainContainer.Padding         = new BorderDouble(3, 0, 3, 5);
                mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                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 chooseThreeDPrinterConfigLabel = new LocalizedString("Choose a 3D Printer Configuration").Translated;
                    string chooseThreeDPrinterConfigFull  = string.Format("{0}:", chooseThreeDPrinterConfigLabel);

                    TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
                    elementHeader.TextColor = this.defaultTextColor;
                    elementHeader.HAnchor   = HAnchor.ParentLeftRight;
                    elementHeader.VAnchor   = Agg.UI.VAnchor.ParentBottom;

                    ActionLink editModeLink;
                    if (!this.editMode)
                    {
                        editModeLink = actionLinkFactory.Generate(new LocalizedString("Edit").Translated, 12, EditModeOnLink_Click);
                    }
                    else
                    {
                        editModeLink = actionLinkFactory.Generate(new LocalizedString("Done").Translated, 12, EditModeOffLink_Click);
                    }

                    editModeLink.TextColor = new RGBA_Bytes(250, 250, 250);
                    editModeLink.VAnchor   = Agg.UI.VAnchor.ParentBottom;

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

                //To do - replace with scrollable widget
                FlowLayoutWidget printerListContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
                //ListBox printerListContainer = new ListBox();
                {
                    printerListContainer.HAnchor         = HAnchor.ParentLeftRight;
                    printerListContainer.VAnchor         = VAnchor.ParentBottomTop;
                    printerListContainer.Padding         = new BorderDouble(3);
                    printerListContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;

                    //Get a list of printer records and add them to radio button list
                    foreach (Printer printer in GetAllPrinters())
                    {
                        PrinterListItem printerListItem;
                        if (this.editMode)
                        {
                            printerListItem = new PrinterListItemEdit(printer, this.windowController);
                        }
                        else
                        {
                            printerListItem = new PrinterListItemView(printer, this.windowController);
                        }

                        printerListContainer.AddChild(printerListItem);
                    }
                }

                FlowLayoutWidget buttonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
                buttonContainer.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
                buttonContainer.Margin  = new BorderDouble(0, 3);
                {
                    closeButton = textImageButtonFactory.Generate(new LocalizedString("Close").Translated);

                    Button addPrinterButton = textImageButtonFactory.Generate(new LocalizedString("Add").Translated, "icon_circle_plus.png");
                    addPrinterButton.Click += new ButtonBase.ButtonEventHandler(AddConnectionLink_Click);

                    Button refreshListButton = textImageButtonFactory.Generate(new LocalizedString("Refresh").Translated);
                    refreshListButton.Click += new ButtonBase.ButtonEventHandler(EditModeOffLink_Click);

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

                    //Add buttons to ButtonContainer
                    buttonContainer.AddChild(addPrinterButton);

                    if (!this.editMode)
                    {
                        buttonContainer.AddChild(refreshListButton);
                    }


                    buttonContainer.AddChild(spacer);
                    buttonContainer.AddChild(closeButton);
                }

                mainContainer.AddChild(headerRow);
                mainContainer.AddChild(printerListContainer);
                mainContainer.AddChild(buttonContainer);

                this.AddChild(mainContainer);

                BindCloseButtonClick();
            }
        }
Пример #25
0
        public PrintLibraryWidget()
        {
            SetDisplayAttributes();

            textImageButtonFactory.normalTextColor   = RGBA_Bytes.White;
            textImageButtonFactory.hoverTextColor    = RGBA_Bytes.White;
            textImageButtonFactory.disabledTextColor = RGBA_Bytes.White;
            textImageButtonFactory.pressedTextColor  = RGBA_Bytes.White;
            textImageButtonFactory.borderWidth       = 0;

            searchButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryBackgroundColor;
            searchButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryBackgroundColor;
            searchButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            searchButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryBackgroundColor;
            searchButtonFactory.borderWidth       = 0;

            FlowLayoutWidget allControls = new FlowLayoutWidget(FlowDirection.TopToBottom);

            {
                FlowLayoutWidget searchPanel = new FlowLayoutWidget();
                searchPanel.BackgroundColor = new RGBA_Bytes(180, 180, 180);
                searchPanel.HAnchor         = HAnchor.ParentLeftRight;
                searchPanel.Padding         = new BorderDouble(3, 3);
                {
                    searchInput         = new MHTextEditWidget();
                    searchInput.Margin  = new BorderDouble(6, 0);
                    searchInput.HAnchor = HAnchor.ParentLeftRight;
                    searchInput.VAnchor = VAnchor.ParentCenter;

                    searchButton        = searchButtonFactory.Generate(new LocalizedString("Search").Translated);
                    searchButton.Margin = new BorderDouble(right: 9);

                    searchPanel.AddChild(searchInput);
                    searchPanel.AddChild(searchButton);
                }

                FlowLayoutWidget buttonPanel = new FlowLayoutWidget();
                buttonPanel.HAnchor = HAnchor.ParentLeftRight;
                buttonPanel.Padding = new BorderDouble(0, 3);
                {
                    Button addToLibrary = textImageButtonFactory.Generate(new LocalizedString("Import").Translated, "icon_import_white_32x32.png");
                    buttonPanel.AddChild(addToLibrary);
                    addToLibrary.Margin = new BorderDouble(0, 0, 3, 0);
                    addToLibrary.Click += new ButtonBase.ButtonEventHandler(loadFile_Click);

                    Button runCreator = textImageButtonFactory.Generate(new LocalizedString("Create").Translated, "icon_creator_white_32x32.png");
                    buttonPanel.AddChild(runCreator);
                    runCreator.Margin = new BorderDouble(0, 0, 3, 0);
                    runCreator.Click += (sender, e) =>
                    {
                        OpenPluginChooserWindow();
                    };

                    addToQueueButton         = textImageButtonFactory.Generate("Add to Queue");
                    addToQueueButton.Margin  = new BorderDouble(3, 0);
                    addToQueueButton.Click  += new ButtonBase.ButtonEventHandler(addToQueueButton_Click);
                    addToQueueButton.Visible = false;
                    buttonPanel.AddChild(addToQueueButton);

                    deleteFromLibraryButton         = textImageButtonFactory.Generate("Remove");
                    deleteFromLibraryButton.Margin  = new BorderDouble(3, 0);
                    deleteFromLibraryButton.Click  += new ButtonBase.ButtonEventHandler(deleteFromQueueButton_Click);
                    deleteFromLibraryButton.Visible = false;
                    buttonPanel.AddChild(deleteFromLibraryButton);

                    GuiWidget spacer = new GuiWidget();
                    spacer.HAnchor = HAnchor.ParentLeftRight;
                    buttonPanel.AddChild(spacer);
                }

                allControls.AddChild(searchPanel);
                allControls.AddChild(PrintLibraryListControl.Instance);
                allControls.AddChild(buttonPanel);
            }
            allControls.AnchorAll();

            this.AddChild(allControls);

            AddHandlers();
        }
Пример #26
0
        private void AddLibraryButtonElements()
        {
            textImageButtonFactory.normalTextColor   = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.hoverTextColor    = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.pressedTextColor  = ActiveTheme.Instance.PrimaryTextColor;
            textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
            textImageButtonFactory.disabledFillColor = new RGBA_Bytes();
            buttonPanel.RemoveAllChildren();
            // the add button
            {
                addToLibraryButton             = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                addToLibraryButton.Enabled     = false;             // The library selector (the first library selected) is protected so we can't add to it.
                addToLibraryButton.ToolTipText = "Add an .stl, .amf, .gcode or .zip file to the Library".Localize();
                addToLibraryButton.Name        = "Library Add Button";
                buttonPanel.AddChild(addToLibraryButton);
                addToLibraryButton.Margin = new BorderDouble(0, 0, 3, 0);
                addToLibraryButton.Click += (sender, e) => UiThread.RunOnIdle(importToLibraryloadFile_ClickOnIdle);
            }

            // the create folder button
            {
                createFolderButton         = textImageButtonFactory.Generate(LocalizedString.Get("Create Folder"));
                createFolderButton.Enabled = false;                 // The library selector (the first library selected) is protected so we can't add to it.
                createFolderButton.Name    = "Create Folder From Library Button";
                buttonPanel.AddChild(createFolderButton);
                createFolderButton.Margin = new BorderDouble(0, 0, 3, 0);
                createFolderButton.Click += (sender, e) =>
                {
                    if (createFolderWindow == null)
                    {
                        createFolderWindow = new CreateFolderWindow((returnInfo) =>
                        {
                            this.libraryDataView.CurrentLibraryProvider.AddCollectionToLibrary(returnInfo.newName);
                        });
                        createFolderWindow.Closed += (sender2, e2) => { createFolderWindow = null; };
                    }
                    else
                    {
                        createFolderWindow.BringToFront();
                    }
                };
            }

            // add in the message widget
            {
                providerMessageWidget = new TextWidget("")
                {
                    PointSize = 8,
                    HAnchor   = HAnchor.ParentRight,
                    VAnchor   = VAnchor.ParentBottom,
                    TextColor = ActiveTheme.Instance.SecondaryTextColor,
                    Margin    = new BorderDouble(6),
                    AutoExpandBoundsToText = true,
                };

                providerMessageContainer = new GuiWidget()
                {
                    VAnchor = VAnchor.FitToChildren | VAnchor.ParentTop,
                    HAnchor = HAnchor.ParentLeftRight,
                    Visible = false,
                };

                providerMessageContainer.AddChild(providerMessageWidget);
                buttonPanel.AddChild(providerMessageContainer, -1);
            }
        }
Пример #27
0
 private void CreateMainButton(ref Button button, FlowLayoutWidget buttonBar, string text)
 {
     button = textImageButtonFactory.Generate(LocalizedString.Get(text));
     buttonBar.AddChild(button);
 }
		public static GuiWidget CreatePrinterExtraControls()
		{
			var dataArea = new FlowLayoutWidget(FlowDirection.TopToBottom)
			{
				HAnchor = HAnchor.ParentLeftRight,
			};

			// OEM_LAYER_DATE:
			string lastUpdateTime = "March 1, 2016";
			if (ActiveSliceSettings.Instance?.OemLayer != null)
			{
				string fromCreatedDate = ActiveSliceSettings.Instance.OemLayer.ValueOrDefault(SettingsKey.created_date);
				try
				{
					if (!string.IsNullOrEmpty(fromCreatedDate))
					{
						DateTime time = Convert.ToDateTime(fromCreatedDate).ToLocalTime();
						lastUpdateTime = time.ToString("MMMM d, yyyy ") + time.ToString("h:mm tt");
					}
				}
				catch
				{
				}
			}

			lastUpdateTime = "Default settings updated: {0} ".Localize().FormatWith(lastUpdateTime);

			dataArea.AddChild(new TextWidget(lastUpdateTime, textColor: ActiveTheme.Instance.SecondaryTextColor)
			{
				HAnchor= HAnchor.ParentCenter,
				Margin = new BorderDouble(0, 15),
			});

			// DELETE_PRINTER:
			{
				// This is a place holder type to allow us to put in the control that will allow the deletion of a printer profile
				TextImageButtonFactory buttonFactory = new TextImageButtonFactory();
				buttonFactory.borderWidth = 1;
				if (ActiveTheme.Instance.IsDarkTheme)
				{
					buttonFactory.normalBorderColor = new RGBA_Bytes(99, 99, 99);
				}
				else
				{
					buttonFactory.normalBorderColor = new RGBA_Bytes(140, 140, 140);
				}

				buttonFactory.normalTextColor = RGBA_Bytes.Red;
				var button = buttonFactory.Generate("Delete Printer".Localize());
				button.Name = "Delete Printer Button";
				button.HAnchor = HAnchor.ParentCenter;
				button.Click += (s, e) =>
				{
					StyledMessageBox.ShowMessageBox((doDelete) =>
					{
						if (doDelete)
						{
							ActiveSliceSettings.Instance.Helpers.SetMarkedForDelete(true);
						}
					}, "Are you sure you want to delete your currently selected printer?".Localize(), "Delete Printer?".Localize(), StyledMessageBox.MessageType.YES_NO, "Delete Printer".Localize());
				};
				dataArea.AddChild(button);
			}

			return dataArea;
		}
        public void doLayout()
        {
            this.RemoveAllChildren();
            TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
            FlowLayoutWidget topToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
            topToBottom.Padding = new BorderDouble(10);
            topToBottom.AnchorAll();

			string fileExportLabelTxt = new LocalizedString("File export options").Translated;
			TextWidget exportLabel = new TextWidget(string.Format("{0}:", fileExportLabelTxt));
            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 noGCodeMessageText = new LocalizedString("Note").Translated;
				string noGCodeMessageTextFull = new LocalizedString("To enable GCode export, select a printer profile").Translated;
				TextWidget noGCodeMessage = new TextWidget(string.Format("{0}: {1}.", noGCodeMessageText, noGCodeMessageTextFull), 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);
        }
		private FlowLayoutWidget GetBottomRow(TextImageButtonFactory buttonFactory)
		{
			var container = new FlowLayoutWidget()
			{
				HAnchor = HAnchor.ParentLeftRight,
				Margin = new BorderDouble(top: 3)
			};

			Button duplicateButton = buttonFactory.Generate("Duplicate".Localize());
			duplicateButton.Click += (s, e) =>
			{
				UiThread.RunOnIdle(() =>
				{
					string sanitizedName = numberMatch.Replace(presetNameInput.Text, "").Trim();
					string newProfileName = GetNonCollidingName(sanitizedName, presetsContext.PresetLayers.Select(preset => preset.ValueOrDefault(SettingsKey.layer_name)));

					var clonedLayer = presetsContext.PersistenceLayer.Clone();
					clonedLayer.Name = newProfileName;
					presetsContext.PresetLayers.Add(clonedLayer);

					presetsContext.SetAsActive(clonedLayer.LayerID);
					presetsContext.PersistenceLayer = clonedLayer;

					middleRow.CloseAllChildren();
					middleRow.AddChild(CreateSliceSettingsWidget(clonedLayer));

					presetNameInput.Text = newProfileName;
				});
			};

			Button deleteButton = buttonFactory.Generate("Delete".Localize());
			deleteButton.Click += (s, e) =>
			{
				UiThread.RunOnIdle(() =>
				{
					presetsContext.DeleteLayer();
					this.Close();
				});
			};

			Button closeButton = buttonFactory.Generate("Close".Localize());
			closeButton.Click += (sender, e) =>
			{
				this.CloseOnIdle();
			};

			container.AddChild(duplicateButton);
			container.AddChild(deleteButton);
			container.AddChild(new HorizontalSpacer());
			container.AddChild(closeButton);

			return container;
		}
Пример #31
0
        public EePromMarlinWindow()
            : base(650 * GuiWidget.DeviceScale, 480 * GuiWidget.DeviceScale)
        {
            AlwaysOnTopOfMain = true;
            Title             = "Marlin Firmware EEPROM Settings".Localize();

            currentEePromSettings             = new EePromMarlinSettings();
            currentEePromSettings.eventAdded += SetUiToPrinterSettings;

            GuiWidget mainContainer = new GuiWidget();

            mainContainer.AnchorAll();
            mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
            mainContainer.Padding         = new BorderDouble(3, 0);

            // space filling color
            GuiWidget spaceFiller = new GuiWidget(0, 500);

            spaceFiller.VAnchor         = VAnchor.ParentBottom;
            spaceFiller.HAnchor         = HAnchor.ParentLeftRight;
            spaceFiller.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            spaceFiller.Padding         = new BorderDouble(top: 3);
            mainContainer.AddChild(spaceFiller);

            double topBarHeight = 0;
            // the top button bar
            {
                FlowLayoutWidget topButtonBar = new FlowLayoutWidget();
                topButtonBar.HAnchor         = HAnchor.ParentLeftRight;
                topButtonBar.VAnchor         = VAnchor.FitToChildren | VAnchor.ParentTop;
                topButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

                topButtonBar.Margin = new BorderDouble(0, 3);

                Button buttonSetToFactorySettings = textImageButtonFactory.Generate("Reset to Factory Defaults".Localize());
                topButtonBar.AddChild(buttonSetToFactorySettings);

                buttonSetToFactorySettings.Click += (sender, e) =>
                {
                    currentEePromSettings.SetPrinterToFactorySettings();
                    currentEePromSettings.Update();
                };

                mainContainer.AddChild(topButtonBar);

                topBarHeight = topButtonBar.Height;
            }

            // the center content
            FlowLayoutWidget conterContent = new FlowLayoutWidget(FlowDirection.TopToBottom);

            conterContent.VAnchor         = VAnchor.FitToChildren | VAnchor.ParentTop;
            conterContent.HAnchor         = HAnchor.ParentLeftRight;
            conterContent.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            conterContent.Padding         = new BorderDouble(top: 3);
            conterContent.Margin          = new BorderDouble(top: topBarHeight);

            conterContent.AddChild(Create4FieldSet("Steps per mm:".Localize(),
                                                   "X:", ref stepsPerMmX,
                                                   "Y:", ref stepsPerMmY,
                                                   "Z:", ref stepsPerMmZ,
                                                   "E:", ref stepsPerMmE));

            conterContent.AddChild(Create4FieldSet("Maximum feedrates [mm/s]:".Localize(),
                                                   "X:", ref maxFeedrateMmPerSX,
                                                   "Y:", ref maxFeedrateMmPerSY,
                                                   "Z:", ref maxFeedrateMmPerSZ,
                                                   "E:", ref maxFeedrateMmPerSE));

            conterContent.AddChild(Create4FieldSet("Maximum Acceleration [mm/s²]:".Localize(),
                                                   "X:", ref maxAccelerationMmPerSSqrdX,
                                                   "Y:", ref maxAccelerationMmPerSSqrdY,
                                                   "Z:", ref maxAccelerationMmPerSSqrdZ,
                                                   "E:", ref maxAccelerationMmPerSSqrdE));

            conterContent.AddChild(CreateField("Acceleration:".Localize(), ref acceleration));
            conterContent.AddChild(CreateField("Retract Acceleration:".Localize(), ref retractAcceleration));

            conterContent.AddChild(Create3FieldSet("PID settings:".Localize(),
                                                   "P:", ref pidP,
                                                   "I:", ref pidI,
                                                   "D:", ref pidD));

            conterContent.AddChild(Create3FieldSet("Homing Offset:".Localize(),
                                                   "X:", ref homingOffsetX,
                                                   "Y:", ref homingOffsetY,
                                                   "Z:", ref homingOffsetZ));

            conterContent.AddChild(CreateField("Min feedrate [mm/s]:".Localize(), ref minFeedrate));
            conterContent.AddChild(CreateField("Min travel feedrate [mm/s]:".Localize(), ref minTravelFeedrate));
            conterContent.AddChild(CreateField("Minimum segment time [ms]:".Localize(), ref minSegmentTime));
            conterContent.AddChild(CreateField("Maximum X-Y jerk [mm/s]:".Localize(), ref maxXYJerk));
            conterContent.AddChild(CreateField("Maximum Z jerk [mm/s]:".Localize(), ref maxZJerk));

            GuiWidget topBottomSpacer = new GuiWidget(1, 1);

            topBottomSpacer.VAnchor = VAnchor.ParentBottomTop;
            conterContent.AddChild(topBottomSpacer);

            mainContainer.AddChild(conterContent);

            // the bottom button bar
            {
                FlowLayoutWidget bottomButtonBar = new FlowLayoutWidget();
                bottomButtonBar.HAnchor         = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
                bottomButtonBar.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
                bottomButtonBar.Margin          = new BorderDouble(0, 3);

                Button buttonSave = textImageButtonFactory.Generate("Save to EEProm".Localize());
                bottomButtonBar.AddChild(buttonSave);
                buttonSave.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(() =>
                    {
                        SaveSettingsToActive();
                        currentEePromSettings.SaveToEeProm();
                        Close();
                    });
                };

                CreateSpacer(bottomButtonBar);

                // put in the import button
#if true
                {
                    Button buttonImport = textImageButtonFactory.Generate("Import".Localize() + "...");
                    buttonImport.Margin = new BorderDouble(0, 3);
                    buttonImport.Click += (sender, e) =>
                    {
                        UiThread.RunOnIdle(() =>
                        {
                            FileDialog.OpenFileDialog(
                                new OpenFileDialogParams("EEPROM Settings" + "|*.ini")
                            {
                                ActionButtonLabel = "Import EEPROM Settings".Localize(),
                                Title             = "Import EEPROM".Localize(),
                            },
                                (openParams) =>
                            {
                                if (!string.IsNullOrEmpty(openParams.FileName))
                                {
                                    currentEePromSettings.Import(openParams.FileName);
                                    SetUiToPrinterSettings(null, null);
                                }
                            });
                        });
                    };
                    bottomButtonBar.AddChild(buttonImport);
                }

                // put in the export button
                {
                    Button buttonExport = textImageButtonFactory.Generate("Export".Localize() + "...");
                    buttonExport.Margin = new BorderDouble(0, 3);
                    buttonExport.Click += (sender, e) =>
                    {
                        UiThread.RunOnIdle(() =>
                        {
                            string defaultFileNameNoPath = "eeprom_settings.ini";
                            FileDialog.SaveFileDialog(
                                new SaveFileDialogParams("EEPROM Settings" + "|*.ini")
                            {
                                ActionButtonLabel = "Export EEPROM Settings".Localize(),
                                Title             = "Export EEPROM".Localize(),
                                FileName          = defaultFileNameNoPath
                            },
                                (saveParams) =>
                            {
                                if (!string.IsNullOrEmpty(saveParams.FileName) &&
                                    saveParams.FileName != defaultFileNameNoPath)
                                {
                                    currentEePromSettings.Export(saveParams.FileName);
                                }
                            });
                        });
                    };
                    bottomButtonBar.AddChild(buttonExport);
                }
#endif

                Button buttonAbort = textImageButtonFactory.Generate("Close".Localize());
                bottomButtonBar.AddChild(buttonAbort);
                buttonAbort.Click += buttonAbort_Click;

                mainContainer.AddChild(bottomButtonBar);
            }

            PrinterConnectionAndCommunication.Instance.CommunicationUnconditionalFromPrinter.RegisterEvent(currentEePromSettings.Add, ref unregisterEvents);

#if __ANDROID__
            this.AddChild(new SoftKeyboardContentOffset(mainContainer));
#else
            AddChild(mainContainer);
#endif

            ShowAsSystemWindow();

            // and ask the printer to send the settings
            currentEePromSettings.Update();

            foreach (GuiWidget widget in leftStuffToSize)
            {
                widget.Width = maxWidthOfLeftStuff;
            }
        }
Пример #32
0
		private void CreateAndAddChildren()
		{
			TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
			textImageButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
			textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;

			CloseAllChildren();
			gcodeViewWidget = null;
			gcodeProcessingStateInfoText = null;

			FlowLayoutWidget mainContainerTopToBottom = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainerTopToBottom.HAnchor = Agg.UI.HAnchor.Max_FitToChildren_ParentWidth;
			mainContainerTopToBottom.VAnchor = Agg.UI.VAnchor.Max_FitToChildren_ParentHeight;

			buttonBottomPanel = new FlowLayoutWidget(FlowDirection.LeftToRight);
			buttonBottomPanel.HAnchor = HAnchor.ParentLeftRight;
			buttonBottomPanel.Padding = new BorderDouble(3, 3);
			buttonBottomPanel.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			generateGCodeButton = textImageButtonFactory.Generate(LocalizedString.Get("Generate"));
			generateGCodeButton.Click += new EventHandler(generateButton_Click);
			buttonBottomPanel.AddChild(generateGCodeButton);

			layerSelectionButtonsPanel = new FlowLayoutWidget(FlowDirection.RightToLeft);
			layerSelectionButtonsPanel.HAnchor = HAnchor.ParentLeftRight;
			layerSelectionButtonsPanel.Padding = new BorderDouble(0);

			GuiWidget holdPanelOpen = new GuiWidget(1, generateGCodeButton.Height);
			layerSelectionButtonsPanel.AddChild(holdPanelOpen);

			if (windowMode == WindowMode.StandAlone)
			{
				Button closeButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
				layerSelectionButtonsPanel.AddChild(closeButton);
				closeButton.Click += (sender, e) =>
				{
					CloseOnIdle();
				};
			}

			FlowLayoutWidget centerPartPreviewAndControls = new FlowLayoutWidget(FlowDirection.LeftToRight);
			centerPartPreviewAndControls.AnchorAll();

			gcodeDisplayWidget = new GuiWidget(HAnchor.ParentLeftRight, Agg.UI.VAnchor.ParentBottomTop);
			string firstProcessingMessage = "Press 'Add' to select an item.".Localize();

			if (printItem != null)
			{
				firstProcessingMessage = "Loading G-Code...".Localize();
				if (Path.GetExtension(printItem.FileLocation).ToUpper() == ".GCODE")
				{
					gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(printItem.FileLocation));
				}
				else
				{
					if (File.Exists(printItem.FileLocation))
					{
						string gcodePathAndFileName = printItem.GetGCodePathAndFileName();
						bool gcodeFileIsComplete = printItem.IsGCodeFileComplete(gcodePathAndFileName);

						if (printItem.SlicingHadError)
						{
							firstProcessingMessage = slicingErrorMessage;
						}
						else
						{
							firstProcessingMessage = pressGenerateMessage;
						}

						if (File.Exists(gcodePathAndFileName) && gcodeFileIsComplete)
						{
							gcodeDisplayWidget.AddChild(CreateGCodeViewWidget(gcodePathAndFileName));
						}

						// we only hook these up to make sure we can regenerate the gcode when we want
						printItem.SlicingOutputMessage += sliceItem_SlicingOutputMessage;
						printItem.SlicingDone += sliceItem_Done;
					}
					else
					{
						firstProcessingMessage = string.Format("{0}\n'{1}'", fileNotFoundMessage, printItem.Name);
					}
				}
			}
			else
			{
				generateGCodeButton.Visible = false;
			}

			SetProcessingMessage(firstProcessingMessage);
			centerPartPreviewAndControls.AddChild(gcodeDisplayWidget);

			buttonRightPanel = CreateRightButtonPanel();
			buttonRightPanel.Visible = false;
			centerPartPreviewAndControls.AddChild(buttonRightPanel);

			// add in a spacer
			layerSelectionButtonsPanel.AddChild(new GuiWidget(HAnchor.ParentLeftRight));
			buttonBottomPanel.AddChild(layerSelectionButtonsPanel);

			mainContainerTopToBottom.AddChild(centerPartPreviewAndControls);
			mainContainerTopToBottom.AddChild(buttonBottomPanel);
			this.AddChild(mainContainerTopToBottom);

			meshViewerWidget = new MeshViewerWidget(viewerVolume, bedCenter, bedShape, "".Localize());
			meshViewerWidget.AnchorAll();
			meshViewerWidget.AllowBedRenderingWhenEmpty = true;
			gcodeDisplayWidget.AddChild(meshViewerWidget);
			meshViewerWidget.Visible = false;
			meshViewerWidget.TrackballTumbleWidget.DrawGlContent += new EventHandler(TrackballTumbleWidget_DrawGlContent);

			viewControls2D = new ViewControls2D();
			AddChild(viewControls2D);

			viewControls2D.ResetView += (sender, e) =>
			{
				SetDefaultView2D();
			};

			viewControls3D = new ViewControls3D(meshViewerWidget);
			viewControls3D.PartSelectVisible = false;
			AddChild(viewControls3D);

			viewControls3D.ResetView += (sender, e) =>
			{
				SetDefaultView();
			};

			viewControls3D.ActiveButton = ViewControls3DButtons.Rotate;
			viewControls3D.Visible = false;

			viewControlsToggle = new ViewControlsToggle();
			viewControlsToggle.HAnchor = Agg.UI.HAnchor.ParentRight;
			AddChild(viewControlsToggle);
			viewControlsToggle.Visible = false;

			//viewControls3D.translateButton.ClickButton(null);

			SetDefaultView();

			viewControls2D.translateButton.Click += (sender, e) =>
			{
				gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Move;
			};
			viewControls2D.scaleButton.Click += (sender, e) =>
			{
				gcodeViewWidget.TransformState = ViewGcodeWidget.ETransformState.Scale;
			};

			AddHandlers();
		}
Пример #33
0
        protected override void AddChildElements()
        {
            actionBarButtonFactory.invertImageLocation = false;
            actionBarButtonFactory.borderWidth         = 1;
            if (ActiveTheme.Instance.IsDarkTheme)
            {
                actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77);
            }
            else
            {
                actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190);
            }
            actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128);

            // connect and disconnect buttons
            {
                string connectString = "Connect".Localize().ToUpper();
                connectPrinterButton             = actionBarButtonFactory.Generate(connectString, "icon_power_32x32.png");
                connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize();
                if (ApplicationController.Instance.WidescreenMode)
                {
                    connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3);
                }
                else
                {
                    connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);
                }
                connectPrinterButton.VAnchor = VAnchor.ParentTop;
                connectPrinterButton.Cursor  = Cursors.Hand;
                connectPrinterButton.Click  += (s, e) =>
                {
                    Button buttonClicked = ((Button)s);
                    if (buttonClicked.Enabled)
                    {
                        if (ActiveSliceSettings.Instance.PrinterSelected)
                        {
                            UserRequestedConnectToActivePrinter();
                        }
                    }
                };

                string disconnectString = "Disconnect".Localize().ToUpper();
                disconnectPrinterButton             = actionBarButtonFactory.Generate(disconnectString, "icon_power_32x32.png");
                disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize();
                if (ApplicationController.Instance.WidescreenMode)
                {
                    disconnectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3);
                }
                else
                {
                    disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);
                }
                disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
                disconnectPrinterButton.Cursor  = Cursors.Hand;
                disconnectPrinterButton.Click  += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect);

                // Bind connect button states to active printer state
                this.SetConnectionButtonVisibleState();

                actionBarButtonFactory.invertImageLocation = true;

                this.AddChild(connectPrinterButton);
                this.AddChild(disconnectPrinterButton);
            }

            // printer selector and edit button
            {
                FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget()
                {
                    HAnchor = HAnchor.ParentLeftRight,
                };

                int rightMarginForWideScreenMode = ApplicationController.Instance.WidescreenMode ? 6 : 0;
                printerSelector = new PrinterSelector()
                {
                    HAnchor = HAnchor.ParentLeftRight,
                    Cursor  = Cursors.Hand,
                    Margin  = new BorderDouble(0, 6, rightMarginForWideScreenMode, 3)
                };
                printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true);
                // make sure the control can get smaller but maintains its height
                printerSelector.MinimumSize = new Vector2(0, connectPrinterButton.MinimumSize.y);
                printerSelectorAndEditButton.AddChild(printerSelector);

                Button editButton = TextImageButtonFactory.GetThemedEditButton();
                editButton.VAnchor = VAnchor.ParentCenter;
                editButton.Click  += UiNavigation.OpenEditPrinterWizard_Click;
                printerSelectorAndEditButton.AddChild(editButton);
                this.AddChild(printerSelectorAndEditButton);
            }

            // reset connection button
            {
                string resetConnectionText   = "Reset\nConnection".Localize().ToUpper();
                Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png");
                if (ApplicationController.Instance.WidescreenMode)
                {
                    resetConnectionButton.Margin = new BorderDouble(0, 0, 3, 3);
                }
                else
                {
                    resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3);
                }
                this.AddChild(resetConnectionButton);

                resetConnectionButton.Click  += new EventHandler((s, e) => PrinterConnectionAndCommunication.Instance.RebootBoard());
                resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection);

                SliceSettingsWidget.SettingChanged.RegisterEvent((sender, e) =>
                {
                    StringEventArgs stringEvent = e as StringEventArgs;
                    if (stringEvent != null)
                    {
                        if (stringEvent.Data == SettingsKey.show_reset_connection)
                        {
                            resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection);
                        }
                    }
                }, ref unregisterEvents);
            }

            ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
            PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
            PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
        }