From e998f137aabc28580f3e227d07b227244835a7a7 Mon Sep 17 00:00:00 2001 From: John Lewin Date: Thu, 1 Feb 2018 14:51:44 -0800 Subject: [PATCH] Rename Connection.PrinterIsConnected -> Connection.IsConnected --- ActionBar/TemperatureWidgetBase.cs | 4 +-- .../CalibrationControls.cs | 2 +- .../PrintLeveling/PrintLevelPages.cs | 2 +- EeProm/EePromRepetierWindow.cs | 2 +- Library/Providers/SDCard/SDCardContainer.cs | 2 +- .../Io/RequestTemperaturesStream.cs | 2 +- PrinterCommunication/PrinterConnection.cs | 30 +++++++++---------- .../ControlWidgets/PowerControls.cs | 4 +-- .../SetupStepComPortManual.cs | 2 +- .../PrinterConnections/SetupStepComPortTwo.cs | 2 +- Queue/QueueData.cs | 2 +- SetupWizard/AndroidConnectDevicePage.cs | 2 +- SlicerConfiguration/Settings/GCodeMacro.cs | 2 +- SlicerConfiguration/UIFields/ComPortField.cs | 4 +-- SlicerConfiguration/UIFields/IpAddessField.cs | 4 +-- 15 files changed, 33 insertions(+), 33 deletions(-) diff --git a/ActionBar/TemperatureWidgetBase.cs b/ActionBar/TemperatureWidgetBase.cs index eecf335ea..76ef91e65 100644 --- a/ActionBar/TemperatureWidgetBase.cs +++ b/ActionBar/TemperatureWidgetBase.cs @@ -110,7 +110,7 @@ namespace MatterHackers.MatterControl.ActionBar { if (disableablePanel != null) { - disableablePanel.Enabled = printer.Connection.PrinterIsConnected; + disableablePanel.Enabled = printer.Connection.IsConnected; } }, ref unregisterEvents); @@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.ActionBar public override void OnLoad(EventArgs args) { // Wrap popup content in a DisableablePanel - disableablePanel = new DisableablePanel(this.GetPopupContent(), printer.Connection.PrinterIsConnected, alpha: 140); + disableablePanel = new DisableablePanel(this.GetPopupContent(), printer.Connection.IsConnected, alpha: 140); // Set as popup this.PopupContent = disableablePanel; diff --git a/ConfigurationPage/CalibrationSettings/CalibrationControls.cs b/ConfigurationPage/CalibrationSettings/CalibrationControls.cs index 2ccf989ce..e6d0ea87d 100644 --- a/ConfigurationPage/CalibrationSettings/CalibrationControls.cs +++ b/ConfigurationPage/CalibrationSettings/CalibrationControls.cs @@ -147,7 +147,7 @@ namespace MatterHackers.MatterControl.PrinterControls else { this.Enabled = true; - runPrintLevelingButton.Enabled = printer.Connection.PrinterIsConnected; + runPrintLevelingButton.Enabled = printer.Connection.IsConnected; } } } diff --git a/ConfigurationPage/PrintLeveling/PrintLevelPages.cs b/ConfigurationPage/PrintLeveling/PrintLevelPages.cs index 8e30f18b1..c6759c50a 100644 --- a/ConfigurationPage/PrintLeveling/PrintLevelPages.cs +++ b/ConfigurationPage/PrintLeveling/PrintLevelPages.cs @@ -576,7 +576,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling container.backButton.Enabled = false; container.nextButton.Enabled = false; - if (printer.Connection.PrinterIsConnected + if (printer.Connection.IsConnected && !(printer.Connection.PrinterIsPrinting || printer.Connection.PrinterIsPaused)) { diff --git a/EeProm/EePromRepetierWindow.cs b/EeProm/EePromRepetierWindow.cs index e12412eb9..7b552dee4 100644 --- a/EeProm/EePromRepetierWindow.cs +++ b/EeProm/EePromRepetierWindow.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.EeProm { printerConnection.CommunicationStateChanged.RegisterEvent((s, e) => { - if(!printerConnection.PrinterIsConnected) + if(!printerConnection.IsConnected) { this.CloseOnIdle(); } diff --git a/Library/Providers/SDCard/SDCardContainer.cs b/Library/Providers/SDCard/SDCardContainer.cs index a14166cf1..4c384e328 100644 --- a/Library/Providers/SDCard/SDCardContainer.cs +++ b/Library/Providers/SDCard/SDCardContainer.cs @@ -84,7 +84,7 @@ namespace MatterHackers.MatterControl.Library { this.Items.Clear(); - if (printer.Connection.PrinterIsConnected + if (printer.Connection.IsConnected && !(printer.Connection.PrinterIsPrinting || printer.Connection.PrinterIsPaused)) { autoResetEvent = new AutoResetEvent(false); diff --git a/PrinterCommunication/Io/RequestTemperaturesStream.cs b/PrinterCommunication/Io/RequestTemperaturesStream.cs index b42d1b0b8..0f5dac2c9 100644 --- a/PrinterCommunication/Io/RequestTemperaturesStream.cs +++ b/PrinterCommunication/Io/RequestTemperaturesStream.cs @@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io { if (!printerConnection.WaitingForPositionRead && nextReadTimeMs < UiThread.CurrentTimerMs - && printerConnection.PrinterIsConnected) + && printerConnection.IsConnected) { nextReadTimeMs = UiThread.CurrentTimerMs + 1000; return "M105"; diff --git a/PrinterCommunication/PrinterConnection.cs b/PrinterCommunication/PrinterConnection.cs index 75082eca4..20debfcb8 100644 --- a/PrinterCommunication/PrinterConnection.cs +++ b/PrinterCommunication/PrinterConnection.cs @@ -577,7 +577,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication { fanSpeed = Math.Max(0, Math.Min(255, value)); OnFanSpeedSet(null); - if (PrinterIsConnected) + if (this.IsConnected) { QueueLine("M106 S{0}".FormatWith((int)(fanSpeed + .5))); } @@ -623,7 +623,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication } } - public bool PrinterIsConnected + public bool IsConnected { get { @@ -780,7 +780,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication { _targetBedTemperature = value; OnBedTemperatureSet(new TemperatureEventArgs(0, TargetBedTemperature)); - if (PrinterIsConnected) + if (this.IsConnected) { QueueLine("M140 S{0}".FormatWith(_targetBedTemperature)); } @@ -902,7 +902,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication // make sure we don't have a left over print task activePrintTask = null; - if (PrinterIsConnected) + if (this.IsConnected) { this.OnConnectionFailed(ConnectionFailure.AlreadyConnected); return; @@ -916,7 +916,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication if (serialPortIsAvailable && !serialPortIsAlreadyOpen) { - if (!PrinterIsConnected) + if (!this.IsConnected) { try { @@ -1055,7 +1055,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication public void Disable() { - if (PrinterIsConnected) + if (this.IsConnected) { // Make sure we send this without waiting for the printer to respond. We want to try and turn off the heaters. // It may be possible in the future to make this go into the printer queue for assured sending but it means @@ -1278,7 +1278,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication public void OnIdle() { - if (PrinterIsConnected && ReadThread.NumRunning == 0) + if (this.IsConnected && ReadThread.NumRunning == 0) { ReadThread.Start(this); } @@ -1420,9 +1420,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication timeSinceLastReadAnything.Restart(); // we want this while loop to be as fast as possible. Don't allow any significant work to happen in here while (CommunicationState == CommunicationStates.AttemptingToConnect - || (PrinterIsConnected && serialPort != null && serialPort.IsOpen && !Disconnecting && readThreadHolder.IsCurrentThread())) + || (this.IsConnected && serialPort != null && serialPort.IsOpen && !Disconnecting && readThreadHolder.IsCurrentThread())) { - if ((PrinterIsConnected + if ((this.IsConnected || this.communicationState == CommunicationStates.AttemptingToConnect) && CommunicationState != CommunicationStates.PrintingFromSd) { @@ -1879,7 +1879,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication { targetHotendTemperature[hotendIndex0Based] = temperature; OnHotendTemperatureSet(new TemperatureEventArgs(hotendIndex0Based, temperature)); - if (PrinterIsConnected) + if (this.IsConnected) { QueueLine("M104 T{0} S{1}".FormatWith(hotendIndex0Based, targetHotendTemperature[hotendIndex0Based])); } @@ -1890,7 +1890,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication public async void StartPrint(string gcodeFilename, PrintTask printTaskToUse = null) { - if (!PrinterIsConnected || PrinterIsPrinting) + if (!this.IsConnected || PrinterIsPrinting) { return; } @@ -1959,7 +1959,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication public bool StartSdCardPrint(string m23FileName) { - if (!PrinterIsConnected + if (!this.IsConnected || PrinterIsPrinting || string.IsNullOrEmpty(m23FileName)) { @@ -2395,7 +2395,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication int waitTimeInMs = 60000; // 60 seconds if (waitingForPosition.IsRunning && waitingForPosition.ElapsedMilliseconds < waitTimeInMs - && PrinterIsConnected) + && this.IsConnected) { // we are waiting for a position response don't print more return; @@ -2407,7 +2407,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication if (currentSentLine != null) { if (currentSentLine.Contains("M114") - && PrinterIsConnected) + && this.IsConnected) { waitingForPosition.Restart(); } @@ -2558,7 +2558,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication private void WriteRaw(string lineToWrite, string lineWithoutChecksum) { - if (PrinterIsConnected || CommunicationState == CommunicationStates.AttemptingToConnect) + if (this.IsConnected || CommunicationState == CommunicationStates.AttemptingToConnect) { if (serialPort != null && serialPort.IsOpen) { diff --git a/PrinterControls/ControlWidgets/PowerControls.cs b/PrinterControls/ControlWidgets/PowerControls.cs index c1ec9abd5..4b9360bb5 100644 --- a/PrinterControls/ControlWidgets/PowerControls.cs +++ b/PrinterControls/ControlWidgets/PowerControls.cs @@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.PrinterControls : base(FlowDirection.TopToBottom) { this.printer = printer; - this.Enabled = printer.Connection.PrinterIsConnected; + this.Enabled = printer.Connection.IsConnected; this.AddChild( settingsItem = new SettingsItem( @@ -68,7 +68,7 @@ namespace MatterHackers.MatterControl.PrinterControls printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => { - this.Enabled = printer.Connection.PrinterIsConnected + this.Enabled = printer.Connection.IsConnected && printer.Settings.GetValue(SettingsKey.has_power_control); }, ref unregisterEvents); diff --git a/PrinterControls/PrinterConnections/SetupStepComPortManual.cs b/PrinterControls/PrinterConnections/SetupStepComPortManual.cs index 40679c0e8..efc29e358 100644 --- a/PrinterControls/PrinterConnections/SetupStepComPortManual.cs +++ b/PrinterControls/PrinterConnections/SetupStepComPortManual.cs @@ -167,7 +167,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections private void onPrinterStatusChanged(object sender, EventArgs e) { - if (printer.Connection.PrinterIsConnected) + if (printer.Connection.IsConnected) { printerComPortHelpLink.Visible = false; printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor; diff --git a/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs b/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs index d26b39650..543feae52 100644 --- a/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs +++ b/PrinterControls/PrinterConnections/SetupStepComPortTwo.cs @@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections private void onPrinterStatusChanged(object sender, EventArgs e) { - if (printer.Connection.PrinterIsConnected) + if (printer.Connection.IsConnected) { printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor; printerErrorMessage.Text = "Connection succeeded".Localize() + "!"; diff --git a/Queue/QueueData.cs b/Queue/QueueData.cs index 978a4d2e6..9a1f9ac38 100644 --- a/Queue/QueueData.cs +++ b/Queue/QueueData.cs @@ -133,7 +133,7 @@ namespace MatterHackers.MatterControl.PrintQueue public void LoadFilesFromSD() { - if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsConnected + if (ApplicationController.Instance.ActivePrinter.Connection.IsConnected && !(ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting || ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused)) { diff --git a/SetupWizard/AndroidConnectDevicePage.cs b/SetupWizard/AndroidConnectDevicePage.cs index 7cb603769..1112e4e4d 100644 --- a/SetupWizard/AndroidConnectDevicePage.cs +++ b/SetupWizard/AndroidConnectDevicePage.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl connectButtonContainer.Visible = false; retryButtonContainer.Visible = false; - if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsConnected) + if (ApplicationController.Instance.ActivePrinter.Connection.IsConnected) { generalError.Text = "{0}!".FormatWith ("Connection succeeded".Localize ()); generalError.Visible = true; diff --git a/SlicerConfiguration/Settings/GCodeMacro.cs b/SlicerConfiguration/Settings/GCodeMacro.cs index 907042f3a..02120c89e 100644 --- a/SlicerConfiguration/Settings/GCodeMacro.cs +++ b/SlicerConfiguration/Settings/GCodeMacro.cs @@ -56,7 +56,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration public void Run(PrinterConnection printerConnection) { - if (printerConnection.PrinterIsConnected) + if (printerConnection.IsConnected) { printerConnection.MacroStart(); printerConnection.QueueLine(GCode); diff --git a/SlicerConfiguration/UIFields/ComPortField.cs b/SlicerConfiguration/UIFields/ComPortField.cs index db3c3ada6..057957c7f 100644 --- a/SlicerConfiguration/UIFields/ComPortField.cs +++ b/SlicerConfiguration/UIFields/ComPortField.cs @@ -54,7 +54,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration { EventHandler unregisterEvents = null; - bool canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; + bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; // The COM_PORT control is unique in its approach to the SlicerConfigName. It uses "com_port" settings name to // bind to a context that will place it in the SliceSetting view but it binds its values to a machine @@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration // Prevent droplist interaction when connected printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => { - canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; + canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; dropdownList.Enabled = canChangeComPort; dropdownList.TextColor = canChangeComPort ? ActiveTheme.Instance.PrimaryTextColor : new Color(ActiveTheme.Instance.PrimaryTextColor, 150); dropdownList.BorderColor = canChangeComPort ? ActiveTheme.Instance.SecondaryTextColor : new Color(ActiveTheme.Instance.SecondaryTextColor, 150); diff --git a/SlicerConfiguration/UIFields/IpAddessField.cs b/SlicerConfiguration/UIFields/IpAddessField.cs index 789db6af3..5c035c46d 100644 --- a/SlicerConfiguration/UIFields/IpAddessField.cs +++ b/SlicerConfiguration/UIFields/IpAddessField.cs @@ -33,7 +33,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration var theme = ApplicationController.Instance.Theme; base.Initialize(tabIndex); - bool canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; + bool canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; //This setting defaults to Manual var selectedMachine = printer.Settings.GetValue(SettingsKey.selector_ip_address); dropdownList = new DropDownList(selectedMachine, theme.Colors.PrimaryTextColor, maxHeight: 200, pointSize: theme.DefaultFontSize) @@ -60,7 +60,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration // Prevent droplist interaction when connected printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => { - canChangeComPort = !printer.Connection.PrinterIsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; + canChangeComPort = !printer.Connection.IsConnected && printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect; dropdownList.Enabled = canChangeComPort; dropdownList.TextColor = canChangeComPort ? theme.Colors.PrimaryTextColor : new Color(theme.Colors.PrimaryTextColor, 150); dropdownList.BorderColor = canChangeComPort ? theme.Colors.SecondaryTextColor : new Color(theme.Colors.SecondaryTextColor, 150);