Table of Contents

Class MainViewModel

Namespace
McServerLauncher.ViewModels
Assembly
McServerLauncher.dll

Main ViewModel: manages the server list, the selected server and persistence.

public class MainViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
Inheritance
MainViewModel
Implements
Inherited Members

Constructors

MainViewModel()

public MainViewModel()

Properties

AddServerCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.AddServer().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand AddServerCommand { get; }

Property Value

IAsyncRelayCommand

AnyServerRunning

True if any server is running (to warn on close).

public bool AnyServerRunning { get; }

Property Value

bool

ChangeIconForSelectedCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.ChangeIconForSelected().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ChangeIconForSelectedCommand { get; }

Property Value

IAsyncRelayCommand

ConfigureServerCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.ConfigureServer().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ConfigureServerCommand { get; }

Property Value

IAsyncRelayCommand

CreateServerCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.CreateServer().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand CreateServerCommand { get; }

Property Value

IAsyncRelayCommand

CreateTunnelForSelectedCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.CreateTunnelForSelected().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand CreateTunnelForSelectedCommand { get; }

Property Value

IAsyncRelayCommand

DismissUpdateCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.DismissUpdate().

[ExcludeFromCodeCoverage]
public IRelayCommand DismissUpdateCommand { get; }

Property Value

IRelayCommand

EditServerCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.EditServer().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand EditServerCommand { get; }

Property Value

IAsyncRelayCommand

HasSelection

public bool HasSelection { get; }

Property Value

bool

IsUpdating

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

Property Value

bool

Languages

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

Property Value

IReadOnlyList<MainViewModel.LanguageOption>

OpenSettingsCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.OpenSettings().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand OpenSettingsCommand { get; }

Property Value

IAsyncRelayCommand

RemoveServerCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.RemoveServer().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand RemoveServerCommand { get; }

Property Value

IAsyncRelayCommand

SaveCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.Save().

[ExcludeFromCodeCoverage]
public IRelayCommand SaveCommand { get; }

Property Value

IRelayCommand

SelectedLanguage

[ExcludeFromCodeCoverage]
public MainViewModel.LanguageOption? SelectedLanguage { get; set; }

Property Value

MainViewModel.LanguageOption

SelectedServer

[ExcludeFromCodeCoverage]
public ServerViewModel? SelectedServer { get; set; }

Property Value

ServerViewModel

Servers

public ObservableCollection<ServerViewModel> Servers { get; }

Property Value

ObservableCollection<ServerViewModel>

UpdateAvailable

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

Property Value

bool

UpdateNowCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.UpdateNow().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand UpdateNowCommand { get; }

Property Value

IAsyncRelayCommand

UpdateText

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

Property Value

string

Methods

ShowWhatsNewIfUpdated(Window)

If the current version differs from the last one seen by the user (i.e. it was just updated), shows the what's-new window. Saves the seen version so it isn't repeated.

public void ShowWhatsNewIfUpdated(Window owner)

Parameters

owner Window

ShutdownAllAsync()

Stops all servers IN PARALLEL and saves when the app closes.

public Task ShutdownAllAsync()

Returns

Task

WarnIfServersFileWasCorruptAsync(Window)

If servers.json was corrupt at startup, tells the user what happened — recovered from the ".bak" backup, or started empty with the damaged file kept as ".bad" — instead of silently showing an empty list. Called from MainWindow.Loaded, which in Avalonia can fire again every time the window re-attaches to the visual tree (e.g. restoring from the tray), so the warning is one-shot per session.

public Task WarnIfServersFileWasCorruptAsync(Window owner)

Parameters

owner Window

Returns

Task