diff --git a/ActivePrinterProfile.cs b/ActivePrinterProfile.cs
new file mode 100644
index 000000000..22c5550da
--- /dev/null
+++ b/ActivePrinterProfile.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Diagnostics;
+using System.Text;
+using System.IO;
+
+using MatterHackers.Agg;
+using MatterHackers.Agg.UI;
+using MatterHackers.VectorMath;
+using MatterHackers.MatterControl.ContactForm;
+using MatterHackers.MatterControl.DataStorage;
+using MatterHackers.Localizations;
+
+namespace MatterHackers.MatterControl
+{
+ public class ActivePrinterProfile
+ {
+ static ActivePrinterProfile globalInstance = null;
+
+ // private so that it can only be gotten through the Instance
+ ActivePrinterProfile()
+ {
+ }
+
+ public Printer ActivePrinter { get; set; }
+
+ public static ActivePrinterProfile Instance
+ {
+ get
+ {
+ if (globalInstance == null)
+ {
+ globalInstance = new ActivePrinterProfile();
+ }
+
+ return globalInstance;
+ }
+
+ set
+ {
+ if (globalInstance != value)
+ {
+ PrinterCommunication.Instance.Disable();
+ globalInstance = value;
+ PrinterCommunication.Instance.OnActivePrinterChanged(null);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/MatterControl.csproj b/MatterControl.csproj
index 2d009ad14..0c5d9fb07 100644
--- a/MatterControl.csproj
+++ b/MatterControl.csproj
@@ -72,6 +72,7 @@
+
diff --git a/PrinterCommunication.cs b/PrinterCommunication.cs
index f23325f90..221e12312 100644
--- a/PrinterCommunication.cs
+++ b/PrinterCommunication.cs
@@ -198,7 +198,6 @@ namespace MatterHackers.MatterControl
Thread readFromPrinterThread;
Thread connectThread;
- private Printer activePrinter;
private PrintItemWrapper activePrintItem;
int lastRemainingSecondsReported = 0;
@@ -411,17 +410,11 @@ namespace MatterHackers.MatterControl
{
get
{
- return this.activePrinter;
+ return ActivePrinterProfile.Instance.ActivePrinter;
}
set
{
- if (this.activePrinter != value)
- {
- Disable();
- this.activePrinter = value;
- this.CommunicationState = CommunicationStates.Disconnected;
- OnActivePrinterChanged(null);
- }
+ ActivePrinterProfile.Instance.ActivePrinter = value;
}
}
@@ -1362,7 +1355,7 @@ namespace MatterHackers.MatterControl
FanSpeedSet.CallEvents(this, e);
}
- void OnActivePrinterChanged(EventArgs e)
+ public void OnActivePrinterChanged(EventArgs e)
{
ActivePrinterChanged.CallEvents(this, e);
}
diff --git a/SliceConfiguration/ActiveSliceSettings.cs b/SliceConfiguration/ActiveSliceSettings.cs
index a725d4f65..9f4148d78 100644
--- a/SliceConfiguration/ActiveSliceSettings.cs
+++ b/SliceConfiguration/ActiveSliceSettings.cs
@@ -67,6 +67,7 @@ namespace MatterHackers.MatterControl
SettingsChanged.CallEvents(this, null);
}
+ // private so that it can only be gotten through the Instance
ActiveSliceSettings()
{
}