protected void AddChildElements() { addButton = textImageButtonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png", 32, 32).InvertLightness()); addButton.ToolTipText = "Add a file to be printed".Localize(); addButton.Margin = new BorderDouble(6, 6, 6, 3); startButton = textImageButtonFactory.GenerateTooltipButton("Print".Localize(), StaticData.Instance.LoadIcon("icon_play_32x32.png", 32, 32).InvertLightness()); startButton.Name = "Start Print Button"; startButton.ToolTipText = "Begin printing the selected item.".Localize(); startButton.Margin = new BorderDouble(6, 6, 6, 3); startButton.Click += onStartButton_Click; configureButton = textImageButtonFactory.GenerateTooltipButton("Finish Setup...".Localize()); configureButton.Name = "Finish Setup Button"; configureButton.ToolTipText = "Run setup configuration for printer.".Localize(); configureButton.Margin = new BorderDouble(6, 6, 6, 3); configureButton.Click += onStartButton_Click; connectButton = textImageButtonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("icon_power_32x32.png", 32, 32).InvertLightness()); connectButton.ToolTipText = "Connect to the printer".Localize(); connectButton.Margin = new BorderDouble(6, 6, 6, 3); connectButton.Click += (s, e) => { if (ActiveSliceSettings.Instance.PrinterSelected) { #if __ANDROID__ if (!FrostedSerialPort.HasPermissionToDevice()) { // Opens the USB device permissions dialog which will call back into our UsbDevice broadcast receiver to connect FrostedSerialPort.RequestPermissionToDevice(RunTroubleShooting); } else #endif { PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(true); } } }; addPrinterButton = textImageButtonFactory.GenerateTooltipButton("Add Printer".Localize()); addPrinterButton.ToolTipText = "Select and add a new printer.".Localize(); addPrinterButton.Margin = new BorderDouble(6, 6, 6, 3); addPrinterButton.Click += (s, e) => { UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup(true)); }; selectPrinterButton = textImageButtonFactory.GenerateTooltipButton("Select Printer".Localize()); selectPrinterButton.ToolTipText = "Select an existing printer.".Localize(); selectPrinterButton.Margin = new BorderDouble(6, 6, 6, 3); selectPrinterButton.Click += (s, e) => { WizardWindow.Show <SetupOptionsPage>("/SetupOptions", "Setup Wizard"); }; string resetConnectionButtontText = "Reset".Localize(); string resetConnectionButtonMessage = "Reboots the firmware on the controller".Localize(); resetConnectionButton = textImageButtonFactory.GenerateTooltipButton(resetConnectionButtontText, StaticData.Instance.LoadIcon("e_stop4.png", 32, 32).InvertLightness()); resetConnectionButton.ToolTipText = resetConnectionButtonMessage; resetConnectionButton.ToolTipText = resetConnectionButtonMessage; resetConnectionButton.Margin = new BorderDouble(6, 6, 6, 3); string skipButtonText = "Skip".Localize(); string skipButtonMessage = "Skip the current item and move to the next in queue".Localize(); skipButton = makeButton(skipButtonText, skipButtonMessage); string removeButtonText = "Remove".Localize(); string removeButtonMessage = "Remove current item from queue".Localize(); removeButton = makeButton(removeButtonText, removeButtonMessage); removeButton.Click += onRemoveButton_Click; string pauseButtonText = "Pause".Localize(); string pauseButtonMessage = "Pause the current print".Localize(); pauseButton = makeButton(pauseButtonText, pauseButtonMessage); pauseButton.Click += (s, e) => { PrinterConnectionAndCommunication.Instance.RequestPause(); pauseButton.Enabled = false; }; this.AddChild(pauseButton); allPrintButtons.Add(pauseButton); string cancelCancelButtonText = "Cancel Connect".Localize(); string cancelConnectButtonMessage = "Stop trying to connect to the printer.".Localize(); cancelConnectButton = makeButton(cancelCancelButtonText, cancelConnectButtonMessage); string cancelButtonText = "Cancel".Localize(); string cancelButtonMessage = "Stop the current print".Localize(); cancelButton = makeButton(cancelButtonText, cancelButtonMessage); cancelButton.Name = "Cancel Print Button"; string resumeButtonText = "Resume".Localize(); string resumeButtonMessage = "Resume the current print".Localize(); resumeButton = makeButton(resumeButtonText, resumeButtonMessage); resumeButton.Name = "Resume Button"; resumeButton.Click += (s, e) => { if (PrinterConnectionAndCommunication.Instance.PrinterIsPaused) { PrinterConnectionAndCommunication.Instance.Resume(); } pauseButton.Enabled = true; }; this.AddChild(resumeButton); allPrintButtons.Add(resumeButton); string reprintButtonText = "Print Again".Localize(); string reprintButtonMessage = "Print current item again".Localize(); reprintButton = makeButton(reprintButtonText, reprintButtonMessage); reprintButton.Name = "Print Again Button"; string doneCurrentPartButtonText = "Done".Localize(); string doenCurrentPartButtonMessage = "Move to next print in queue".Localize(); doneWithCurrentPartButton = makeButton(doneCurrentPartButtonText, doenCurrentPartButtonMessage); doneWithCurrentPartButton.Name = "Done Button"; this.Margin = new BorderDouble(0, 0, 10, 0); this.HAnchor = HAnchor.FitToChildren; this.AddChild(connectButton); allPrintButtons.Add(connectButton); this.AddChild(addPrinterButton); allPrintButtons.Add(addPrinterButton); this.AddChild(selectPrinterButton); allPrintButtons.Add(selectPrinterButton); this.AddChild(addButton); allPrintButtons.Add(addButton); this.AddChild(startButton); allPrintButtons.Add(startButton); this.AddChild(configureButton); allPrintButtons.Add(configureButton); this.AddChild(doneWithCurrentPartButton); allPrintButtons.Add(doneWithCurrentPartButton); this.AddChild(skipButton); allPrintButtons.Add(skipButton); this.AddChild(cancelButton); allPrintButtons.Add(cancelButton); this.AddChild(cancelConnectButton); allPrintButtons.Add(cancelConnectButton); this.AddChild(reprintButton); allPrintButtons.Add(reprintButton); this.AddChild(removeButton); allPrintButtons.Add(removeButton); this.AddChild(resetConnectionButton); allPrintButtons.Add(resetConnectionButton); SetButtonStates(); }
protected void AddChildElements() { actionBarButtonFactory.invertImageLocation = false; actionBarButtonFactory.borderWidth = 1; if (ActiveTheme.Instance.IsDarkTheme) { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77); } else { actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190); } actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128); // connect and disconnect buttons { connectPrinterButton = actionBarButtonFactory.Generate("Connect".Localize().ToUpper(), "icon_power_32x32.png"); connectPrinterButton.Name = "Connect to printer button"; connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize(); connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); connectPrinterButton.VAnchor = VAnchor.ParentTop; connectPrinterButton.Cursor = Cursors.Hand; connectPrinterButton.Click += (s, e) => { Button buttonClicked = ((Button)s); if (buttonClicked.Enabled) { if (ActiveSliceSettings.Instance.PrinterSelected) { UserRequestedConnectToActivePrinter(); } } }; disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), "icon_power_32x32.png"); disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize(); disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3); disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.Cursor = Cursors.Hand; disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect); actionBarButtonFactory.invertImageLocation = true; this.AddChild(connectPrinterButton); this.AddChild(disconnectPrinterButton); } // printer selector and edit button { GuiWidget container = new GuiWidget() { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.FitToChildren, }; FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget() { HAnchor = HAnchor.ParentLeftRight, }; printerSelector = new PrinterSelector() { HAnchor = HAnchor.ParentLeftRight, Cursor = Cursors.Hand, Margin = new BorderDouble(0, 6, 0, 3) }; printerSelector.AddPrinter += (s, e) => WizardWindow.ShowPrinterSetup(true); // make sure the control can get smaller but maintains its height printerSelector.MinimumSize = new Vector2(0, connectPrinterButton.MinimumSize.y); printerSelectorAndEditButton.AddChild(printerSelector); editPrinterButton = TextImageButtonFactory.GetThemedEditButton(); editPrinterButton.Name = "Edit Printer Button"; editPrinterButton.VAnchor = VAnchor.ParentCenter; editPrinterButton.Click += UiNavigation.OpenEditPrinterWizard_Click; printerSelectorAndEditButton.AddChild(editPrinterButton); container.AddChild(printerSelectorAndEditButton); printerSelectorAndEditOverlay = new GuiWidget() { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, Selectable = false, }; container.AddChild(printerSelectorAndEditOverlay); this.AddChild(container); } // reset connection button { string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3); this.AddChild(resetConnectionButton); resetConnectionButton.Click += new EventHandler((s, e) => PrinterConnectionAndCommunication.Instance.RebootBoard()); resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection); SliceSettingsWidget.SettingChanged.RegisterEvent((sender, e) => { StringEventArgs stringEvent = e as StringEventArgs; if (stringEvent != null) { if (stringEvent.Data == SettingsKey.show_reset_connection) { resetConnectionButton.Visible = ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.show_reset_connection); } } }, ref unregisterEvents); } // Bind connect button states to active printer state this.SetConnectionButtonVisibleState(); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents); }