From 73db6d8db929ae25e4ea4e3e2147a9d33d29fbc0 Mon Sep 17 00:00:00 2001 From: larsbrubaker Date: Fri, 27 Jun 2014 10:57:14 -0700 Subject: [PATCH] Made all the GetPortNames go through FrostedSerialPort Cleaned up some using statements. --- PrinterCommunication/ActivePrinterProfile.cs | 21 +++++-------------- .../PrinterConnectionAndCommunication.cs | 3 +-- .../PrinterConnections/AddConnectionWidget.cs | 10 ++++----- .../BaseConnectionWidget.cs | 8 ------- .../ChooseConnectionWidget.cs | 14 ++----------- 5 files changed, 13 insertions(+), 43 deletions(-) diff --git a/PrinterCommunication/ActivePrinterProfile.cs b/PrinterCommunication/ActivePrinterProfile.cs index 566e8da01..974dc356a 100644 --- a/PrinterCommunication/ActivePrinterProfile.cs +++ b/PrinterCommunication/ActivePrinterProfile.cs @@ -28,26 +28,15 @@ either expressed or implied, of the FreeBSD Project. */ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.IO.Ports; -using System.Threading; -using System.Diagnostics; -using System.Collections; -using System.IO; -using System.Runtime.InteropServices; -using System.Globalization; - -using MatterHackers.Agg; using MatterHackers.Agg.UI; -using MatterHackers.VectorMath; -using MatterHackers.MatterControl.ContactForm; -using MatterHackers.MatterControl.DataStorage; -using MatterHackers.Localizations; -using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling; +using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrinterCommunication; +using MatterHackers.MatterControl.SlicerConfiguration; +using MatterHackers.SerialPortCommunication.FrostedSerial; namespace MatterHackers.MatterControl { @@ -368,7 +357,7 @@ namespace MatterHackers.MatterControl { string query = string.Format("SELECT * FROM Printer;"); IEnumerable printer_profiles = (IEnumerable)Datastore.Instance.dbSQLite.Query(query); - string[] comportNames = SerialPort.GetPortNames(); + string[] comportNames = FrostedSerialPort.GetPortNames(); foreach (DataStorage.Printer printer in printer_profiles) { diff --git a/PrinterCommunication/PrinterConnectionAndCommunication.cs b/PrinterCommunication/PrinterConnectionAndCommunication.cs index 094b3719d..41d576e7f 100644 --- a/PrinterCommunication/PrinterConnectionAndCommunication.cs +++ b/PrinterCommunication/PrinterConnectionAndCommunication.cs @@ -36,7 +36,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; -using System.IO.Ports; using System.Linq; using System.Runtime.InteropServices; using System.Threading; @@ -1300,7 +1299,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // Allow the user to set the appropriate properties. - var portNames = SerialPort.GetPortNames(); + var portNames = FrostedSerialPort.GetPortNames(); //Debug.WriteLine("Open ports: {0}".FormatWith(portNames.Length)); if (portNames.Length > 0) { diff --git a/PrinterControls/PrinterConnections/AddConnectionWidget.cs b/PrinterControls/PrinterConnections/AddConnectionWidget.cs index fb09acd75..e0a1b858a 100644 --- a/PrinterControls/PrinterConnections/AddConnectionWidget.cs +++ b/PrinterControls/PrinterConnections/AddConnectionWidget.cs @@ -1,11 +1,11 @@ using System; using System.Collections.Generic; -using System.IO.Ports; using MatterHackers.Agg; using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PrinterCommunication; +using MatterHackers.SerialPortCommunication.FrostedSerial; namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections { @@ -63,7 +63,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections this.ActivePrinter.BaudRate = "250000"; try { - this.ActivePrinter.ComPort = SerialPort.GetPortNames()[0]; + this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames()[0]; } catch { @@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections { try { - this.ActivePrinter.ComPort = SerialPort.GetPortNames()[0]; + this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames()[0]; } catch { @@ -139,7 +139,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections int portIndex = 0; - foreach (string serialPort in SerialPort.GetPortNames()) + 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."); @@ -156,7 +156,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections if (portIndex == 0) { - foreach (string serialPort in SerialPort.GetPortNames()) + foreach (string serialPort in FrostedSerialPort.GetPortNames()) { SerialPortIndexRadioButton comPortOption = createComPortOption(serialPort); comPortContainer.AddChild(comPortOption); diff --git a/PrinterControls/PrinterConnections/BaseConnectionWidget.cs b/PrinterControls/PrinterConnections/BaseConnectionWidget.cs index b8252d2bd..6825aa14b 100644 --- a/PrinterControls/PrinterConnections/BaseConnectionWidget.cs +++ b/PrinterControls/PrinterConnections/BaseConnectionWidget.cs @@ -1,16 +1,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO.Ports; -using System.Diagnostics; using MatterHackers.Agg; using MatterHackers.Agg.UI; -using MatterHackers.Agg.OpenGlGui; -using MatterHackers.PolygonMesh; -using MatterHackers.RenderOpenGl; -using MatterHackers.VectorMath; using MatterHackers.Agg.VertexSource; using MatterHackers.MatterControl.DataStorage; diff --git a/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs b/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs index 6bbf0f445..717a67786 100644 --- a/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs +++ b/PrinterControls/PrinterConnections/ChooseConnectionWidget.cs @@ -1,18 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.IO.Ports; -using System.Diagnostics; - +using System.Collections.Generic; using MatterHackers.Agg; using MatterHackers.Agg.UI; -using MatterHackers.Agg.OpenGlGui; -using MatterHackers.PolygonMesh; -using MatterHackers.RenderOpenGl; -using MatterHackers.VectorMath; -using MatterHackers.MatterControl.DataStorage; using MatterHackers.Localizations; +using MatterHackers.MatterControl.DataStorage; namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections {