Merge pull request #2848 from jlewin/design_tools
Remove Connect failed/troubleshoot UI from PrinterConnection
This commit is contained in:
commit
b23ae8ca68
4 changed files with 28 additions and 13 deletions
|
|
@ -179,7 +179,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
printer.Settings.printer.Connection.Connect(false);
|
||||
printer.Settings.printer.Connection.Connect();
|
||||
}, 2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using MatterHackers.Agg.Platform;
|
|||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||
|
||||
|
|
@ -49,6 +50,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
private EventHandler unregisterEvents;
|
||||
private PrinterConfig printer;
|
||||
|
||||
private bool listenForConnectFailed = false;
|
||||
private long connectStartMs;
|
||||
|
||||
public PrinterConnectButton(PrinterConfig printer, ThemeConfig theme)
|
||||
{
|
||||
this.printer = printer;
|
||||
|
|
@ -77,6 +81,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
cancelConnectButton.ToolTipText = "Stop trying to connect to the printer.".Localize();
|
||||
cancelConnectButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
listenForConnectFailed = false;
|
||||
ApplicationController.Instance.ConditionalCancelPrint();
|
||||
cancelConnectButton.Enabled = false;
|
||||
});
|
||||
|
|
@ -121,6 +126,21 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
printer.Connection.EnableChanged.RegisterEvent((s, e) => SetVisibleStates(), ref unregisterEvents);
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) => SetVisibleStates(), ref unregisterEvents);
|
||||
printer.Connection.ConnectionFailed.RegisterEvent((s, e) =>
|
||||
{
|
||||
#if !__ANDROID__
|
||||
// TODO: Someday this functionality should be revised to an awaitable Connect() call in the Connect button that
|
||||
// shows troubleshooting on failed attempts, rather than hooking the failed event and trying to determine if the
|
||||
// Connect button started the task
|
||||
if (listenForConnectFailed
|
||||
&& UiThread.CurrentTimerMs - connectStartMs < 25000)
|
||||
{
|
||||
// User initiated connect attempt failed, show port selection dialog
|
||||
DialogWindow.Show(new SetupStepComPortOne(printer));
|
||||
}
|
||||
#endif
|
||||
listenForConnectFailed = false;
|
||||
}, ref unregisterEvents);
|
||||
|
||||
this.SetVisibleStates();
|
||||
}
|
||||
|
|
@ -135,6 +155,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
if (printer.Settings.PrinterSelected)
|
||||
{
|
||||
listenForConnectFailed = true;
|
||||
connectStartMs = UiThread.CurrentTimerMs;
|
||||
|
||||
#if __ANDROID__
|
||||
if (!printer.Settings.GetValue<bool>(SettingsKey.enable_network_printing)
|
||||
&& !FrostedSerialPort.HasPermissionToDevice())
|
||||
|
|
@ -146,7 +169,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
#endif
|
||||
{
|
||||
printer.Connection.HaltConnectionThread();
|
||||
printer.Connection.Connect(true);
|
||||
printer.Connection.Connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -191,6 +214,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
break;
|
||||
|
||||
default:
|
||||
listenForConnectFailed = false;
|
||||
SetChildVisible(disconnectButton, true);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ using MatterControl.Printing;
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.SerialPortCommunication;
|
||||
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
||||
|
|
@ -854,7 +853,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
}
|
||||
|
||||
public void Connect(bool showHelpIfNoPort = false)
|
||||
public void Connect()
|
||||
{
|
||||
// TODO: Consider adding any conditions that would results in a connection failure to this initial test
|
||||
// Start the process of requesting permission and exit if permission is not currently granted
|
||||
|
|
@ -1044,14 +1043,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
OnConnectionFailed(
|
||||
ConnectionFailure.PortUnavailable,
|
||||
$"{this.ComPort} is not available");
|
||||
|
||||
#if !__ANDROID__
|
||||
// Only pop up the com port helper if the USER actually CLICKED the connect button.
|
||||
if (showHelpIfNoPort)
|
||||
{
|
||||
DialogWindow.Show(new SetupStepComPortOne(printer));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
ApplicationController.Instance.ActivePrinter.Connection.Connect(true);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.Connect();
|
||||
}
|
||||
|
||||
void NextButton_Click(object sender, EventArgs mouseEvent)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue