Account for FrostedSerialPort.GetPortNames() having zero items, don't filter 002/002

This commit is contained in:
John Lewin 2015-02-02 12:46:28 -08:00
parent 0af9175f97
commit b3a9afcd94
2 changed files with 5 additions and 4 deletions

View file

@ -7,6 +7,7 @@ using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.SerialPortCommunication.FrostedSerial;
using System.Linq;
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
@ -64,7 +65,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
this.ActivePrinter.BaudRate = "250000";
try
{
this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames()[0];
this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
}
catch
{
@ -84,7 +85,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
{
try
{
this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames()[0];
this.ActivePrinter.ComPort = FrostedSerialPort.GetPortNames().FirstOrDefault();
}
catch
{
@ -108,7 +109,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
ConnectionControlContainer = new FlowLayoutWidget(FlowDirection.TopToBottom);
ConnectionControlContainer.Padding = new BorderDouble(5);
ConnectionControlContainer.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
ConnectionControlContainer.HAnchor = HAnchor.ParentLeftRight;
ConnectionControlContainer.HAnchor = HAnchor.ParentLeftRight;
{
TextWidget printerNameLabel = new TextWidget(LocalizedString.Get("Printer Name"), 0, 0, 10);
printerNameLabel.TextColor = this.defaultTextColor;