Move last selected profile management into ProfileManager
- Multi-user support: store the value in a user specific key
This commit is contained in:
parent
a8598abafe
commit
be3eed0f5d
3 changed files with 28 additions and 6 deletions
|
|
@ -135,7 +135,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
string[] comportNames = FrostedSerialPort.GetPortNames();
|
||||
|
||||
var startupProfile = ProfileManager.LoadProfile(UserSettings.Instance.get("ActiveProfileID"));
|
||||
var startupProfile = ProfileManager.Instance.LoadLastProfile();
|
||||
if (startupProfile != null)
|
||||
{
|
||||
portExists = comportNames.Contains(startupProfile.ComPort());
|
||||
|
|
@ -162,9 +162,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
var profile = ProfileManager.LoadProfile(printerID);
|
||||
|
||||
UserSettings.Instance.set("ActiveProfileID", printerID);
|
||||
|
||||
UserSettings.Instance.set("ActiveUserName", ApplicationController.Instance.GetSessionUsernameForFileSystem());
|
||||
ProfileManager.Instance.SetLastProfile(printerID);
|
||||
|
||||
Instance = profile ?? ProfileManager.LoadEmptyProfile();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,6 +157,30 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return new SettingsProfile(printerSettings);
|
||||
}
|
||||
|
||||
public string LastProfileID
|
||||
{
|
||||
get
|
||||
{
|
||||
string activeUserName = UserSettings.Instance.get("ActiveUserName");
|
||||
string settingsKey = $"ActiveProfileID-{activeUserName}";
|
||||
|
||||
return UserSettings.Instance.get(settingsKey);
|
||||
}
|
||||
}
|
||||
|
||||
public SettingsProfile LoadLastProfile()
|
||||
{
|
||||
return LoadProfile(this.LastProfileID);
|
||||
}
|
||||
|
||||
public void SetLastProfile(string printerID)
|
||||
{
|
||||
string activeUserName = UserSettings.Instance.get("ActiveUserName");
|
||||
string settingsKey = $"ActiveProfileID-{activeUserName}";
|
||||
|
||||
UserSettings.Instance.set(settingsKey, printerID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the specified SettingsProfile
|
||||
/// </summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue