Class SettingsViewModel
- Namespace
- McServerLauncher.ViewModels
- Assembly
- McServerLauncher.dll
The settings screen: language, window behaviour, the desktop shortcut, notifications, colours and the player history.
public class SettingsViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
- Inheritance
-
SettingsViewModel
- Implements
- Inherited Members
Remarks
It used to be a dialog with Cancel and Save, editing a copy. As a screen of the app it saves as it goes: every change lands in the one AppSettings the app runs on and is written to disk straight away, so there is no "did I save that?" and nothing to lose by switching away.
The one thing not saved as typed is a colour that is not a colour yet. #E0 is what a box
holds half way through typing #E05561; written to disk it would come back next launch as
a broken value. The box keeps what was typed; the file only ever gets something drawable.
Constructors
SettingsViewModel(MainViewModel?, AppSettings, AppSettingsService, Action, Action)
public SettingsViewModel(MainViewModel? main, AppSettings settings, AppSettingsService service, Action applyConsoleColours, Action applyWindowBehavior)
Parameters
mainMainViewModelFor the language, which the main view model already persists; null in tests.
settingsAppSettingsThe settings the app runs on, edited in place.
serviceAppSettingsServiceWrites them to disk.
applyConsoleColoursActionRepaints the consoles after a console colour changes.
applyWindowBehaviorActionApplies the tray options after they change.
Properties
CloseToTray
public bool CloseToTray { get; set; }
Property Value
ColorError
[ExcludeFromCodeCoverage]
public string ColorError { get; set; }
Property Value
ColorInfo
[ExcludeFromCodeCoverage]
public string ColorInfo { get; set; }
Property Value
ColorSuccess
[ExcludeFromCodeCoverage]
public string ColorSuccess { get; set; }
Property Value
ColorWarning
[ExcludeFromCodeCoverage]
public string ColorWarning { get; set; }
Property Value
ConsoleChatColor
[ExcludeFromCodeCoverage]
public string ConsoleChatColor { get; set; }
Property Value
ConsolePlayersColor
[ExcludeFromCodeCoverage]
public string ConsolePlayersColor { get; set; }
Property Value
CreateShortcutCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.CreateShortcut().
[ExcludeFromCodeCoverage]
public IRelayCommand CreateShortcutCommand { get; }
Property Value
DedicatedServerMachine
Whether the servers may use all the machine's memory but 2 GB, instead of half.
public bool DedicatedServerMachine { get; set; }
Property Value
Remarks
Read at each start: a server already running keeps the ceiling it started with.
HistoryEnabled
[ExcludeFromCodeCoverage]
public bool HistoryEnabled { get; set; }
Property Value
HistoryMaxEvents
[ExcludeFromCodeCoverage]
public decimal HistoryMaxEvents { get; set; }
Property Value
HistoryRecordChat
[ExcludeFromCodeCoverage]
public bool HistoryRecordChat { get; set; }
Property Value
HistoryRetentionDays
[ExcludeFromCodeCoverage]
public decimal HistoryRetentionDays { get; set; }
Property Value
HistorySizeText
How much the history takes on disk, for every server together.
public string HistorySizeText { get; }
Property Value
IsColorsPage
public bool IsColorsPage { get; }
Property Value
IsGeneralPage
public bool IsGeneralPage { get; }
Property Value
IsNotificationsPage
public bool IsNotificationsPage { get; }
Property Value
IsPlayersPage
public bool IsPlayersPage { get; }
Property Value
Languages
public IReadOnlyList<MainViewModel.LanguageOption> Languages { get; }
Property Value
MemoryAgentEnabled
Whether the memory agent may hold a server's heap tighter while the PC is short of memory.
public bool MemoryAgentEnabled { get; set; }
Property Value
Remarks
Read at each start: a server already running keeps the agent it started with.
MinimizeToTray
public bool MinimizeToTray { get; set; }
Property Value
Notifications
The live notification settings: the same object Global points at, so a switch flipped here takes effect on the next notification without any copying.
public NotificationSettings Notifications { get; }
Property Value
Page
[ExcludeFromCodeCoverage]
public SettingsPage Page { get; set; }
Property Value
ReceiveBetas
Whether the update check offers betas as well as stable versions.
public bool ReceiveBetas { get; set; }
Property Value
Remarks
Asks again straight away, so the answer on screen follows the switch: turning it off takes back a beta already being offered, and turning it on shows one that is there.
ResetColorsCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ResetColors().
[ExcludeFromCodeCoverage]
public IRelayCommand ResetColorsCommand { get; }
Property Value
SelectedLanguage
The main view model already persists the language and offers the restart it needs.
public MainViewModel.LanguageOption? SelectedLanguage { get; set; }
Property Value
ShortcutStatus
[ExcludeFromCodeCoverage]
public string? ShortcutStatus { get; set; }
Property Value
ShortcutStatusBrush
[ExcludeFromCodeCoverage]
public IBrush? ShortcutStatusBrush { get; set; }
Property Value
- IBrush
ShowColorsCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowColors().
[ExcludeFromCodeCoverage]
public IRelayCommand ShowColorsCommand { get; }
Property Value
ShowGeneralCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowGeneral().
[ExcludeFromCodeCoverage]
public IRelayCommand ShowGeneralCommand { get; }
Property Value
ShowNotificationsCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowNotifications().
[ExcludeFromCodeCoverage]
public IRelayCommand ShowNotificationsCommand { get; }
Property Value
ShowPlayersCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowPlayers().
[ExcludeFromCodeCoverage]
public IRelayCommand ShowPlayersCommand { get; }
Property Value
TestNotificationCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.TestNotification().
[ExcludeFromCodeCoverage]
public IRelayCommand TestNotificationCommand { get; }
Property Value
Methods
Persist()
Writes the settings as they stand. Called after every change, including the notification switches the view binds straight to the model.
public void Persist()