diff --git a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs index cb90c9310..baef0a9b9 100644 --- a/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs +++ b/MatterControlLib/PrinterControls/PrinterConnections/SetupStepComPortManual.cs @@ -33,6 +33,7 @@ using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.PrinterCommunication; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.SerialPortCommunication.FrostedSerial; namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections @@ -79,7 +80,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections printer.Connection.ConnectionFailed += Connection_CommunicationStateChanged; printer.Connection.ConnectionSucceeded += Connection_CommunicationStateChanged; - printer.Settings.Helpers.SetComPort(GetSelectedSerialPort()); printer.Connection.Connect(); connectButton.Visible = false; @@ -140,8 +140,34 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections HAnchor = HAnchor.Stretch }; - var serialPortContainer = new FlowLayoutWidget(FlowDirection.TopToBottom); - CreateSerialPortControls(serialPortContainer, null); + var serialPortContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + HAnchor = HAnchor.Stretch + }; + + var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All); + var menuTheme = ApplicationController.Instance.MenuTheme; + var tabIndex = 0; + var settingsToAdd = new[] + { + SettingsKey.com_port, + SettingsKey.baud_rate, + }; + + // turn off the port wizard button in this context + ComPortField.ShowPortWizardButton = false; + foreach (var key in settingsToAdd) + { + var settingsRow = SliceSettingsTabView.CreateItemRow( + PrinterSettings.SettingsData[key], + settingsContext, + printer, + menuTheme, + ref tabIndex); + + serialPortContainer.AddChild(settingsRow); + } + ComPortField.ShowPortWizardButton = false; var comPortMessageContainer = new FlowLayoutWidget { @@ -202,71 +228,5 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections nextButton.Visible = false; } } - - protected void CreateSerialPortControls(FlowLayoutWidget comPortContainer, string activePrinterSerialPort) - { - int portIndex = 0; - - // Add a radio button for each filtered port - foreach (string portName in FrostedSerialPort.GetPortNames()) - { - SerialPortIndexRadioButton comPortOption = CreateComPortOption(portName, activePrinterSerialPort == portName); - if (comPortOption.Checked) - { - printerComPortIsAvailable = true; - } - - serialPortButtonsList.Add(comPortOption); - comPortContainer.AddChild(comPortOption); - - portIndex++; - } - - // Add a virtual entry for serial ports that were previously configured but are not currently connected - if (!printerComPortIsAvailable && activePrinterSerialPort != null) - { - SerialPortIndexRadioButton comPortOption = CreateComPortOption(activePrinterSerialPort, true); - comPortOption.Enabled = false; - - comPortContainer.AddChild(comPortOption); - serialPortButtonsList.Add(comPortOption); - portIndex++; - } - - // If there are still no com ports show a message to that effect - if (portIndex == 0) - { - var comPortOption = new TextWidget("No COM ports available".Localize()) - { - Margin = new BorderDouble(3, 6, 5, 6), - TextColor = theme.TextColor - }; - comPortContainer.AddChild(comPortOption); - } - } - - private SerialPortIndexRadioButton CreateComPortOption(string portName, bool isActivePrinterPort) - { - return new SerialPortIndexRadioButton(portName, portName) - { - HAnchor = HAnchor.Left, - Margin = new BorderDouble(3, 3, 5, 3), - TextColor = theme.TextColor, - Checked = isActivePrinterPort - }; - } - - private string GetSelectedSerialPort() - { - foreach (SerialPortIndexRadioButton button in serialPortButtonsList) - { - if (button.Checked) - { - return button.PortValue; - } - } - - throw new Exception("Could not find a selected button.".Localize()); - } } } \ No newline at end of file diff --git a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs index 0bc126a9c..4e32411dd 100644 --- a/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs +++ b/MatterControlLib/SlicerConfiguration/UIFields/ComPortField.cs @@ -52,6 +52,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration } public new string Name { get; set; } + public static bool ShowPortWizardButton { get; set; } = true; public override void Initialize(int tabIndex) { @@ -103,18 +104,21 @@ namespace MatterHackers.MatterControl.SlicerConfiguration unregisterEvents?.Invoke(null, null); }; - var configureIcon = new IconButton(StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16, theme.InvertIcons), theme) + if (ShowPortWizardButton) { - VAnchor = VAnchor.Center, - Margin = theme.ButtonSpacing, - ToolTipText = "Port Wizard".Localize() - }; - configureIcon.Click += (s, e) => - { - DialogWindow.Show(new SetupStepComPortOne(printer)); - }; - - panel.AddChild(configureIcon); + var configureIcon = new IconButton(StaticData.Instance.LoadIcon("fa-cog_16.png", 16, 16, theme.InvertIcons), theme) + { + VAnchor = VAnchor.Center, + Margin = theme.ButtonSpacing, + ToolTipText = "Port Wizard".Localize() + }; + configureIcon.Click += (s, e) => + { + DialogWindow.Show(new SetupStepComPortOne(printer)); + }; + + panel.AddChild(configureIcon); + } panel.AddChild(dropdownList); diff --git a/Submodules/MatterSlice b/Submodules/MatterSlice index 76cfdeaa8..d52b44473 160000 --- a/Submodules/MatterSlice +++ b/Submodules/MatterSlice @@ -1 +1 @@ -Subproject commit 76cfdeaa803464bc15406805507773fd66a768ff +Subproject commit d52b44473d47b65d8be78e2f177fb940a65ff3a4 diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index de9c91f79..db87d039f 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit de9c91f7986348b0b891c6614bf7af279e540cbc +Subproject commit db87d039f6736f57ccb672632afa376ab907bc06