Table of Contents

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

main MainViewModel

For the language, which the main view model already persists; null in tests.

settings AppSettings

The settings the app runs on, edited in place.

service AppSettingsService

Writes them to disk.

applyConsoleColours Action

Repaints the consoles after a console colour changes.

applyWindowBehavior Action

Applies the tray options after they change.

Properties

CloseToTray

public bool CloseToTray { get; set; }

Property Value

bool

ColorError

[ExcludeFromCodeCoverage]
public string ColorError { get; set; }

Property Value

string

ColorInfo

[ExcludeFromCodeCoverage]
public string ColorInfo { get; set; }

Property Value

string

ColorSuccess

[ExcludeFromCodeCoverage]
public string ColorSuccess { get; set; }

Property Value

string

ColorWarning

[ExcludeFromCodeCoverage]
public string ColorWarning { get; set; }

Property Value

string

ConsoleChatColor

[ExcludeFromCodeCoverage]
public string ConsoleChatColor { get; set; }

Property Value

string

ConsolePlayersColor

[ExcludeFromCodeCoverage]
public string ConsolePlayersColor { get; set; }

Property Value

string

CreateShortcutCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.CreateShortcut().

[ExcludeFromCodeCoverage]
public IRelayCommand CreateShortcutCommand { get; }

Property Value

IRelayCommand

DedicatedServerMachine

Whether the servers may use all the machine's memory but 2 GB, instead of half.

public bool DedicatedServerMachine { get; set; }

Property Value

bool

Remarks

Read at each start: a server already running keeps the ceiling it started with.

HistoryEnabled

[ExcludeFromCodeCoverage]
public bool HistoryEnabled { get; set; }

Property Value

bool

HistoryMaxEvents

[ExcludeFromCodeCoverage]
public decimal HistoryMaxEvents { get; set; }

Property Value

decimal

HistoryRecordChat

[ExcludeFromCodeCoverage]
public bool HistoryRecordChat { get; set; }

Property Value

bool

HistoryRetentionDays

[ExcludeFromCodeCoverage]
public decimal HistoryRetentionDays { get; set; }

Property Value

decimal

HistorySizeText

How much the history takes on disk, for every server together.

public string HistorySizeText { get; }

Property Value

string

IsColorsPage

public bool IsColorsPage { get; }

Property Value

bool

IsGeneralPage

public bool IsGeneralPage { get; }

Property Value

bool

IsNotificationsPage

public bool IsNotificationsPage { get; }

Property Value

bool

IsPlayersPage

public bool IsPlayersPage { get; }

Property Value

bool

Languages

public IReadOnlyList<MainViewModel.LanguageOption> Languages { get; }

Property Value

IReadOnlyList<MainViewModel.LanguageOption>

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

bool

Remarks

Read at each start: a server already running keeps the agent it started with.

MinimizeToTray

public bool MinimizeToTray { get; set; }

Property Value

bool

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

NotificationSettings

Page

[ExcludeFromCodeCoverage]
public SettingsPage Page { get; set; }

Property Value

SettingsPage

ReceiveBetas

Whether the update check offers betas as well as stable versions.

public bool ReceiveBetas { get; set; }

Property Value

bool

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

IRelayCommand

SelectedLanguage

The main view model already persists the language and offers the restart it needs.

public MainViewModel.LanguageOption? SelectedLanguage { get; set; }

Property Value

MainViewModel.LanguageOption

ShortcutStatus

[ExcludeFromCodeCoverage]
public string? ShortcutStatus { get; set; }

Property Value

string

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

IRelayCommand

ShowGeneralCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowGeneral().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowGeneralCommand { get; }

Property Value

IRelayCommand

ShowNotificationsCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowNotifications().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowNotificationsCommand { get; }

Property Value

IRelayCommand

ShowPlayersCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.ShowPlayers().

[ExcludeFromCodeCoverage]
public IRelayCommand ShowPlayersCommand { get; }

Property Value

IRelayCommand

TestNotificationCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.SettingsViewModel.TestNotification().

[ExcludeFromCodeCoverage]
public IRelayCommand TestNotificationCommand { get; }

Property Value

IRelayCommand

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()