Example #1
0
        public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
            : base(printerRecord, windowController)
        {
            this.printerRecord   = printerRecord;
            this.Margin          = new BorderDouble(1);
            this.BackgroundColor = this.defaultBackgroundColor;
            this.Padding         = new BorderDouble(0);
            this.HAnchor         = HAnchor.ParentLeftRight;

            FlowLayoutWidget printerNameContainer = new FlowLayoutWidget();

            printerNameContainer.HAnchor = HAnchor.ParentLeftRight;

            printerName           = new TextWidget(this.printerRecord.Name);
            printerName.TextColor = this.defaultTextColor;
            printerName.Margin    = new BorderDouble(5, 10, 0, 10);
            printerName.HAnchor   = HAnchor.ParentLeftRight;

            printerNameContainer.AddChild(printerName);

            FlowLayoutWidget rightButtonOverlayContainer = new FlowLayoutWidget(FlowDirection.RightToLeft);

            rightButtonOverlayContainer.HAnchor = HAnchor.ParentLeftRight;
            rightButtonOverlayContainer.VAnchor = VAnchor.ParentBottomTop;

            this.rightButtonOverlay         = getItemActionButtons();
            this.rightButtonOverlay.Padding = new BorderDouble(0);
            this.rightButtonOverlay.Visible = true;
            rightButtonOverlayContainer.AddChild(rightButtonOverlay);

            this.AddChild(printerNameContainer);
            this.AddChild(rightButtonOverlayContainer);
        }
        public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
            : base(printerRecord, windowController)
        {
            this.printerRecord   = printerRecord;
            this.Margin          = new BorderDouble(1);
            this.BackgroundColor = this.defaultBackgroundColor;
            this.Padding         = new BorderDouble(0);
            this.HAnchor         = HAnchor.ParentLeftRight;

            printerName           = new TextWidget(this.printerRecord.Name);
            printerName.TextColor = this.defaultTextColor;
            printerName.Margin    = new BorderDouble(5, 10, 5, 10);
            printerName.HAnchor   = HAnchor.ParentLeftRight;

            this.AddChild(printerName);

            this.rightButtonOverlay         = getItemActionButtons();
            this.rightButtonOverlay.Padding = new BorderDouble(0);
            this.rightButtonOverlay.Visible = true;


            this.AddChild(rightButtonOverlay);


            //BindHandlers();
        }
Example #3
0
        public SetupStepInstallDriver(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            this.printerDriverFilePath = this.PrinterSetupStatus.DriverFilePath;

            headerLabel.Text       = string.Format(new LocalizedString("Install Communication Driver").Translated);
            printerDriverContainer = createPrinterDriverContainer();
            contentRow.AddChild(printerDriverContainer);
            {
                //Construct buttons
                installButton        = textImageButtonFactory.Generate(new LocalizedString("Install Driver").Translated);
                installButton.Click += new ButtonBase.ButtonEventHandler(installButton_Click);

                skipButton        = textImageButtonFactory.Generate(new LocalizedString("Skip").Translated);
                skipButton.Click += new ButtonBase.ButtonEventHandler(skipButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(installButton);
                footerRow.AddChild(skipButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
Example #4
0
        public SetupStepComPortManual(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            linkButtonFactory.fontSize = 8;

            FlowLayoutWidget printerComPortContainer = createComPortContainer();

            contentRow.AddChild(printerComPortContainer);
            {
                //Construct buttons
                nextButton         = textImageButtonFactory.Generate(LocalizedString.Get("Done"));
                nextButton.Click  += new EventHandler(NextButton_Click);
                nextButton.Visible = false;

                connectButton        = textImageButtonFactory.Generate(LocalizedString.Get("Connect"));
                connectButton.Click += new EventHandler(ConnectButton_Click);

                PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

                refreshButton        = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
                refreshButton.Click += new EventHandler(RefreshButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(connectButton);
                footerRow.AddChild(refreshButton);
                footerRow.AddChild(hSpacer);
                footerRow.AddChild(cancelButton);
            }
        }
Example #5
0
 public ConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose)
     : base()
 {
     this.windowController       = windowController;
     this.containerWindowToClose = containerWindowToClose;
     ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
 }
Example #6
0
        public SetupStepComPortTwo(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            startingPortNames = FrostedSerialPort.GetPortNames();
            contentRow.AddChild(createPrinterConnectionMessageContainer());
            {
                //Construct buttons
                nextButton         = textImageButtonFactory.Generate(LocalizedString.Get("Done"));
                nextButton.Click  += new EventHandler(NextButton_Click);
                nextButton.Visible = false;

                connectButton        = textImageButtonFactory.Generate(LocalizedString.Get("Connect"));
                connectButton.Click += new EventHandler(ConnectButton_Click);

                PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(connectButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
		public SetupStepInstallDriver(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
			: base(windowController, containerWindowToClose, setupPrinterStatus)
		{
			this.driversToInstall = this.currentPrinterSetupStatus.DriversToInstall;

			headerLabel.Text = string.Format(LocalizedString.Get("Install Communication Driver"));
			printerDriverContainer = createPrinterDriverContainer();
			contentRow.AddChild(printerDriverContainer);
			{
				//Construct buttons
				installButton = textImageButtonFactory.Generate(LocalizedString.Get("Install Driver"));
				installButton.Click += (sender, e) =>
				{
					UiThread.RunOnIdle(installButton_Click);
				};

				skipButton = textImageButtonFactory.Generate(LocalizedString.Get("Skip"));
				skipButton.Click += new EventHandler(skipButton_Click);

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

				//Add buttons to buttonContainer
				footerRow.AddChild(installButton);
				footerRow.AddChild(skipButton);
				footerRow.AddChild(hSpacer);

				footerRow.AddChild(cancelButton);
			}
		}
Example #8
0
        public SetupStepMakeModelName(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter = null)
            : base(windowController, containerWindowToClose, setupPrinter)
        {
            //Construct inputs
            printerNameContainer  = createPrinterNameContainer();
            printerMakeContainer  = createPrinterMakeContainer();
            printerModelContainer = createPrinterModelContainer();

            //Add inputs to main container
            contentRow.AddChild(printerNameContainer);
            contentRow.AddChild(printerMakeContainer);
            contentRow.AddChild(printerModelContainer);

            //Construct buttons
            nextButton        = textImageButtonFactory.Generate(LocalizedString.Get("Save & Continue"));
            nextButton.Click += new EventHandler(NextButton_Click);

            GuiWidget hSpacer = new GuiWidget();

            hSpacer.HAnchor = HAnchor.ParentLeftRight;

            //Add buttons to buttonContainer
            footerRow.AddChild(nextButton);
            footerRow.AddChild(hSpacer);
            footerRow.AddChild(cancelButton);

            usingDefaultName = true;

            SetElementState();
        }
        public SetupStepInstallDriver(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            this.driversToInstall = this.currentPrinterSetupStatus.DriversToInstall;

            headerLabel.Text       = string.Format(LocalizedString.Get("Install Communication Driver"));
            printerDriverContainer = createPrinterDriverContainer();
            contentRow.AddChild(printerDriverContainer);
            {
                //Construct buttons
                installButton        = textImageButtonFactory.Generate(LocalizedString.Get("Install Driver"));
                installButton.Click += (sender, e) =>
                {
                    UiThread.RunOnIdle(installButton_Click);
                };

                skipButton        = textImageButtonFactory.Generate(LocalizedString.Get("Skip"));
                skipButton.Click += new EventHandler(skipButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(installButton);
                footerRow.AddChild(skipButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
        public SetupStepComPortTwo(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {

            startingPortNames = SerialPort.GetPortNames();
            contentRow.AddChild(createPrinterConnectionMessageContainer());
            {
                //Construct buttons
				nextButton = textImageButtonFactory.Generate(new LocalizedString("Done").Translated);
                nextButton.Click += new ButtonBase.ButtonEventHandler(NextButton_Click);
                nextButton.Visible = false;

				connectButton = textImageButtonFactory.Generate(new LocalizedString("Connect").Translated);
                connectButton.Click += new ButtonBase.ButtonEventHandler(ConnectButton_Click);

                PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(connectButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
		public SetupStepComPortManual(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
			: base(windowController, containerWindowToClose, setupPrinterStatus)
		{
			linkButtonFactory.fontSize = 8;

			FlowLayoutWidget printerComPortContainer = createComPortContainer();
			contentRow.AddChild(printerComPortContainer);
			{
				//Construct buttons
				nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Done"));
				nextButton.Click += new EventHandler(NextButton_Click);
				nextButton.Visible = false;

				connectButton = textImageButtonFactory.Generate(LocalizedString.Get("Connect"));
				connectButton.Click += new EventHandler(ConnectButton_Click);

				PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);

				refreshButton = textImageButtonFactory.Generate(LocalizedString.Get("Refresh"));
				refreshButton.Click += new EventHandler(RefreshButton_Click);

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

				//Add buttons to buttonContainer
				footerRow.AddChild(nextButton);
				footerRow.AddChild(connectButton);
				footerRow.AddChild(refreshButton);
				footerRow.AddChild(hSpacer);
				footerRow.AddChild(cancelButton);
			}
		}
        public SetupStepMakeModelName(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter = null)
            : base(windowController, containerWindowToClose, setupPrinter)
        {
            //Construct inputs
            printerNameContainer = createPrinterNameContainer();
            printerMakeContainer = createPrinterMakeContainer();
            printerModelContainer = createPrinterModelContainer();

            //Add inputs to main container
            contentRow.AddChild(printerNameContainer);
            contentRow.AddChild(printerMakeContainer);
            contentRow.AddChild(printerModelContainer);

            //Construct buttons
			nextButton = textImageButtonFactory.Generate(new LocalizedString("Save & Continue").Translated);
            nextButton.Click += new ButtonBase.ButtonEventHandler(NextButton_Click);

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

            //Add buttons to buttonContainer
            footerRow.AddChild(nextButton);
            footerRow.AddChild(hSpacer);
            footerRow.AddChild(cancelButton);

            SetElementState();
        }
Example #13
0
 public ConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose)
     : base()
 {
     this.windowController       = windowController;
     this.containerWindowToClose = containerWindowToClose;
     AddHandlers();
 }
Example #14
0
        public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
            : base(printerRecord, windowController)
        {
            linkButtonFactory.fontSize = 10;
            linkButtonFactory.padding  = 0;
            linkButtonFactory.margin   = new BorderDouble(3, 0);

            this.printerRecord   = printerRecord;
            this.Margin          = new BorderDouble(1);
            this.BackgroundColor = this.defaultBackgroundColor;
            this.Padding         = new BorderDouble(5);
            this.HAnchor         = HAnchor.ParentLeftRight;

            printerName           = new TextWidget(this.printerRecord.Name);
            printerName.TextColor = this.defaultTextColor;
            printerName.HAnchor   = HAnchor.ParentLeftRight;

            editLink         = linkButtonFactory.Generate(new LocalizedString("edit").Translated);
            editLink.VAnchor = VAnchor.ParentCenter;

            removeLink         = linkButtonFactory.Generate(new LocalizedString("remove").Translated);
            removeLink.VAnchor = VAnchor.ParentCenter;

            this.AddChild(printerName);
            this.AddChild(editLink);
            this.AddChild(removeLink);

            BindHandlers();
        }
        public SetupStepInstallDriver(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            this.printerDriverFilePath = this.PrinterSetupStatus.DriverFilePath;

			headerLabel.Text = string.Format(new LocalizedString("Install Communication Driver").Translated);
            printerDriverContainer = createPrinterDriverContainer();
            contentRow.AddChild(printerDriverContainer);
            {
                //Construct buttons
				installButton = textImageButtonFactory.Generate(new LocalizedString("Install Driver").Translated);
                installButton.Click += new ButtonBase.ButtonEventHandler(installButton_Click);

				skipButton = textImageButtonFactory.Generate(new LocalizedString("Skip").Translated);
                skipButton.Click += new ButtonBase.ButtonEventHandler(skipButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(installButton);
                footerRow.AddChild(skipButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
        public SetupConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
            : base(windowController, containerWindowToClose)
        {
            SetDisplayAttributes();

            if (printerSetupStatus == null)
            {
                this.PrinterSetupStatus = new PrinterSetupStatus();
            }
            else
            {
                this.PrinterSetupStatus = printerSetupStatus;
            }


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

            //Create the main container
            GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);

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

            //Create the header row for the widget
            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;
            {
                string defaultHeaderTitle = LocalizedString.Get("3D Printer Setup");
                headerLabel = new TextWidget(defaultHeaderTitle, pointSize: 14);
                headerLabel.AutoExpandBoundsToText = true;
                headerLabel.TextColor = this.defaultTextColor;
                headerRow.AddChild(headerLabel);
            }

            //Create the main control container
            contentRow                 = new FlowLayoutWidget(FlowDirection.TopToBottom);
            contentRow.Padding         = new BorderDouble(5);
            contentRow.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
            contentRow.HAnchor         = HAnchor.ParentLeftRight;
            contentRow.VAnchor         = VAnchor.ParentBottomTop;

            //Create the footer (button) container
            footerRow         = new FlowLayoutWidget(FlowDirection.LeftToRight);
            footerRow.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
            footerRow.Margin  = new BorderDouble(0, 3);

            mainContainer.AddChild(headerRow);
            mainContainer.AddChild(contentRow);
            mainContainer.AddChild(footerRow);
            this.AddChild(mainContainer);
        }
		public SetupConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
			: base(windowController, containerWindowToClose)
		{
			SetDisplayAttributes();

			if (printerSetupStatus == null)
			{
				this.currentPrinterSetupStatus = new PrinterSetupStatus();
			}
			else
			{
				this.currentPrinterSetupStatus = printerSetupStatus;
			}

			cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
			cancelButton.Name = "Setup Connection Cancel Button";
			cancelButton.Click += new EventHandler(CancelButton_Click);

			//Create the main container
			GuiWidget mainContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
			mainContainer.AnchorAll();
			mainContainer.Padding = new BorderDouble(3, 5, 3, 5);
			mainContainer.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;

			//Create the header row for the widget
			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;
			{
				string defaultHeaderTitle = LocalizedString.Get("3D Printer Setup");
				headerLabel = new TextWidget(defaultHeaderTitle, pointSize: 14);
				headerLabel.AutoExpandBoundsToText = true;
				headerLabel.TextColor = this.defaultTextColor;
				headerRow.AddChild(headerLabel);
			}

			//Create the main control container
			contentRow = new FlowLayoutWidget(FlowDirection.TopToBottom);
			contentRow.Padding = new BorderDouble(5);
			contentRow.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
			contentRow.HAnchor = HAnchor.ParentLeftRight;
			contentRow.VAnchor = VAnchor.ParentBottomTop;

			//Create the footer (button) container
			footerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
			footerRow.HAnchor = HAnchor.ParentLeft | HAnchor.ParentRight;
			footerRow.Margin = new BorderDouble(0, 3);

			mainContainer.AddChild(headerRow);
			mainContainer.AddChild(contentRow);
			mainContainer.AddChild(footerRow);
			this.AddChild(mainContainer);
		}
Example #18
0
        public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
            : base(printerRecord, windowController)
        {
            this.Margin          = new BorderDouble(1);
            this.BackgroundColor = this.defaultBackgroundColor;
            this.Padding         = new BorderDouble(0);
            this.Name            = this.printerRecord.Name + " Profile";

            string[] comportNames    = FrostedSerialPort.GetPortNames();
            bool     portIsAvailable = comportNames.Contains(printerRecord.ComPort);

            printerName           = new TextWidget(this.printerRecord.Name);
            printerName.TextColor = this.defaultTextColor;
            printerName.HAnchor   = HAnchor.ParentLeftRight;
            printerName.Margin    = new BorderDouble(5, 10, 5, 10);

            string     availableText  = LocalizedString.Get("Unavailable");
            RGBA_Bytes availableColor = new RGBA_Bytes(158, 18, 0);

            if (portIsAvailable)
            {
                availableText = "";
            }

            if (ActivePrinterProfile.Instance.ActivePrinter != null)
            {
                int connectedPrinterHash = ActivePrinterProfile.Instance.ActivePrinter.GetHashCode();
                int printerOptionHash    = printerRecord.GetHashCode();
                if (connectedPrinterHash == printerOptionHash)
                {
                    availableText  = PrinterConnectionAndCommunication.Instance.PrinterConnectionStatusVerbose;
                    availableColor = new RGBA_Bytes(0, 95, 107);
                }
            }

            TextWidget availableIndicator = new TextWidget(availableText, pointSize: 10);

            availableIndicator.TextColor = availableColor;
            availableIndicator.Padding   = new BorderDouble(3, 0, 0, 3);
            availableIndicator.Margin    = new BorderDouble(right: 5);
            availableIndicator.VAnchor   = Agg.UI.VAnchor.ParentCenter;

            this.AddChild(printerName);
            this.AddChild(availableIndicator);
            this.HAnchor = HAnchor.ParentLeftRight;

            BindHandlers();
        }
		public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
			: base(printerRecord, windowController)
		{
			this.Margin = new BorderDouble(1);
			this.BackgroundColor = this.defaultBackgroundColor;
			this.Padding = new BorderDouble(0);
			this.Name = this.printerRecord.Name + " Profile";

			string[] comportNames = FrostedSerialPort.GetPortNames();
			bool portIsAvailable = comportNames.Contains(printerRecord.ComPort);

			printerName = new TextWidget(this.printerRecord.Name);
			printerName.TextColor = this.defaultTextColor;
			printerName.HAnchor = HAnchor.ParentLeftRight;
			printerName.Margin = new BorderDouble(5, 10, 5, 10);

			string availableText = LocalizedString.Get("Unavailable");
			RGBA_Bytes availableColor = new RGBA_Bytes(158, 18, 0);
			if (portIsAvailable)
			{
				availableText = "";
			}

			if (ActivePrinterProfile.Instance.ActivePrinter != null)
			{
				int connectedPrinterHash = ActivePrinterProfile.Instance.ActivePrinter.GetHashCode();
				int printerOptionHash = printerRecord.GetHashCode();
				if (connectedPrinterHash == printerOptionHash)
				{
					availableText = PrinterConnectionAndCommunication.Instance.PrinterConnectionStatusVerbose;
					availableColor = new RGBA_Bytes(0, 95, 107);
				}
			}

			TextWidget availableIndicator = new TextWidget(availableText, pointSize: 10);
			availableIndicator.TextColor = availableColor;
			availableIndicator.Padding = new BorderDouble(3, 0, 0, 3);
			availableIndicator.Margin = new BorderDouble(right: 5);
			availableIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;

			this.AddChild(printerName);
			this.AddChild(availableIndicator);
			this.HAnchor = HAnchor.ParentLeftRight;

			BindHandlers();
		}
		public SetupStepComPortOne(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
			: base(windowController, containerWindowToClose, setupPrinter)
		{
			contentRow.AddChild(createPrinterConnectionMessageContainer());
			{
				//Construct buttons
				nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Continue"));
				nextButton.Click += new EventHandler(NextButton_Click);

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

				//Add buttons to buttonContainer
				footerRow.AddChild(nextButton);
				footerRow.AddChild(hSpacer);

				footerRow.AddChild(cancelButton);
			}
		}
Example #21
0
        public SetupStepComPortOne(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
            : base(windowController, containerWindowToClose, setupPrinter)
        {
            contentRow.AddChild(createPrinterConnectionMessageContainer());
            {
                //Construct buttons
                nextButton        = textImageButtonFactory.Generate(new LocalizedString("Continue").Translated);
                nextButton.Click += new ButtonBase.ButtonEventHandler(NextButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(hSpacer);

                footerRow.AddChild(cancelButton);
            }
        }
Example #22
0
        public SetupStepMakeModelName(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
            : base(windowController, containerWindowToClose, printerSetupStatus)
        {
            //Construct inputs
            printerNameContainer = createPrinterNameContainer();
            printerMakeContainer = createPrinterMakeContainer();

            if (printerManufacturerSelector.CountOfMakes == 1)
            {
                ActivePrinter.Make = printerManufacturerSelector.ManufacturerDropList.SelectedValue;

                printerMakeContainer.Visible  = false;
                printerModelContainer         = createPrinterModelContainer(printerManufacturerSelector.ManufacturerDropList.SelectedValue);
                printerModelContainer.Visible = true;
            }
            else
            {
                printerModelContainer = createPrinterModelContainer();
            }

            //Add inputs to main container
            contentRow.AddChild(printerNameContainer);
            contentRow.AddChild(printerMakeContainer);
            contentRow.AddChild(printerModelContainer);

            //Construct buttons
            nextButton        = textImageButtonFactory.Generate(LocalizedString.Get("Save & Continue"));
            nextButton.Name   = "Save & Continue Button";
            nextButton.Click += new EventHandler(NextButton_Click);

            GuiWidget hSpacer = new GuiWidget();

            hSpacer.HAnchor = HAnchor.ParentLeftRight;

            //Add buttons to buttonContainer
            footerRow.AddChild(nextButton);
            footerRow.AddChild(hSpacer);
            footerRow.AddChild(cancelButton);

            usingDefaultName = true;

            SetElementState();
        }
		public SetupStepMakeModelName(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus printerSetupStatus = null)
			: base(windowController, containerWindowToClose, printerSetupStatus)
		{
			//Construct inputs
			printerNameContainer = createPrinterNameContainer();
			printerMakeContainer = createPrinterMakeContainer();

			if (printerManufacturerSelector.CountOfMakes == 1)
			{
				ActivePrinter.Make = printerManufacturerSelector.ManufacturerDropList.SelectedValue;

				printerMakeContainer.Visible = false;
				printerModelContainer = createPrinterModelContainer(printerManufacturerSelector.ManufacturerDropList.SelectedValue);
				printerModelContainer.Visible = true;
			}
			else
			{
				printerModelContainer = createPrinterModelContainer();
			}

			//Add inputs to main container
			contentRow.AddChild(printerNameContainer);
			contentRow.AddChild(printerMakeContainer);
			contentRow.AddChild(printerModelContainer);

			//Construct buttons
			nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Save & Continue"));
			nextButton.Name = "Save & Continue Button";
			nextButton.Click += new EventHandler(NextButton_Click);

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

			//Add buttons to buttonContainer
			footerRow.AddChild(nextButton);
			footerRow.AddChild(hSpacer);
			footerRow.AddChild(cancelButton);

			usingDefaultName = true;

			SetElementState();
		}
Example #24
0
 public static void Show()
 {
     if (connectionWindowIsOpen == false)
     {
         connectionWindow         = new ConnectionWindow();
         connectionWindowIsOpen   = true;
         connectionWindow.Closed += (parentSender, e) =>
         {
             connectionWindowIsOpen = false;
             connectionWindow       = null;
         };
     }
     else
     {
         if (connectionWindow != null)
         {
             connectionWindow.BringToFront();
         }
     }
 }
		public static void Show()
		{
			if (connectionWindowIsOpen == false)
			{
				connectionWindow = new ConnectionWindow();
				connectionWindowIsOpen = true;
				connectionWindow.Closed += (parentSender, e) =>
				{
					connectionWindowIsOpen = false;
					connectionWindow = null;
				};
			}
			else
			{
				if (connectionWindow != null)
				{
					connectionWindow.BringToFront();
				}
			}
		}
        public SetupStepBaudRate(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            linkButtonFactory.fontSize = 8;
            
            printerBaudRateContainer = createPrinterBaudRateContainer();
            contentRow.AddChild(printerBaudRateContainer);
            {                
				nextButton = textImageButtonFactory.Generate(new LocalizedString("Continue").Translated);
                nextButton.Click += new ButtonBase.ButtonEventHandler(NextButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(hSpacer);
                footerRow.AddChild(cancelButton);
            }
            BindBaudRateHandlers();
        }
		public static void OpenConnectionWindow(bool connectAfterSelection = false)
		{
			if (connectAfterSelection)
			{
				ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ConnectToActivePrinter, ref staticUnregisterEvents);
			}

			if (connectionWindow == null)
			{
				connectionWindow = new ConnectionWindow();

				connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed);
			}
			else
			{
				if (connectionWindow != null)
				{
					connectionWindow.BringToFront();
				}
			}
		}
Example #28
0
        public SetupStepBaudRate(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinterStatus)
            : base(windowController, containerWindowToClose, setupPrinterStatus)
        {
            linkButtonFactory.fontSize = 8;

            printerBaudRateContainer = createPrinterBaudRateContainer();
            contentRow.AddChild(printerBaudRateContainer);
            {
                nextButton        = textImageButtonFactory.Generate(LocalizedString.Get("Continue"));
                nextButton.Click += new ButtonBase.ButtonEventHandler(NextButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(hSpacer);
                footerRow.AddChild(cancelButton);
            }
            BindBaudRateHandlers();
        }
Example #29
0
        public SetupStepConfigureConnection(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
            : base(windowController, containerWindowToClose, setupPrinter)
        {
            contentRow.AddChild(createPrinterConnectionMessageContainer());
            {
                //Construct buttons
                nextButton        = textImageButtonFactory.Generate("Connect");
                nextButton.Click += new EventHandler(NextButton_Click);

                skipButton        = textImageButtonFactory.Generate("Skip");
                skipButton.Click += new EventHandler(SkipButton_Click);

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

                //Add buttons to buttonContainer
                footerRow.AddChild(nextButton);
                footerRow.AddChild(skipButton);
                footerRow.AddChild(hSpacer);
                footerRow.AddChild(cancelButton);
            }
        }
 public PrinterListItem(Printer printerRecord, ConnectionWindow windowController)
 {
     this.printerRecord = printerRecord;
     this.windowController = windowController;
 }
        public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
            :base(printerRecord, windowController)
        {            
            linkButtonFactory.fontSize = 10;
            linkButtonFactory.padding = 0;
            linkButtonFactory.margin = new BorderDouble(3, 0);
            
            this.printerRecord = printerRecord;
            this.Margin = new BorderDouble(1);
            this.BackgroundColor = this.defaultBackgroundColor;
            this.Padding = new BorderDouble(5);
            this.HAnchor = HAnchor.ParentLeftRight;

            printerName = new TextWidget(this.printerRecord.Name);
            printerName.TextColor = this.defaultTextColor;
            printerName.HAnchor = HAnchor.ParentLeftRight;

			editLink = linkButtonFactory.Generate(new LocalizedString("edit").Translated);
            editLink.VAnchor = VAnchor.ParentCenter;

			removeLink = linkButtonFactory.Generate(new LocalizedString("remove").Translated);
            removeLink.VAnchor = VAnchor.ParentCenter;

            this.AddChild(printerName);
            this.AddChild(editLink);
            this.AddChild(removeLink);     

            BindHandlers();
        }
Example #32
0
 public PrinterListItem(Printer printerRecord, ConnectionWindow windowController)
 {
     this.printerRecord    = printerRecord;
     this.windowController = windowController;
 }
Example #33
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();
            }
        }
 public ConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose)
     : base()
 {
     this.windowController = windowController;
     this.containerWindowToClose = containerWindowToClose;
     ActiveTheme.Instance.ThemeChanged.RegisterEvent(ThemeChanged, ref unregisterEvents);
 }
        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
                {
                    //No active COM ports
                }
            }
            else
            {
                this.ActivePrinter = activePrinter;
                string editHeaderTitleTxt = LocalizedString.Get("Edit");
                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
                    {
                        //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("Printer 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;


                int portIndex = 0;
                foreach (string serialPort in FrostedSerialPort.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 FrostedSerialPort.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(LocalizedString.Get("No COM ports available"));
                    comPortOption.Margin    = new BorderDouble(3, 6, 5, 6);
                    comPortOption.TextColor = this.subContainerTextColor;
                    comPortContainer.AddChild(comPortOption);
                }
#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);

            this.AddChild(mainContainer);

            BindSaveButtonHandlers();
            BindBaudRateHandlers();
        }
 void OpenConnectionWindow()
 {
     if (this.connectionWindowIsOpen == false)
     {
         connectionWindow = new ConnectionWindow();
         this.connectionWindowIsOpen = true;
         connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed);
     }
     else
     {
         if (connectionWindow != null)
         {
             connectionWindow.BringToFront();
         }
     }
 }
		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();
			}
		}
		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");
				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("Printer 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);

			this.AddChild(mainContainer);

			BindSaveButtonHandlers();
			BindBaudRateHandlers();
		}
		public PrinterListItemEdit(Printer printerRecord, ConnectionWindow windowController)
			: base(printerRecord, windowController)
		{
			this.printerRecord = printerRecord;
			this.Margin = new BorderDouble(1);
			this.BackgroundColor = this.defaultBackgroundColor;
			this.Padding = new BorderDouble(0);
			this.HAnchor = HAnchor.ParentLeftRight;

			FlowLayoutWidget printerNameContainer = new FlowLayoutWidget();
			printerNameContainer.HAnchor = HAnchor.ParentLeftRight;

			printerName = new TextWidget(this.printerRecord.Name);
			printerName.TextColor = this.defaultTextColor;
			printerName.Margin = new BorderDouble(5, 10, 0, 10);
			printerName.HAnchor = HAnchor.ParentLeftRight;

			printerNameContainer.AddChild(printerName);

			FlowLayoutWidget rightButtonOverlayContainer = new FlowLayoutWidget(FlowDirection.RightToLeft);
			rightButtonOverlayContainer.HAnchor = HAnchor.ParentLeftRight;
			rightButtonOverlayContainer.VAnchor = VAnchor.ParentBottomTop;

			this.rightButtonOverlay = getItemActionButtons();
			this.rightButtonOverlay.Padding = new BorderDouble(0);
			this.rightButtonOverlay.Visible = true;
			rightButtonOverlayContainer.AddChild(rightButtonOverlay);

			this.AddChild(printerNameContainer);
			this.AddChild(rightButtonOverlayContainer);
		}
        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, 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 = FrostedSerialPort.GetPortNames()[0];
                }
                catch
                {
                    //No active COM ports
                }
            }
            else
            {
                this.ActivePrinter = activePrinter;
                string editHeaderTitleTxt = LocalizedString.Get("Edit"); 
				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()[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(LocalizedString.Get("Printer 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 ButtonBase.ButtonEventHandler(RefreshComPorts);

                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;

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

                int portIndex = 0;
                foreach (string serialPort in FrostedSerialPort.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 FrostedSerialPort.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(LocalizedString.Get("No COM ports available"));
                    comPortOption.Margin = new BorderDouble(3, 6, 5, 6);
                    comPortOption.TextColor = this.subContainerTextColor;
                    comPortContainer.AddChild(comPortOption);
                }


                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;
                }

                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(LocalizedString.Get("Save"));
                //saveButton.VAnchor = VAnchor.Bottom;

                cancelButton = textImageButtonFactory.Generate(LocalizedString.Get("Cancel"));
                //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();
        }
 void OpenConnectionWindow(ConnectOnSelectFunction functionToCallOnSelect = null)
 {
     if (this.connectionWindowIsOpen == false)
     {
         connectionWindow = new ConnectionWindow();
         this.connectionWindowIsOpen = true;
         this.functionToCallOnSelect = functionToCallOnSelect;
         connectionWindow.Closed += new EventHandler(ConnectionWindow_Closed);
     }
     else
     {
         if (connectionWindow != null)
         {
             connectionWindow.BringToFront();
         }
     }
 }
        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");
                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("Printer 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, SoftKeyboardContentOffset.AndroidKeyboardOffset));
#else
            this.AddChild(mainContainer);
#endif

            BindSaveButtonHandlers();
            BindBaudRateHandlers();
        }
 public ConnectionWidgetBase(ConnectionWindow windowController, GuiWidget containerWindowToClose)
     : base()
 {
     this.windowController = windowController;
     this.containerWindowToClose = containerWindowToClose;
     AddHandlers();
 }
		static private void ConnectionWindow_Closed(object sender, EventArgs e)
		{
			connectionWindow = null;
		}