Moving the ActivePrinterChanged call back and Active Printer calls all into ActivePrinterProfile
This commit is contained in:
parent
5036b364c0
commit
0040895615
21 changed files with 102 additions and 98 deletions
|
|
@ -159,7 +159,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
//this.AnchorAll();
|
||||
this.AddChild(textContainer);
|
||||
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
@ -194,9 +194,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
string statusString = new LocalizedString("Status: {0}").Translated;
|
||||
printerStatusText.Text = string.Format(statusString, PrinterCommunication.Instance.PrinterConnectionStatusVerbose);
|
||||
}
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
printerNameText.Text = PrinterCommunication.Instance.ActivePrinter.Name;
|
||||
printerNameText.Text = ActivePrinterProfile.Instance.ActivePrinter.Name;
|
||||
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ namespace MatterHackers.MatterControl
|
|||
event EventHandler unregisterEvents;
|
||||
private void AddHandlers()
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private string getHelpMessageFromStatus()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
return new LocalizedString("No printer selected. Press 'Connect' to choose a printer.").Translated;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
event EventHandler unregisterEvents;
|
||||
protected override void AddHandlers()
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(ReloadPrinterSelectionWidget, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(ReloadPrinterSelectionWidget, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
if (buttonClicked.Enabled)
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
OpenConnectionWindow();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,14 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO.Ports;
|
||||
using System.Threading;
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Globalization;
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
|
|
@ -18,6 +23,8 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
static ActivePrinterProfile globalInstance = null;
|
||||
|
||||
public RootedObjectEventHandler ActivePrinterChanged = new RootedObjectEventHandler();
|
||||
|
||||
// private so that it can only be gotten through the Instance
|
||||
ActivePrinterProfile()
|
||||
{
|
||||
|
|
@ -43,9 +50,45 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
PrinterCommunication.Instance.Disable();
|
||||
globalInstance = value;
|
||||
PrinterCommunication.Instance.OnActivePrinterChanged(null);
|
||||
globalInstance.OnActivePrinterChanged(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnActivePrinterChanged(EventArgs e)
|
||||
{
|
||||
ActivePrinterChanged.CallEvents(this, e);
|
||||
}
|
||||
|
||||
public static void CheckForAndDoAutoConnect()
|
||||
{
|
||||
DataStorage.Printer autoConnectProfile = ActivePrinterProfile.GetAutoConnectProfile();
|
||||
if (autoConnectProfile != null)
|
||||
{
|
||||
ActivePrinterProfile.Instance.ActivePrinter = autoConnectProfile;
|
||||
PrinterCommunication.Instance.HaltConnectionThread();
|
||||
PrinterCommunication.Instance.ConnectToActivePrinter();
|
||||
}
|
||||
}
|
||||
|
||||
public static DataStorage.Printer GetAutoConnectProfile()
|
||||
{
|
||||
string query = string.Format("SELECT * FROM Printer;");
|
||||
IEnumerable<Printer> printer_profiles = (IEnumerable<Printer>)Datastore.Instance.dbSQLite.Query<Printer>(query);
|
||||
string[] comportNames = SerialPort.GetPortNames();
|
||||
|
||||
foreach (DataStorage.Printer printer in printer_profiles)
|
||||
{
|
||||
if (printer.AutoConnectFlag)
|
||||
{
|
||||
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
||||
if (portIsAvailable)
|
||||
{
|
||||
return printer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,8 +40,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
|
||||
doLayout();
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void doLayout()
|
||||
|
|
@ -76,7 +75,7 @@ namespace MatterHackers.MatterControl
|
|||
topToBottom.AddChild(exportSTL);
|
||||
}
|
||||
|
||||
bool showExportGCodeButton = PrinterCommunication.Instance.ActivePrinter != null || partIsGCode;
|
||||
bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;
|
||||
|
||||
if(showExportGCodeButton)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl
|
|||
public MainSlidePanel()
|
||||
: base(2)
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
||||
|
||||
// do the front panel stuff
|
||||
{
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace MatterHackers.MatterControl
|
|||
UseOpenGL = true;
|
||||
Title = "MatterControl (beta)";
|
||||
|
||||
PrinterCommunication.Instance.Initialize();
|
||||
ActivePrinterProfile.CheckForAndDoAutoConnect();
|
||||
UiThread.RunOnIdle(CheckOnPrinter);
|
||||
|
||||
ShowAsSystemWindow();
|
||||
|
|
|
|||
|
|
@ -35,8 +35,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
|
||||
doLayout();
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(reloadAfterPrinterProfileChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
public void doLayout()
|
||||
|
|
@ -66,7 +65,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
topToBottom.AddChild(exportSTL);
|
||||
}
|
||||
|
||||
bool showExportGCodeButton = PrinterCommunication.Instance.ActivePrinter != null || partIsGCode;
|
||||
bool showExportGCodeButton = ActivePrinterProfile.Instance.ActivePrinter != null || partIsGCode;
|
||||
|
||||
if (showExportGCodeButton)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
bool exportGCodeToFolderButton_Click()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
UiThread.RunOnIdle(MustSelectPrinterMessage);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public string ConnectionFailureMessage { get { return connectionFailureMessage; } }
|
||||
|
||||
public RootedObjectEventHandler ActivePrinterChanged = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler ActivePrintItemChanged = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler BedTemperatureRead = new RootedObjectEventHandler();
|
||||
public RootedObjectEventHandler BedTemperatureSet = new RootedObjectEventHandler();
|
||||
|
|
@ -205,37 +204,6 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
Thread sendGCodeToPrinterThread;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
DataStorage.Printer autoConnectProfile = GetAutoConnectProfile();
|
||||
if (autoConnectProfile != null)
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinter = autoConnectProfile;
|
||||
PrinterCommunication.Instance.HaltConnectionThread();
|
||||
PrinterCommunication.Instance.ConnectToActivePrinter();
|
||||
}
|
||||
}
|
||||
|
||||
private DataStorage.Printer GetAutoConnectProfile()
|
||||
{
|
||||
string query = string.Format("SELECT * FROM Printer;");
|
||||
IEnumerable<Printer> printer_profiles = (IEnumerable<Printer>)Datastore.Instance.dbSQLite.Query<Printer>(query);
|
||||
string[] comportNames = SerialPort.GetPortNames();
|
||||
|
||||
foreach (DataStorage.Printer printer in printer_profiles)
|
||||
{
|
||||
if (printer.AutoConnectFlag)
|
||||
{
|
||||
bool portIsAvailable = comportNames.Contains(printer.ComPort);
|
||||
if (portIsAvailable)
|
||||
{
|
||||
return printer;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool DoPrintLeveling
|
||||
{
|
||||
get
|
||||
|
|
@ -406,7 +374,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
public Printer ActivePrinter
|
||||
private Printer ActivePrinter
|
||||
{
|
||||
get
|
||||
{
|
||||
|
|
@ -1355,11 +1323,6 @@ namespace MatterHackers.MatterControl
|
|||
FanSpeedSet.CallEvents(this, e);
|
||||
}
|
||||
|
||||
public void OnActivePrinterChanged(EventArgs e)
|
||||
{
|
||||
ActivePrinterChanged.CallEvents(this, e);
|
||||
}
|
||||
|
||||
void OnActivePrintItemChanged(EventArgs e)
|
||||
{
|
||||
ActivePrintItemChanged.CallEvents(this, e);
|
||||
|
|
|
|||
|
|
@ -214,10 +214,10 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
void initMacro()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
windowController.ActiveMacro = new CustomCommands();
|
||||
windowController.ActiveMacro.PrinterId = PrinterCommunication.Instance.ActivePrinter.Id;
|
||||
windowController.ActiveMacro.PrinterId = ActivePrinterProfile.Instance.ActivePrinter.Id;
|
||||
windowController.ActiveMacro.Name = "Home All";
|
||||
windowController.ActiveMacro.Value = "G28 ; Home All Axes";
|
||||
}
|
||||
|
|
@ -356,10 +356,10 @@ namespace MatterHackers.MatterControl
|
|||
IEnumerable<DataStorage.CustomCommands> GetMacros()
|
||||
{
|
||||
IEnumerable<DataStorage.CustomCommands> results = Enumerable.Empty<DataStorage.CustomCommands>();
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
//Retrieve a list of saved printers from the Datastore
|
||||
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", PrinterCommunication.Instance.ActivePrinter.Id);
|
||||
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
|
||||
results = (IEnumerable<DataStorage.CustomCommands>)DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.CustomCommands>(query);
|
||||
return results;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,10 +161,10 @@ namespace MatterHackers.MatterControl
|
|||
IEnumerable<DataStorage.CustomCommands> GetMacros()
|
||||
{
|
||||
IEnumerable<DataStorage.CustomCommands> results = Enumerable.Empty<DataStorage.CustomCommands>();
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
//Retrieve a list of saved printers from the Datastore
|
||||
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", PrinterCommunication.Instance.ActivePrinter.Id);
|
||||
string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActivePrinterProfile.Instance.ActivePrinter.Id);
|
||||
results = (IEnumerable<DataStorage.CustomCommands>)DataStorage.Datastore.Instance.dbSQLite.Query<DataStorage.CustomCommands>(query);
|
||||
return results;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -161,9 +161,9 @@ namespace MatterHackers.MatterControl
|
|||
static string GetMovementSpeedsString()
|
||||
{
|
||||
string presets = "x,3000,y,3000,z,315,e0,150"; // stored x,y,z,e1,e2,e3,...
|
||||
if (PrinterCommunication.Instance != null && PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (PrinterCommunication.Instance != null && ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
string savedSettings = PrinterCommunication.Instance.ActivePrinter.ManualMovementSpeeds;
|
||||
string savedSettings = ActivePrinterProfile.Instance.ActivePrinter.ManualMovementSpeeds;
|
||||
if (savedSettings != null && savedSettings != "")
|
||||
{
|
||||
presets = savedSettings;
|
||||
|
|
@ -178,8 +178,8 @@ namespace MatterHackers.MatterControl
|
|||
StringEventArgs stringEvent = e as StringEventArgs;
|
||||
if (stringEvent != null && stringEvent.Data != null)
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinter.ManualMovementSpeeds = stringEvent.Data;
|
||||
PrinterCommunication.Instance.ActivePrinter.Commit();
|
||||
ActivePrinterProfile.Instance.ActivePrinter.ManualMovementSpeeds = stringEvent.Data;
|
||||
ActivePrinterProfile.Instance.ActivePrinter.Commit();
|
||||
MainSlidePanel.Instance.ReloadBackPanel();
|
||||
}
|
||||
}
|
||||
|
|
@ -211,7 +211,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
sdCardManagerContainer = new DisablablableWidget();
|
||||
sdCardManagerContainer.AddChild(CreateSdCardManagerContainer());
|
||||
if (false)// || PrinterCommunication.Instance.ActivePrinter == null || PrinterCommunication.Instance.ActivePrinter.GetFeatures().HasSdCard())
|
||||
if (false)// || ActivePrinterProfile.Instance.ActivePrinter == null || ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasSdCard())
|
||||
{
|
||||
controlsTopToBottomLayout.AddChild(sdCardManagerContainer);
|
||||
}
|
||||
|
|
@ -253,8 +253,8 @@ namespace MatterHackers.MatterControl
|
|||
fanControlsContainer = new DisablablableWidget();
|
||||
fanControlsContainer.AddChild(fanControlsGroupBox);
|
||||
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null
|
||||
|| PrinterCommunication.Instance.ActivePrinter.GetFeatures().HasFan())
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null
|
||||
|| ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasFan())
|
||||
{
|
||||
controlsTopToBottomLayout.AddChild(fanControlsContainer);
|
||||
}
|
||||
|
|
@ -320,8 +320,8 @@ namespace MatterHackers.MatterControl
|
|||
bedTemperatureControlWidget = new DisablablableWidget();
|
||||
bedTemperatureControlWidget.AddChild(new BedTemperatureControlWidget());
|
||||
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null
|
||||
|| PrinterCommunication.Instance.ActivePrinter.GetFeatures().HasHeatedBed())
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null
|
||||
|| ActivePrinterProfile.Instance.ActivePrinter.GetFeatures().HasHeatedBed())
|
||||
{
|
||||
temperatureControlContainer.AddChild(bedTemperatureControlWidget);
|
||||
}
|
||||
|
|
@ -527,7 +527,7 @@ namespace MatterHackers.MatterControl
|
|||
PrinterCommunication.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
||||
{
|
||||
doLevelingCheckBox.Checked = PrinterCommunication.Instance.DoPrintLeveling;
|
||||
if (doLevelingCheckBox.Checked && PrinterCommunication.Instance.ActivePrinter.PrintLevelingProbePositions == null)
|
||||
if (doLevelingCheckBox.Checked && ActivePrinterProfile.Instance.ActivePrinter.PrintLevelingProbePositions == null)
|
||||
{
|
||||
//OpenPrintLevelWizard();
|
||||
}
|
||||
|
|
@ -643,7 +643,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void SetVisibleControls()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
// no printer selected
|
||||
extruderTemperatureControlWidget.SetEnableLevel(DisablablableWidget.EnableLevel.Disabled);
|
||||
|
|
|
|||
|
|
@ -56,9 +56,9 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
availableText = "";
|
||||
}
|
||||
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
int connectedPrinterHash = PrinterCommunication.Instance.ActivePrinter.GetHashCode();
|
||||
int connectedPrinterHash = ActivePrinterProfile.Instance.ActivePrinter.GetHashCode();
|
||||
int printerOptionHash = printerRecord.GetHashCode();
|
||||
if (connectedPrinterHash == printerOptionHash)
|
||||
{
|
||||
|
|
@ -92,7 +92,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
if (this.PositionWithinLocalBounds(mouseEvent.X, mouseEvent.Y))
|
||||
{
|
||||
UiThread.RunOnIdle(CloseOnIdle);
|
||||
PrinterCommunication.Instance.ActivePrinter = this.printerRecord;
|
||||
ActivePrinterProfile.Instance.ActivePrinter = this.printerRecord;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -172,17 +172,17 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
void RemoveConnectionLink_Click(object sender, MouseEventArgs mouseEvent)
|
||||
{
|
||||
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
int connectedPrinterHash = PrinterCommunication.Instance.ActivePrinter.GetHashCode();
|
||||
int connectedPrinterHash = ActivePrinterProfile.Instance.ActivePrinter.GetHashCode();
|
||||
int printerOptionHash = this.printerRecord.GetHashCode();
|
||||
|
||||
//Disconnect printer if the printer being removed is currently connected
|
||||
if (connectedPrinterHash == printerOptionHash)
|
||||
{
|
||||
PrinterCommunication.Instance.Disable();
|
||||
PrinterCommunication.Instance.ActivePrinter = null;
|
||||
ActivePrinterProfile.Instance.ActivePrinter = null;
|
||||
}
|
||||
}
|
||||
this.printerRecord.Delete();
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
protected void SaveAndExit()
|
||||
{
|
||||
this.ActivePrinter.Commit();
|
||||
PrinterCommunication.Instance.ActivePrinter = this.ActivePrinter;
|
||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
||||
this.containerWindowToClose.Close();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
string printerComPortErrorLbl = new LocalizedString("Attempting to connect").Translated;
|
||||
string printerComPortErrorLblFull = string.Format("{0}...",printerComPortErrorLbl);
|
||||
printerComPortError.Text = printerComPortErrorLblFull;
|
||||
PrinterCommunication.Instance.ActivePrinter = this.ActivePrinter;
|
||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
||||
PrinterCommunication.Instance.ConnectToActivePrinter();
|
||||
connectButton.Visible = false;
|
||||
refreshButton.Visible = false;
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
string printerErrorMessageLblTwoFull = string.Format("{0}...",printerErrorMessageLblTwo);
|
||||
printerErrorMessage.Text = printerErrorMessageLblTwoFull;
|
||||
this.ActivePrinter.Commit();
|
||||
PrinterCommunication.Instance.ActivePrinter = this.ActivePrinter;
|
||||
ActivePrinterProfile.Instance.ActivePrinter = this.ActivePrinter;
|
||||
PrinterCommunication.Instance.ConnectToActivePrinter();
|
||||
connectButton.Visible = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl
|
|||
#if false
|
||||
SetBedLevelEquation(0, 0, 0);
|
||||
#else
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
PrintLeveling.Instance.SetPrintLevelingEquation(
|
||||
PrinterCommunication.Instance.GetPrintLevelingProbePosition(0),
|
||||
|
|
@ -315,22 +315,22 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public void LoadPrinterConfigurationSettings()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
DataStorage.SliceSettingsCollection collection;
|
||||
if (PrinterCommunication.Instance.ActivePrinter.DefaultSettingsCollectionId != 0)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId != 0)
|
||||
{
|
||||
int activePrinterSettingsID = PrinterCommunication.Instance.ActivePrinter.DefaultSettingsCollectionId;
|
||||
int activePrinterSettingsID = ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId;
|
||||
collection = DataStorage.Datastore.Instance.dbSQLite.Table<DataStorage.SliceSettingsCollection>().Where(v => v.Id == activePrinterSettingsID).Take(1).FirstOrDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
collection = new DataStorage.SliceSettingsCollection();
|
||||
collection.Name = PrinterCommunication.Instance.ActivePrinter.Name;
|
||||
collection.Name = ActivePrinterProfile.Instance.ActivePrinter.Name;
|
||||
collection.Commit();
|
||||
|
||||
PrinterCommunication.Instance.ActivePrinter.DefaultSettingsCollectionId = collection.Id;
|
||||
PrinterCommunication.Instance.ActivePrinter.Commit();
|
||||
ActivePrinterProfile.Instance.ActivePrinter.DefaultSettingsCollectionId = collection.Id;
|
||||
ActivePrinterProfile.Instance.ActivePrinter.Commit();
|
||||
}
|
||||
SettingsLayer printerSettingsLayer = LoadConfigurationSettingsFromDatastore(collection);
|
||||
this.activeSettingsLayers.Add(printerSettingsLayer);
|
||||
|
|
|
|||
|
|
@ -259,13 +259,13 @@ namespace MatterHackers.MatterControl
|
|||
void SetStatusDisplay()
|
||||
{
|
||||
string settingsLayerDescription;
|
||||
if (PrinterCommunication.Instance.ActivePrinter == null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
settingsLayerDescription = "Default Settings";
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsLayerDescription = PrinterCommunication.Instance.ActivePrinter.Name;
|
||||
settingsLayerDescription = ActivePrinterProfile.Instance.ActivePrinter.Name;
|
||||
}
|
||||
settingsStatusDescription.Text = string.Format("{0}", settingsLayerDescription);
|
||||
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ namespace MatterHackers.MatterControl
|
|||
private void AddHandlers()
|
||||
{
|
||||
PrinterCommunication.Instance.ConnectionStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
|
|
@ -255,7 +255,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void SetVisibleControls()
|
||||
{
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
categoryTabs.Visible = true;
|
||||
settingsControlBar.Visible = true;
|
||||
|
|
@ -678,7 +678,7 @@ namespace MatterHackers.MatterControl
|
|||
private void SaveSetting(string slicerConfigName, string value)
|
||||
{
|
||||
//Hacky solution prevents saves when no printer is loaded
|
||||
if (PrinterCommunication.Instance.ActivePrinter != null)
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter != null)
|
||||
{
|
||||
SliceSettingsLayerSelector.Instance.SaveSetting(slicerConfigName, value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace MatterHackers.MatterControl
|
|||
public WidescreenPanel()
|
||||
: base()
|
||||
{
|
||||
PrinterCommunication.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
||||
ActivePrinterProfile.Instance.ActivePrinterChanged.RegisterEvent(LoadSettingsOnPrinterChanged, ref unregisterEvents);
|
||||
|
||||
// do the front panel stuff
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue