Eliminate PrinterConnection.Instance
This commit is contained in:
parent
928fed9efe
commit
76e7af0436
26 changed files with 265 additions and 270 deletions
|
|
@ -60,8 +60,8 @@ namespace MatterHackers.MatterControl
|
|||
else
|
||||
{
|
||||
// TODO: when this oppens a new tab we will not need to check any printer
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting
|
||||
|| PrinterConnection.Instance.PrinterIsPaused)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting
|
||||
|| ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused)
|
||||
{
|
||||
if (this.SelectedIndex != lastSelectedIndex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -339,7 +339,7 @@ namespace MatterHackers.MatterControl
|
|||
thumbGenResetEvent?.Set();
|
||||
};
|
||||
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
PrinterConnection.AnyCommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
var printerConnection = s as PrinterConnection;
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ namespace MatterHackers.MatterControl
|
|||
case CommunicationStates.Printing:
|
||||
if (UserSettings.Instance.IsTouchScreen)
|
||||
{
|
||||
// TODO: In general this basic hook won't work with multi-tenancy
|
||||
// TODO: This basic hook won't work with multi-tenancy. Need to lookup the passed in sender from ActivePrinters use the found instance instead of the .ActivePrinter below
|
||||
UiThread.RunOnIdle(() => PrintingWindow.Show(ApplicationController.Instance.ActivePrinter)); // HACK: We need to show the instance that's printing not the static instance
|
||||
}
|
||||
|
||||
|
|
@ -358,20 +358,21 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
this.InitializeLibrary();
|
||||
|
||||
PrinterConnection.Instance.ConnectionSucceeded.RegisterEvent((s, e) =>
|
||||
PrinterConnection.AnyConnectionSucceeded.RegisterEvent((s, e) =>
|
||||
{
|
||||
// run the print leveling wizard if we need to for this printer
|
||||
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_required_to_print)
|
||||
|| ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled))
|
||||
var printer = ApplicationController.Instance.ActivePrinters.Where(p => p.Connection == s).FirstOrDefault();
|
||||
if (printer != null
|
||||
&& (printer.Settings.GetValue<bool>(SettingsKey.print_leveling_required_to_print)
|
||||
|| printer.Settings.GetValue<bool>(SettingsKey.print_leveling_enabled)))
|
||||
{
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();
|
||||
if (levelingData?.HasBeenRunAndEnabled() != true)
|
||||
{
|
||||
UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(ApplicationController.Instance.ActivePrinter));// HACK: We need to show the instance that's printing not the static instance
|
||||
UiThread.RunOnIdle(() => LevelWizardBase.ShowPrintLevelWizard(printer));
|
||||
}
|
||||
}
|
||||
}, ref unregisterEvents);
|
||||
|
||||
}
|
||||
|
||||
public void StartSignIn()
|
||||
|
|
@ -718,13 +719,13 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
|
||||
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected
|
||||
&& ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.auto_connect))
|
||||
if (this.ActivePrinter.Settings.PrinterSelected
|
||||
&& this.ActivePrinter.Settings.GetValue<bool>(SettingsKey.auto_connect))
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
//PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
||||
PrinterConnection.Instance.ConnectToActivePrinter();
|
||||
this.ActivePrinter.Connection.ConnectToActivePrinter();
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
|
|
@ -847,14 +848,14 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
bool canceled = false;
|
||||
|
||||
if (PrinterConnection.Instance.SecondsPrinted > 120)
|
||||
if (this.ActivePrinter.Connection.SecondsPrinted > 120)
|
||||
{
|
||||
StyledMessageBox.ShowMessageBox(
|
||||
(bool response) =>
|
||||
{
|
||||
if (response)
|
||||
{
|
||||
UiThread.RunOnIdle(() => PrinterConnection.Instance.Stop());
|
||||
UiThread.RunOnIdle(() => this.ActivePrinter.Connection.Stop());
|
||||
canceled = true;
|
||||
}
|
||||
|
||||
|
|
@ -868,7 +869,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.Stop();
|
||||
this.ActivePrinter.Connection.Stop();
|
||||
canceled = false;
|
||||
}
|
||||
|
||||
|
|
@ -944,14 +945,14 @@ namespace MatterHackers.MatterControl
|
|||
if (ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.has_sd_card_reader)
|
||||
&& pathAndFile == QueueData.SdCardFileName)
|
||||
{
|
||||
PrinterConnection.Instance.StartSdCardPrint();
|
||||
this.ActivePrinter.Connection.StartSdCardPrint();
|
||||
}
|
||||
else if (ActiveSliceSettings.Instance.IsValid())
|
||||
{
|
||||
if (File.Exists(pathAndFile))
|
||||
{
|
||||
// clear the output cache prior to starting a print
|
||||
PrinterConnection.Instance.TerminalLog.Clear();
|
||||
this.ActivePrinter.Connection.TerminalLog.Clear();
|
||||
|
||||
string hideGCodeWarning = ApplicationSettings.Instance.get(ApplicationSettingsKey.HideGCodeWarning);
|
||||
|
||||
|
|
@ -982,7 +983,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
if (messageBoxResponse)
|
||||
{
|
||||
PrinterConnection.Instance.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ActivePrinter.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
PrintItemWrapper partToPrint = printItem;
|
||||
SlicingQueue.Instance.QueuePartForSlicing(partToPrint);
|
||||
partToPrint.SlicingDone += partToPrint_SliceDone;
|
||||
|
|
@ -1001,7 +1002,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
else
|
||||
{
|
||||
PrinterConnection.Instance.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
this.ActivePrinter.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
PrintItemWrapper partToPrint = printItem;
|
||||
SlicingQueue.Instance.QueuePartForSlicing(partToPrint);
|
||||
partToPrint.SlicingDone += partToPrint_SliceDone;
|
||||
|
|
@ -1019,8 +1020,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public void PrintActivePartIfPossible(PrintItemWrapper printItem, bool overrideAllowGCode = false)
|
||||
{
|
||||
if (PrinterConnection.Instance.CommunicationState == CommunicationStates.Connected
|
||||
|| PrinterConnection.Instance.CommunicationState == CommunicationStates.FinishedPrint)
|
||||
if (this.ActivePrinter.Connection.CommunicationState == CommunicationStates.Connected
|
||||
|| this.ActivePrinter.Connection.CommunicationState == CommunicationStates.FinishedPrint)
|
||||
{
|
||||
PrintPart(printItem, overrideAllowGCode);
|
||||
}
|
||||
|
|
@ -1060,7 +1061,7 @@ namespace MatterHackers.MatterControl
|
|||
// read the last few k of the file and see if it says "filament used". We use this marker to tell if the file finished writing
|
||||
if (originalIsGCode)
|
||||
{
|
||||
PrinterConnection.Instance.StartPrint(gcodePathAndFileName);
|
||||
this.ActivePrinter.Connection.StartPrint(gcodePathAndFileName);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
|
@ -1076,14 +1077,14 @@ namespace MatterHackers.MatterControl
|
|||
string fileEnd = System.Text.Encoding.UTF8.GetString(buffer);
|
||||
if (fileEnd.Contains("filament used"))
|
||||
{
|
||||
PrinterConnection.Instance.StartPrint(gcodePathAndFileName);
|
||||
this.ActivePrinter.Connection.StartPrint(gcodePathAndFileName);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PrinterConnection.Instance.CommunicationState = CommunicationStates.Connected;
|
||||
this.ActivePrinter.Connection.CommunicationState = CommunicationStates.Connected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -365,8 +365,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public PrinterConfig(bool loadLastBedplate, PrinterSettings settings = null)
|
||||
{
|
||||
// TODO: Not quite there yet. Need to have a system that loads settings, creates a connection and assigns it all to a printer instance. Hopefully soon...
|
||||
this.Connection = PrinterConnection.Instance;
|
||||
this.Connection = new PrinterConnection();
|
||||
this.Settings = settings ?? ActiveSliceSettings.Instance;
|
||||
this.Settings.printer = this;
|
||||
this.Connection.printer = this;
|
||||
|
|
|
|||
|
|
@ -80,10 +80,10 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (PrinterConnection.Instance.CommunicationState == CommunicationStates.Connected)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Connected)
|
||||
{
|
||||
PrinterConnection.Instance.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
PrinterConnection.Instance.StartPrint(lastPrintTask.PrintingGCodeFileName, lastPrintTask);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.CommunicationState = CommunicationStates.PreparingToPrint;
|
||||
ApplicationController.Instance.ActivePrinter.Connection.StartPrint(lastPrintTask.PrintingGCodeFileName, lastPrintTask);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -112,7 +112,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
if (instance == null)
|
||||
{
|
||||
instance = new PrintHistoryData();
|
||||
PrinterConnection.Instance.ConnectionSucceeded.RegisterEvent((s, e) =>
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ConnectionSucceeded.RegisterEvent((s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(PrintRecovery.CheckIfNeedToRecoverPrint);
|
||||
}, ref unregisterEvents);
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ namespace MatterHackers.MatterControl.PrintHistory
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
if (!PrinterCommunication.PrinterConnection.Instance.PrintIsActive)
|
||||
if (!ApplicationController.Instance.ActivePrinter.Connection.PrintIsActive)
|
||||
{
|
||||
ApplicationController.Instance.PrintActivePartIfPossible(new PrintItemWrapper(printTask.PrintItemId));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ namespace MatterHackers.MatterControl
|
|||
RenderOrthographic ? RenderType.ORTHOGROPHIC : RenderType.RAY_TRACE,
|
||||
BigRenderSize.x,
|
||||
BigRenderSize.y,
|
||||
allowMultiThreading: !PrinterConnection.Instance.PrinterIsPrinting);
|
||||
allowMultiThreading: !ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting);
|
||||
|
||||
if (thumbnail != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
PrinterConnection.Instance.TerminalLog.WriteLine($"Error adding file: {filePath}\r\n{ex.Message}");
|
||||
ApplicationController.Instance.ActivePrinter.Connection.TerminalLog.WriteLine($"Error adding file: {filePath}\r\n{ex.Message}");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,16 +53,16 @@ namespace MatterHackers.MatterControl.Library
|
|||
|
||||
public void LoadFilesFromSD()
|
||||
{
|
||||
var printer = PrinterConnection.Instance;
|
||||
var printer = ApplicationController.Instance.ActivePrinter;
|
||||
|
||||
if (printer.PrinterIsConnected
|
||||
&& !(printer.PrinterIsPrinting || printer.PrinterIsPaused))
|
||||
if (printer.Connection.PrinterIsConnected
|
||||
&& !(printer.Connection.PrinterIsPrinting || printer.Connection.PrinterIsPaused))
|
||||
{
|
||||
|
||||
printer.ReadLine.RegisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
printer.Connection.ReadLine.RegisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
|
||||
gotBeginFileList = false;
|
||||
printer.SendLineToPrinterNow("M21\r\nM20");
|
||||
printer.Connection.SendLineToPrinterNow("M21\r\nM20");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
break;
|
||||
|
||||
case "End file list":
|
||||
PrinterConnection.Instance.ReadLine.UnregisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ReadLine.UnregisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
this.OnReloaded();
|
||||
break;
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl.Library
|
|||
public override void Dispose()
|
||||
{
|
||||
// In case "End file list" is never received
|
||||
PrinterConnection.Instance.ReadLine.UnregisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ReadLine.UnregisterEvent(Printer_LineRead, ref unregisterEvents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,12 +406,12 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
UserSettings.Instance.Fields.StartCountDurringExit = UserSettings.Instance.Fields.StartCount;
|
||||
|
||||
if (PrinterConnection.Instance.CommunicationState != CommunicationStates.PrintingFromSd)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState != CommunicationStates.PrintingFromSd)
|
||||
{
|
||||
PrinterConnection.Instance.Disable();
|
||||
ApplicationController.Instance.ActivePrinter.Connection.Disable();
|
||||
}
|
||||
//Close connection to the local datastore
|
||||
PrinterConnection.Instance.HaltConnectionThread();
|
||||
ApplicationController.Instance.ActivePrinter.Connection.HaltConnectionThread();
|
||||
SlicingQueue.Instance.ShutDownSlicingThread();
|
||||
ApplicationController.Instance.OnApplicationClosed();
|
||||
|
||||
|
|
@ -456,13 +456,13 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (!closeHasBeenConfirmed
|
||||
&& !closeMessageBoxIsOpen
|
||||
&& PrinterConnection.Instance.PrinterIsPrinting)
|
||||
&& ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting)
|
||||
{
|
||||
cancelClose = true;
|
||||
// Record that we are waiting for a response to the request to close
|
||||
closeMessageBoxIsOpen = true;
|
||||
|
||||
if (PrinterConnection.Instance.CommunicationState != CommunicationStates.PrintingFromSd)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState != CommunicationStates.PrintingFromSd)
|
||||
{
|
||||
// Needed as we can't assign to CancelClose inside of the lambda below
|
||||
StyledMessageBox.ShowMessageBox(ConditionalyCloseNow,
|
||||
|
|
@ -499,12 +499,12 @@ namespace MatterHackers.MatterControl
|
|||
if (continueWithShutdown)
|
||||
{
|
||||
closeHasBeenConfirmed = true;
|
||||
bool printingFromSdCard = PrinterConnection.Instance.CommunicationState == CommunicationStates.PrintingFromSd
|
||||
|| (PrinterConnection.Instance.CommunicationState == CommunicationStates.Paused
|
||||
&& PrinterConnection.Instance.PrePauseCommunicationState == CommunicationStates.PrintingFromSd);
|
||||
bool printingFromSdCard = ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.PrintingFromSd
|
||||
|| (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Paused
|
||||
&& ApplicationController.Instance.ActivePrinter.Connection.PrePauseCommunicationState == CommunicationStates.PrintingFromSd);
|
||||
if (!printingFromSdCard)
|
||||
{
|
||||
PrinterConnection.Instance.Disable();
|
||||
ApplicationController.Instance.ActivePrinter.Connection.Disable();
|
||||
}
|
||||
|
||||
MatterControlApplication app = MatterControlApplication.Instance;
|
||||
|
|
@ -691,7 +691,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
try
|
||||
{
|
||||
PrinterConnection.Instance.OnIdle();
|
||||
ApplicationController.Instance.ActivePrinter.Connection.OnIdle();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
createPrinter.HAnchor = HAnchor.Left;
|
||||
createPrinter.Click += (s, e) =>
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsPrinting
|
||||
|| PrinterConnection.Instance.PrinterIsPaused)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting
|
||||
|| ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
StyledMessageBox.ShowMessageBox(null, "Please wait until the print has finished and try again.".Localize(), "Can't add printers while printing".Localize())
|
||||
|
|
|
|||
|
|
@ -77,6 +77,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
/// </summary>
|
||||
public class PrinterConnection
|
||||
{
|
||||
public static RootedObjectEventHandler AnyCommunicationStateChanged = new RootedObjectEventHandler();
|
||||
|
||||
public static RootedObjectEventHandler AnyConnectionSucceeded = new RootedObjectEventHandler();
|
||||
|
||||
public RootedObjectEventHandler BedTemperatureRead = new RootedObjectEventHandler();
|
||||
|
||||
public RootedObjectEventHandler BedTemperatureSet = new RootedObjectEventHandler();
|
||||
|
|
@ -353,18 +357,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
[Flags]
|
||||
public enum Axis { X = 1, Y = 2, Z = 4, E = 8, XYZ = (X | Y | Z) }
|
||||
|
||||
public static PrinterConnection Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (globalInstance == null)
|
||||
{
|
||||
globalInstance = new PrinterConnection();
|
||||
}
|
||||
return globalInstance;
|
||||
}
|
||||
}
|
||||
|
||||
public double ActualBedTemperature
|
||||
{
|
||||
get
|
||||
|
|
@ -1015,7 +1007,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
// Only pop up the com port helper if the USER actually CLICKED the connect button.
|
||||
if (showHelpIfNoPort)
|
||||
{
|
||||
WizardWindow.ShowComPortSetup();
|
||||
WizardWindow.ShowComPortSetup(printer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -1219,6 +1211,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
public void OnCommunicationStateChanged(EventArgs e)
|
||||
{
|
||||
// Call global even
|
||||
AnyCommunicationStateChanged.CallEvents(this, e);
|
||||
|
||||
// Call instance event
|
||||
CommunicationStateChanged.CallEvents(this, e);
|
||||
PrintingStateChanged.CallEvents(this, null);
|
||||
#if __ANDROID__
|
||||
|
|
@ -1233,7 +1229,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
File.WriteAllLines(pathToPrintOutputFile, PrinterConnection.Instance.TerminalLog.PrinterLines);
|
||||
File.WriteAllLines(pathToPrintOutputFile, ApplicationController.Instance.ActivePrinter.Connection.TerminalLog.PrinterLines);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1499,7 +1495,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
string connectGCode = printer.Settings.GetValue(SettingsKey.connect_gcode);
|
||||
SendLineToPrinterNow(connectGCode);
|
||||
|
||||
// and call back anyone who would like to know we connected
|
||||
// Call global event
|
||||
AnyConnectionSucceeded.CallEvents(this, null);
|
||||
|
||||
// Call instance event
|
||||
ConnectionSucceeded.CallEvents(this, null);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -48,8 +48,11 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
private Button printerBaudRateHelpLink;
|
||||
private TextWidget printerBaudRateHelpMessage;
|
||||
|
||||
public SetupStepBaudRate()
|
||||
private PrinterConfig printer;
|
||||
|
||||
public SetupStepBaudRate(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
printerBaudRateContainer = createPrinterBaudRateContainer();
|
||||
contentRow.AddChild(printerBaudRateContainer);
|
||||
{
|
||||
|
|
@ -59,7 +62,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
bool canContinue = this.OnSave();
|
||||
if (canContinue)
|
||||
{
|
||||
UiThread.RunOnIdle(MoveToNextWidget);
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToInstallDriverOrComPortOne(printer);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -191,11 +197,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
}
|
||||
}
|
||||
|
||||
private void MoveToNextWidget()
|
||||
{
|
||||
WizardWindow.ChangeToInstallDriverOrComPortOne();
|
||||
}
|
||||
|
||||
private bool OnSave()
|
||||
{
|
||||
string baudRate = null;
|
||||
|
|
|
|||
|
|
@ -52,15 +52,17 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
private EventHandler unregisterEvents;
|
||||
protected List<SerialPortIndexRadioButton> SerialPortButtonsList = new List<SerialPortIndexRadioButton>();
|
||||
PrinterConnection printerConnection = PrinterConnection.Instance;
|
||||
private PrinterConfig printer;
|
||||
|
||||
public SetupStepComPortManual()
|
||||
public SetupStepComPortManual(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
|
||||
FlowLayoutWidget printerComPortContainer = createComPortContainer();
|
||||
contentRow.AddChild(printerComPortContainer);
|
||||
|
||||
cancelButton.Click += (s, e) => printerConnection.HaltConnectionThread();
|
||||
|
||||
cancelButton.Click += (s, e) => printer.Connection.HaltConnectionThread();
|
||||
|
||||
//Construct buttons
|
||||
nextButton = textImageButtonFactory.Generate("Done".Localize());
|
||||
nextButton.Click += (s, e) => UiThread.RunOnIdle(Parent.Close);
|
||||
|
|
@ -78,7 +80,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
ActiveSliceSettings.Instance.Helpers.SetComPort(GetSelectedSerialPort());
|
||||
printerConnection.ConnectToActivePrinter();
|
||||
printer.Connection.ConnectToActivePrinter();
|
||||
|
||||
connectButton.Visible = false;
|
||||
refreshButton.Visible = false;
|
||||
|
|
@ -94,14 +96,14 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
refreshButton = textImageButtonFactory.Generate("Refresh".Localize());
|
||||
refreshButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepComPortManual>();
|
||||
WizardWindow.ChangeToPage(new SetupStepComPortManual(printer));
|
||||
});
|
||||
|
||||
this.AddPageAction(nextButton);
|
||||
this.AddPageAction(connectButton);
|
||||
this.AddPageAction(refreshButton);
|
||||
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
|
|
@ -155,12 +157,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
container.AddChild(printerComPortHelpMessage);
|
||||
|
||||
container.HAnchor = HAnchor.Stretch;
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private void onPrinterStatusChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (printerConnection.PrinterIsConnected)
|
||||
if (printer.Connection.PrinterIsConnected)
|
||||
{
|
||||
printerComPortHelpLink.Visible = false;
|
||||
printerComPortError.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
|
@ -169,7 +172,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
connectButton.Visible = false;
|
||||
UiThread.RunOnIdle(() => this?.Parent?.Close());
|
||||
}
|
||||
else if (printerConnection.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
else if (printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
printerComPortHelpLink.Visible = false;
|
||||
printerComPortError.TextColor = RGBA_Bytes.Red;
|
||||
|
|
@ -179,11 +182,6 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
}
|
||||
}
|
||||
|
||||
private void MoveToNextWidget(object state)
|
||||
{
|
||||
WizardWindow.ChangeToInstallDriverOrComPortOne();
|
||||
}
|
||||
|
||||
protected void CreateSerialPortControls(FlowLayoutWidget comPortContainer, string activePrinterSerialPort)
|
||||
{
|
||||
int portIndex = 0;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
|
|
@ -37,98 +36,88 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
public class SetupStepComPortOne : WizardPage
|
||||
{
|
||||
private Button nextButton;
|
||||
|
||||
public SetupStepComPortOne()
|
||||
public SetupStepComPortOne(PrinterConfig printer)
|
||||
{
|
||||
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
//Construct buttons
|
||||
nextButton = textImageButtonFactory.Generate("Continue".Localize());
|
||||
nextButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepComPortTwo>();
|
||||
});
|
||||
VAnchor = VAnchor.Stretch,
|
||||
Margin = new BorderDouble(5),
|
||||
HAnchor = HAnchor.Stretch
|
||||
};
|
||||
|
||||
this.AddPageAction(nextButton);
|
||||
}
|
||||
}
|
||||
|
||||
public FlowLayoutWidget createPrinterConnectionMessageContainer()
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
container.VAnchor = VAnchor.Stretch;
|
||||
container.Margin = new BorderDouble(5);
|
||||
BorderDouble elementMargin = new BorderDouble(top: 5);
|
||||
|
||||
TextWidget printerMessageOne = new TextWidget("MatterControl will now attempt to auto-detect printer.".Localize(), 0, 0, 10);
|
||||
printerMessageOne.Margin = new BorderDouble(0, 10, 0, 5);
|
||||
printerMessageOne.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerMessageOne.HAnchor = HAnchor.Stretch;
|
||||
printerMessageOne.Margin = elementMargin;
|
||||
var printerMessageOne = new TextWidget("MatterControl will now attempt to auto-detect printer.".Localize(), 0, 0, 10)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
container.AddChild(printerMessageOne);
|
||||
|
||||
string printerMessageTwoTxt = "Disconnect printer".Localize();
|
||||
string printerMessageTwoTxtEnd = "if currently connected".Localize();
|
||||
string printerMessageTwoTxtFull = string.Format("1.) {0} ({1}).", printerMessageTwoTxt, printerMessageTwoTxtEnd);
|
||||
TextWidget printerMessageTwo = new TextWidget(printerMessageTwoTxtFull, 0, 0, 12);
|
||||
printerMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerMessageTwo.HAnchor = HAnchor.Stretch;
|
||||
printerMessageTwo.Margin = elementMargin;
|
||||
var printerMessageTwo = new TextWidget(string.Format("1.) {0} ({1}).", "Disconnect printer".Localize(), "if currently connected".Localize()), 0, 0, 12)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
container.AddChild(printerMessageTwo);
|
||||
|
||||
string printerMessageThreeTxt = "Press".Localize();
|
||||
string printerMessageThreeTxtEnd = "Continue".Localize();
|
||||
string printerMessageThreeFull = string.Format("2.) {0} '{1}'.", printerMessageThreeTxt, printerMessageThreeTxtEnd);
|
||||
TextWidget printerMessageThree = new TextWidget(printerMessageThreeFull, 0, 0, 12);
|
||||
printerMessageThree.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerMessageThree.HAnchor = HAnchor.Stretch;
|
||||
printerMessageThree.Margin = elementMargin;
|
||||
var printerMessageThree = new TextWidget(string.Format("2.) {0} '{1}'.", "Press".Localize(), "Continue".Localize()), 0, 0, 12)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
container.AddChild(printerMessageThree);
|
||||
|
||||
GuiWidget vSpacer = new GuiWidget();
|
||||
vSpacer.VAnchor = VAnchor.Stretch;
|
||||
container.AddChild(vSpacer);
|
||||
|
||||
string setupManualConfigurationOrSkipConnectionText = LocalizedString.Get(("You can also"));
|
||||
string setupManualConfigurationOrSkipConnectionTextFull = String.Format("{0}:", setupManualConfigurationOrSkipConnectionText);
|
||||
TextWidget setupManualConfigurationOrSkipConnectionWidget = new TextWidget(setupManualConfigurationOrSkipConnectionTextFull, 0, 0, 10);
|
||||
setupManualConfigurationOrSkipConnectionWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
setupManualConfigurationOrSkipConnectionWidget.HAnchor = HAnchor.Stretch;
|
||||
setupManualConfigurationOrSkipConnectionWidget.Margin = elementMargin;
|
||||
var setupManualConfigurationOrSkipConnectionWidget = new TextWidget("You can also".Localize() + ":", 0, 0, 10)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
container.AddChild(setupManualConfigurationOrSkipConnectionWidget);
|
||||
|
||||
Button manualLink = linkButtonFactory.Generate("Manually Configure Connection".Localize());
|
||||
manualLink.Margin = new BorderDouble(0, 5);
|
||||
manualLink.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepComPortManual>();
|
||||
WizardWindow.ChangeToPage(new SetupStepComPortManual(printer));
|
||||
});
|
||||
container.AddChild(manualLink);
|
||||
|
||||
string printerMessageFourText = "or".Localize();
|
||||
TextWidget printerMessageFour = new TextWidget(printerMessageFourText, 0, 0, 10);
|
||||
printerMessageFour.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerMessageFour.HAnchor = HAnchor.Stretch;
|
||||
printerMessageFour.Margin = elementMargin;
|
||||
var printerMessageFour = new TextWidget("or".Localize(), 0, 0, 10)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
container.AddChild(printerMessageFour);
|
||||
|
||||
Button skipConnectionLink = linkButtonFactory.Generate("Skip Connection Setup".Localize());
|
||||
skipConnectionLink.Margin = new BorderDouble(0, 8);
|
||||
skipConnectionLink.Click += SkipConnectionLink_Click;
|
||||
|
||||
container.AddChild(printerMessageOne);
|
||||
container.AddChild(printerMessageTwo);
|
||||
container.AddChild(printerMessageThree);
|
||||
container.AddChild(vSpacer);
|
||||
container.AddChild(setupManualConfigurationOrSkipConnectionWidget);
|
||||
container.AddChild(manualLink);
|
||||
container.AddChild(printerMessageFour);
|
||||
container.AddChild(skipConnectionLink);
|
||||
|
||||
container.HAnchor = HAnchor.Stretch;
|
||||
return container;
|
||||
}
|
||||
|
||||
private void SkipConnectionLink_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
UiThread.RunOnIdle(() => {
|
||||
PrinterConnection.Instance.HaltConnectionThread();
|
||||
skipConnectionLink.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
printer.Connection.HaltConnectionThread();
|
||||
Parent.Close();
|
||||
});
|
||||
container.AddChild(skipConnectionLink);
|
||||
|
||||
contentRow.AddChild(container);
|
||||
|
||||
//Construct buttons
|
||||
var nextButton = textImageButtonFactory.Generate("Continue".Localize());
|
||||
nextButton.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage(new SetupStepComPortTwo(printer));
|
||||
});
|
||||
|
||||
this.AddPageAction(nextButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -47,14 +47,16 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
private TextWidget printerErrorMessage;
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
PrinterConnection printerConnection = PrinterConnection.Instance;
|
||||
private PrinterConfig printer;
|
||||
|
||||
public SetupStepComPortTwo()
|
||||
public SetupStepComPortTwo(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
|
||||
startingPortNames = FrostedSerialPort.GetPortNames();
|
||||
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
||||
{
|
||||
cancelButton.Click += (s, e) => printerConnection.HaltConnectionThread();
|
||||
cancelButton.Click += (s, e) => printer.Connection.HaltConnectionThread();
|
||||
|
||||
//Construct buttons
|
||||
nextButton = textImageButtonFactory.Generate("Done".Localize());
|
||||
|
|
@ -77,12 +79,12 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
printerErrorMessage.Text = "Attempting to connect".Localize() + "...";
|
||||
|
||||
ActiveSliceSettings.Instance.Helpers.SetComPort(candidatePort);
|
||||
printerConnection.ConnectToActivePrinter();
|
||||
printer.Connection.ConnectToActivePrinter();
|
||||
connectButton.Visible = false;
|
||||
}
|
||||
};
|
||||
|
||||
printerConnection.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
|
||||
this.AddPageAction(nextButton);
|
||||
this.AddPageAction(connectButton);
|
||||
|
|
@ -131,14 +133,16 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
manualLink.Margin = new BorderDouble(0, 5);
|
||||
manualLink.Click += (s, e) => UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepComPortManual>();
|
||||
WizardWindow.ChangeToPage(new SetupStepComPortManual(printer));
|
||||
});
|
||||
|
||||
printerErrorMessage = new TextWidget("", 0, 0, 10);
|
||||
printerErrorMessage.AutoExpandBoundsToText = true;
|
||||
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
||||
printerErrorMessage.HAnchor = HAnchor.Stretch;
|
||||
printerErrorMessage.Margin = elementMargin;
|
||||
printerErrorMessage = new TextWidget("", 0, 0, 10)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
TextColor = RGBA_Bytes.Red,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = elementMargin
|
||||
};
|
||||
|
||||
container.AddChild(printerMessageOne);
|
||||
container.AddChild(printerMessageFour);
|
||||
|
|
@ -152,7 +156,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
private void onPrinterStatusChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (printerConnection.PrinterIsConnected)
|
||||
if (printer.Connection.PrinterIsConnected)
|
||||
{
|
||||
printerErrorMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerErrorMessage.Text = "Connection succeeded".Localize() + "!";
|
||||
|
|
@ -160,7 +164,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
connectButton.Visible = false;
|
||||
UiThread.RunOnIdle(() => this?.Parent?.Close());
|
||||
}
|
||||
else if (printerConnection.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
else if (printer.Connection.CommunicationState != CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
printerErrorMessage.TextColor = RGBA_Bytes.Red;
|
||||
printerErrorMessage.Text = "Uh-oh! Could not connect to printer.".Localize();
|
||||
|
|
|
|||
|
|
@ -44,62 +44,62 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
private static List<string> printerDrivers = null;
|
||||
|
||||
private FlowLayoutWidget printerDriverContainer;
|
||||
private TextWidget printerDriverMessage;
|
||||
|
||||
private Button installButton;
|
||||
private Button skipButton;
|
||||
|
||||
public SetupStepInstallDriver()
|
||||
private PrinterConfig printer;
|
||||
|
||||
public SetupStepInstallDriver(PrinterConfig printer)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.HeaderText = "Install Communication Driver";
|
||||
|
||||
printerDriverContainer = createPrinterDriverContainer();
|
||||
contentRow.AddChild(printerDriverContainer);
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
//Construct buttons
|
||||
installButton = textImageButtonFactory.Generate("Install Driver".Localize());
|
||||
installButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
bool canContinue = this.InstallDriver();
|
||||
if (canContinue)
|
||||
{
|
||||
WizardWindow.ChangeToSetupBaudOrComPortOne();
|
||||
}
|
||||
});
|
||||
};
|
||||
Margin = new BorderDouble(0, 5),
|
||||
HAnchor = HAnchor.Stretch
|
||||
};
|
||||
|
||||
skipButton = textImageButtonFactory.Generate("Skip".Localize());
|
||||
skipButton.Click += (s, e) => WizardWindow.ChangeToSetupBaudOrComPortOne();
|
||||
printerDriverMessage = new TextWidget("This printer requires a driver for communication.".Localize(), 0, 0, 10)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = new BorderDouble(top: 3)
|
||||
};
|
||||
|
||||
this.AddPageAction(installButton);
|
||||
this.AddPageAction(skipButton);
|
||||
}
|
||||
}
|
||||
|
||||
private FlowLayoutWidget createPrinterDriverContainer()
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
container.Margin = new BorderDouble(0, 5);
|
||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
||||
|
||||
printerDriverMessage = new TextWidget("This printer requires a driver for communication.".Localize(), 0, 0, 10);
|
||||
printerDriverMessage.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerDriverMessage.HAnchor = HAnchor.Stretch;
|
||||
printerDriverMessage.Margin = elementMargin;
|
||||
|
||||
TextWidget printerDriverMessageTwo = new TextWidget("Driver located. Would you like to install?".Localize(), 0, 0, 10);
|
||||
printerDriverMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printerDriverMessageTwo.HAnchor = HAnchor.Stretch;
|
||||
printerDriverMessageTwo.Margin = elementMargin;
|
||||
var printerDriverMessageTwo = new TextWidget("Driver located. Would you like to install?".Localize(), 0, 0, 10)
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Margin = new BorderDouble(top: 3)
|
||||
};
|
||||
|
||||
container.AddChild(printerDriverMessage);
|
||||
container.AddChild(printerDriverMessageTwo);
|
||||
|
||||
container.HAnchor = HAnchor.Stretch;
|
||||
return container;
|
||||
contentRow.AddChild(container);
|
||||
|
||||
//Construct buttons
|
||||
installButton = textImageButtonFactory.Generate("Install Driver".Localize());
|
||||
installButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
bool canContinue = this.InstallDriver();
|
||||
if (canContinue)
|
||||
{
|
||||
WizardWindow.ChangeToSetupBaudOrComPortOne(printer);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
skipButton = textImageButtonFactory.Generate("Skip".Localize());
|
||||
skipButton.Click += (s, e) => WizardWindow.ChangeToSetupBaudOrComPortOne(printer);
|
||||
|
||||
this.AddPageAction(installButton);
|
||||
this.AddPageAction(skipButton);
|
||||
}
|
||||
|
||||
private void InstallDriver(string fileName)
|
||||
|
|
@ -113,10 +113,10 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
Process driverInstallerProcess = new Process();
|
||||
// Prepare the process to run
|
||||
|
||||
|
||||
// Enter in the command line arguments, everything you would enter after the executable name itself
|
||||
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
||||
|
||||
|
||||
// Enter the executable to run, including the complete path
|
||||
string printerDriverInstallerExePathAndFileName = Path.GetFullPath(Path.Combine(".", "InfInstaller.exe"));
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
var driverInstallerProcess = new Process();
|
||||
// Prepare the process to run
|
||||
|
||||
|
||||
// Enter in the command line arguments, everything you would enter after the executable name itself
|
||||
driverInstallerProcess.StartInfo.Arguments = Path.GetFullPath(fileName);
|
||||
|
||||
|
|
@ -185,26 +185,25 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
}
|
||||
}
|
||||
|
||||
public static List<string> PrinterDrivers()
|
||||
public static List<string> PrinterDrivers(PrinterConfig printer)
|
||||
{
|
||||
if (printerDrivers == null)
|
||||
{
|
||||
printerDrivers = GetPrintDrivers();
|
||||
printerDrivers = GetPrintDrivers(printer);
|
||||
}
|
||||
|
||||
return printerDrivers;
|
||||
}
|
||||
|
||||
private static List<string> GetPrintDrivers()
|
||||
private static List<string> GetPrintDrivers(PrinterConfig printer)
|
||||
{
|
||||
var drivers = new List<string>();
|
||||
|
||||
//Determine what if any drivers are needed
|
||||
string infFileNames = ActiveSliceSettings.Instance.GetValue(SettingsKey.windows_driver);
|
||||
string infFileNames = printer.Settings.GetValue(SettingsKey.windows_driver);
|
||||
if (!string.IsNullOrEmpty(infFileNames))
|
||||
{
|
||||
string[] fileNames = infFileNames.Split(',');
|
||||
foreach (string fileName in fileNames)
|
||||
foreach (string fileName in infFileNames.Split(','))
|
||||
{
|
||||
switch (AggContext.OperatingSystem)
|
||||
{
|
||||
|
|
@ -258,7 +257,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
printerDriverMessage.Text = "Installing".Localize() + "...";
|
||||
|
||||
foreach (string driverPath in PrinterDrivers())
|
||||
foreach (string driverPath in PrinterDrivers(printer))
|
||||
{
|
||||
InstallDriver(driverPath);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,8 +104,8 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
bool controlsValid = this.ValidateControls();
|
||||
if (controlsValid)
|
||||
{
|
||||
bool profileCreated = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName);
|
||||
if(!profileCreated)
|
||||
var printer = await ProfileManager.CreateProfileAsync(activeMake, activeModel, activeName);
|
||||
if(printer == null)
|
||||
{
|
||||
this.printerNameError.Text = "Error creating profile".Localize();
|
||||
this.printerNameError.Visible = true;
|
||||
|
|
@ -121,14 +121,14 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepInstallDriver>();
|
||||
WizardWindow.ChangeToPage(new SetupStepInstallDriver(printer));
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
WizardWindow.ChangeToPage<SetupStepComPortOne>();
|
||||
WizardWindow.ChangeToPage(new SetupStepComPortOne(printer));
|
||||
});
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -133,16 +133,16 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
public void LoadFilesFromSD()
|
||||
{
|
||||
if (PrinterConnection.Instance.PrinterIsConnected
|
||||
&& !(PrinterConnection.Instance.PrinterIsPrinting
|
||||
|| PrinterConnection.Instance.PrinterIsPaused))
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsConnected
|
||||
&& !(ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPrinting
|
||||
|| ApplicationController.Instance.ActivePrinter.Connection.PrinterIsPaused))
|
||||
{
|
||||
gotBeginFileList = false;
|
||||
PrinterConnection.Instance.ReadLine.RegisterEvent(GetSdCardList, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ReadLine.RegisterEvent(GetSdCardList, ref unregisterEvents);
|
||||
StringBuilder commands = new StringBuilder();
|
||||
commands.AppendLine("M21"); // Init SD card
|
||||
commands.AppendLine("M20"); // List SD card
|
||||
PrinterConnection.Instance.SendLineToPrinterNow(commands.ToString());
|
||||
ApplicationController.Instance.ActivePrinter.Connection.SendLineToPrinterNow(commands.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
break;
|
||||
|
||||
case "End file list":
|
||||
PrinterConnection.Instance.ReadLine.UnregisterEvent(GetSdCardList, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ReadLine.UnregisterEvent(GetSdCardList, ref unregisterEvents);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace MatterHackers.MatterControl
|
|||
contentRow.AddChild(new TextWidget("3. Press 'Connect'.".Localize(), 0, 0, 12,textColor:ActiveTheme.Instance.PrimaryTextColor));
|
||||
|
||||
//Add inputs to main container
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent(communicationStateChanged, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.CommunicationStateChanged.RegisterEvent(communicationStateChanged, ref unregisterEvents);
|
||||
|
||||
connectButtonContainer = new FlowLayoutWidget()
|
||||
{
|
||||
|
|
@ -139,10 +139,10 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
updateControls(true);
|
||||
}
|
||||
|
||||
|
||||
void ConnectButton_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
PrinterConnection.Instance.ConnectToActivePrinter(true);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.ConnectToActivePrinter(true);
|
||||
}
|
||||
|
||||
void NextButton_Click(object sender, EventArgs mouseEvent)
|
||||
|
|
@ -168,19 +168,19 @@ namespace MatterHackers.MatterControl
|
|||
connectButtonContainer.Visible = false;
|
||||
retryButtonContainer.Visible = false;
|
||||
|
||||
if (PrinterConnection.Instance.PrinterIsConnected)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.PrinterIsConnected)
|
||||
{
|
||||
generalError.Text = "{0}!".FormatWith ("Connection succeeded".Localize ());
|
||||
generalError.Visible = true;
|
||||
nextButton.Visible = true;
|
||||
}
|
||||
else if (firstLoad || PrinterConnection.Instance.CommunicationState == CommunicationStates.Disconnected)
|
||||
else if (firstLoad || ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Disconnected)
|
||||
{
|
||||
generalError.Text = "";
|
||||
connectButton.Visible = true;
|
||||
connectButtonContainer.Visible = true;
|
||||
}
|
||||
else if (PrinterConnection.Instance.CommunicationState == CommunicationStates.AttemptingToConnect)
|
||||
else if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.AttemptingToConnect)
|
||||
{
|
||||
generalError.Text = "{0}...".FormatWith("Attempting to connect".Localize());
|
||||
generalError.Visible = true;
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ namespace MatterHackers.MatterControl
|
|||
this.AddPageAction(nextButton);
|
||||
|
||||
// Register for connection notifications
|
||||
PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent(ConnectionStatusChanged, ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.CommunicationStateChanged.RegisterEvent(ConnectionStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void ConnectionStatusChanged(object test, EventArgs args)
|
||||
{
|
||||
if(PrinterConnection.Instance.CommunicationState == CommunicationStates.Connected && connectToPrinterRow != null)
|
||||
if(ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Connected && connectToPrinterRow != null)
|
||||
{
|
||||
connectToPrinterRow.SetSuccessful();
|
||||
nextButton.Visible = true;
|
||||
|
|
@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl
|
|||
"Connect",
|
||||
"Click the 'Connect' button to retry the original connection attempt",
|
||||
false,
|
||||
() => PrinterConnection.Instance.ConnectToActivePrinter());
|
||||
() => ApplicationController.Instance.ActivePrinter.Connection.ConnectToActivePrinter());
|
||||
|
||||
contentRow.AddChild(connectToPrinterRow);
|
||||
|
||||
|
|
|
|||
|
|
@ -75,12 +75,12 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
public static void ShowComPortSetup()
|
||||
public static void ShowComPortSetup(PrinterConfig printer)
|
||||
{
|
||||
WizardWindow wizardWindow = GetWindow(typeof(SetupStepComPortOne));
|
||||
wizardWindow.Title = "Setup Wizard".Localize();
|
||||
|
||||
wizardWindow.ChangeToPage<SetupStepComPortOne>();
|
||||
wizardWindow.ChangeToPage(new SetupStepComPortOne(printer));
|
||||
}
|
||||
|
||||
public static bool IsOpen(Type type)
|
||||
|
|
@ -133,28 +133,28 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
internal void ChangeToInstallDriverOrComPortOne()
|
||||
internal void ChangeToInstallDriverOrComPortOne(PrinterConfig printer)
|
||||
{
|
||||
if (SetupStepInstallDriver.PrinterDrivers().Count > 0
|
||||
if (SetupStepInstallDriver.PrinterDrivers(printer).Count > 0
|
||||
&& AggContext.OperatingSystem == OSType.Windows)
|
||||
{
|
||||
ChangeToPage<SetupStepInstallDriver>();
|
||||
ChangeToPage(new SetupStepInstallDriver(printer));
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeToPage<SetupStepComPortOne>();
|
||||
ChangeToPage(new SetupStepComPortOne(printer));
|
||||
}
|
||||
}
|
||||
|
||||
internal void ChangeToSetupBaudOrComPortOne()
|
||||
internal void ChangeToSetupBaudOrComPortOne(PrinterConfig printer)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ActiveSliceSettings.Instance?.GetValue(SettingsKey.baud_rate)))
|
||||
if (string.IsNullOrEmpty(printer.Settings.GetValue(SettingsKey.baud_rate)))
|
||||
{
|
||||
ChangeToPage<SetupStepBaudRate>();
|
||||
ChangeToPage(new SetupStepBaudRate(printer));
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeToPage<SetupStepComPortOne>();
|
||||
ChangeToPage(new SetupStepComPortOne(printer));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -436,20 +436,20 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return importSuccessful;
|
||||
}
|
||||
|
||||
internal static async Task<bool> CreateProfileAsync(string make, string model, string printerName)
|
||||
internal static async Task<PrinterConfig> CreateProfileAsync(string make, string model, string printerName)
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
|
||||
var publicDevice = OemSettings.Instance.OemProfiles[make][model];
|
||||
if (publicDevice == null)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
var printerSettings = await LoadOemProfileAsync(publicDevice, make, model);
|
||||
if (printerSettings == null)
|
||||
{
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
printerSettings.ID = guid;
|
||||
|
|
@ -475,9 +475,12 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
// Set as active profile
|
||||
ProfileManager.Instance.LastProfileID = guid;
|
||||
|
||||
var printer = new PrinterConfig(false, printerSettings);
|
||||
ApplicationController.Instance.ActivePrinters.Add(printer);
|
||||
|
||||
ActiveSliceSettings.Instance = printerSettings;
|
||||
|
||||
return true;
|
||||
return printer;
|
||||
}
|
||||
|
||||
public static List<string> ThemeIndexNameMapping = new List<string>()
|
||||
|
|
|
|||
|
|
@ -464,7 +464,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
public string GetMovementSpeedsString()
|
||||
{
|
||||
string presets = "x,3000,y,3000,z,315,e0,150"; // stored x,value,y,value,z,value,e1,value,e2,value,e3,value,...
|
||||
if (PrinterConnection.Instance != null)
|
||||
|
||||
// TODO: How does PrinterConnection null affect movement speeds?
|
||||
if (printerSettings.printer.Connection != null)
|
||||
{
|
||||
string savedSettings = printerSettings.GetValue(SettingsKey.manual_movement_speeds);
|
||||
if (!string.IsNullOrEmpty(savedSettings))
|
||||
|
|
|
|||
|
|
@ -45,12 +45,12 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.WaitForPrintFinished();
|
||||
|
||||
// Wait for expected temp
|
||||
testRunner.Delay(() => PrinterConnection.Instance.GetActualHotendTemperature(0) <= 0, 5);
|
||||
Assert.Less(PrinterConnection.Instance.GetActualHotendTemperature(0), 30);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0) <= 0, 5);
|
||||
Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.GetActualHotendTemperature(0), 30);
|
||||
|
||||
// Wait for expected temp
|
||||
testRunner.Delay(() => PrinterConnection.Instance.ActualBedTemperature <= 10, 5);
|
||||
Assert.Less(PrinterConnection.Instance.ActualBedTemperature, 10);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature <= 10, 5);
|
||||
Assert.Less(ApplicationController.Instance.ActivePrinter.Connection.ActualBedTemperature, 10);
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
|
@ -278,7 +278,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
// Wait for printing to complete
|
||||
var printFinishedResetEvent = new AutoResetEvent(false);
|
||||
PrinterConnection.Instance.PrintFinished.RegisterEvent((s, e) => printFinishedResetEvent.Set(), ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.PrintFinished.RegisterEvent((s, e) => printFinishedResetEvent.Set(), ref unregisterEvents);
|
||||
|
||||
testRunner.ClickByName("Start Print Button");
|
||||
|
||||
|
|
@ -312,7 +312,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);
|
||||
|
||||
// Wait for slicing to complete before setting target values
|
||||
testRunner.Delay(() => PrinterConnection.Instance.DetailedPrintingState == DetailedPrintingState.Printing, 8);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.DetailedPrintingState == DetailedPrintingState.Printing, 8);
|
||||
testRunner.Delay();
|
||||
|
||||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);
|
||||
|
|
@ -369,7 +369,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
testRunner.SwitchToControlsTab();
|
||||
|
||||
var printFinishedResetEvent = new AutoResetEvent(false);
|
||||
PrinterConnection.Instance.PrintFinished.RegisterEvent((s, e) => printFinishedResetEvent.Set(), ref unregisterEvents);
|
||||
ApplicationController.Instance.ActivePrinter.Connection.PrintFinished.RegisterEvent((s, e) => printFinishedResetEvent.Set(), ref unregisterEvents);
|
||||
|
||||
testRunner.ClickByName("Start Print Button");
|
||||
|
||||
|
|
@ -403,7 +403,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
ConfirmExpectedSpeeds(testRunner, targetExtrusionRate, targetFeedRate);
|
||||
|
||||
// Wait for slicing to complete before setting target values
|
||||
testRunner.Delay(() => PrinterConnection.Instance.DetailedPrintingState == DetailedPrintingState.Printing, 8);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.DetailedPrintingState == DetailedPrintingState.Printing, 8);
|
||||
testRunner.Delay();
|
||||
|
||||
// Values should remain after print completes
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Assert.IsTrue(testRunner.NameExists("Start Print Button"));
|
||||
|
||||
int g28Count = 0;
|
||||
foreach(var line in PrinterConnection.Instance.TerminalLog.PrinterLines)
|
||||
foreach(var line in ApplicationController.Instance.ActivePrinter.Connection.TerminalLog.PrinterLines)
|
||||
{
|
||||
if(line.Contains("G28"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -433,12 +433,12 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
public static void WaitForPrintFinished(this AutomationRunner testRunner, int maxSeconds = 500)
|
||||
{
|
||||
testRunner.Delay(() => PrinterConnection.Instance.CommunicationState == CommunicationStates.FinishedPrint, maxSeconds);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.FinishedPrint, maxSeconds);
|
||||
}
|
||||
|
||||
public static void WaitForCommunicationStateDisconnected(this AutomationRunner testRunner, int maxSeconds = 500)
|
||||
{
|
||||
testRunner.Delay(() => PrinterConnection.Instance.CommunicationState == CommunicationStates.Disconnected, maxSeconds);
|
||||
testRunner.Delay(() => ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Disconnected, maxSeconds);
|
||||
}
|
||||
|
||||
public static async Task RunTest(
|
||||
|
|
@ -496,9 +496,9 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
|
||||
await AutomationRunner.ShowWindowAndExecuteTests(matterControlWindow, testMethod, maxTimeToRun, defaultTestImages, config.AutomationInputType, () =>
|
||||
{
|
||||
if (PrinterConnection.Instance.CommunicationState == CommunicationStates.Printing)
|
||||
if (ApplicationController.Instance.ActivePrinter.Connection.CommunicationState == CommunicationStates.Printing)
|
||||
{
|
||||
PrinterConnection.Instance.Disable();
|
||||
ApplicationController.Instance.ActivePrinter.Connection.Disable();
|
||||
}
|
||||
|
||||
MatterControlApplication app = MatterControlApplication.Instance;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue