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
AnyServerRunning
True if any server is running (to warn on close).
public bool AnyServerRunning { get; }
Property Value
ChangeIconForSelectedCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.ChangeIconForSelected().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ChangeIconForSelectedCommand { get; }
Property Value
ConfigureServerCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.ConfigureServer().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ConfigureServerCommand { get; }
Property Value
CreateServerCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.CreateServer().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand CreateServerCommand { get; }
Property Value
CreateTunnelForSelectedCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.CreateTunnelForSelected().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand CreateTunnelForSelectedCommand { get; }
Property Value
DismissUpdateCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.DismissUpdate().
[ExcludeFromCodeCoverage]
public IRelayCommand DismissUpdateCommand { get; }
Property Value
EditServerCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.EditServer().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand EditServerCommand { get; }
Property Value
HasSelection
public bool HasSelection { get; }
Property Value
IsUpdating
[ExcludeFromCodeCoverage]
public bool IsUpdating { get; set; }
Property Value
Languages
public IReadOnlyList<MainViewModel.LanguageOption> Languages { get; }
Property Value
OpenSettingsCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.OpenSettings().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand OpenSettingsCommand { get; }
Property Value
RemoveServerCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.RemoveServer().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand RemoveServerCommand { get; }
Property Value
SaveCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.Save().
[ExcludeFromCodeCoverage]
public IRelayCommand SaveCommand { get; }
Property Value
SelectedLanguage
[ExcludeFromCodeCoverage]
public MainViewModel.LanguageOption? SelectedLanguage { get; set; }
Property Value
SelectedServer
[ExcludeFromCodeCoverage]
public ServerViewModel? SelectedServer { get; set; }
Property Value
Servers
public ObservableCollection<ServerViewModel> Servers { get; }
Property Value
UpdateAvailable
[ExcludeFromCodeCoverage]
public bool UpdateAvailable { get; set; }
Property Value
UpdateNowCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.MainViewModel.UpdateNow().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand UpdateNowCommand { get; }
Property Value
UpdateText
[ExcludeFromCodeCoverage]
public string UpdateText { get; set; }
Property Value
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
ownerWindow
ShutdownAllAsync()
Stops all servers IN PARALLEL and saves when the app closes.
public Task ShutdownAllAsync()
Returns
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
ownerWindow