commit
c0e7bbb392
2 changed files with 36 additions and 12 deletions
|
|
@ -1203,7 +1203,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
connectThread.Join(JoinThreadTimeoutMs); //Halt connection thread
|
||||
Disable();
|
||||
connectionFailureMessage = "Cancelled";
|
||||
connectionFailureMessage = LocalizedString.Get("Cancelled");
|
||||
OnConnectionFailed(null);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1296,7 +1296,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
else
|
||||
{
|
||||
Debug.WriteLine("Connection failed: {0}".FormatWith(this.ActivePrinter.ComPort));
|
||||
connectionFailureMessage = "Unavailable";
|
||||
connectionFailureMessage = LocalizedString.Get("Unavailable");
|
||||
OnConnectionFailed(null);
|
||||
}
|
||||
}
|
||||
|
|
@ -1354,15 +1354,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
const int GENERIC_WRITE = 0x40000000;
|
||||
|
||||
//Borrowed from Microsoft's Serial Port Open Method :)
|
||||
SafeFileHandle hFile = CreateFile(@"\\.\" + portName, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, 3, dwFlagsAndAttributes, IntPtr.Zero);
|
||||
if (hFile.IsInvalid)
|
||||
using (SafeFileHandle hFile = CreateFile(@"\\.\" + portName, GENERIC_READ | GENERIC_WRITE, 0, IntPtr.Zero, 3, dwFlagsAndAttributes, IntPtr.Zero))
|
||||
{
|
||||
return true;
|
||||
hFile.Close();
|
||||
return hFile.IsInvalid;
|
||||
}
|
||||
|
||||
hFile.Close();
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1387,11 +1383,11 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
void AttemptToConnect(string serialPortName, int baudRate)
|
||||
{
|
||||
connectionFailureMessage = "Unknown Reason";
|
||||
connectionFailureMessage = LocalizedString.Get("Unknown Reason");
|
||||
|
||||
if (PrinterIsConnected)
|
||||
{
|
||||
throw new Exception("You can only connect when not currently connected.");
|
||||
throw new Exception(LocalizedString.Get("You can only connect when not currently connected."));
|
||||
}
|
||||
|
||||
CommunicationState = CommunicationStates.AttemptingToConnect;
|
||||
|
|
@ -1418,7 +1414,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
catch (System.ArgumentOutOfRangeException)
|
||||
{
|
||||
connectionFailureMessage = "Unsupported Baud Rate";
|
||||
connectionFailureMessage = LocalizedString.Get("Unsupported Baud Rate");
|
||||
OnConnectionFailed(null);
|
||||
}
|
||||
|
||||
|
|
@ -1428,6 +1424,16 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the serial port isn't avaiable (i.e. the specified port name wasn't found in GetPortNames()) or the serial
|
||||
// port is already opened in another instance or process, then report the connection problem back to the user
|
||||
connectionFailureMessage = (serialPortIsAlreadyOpen ?
|
||||
LocalizedString.Get("Port already in use") :
|
||||
LocalizedString.Get("Port not found"));
|
||||
|
||||
OnConnectionFailed(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPrintFinished(EventArgs e)
|
||||
|
|
|
|||
|
|
@ -2762,3 +2762,21 @@ Translated:Material 4
|
|||
English:Material 5
|
||||
Translated:Material 5
|
||||
|
||||
English:Unknown Reason
|
||||
Translated:Unknown Reason
|
||||
|
||||
English:Port already in use
|
||||
Translated:Port already in use
|
||||
|
||||
English:Unsupported Baud Rate
|
||||
Translated:Unsupported Baud Rate
|
||||
|
||||
English:Port not found
|
||||
Translated:Port not found
|
||||
|
||||
English:Cancelled
|
||||
Translated:Cancelled
|
||||
|
||||
English:You can only connect when not currently connected.
|
||||
Translated:You can only connect when not currently connected.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue