public static void LoadStartupProfile() { bool portExists = false; string[] comportNames = FrostedSerialPort.GetPortNames(); var startupProfile = ProfileManager.LoadProfile(UserSettings.Instance.get("ActiveProfileID")); if (startupProfile != null) { portExists = comportNames.Contains(startupProfile.ComPort()); Instance = startupProfile; if (portExists && startupProfile.GetValue <bool>("auto_connect")) { UiThread.RunOnIdle(() => { //PrinterConnectionAndCommunication.Instance.HaltConnectionThread(); PrinterConnectionAndCommunication.Instance.ConnectToActivePrinter(); }, 2); } } if (Instance == null) { // Load an empty profile with just the MatterHackers base settings from config.json Instance = ProfileManager.LoadEmptyProfile(); } }
internal static void SwitchToProfile(string printerID) { var profile = ProfileManager.LoadProfile(printerID); UserSettings.Instance.set("ActiveProfileID", printerID); Instance = profile ?? ProfileManager.LoadEmptyProfile(); }
public void SetMarkedForDelete(bool markedForDelete) { var printerInfo = ProfileManager.Instance.ActiveProfile; if (printerInfo != null) { printerInfo.MarkedForDelete = markedForDelete; ProfileManager.Instance.Save(); } // Clear selected printer state UserSettings.Instance.set("ActiveProfileID", ""); UiThread.RunOnIdle(() => ActiveSliceSettings.Instance = ProfileManager.LoadEmptyProfile()); }
public async static Task <PrinterSettings> RecoverProfile(PrinterInfo printerInfo) { bool userIsLoggedIn = !ShouldShowAuthPanel?.Invoke() ?? false; if (userIsLoggedIn && printerInfo != null) { // Attempt to load from MCWS history var printerSettings = await GetFirstValidHistoryItem(printerInfo); if (printerSettings == null) { // Fall back to OemProfile defaults if load from history fails printerSettings = RestoreFromOemProfile(printerInfo); } if (printerSettings == null) { // If we still have failed to recover a profile, create an empty profile with // just enough data to delete the printer printerSettings = ProfileManager.LoadEmptyProfile(); printerSettings.ID = printerInfo.ID; printerSettings.UserLayer[SettingsKey.device_token] = printerInfo.DeviceToken; printerSettings.Helpers.SetComPort(printerInfo.ComPort); printerSettings.SetValue(SettingsKey.printer_name, printerInfo.Name); // Add any setting value to the OemLayer to pass the .PrinterSelected property printerSettings.OemLayer = new PrinterSettingsLayer(); printerSettings.OemLayer.Add("empty", "setting"); printerSettings.Save(); } if (printerSettings != null) { // Persist any profile recovered above as the current printerSettings.Save(); // Update active instance without calling ReloadAll ActiveSliceSettings.RefreshActiveInstance(printerSettings); WarnAboutRevert(printerInfo); } return(printerSettings); } return(null); }
public void SetMarkedForDelete(bool markedForDelete) { var printerInfo = ProfileManager.Instance.ActiveProfile; if (printerInfo != null) { printerInfo.MarkedForDelete = markedForDelete; ProfileManager.Instance.Save(); } // Clear selected printer state UserSettings.Instance.set("ActiveProfileID", ""); UiThread.RunOnIdle(() => { ActiveSliceSettings.Instance = ProfileManager.LoadEmptyProfile(); // Notify listeners of a ProfileListChange event due to this printers removal ProfileManager.ProfilesListChanged.CallEvents(this, null); // Force sync after marking for delete ApplicationController.SyncPrinterProfiles(null); }); }
internal static async Task SwitchToProfile(string printerID) { ProfileManager.Instance.SetLastProfile(printerID); Instance = (await ProfileManager.LoadProfileAsync(printerID)) ?? ProfileManager.LoadEmptyProfile(); }
static ActiveSliceSettings() { // Load last profile or fall back to empty Instance = ProfileManager.Instance?.LoadLastProfileWithoutRecovery() ?? ProfileManager.LoadEmptyProfile(); }