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.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(LocalizedString.Get("Close"));

					Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
					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);
				}

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

				this.AddChild(mainContainer);

				BindCloseButtonClick();
			}
		}
Exemple #2
0
        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.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(LocalizedString.Get("Close"));

                    Button addPrinterButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
                    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);
                }

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

                this.AddChild(mainContainer);

                BindCloseButtonClick();
            }
        }