Class TunnelsViewModel
- Namespace
- McServerLauncher.ViewModels
- Assembly
- McServerLauncher.dll
The tunnels screen: the Playit account, every tunnel on it, and what to do about them.
public class TunnelsViewModel : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
- Inheritance
-
TunnelsViewModel
- Implements
- Inherited Members
Remarks
It exists because the account used to be visible only one server at a time, from inside each server, and connecting to it lived at the bottom of Settings. Nobody could see that a tunnel pointed at nothing, or that two servers were fighting for one, because no screen had both lists in front of it. The rules for reading them are TunnelInventory; this class only asks the account, shows the answer, and carries out what the person clicks.
Nothing destructive happens by itself. The one thing done without asking is renaming a tunnel that still carries the exact name the app gave it, after its server was renamed — and then only that: a name somebody chose is left alone.
Constructors
TunnelsViewModel(ObservableCollection<ServerViewModel>, AppSettings, AppSettingsService, Func<Window?>, Func<ServerViewModel, Task>)
public TunnelsViewModel(ObservableCollection<ServerViewModel> servers, AppSettings appSettings, AppSettingsService settingsService, Func<Window?> owner, Func<ServerViewModel, Task> configure)
Parameters
serversObservableCollection<ServerViewModel>appSettingsAppSettingssettingsServiceAppSettingsServiceownerFunc<Window>configureFunc<ServerViewModel, Task>
Properties
AccountBrush
The account line's dot: grey with no way in, red when Playit refused every one, green otherwise — except that the app's own agent being down is shown, since it is the one carrying the traffic.
public IBrush AccountBrush { get; }
Property Value
- IBrush
AccountText
One line for each way in, so it is clear which one the tunnels below were read with.
public string AccountText { get; }
Property Value
AgentBrush
public IBrush AgentBrush { get; }
Property Value
- IBrush
AgentText
public string AgentText { get; }
Property Value
AllGood
public bool AllGood { get; }
Property Value
CanRetryAgent
public bool CanRetryAgent { get; }
Property Value
ConnectCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.Connect().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ConnectCommand { get; }
Property Value
ConnectText
public string ConnectText { get; }
Property Value
DisconnectCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.Disconnect().
[ExcludeFromCodeCoverage]
public IRelayCommand DisconnectCommand { get; }
Property Value
ErrorText
[ExcludeFromCodeCoverage]
public string? ErrorText { get; set; }
Property Value
HasError
public bool HasError { get; }
Property Value
HasStoredConnection
True when the connect flow has saved something — which is what Disconnect forgets.
public bool HasStoredConnection { get; }
Property Value
HasSuggestions
public bool HasSuggestions { get; }
Property Value
IsConnected
True when there is any way into the account: the app's own agent, the installed one, or a saved key.
public bool IsConnected { get; }
Property Value
IsLoading
[ExcludeFromCodeCoverage]
public bool IsLoading { get; set; }
Property Value
IsNotConnected
public bool IsNotConnected { get; }
Property Value
LastRead
[ExcludeFromCodeCoverage]
public DateTime? LastRead { get; set; }
Property Value
LastReadText
public string LastReadText { get; }
Property Value
OpenWebCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.OpenWeb().
[ExcludeFromCodeCoverage]
public IRelayCommand OpenWebCommand { get; }
Property Value
RefreshCommand
Gets an IAsyncRelayCommand instance wrapping RefreshAsync().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand RefreshCommand { get; }
Property Value
RetryAgentCommand
Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.RetryAgent().
[ExcludeFromCodeCoverage]
public IRelayCommand RetryAgentCommand { get; }
Property Value
Rows
public ObservableCollection<TunnelRowViewModel> Rows { get; }
Property Value
ServiceText
public string ServiceText { get; }
Property Value
ShowAgent
public bool ShowAgent { get; }
Property Value
ShowEmpty
The table's empty state, shown only once the account has actually answered.
public bool ShowEmpty { get; }
Property Value
ShowService
The system service of an agent the user installed, to start and stop it from here.
public bool ShowService { get; }
Property Value
Suggestions
public ObservableCollection<TunnelSuggestionViewModel> Suggestions { get; }
Property Value
SummaryBrush
public IBrush SummaryBrush { get; }
Property Value
- IBrush
SummaryText
public string SummaryText { get; }
Property Value
ToggleServiceCommand
Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.ToggleService().
[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ToggleServiceCommand { get; }
Property Value
Methods
PrefetchAsync()
Reads the account once, shortly after the app opens, so the screen is already filled the first time it is shown.
public Task PrefetchAsync()
Returns
Remarks
Without it, opening Túneles was the moment the first request left, and the table stayed empty for as long as Playit took to answer. A short wait first keeps it out of the way of the start itself. It is one reading, not a timer: after this the screen reads again only when opened, showing the last reading straight away while the new one comes in.
RefreshAsync()
[RelayCommand]
public Task RefreshAsync()
Returns
RenameTunnelsForServerAsync(ServerViewModel, string)
After a server was renamed, gives its tunnels the matching name — those that still carry the name the app gave them. Quiet: it reports in that server's console and never opens a dialog.
public Task RenameTunnelsForServerAsync(ServerViewModel server, string oldName)
Parameters
serverServerViewModeloldNamestring
Returns
ShowReport(TunnelReport)
Puts a reading of the account on screen: the table, the suggestions and the summary.
public void ShowReport(TunnelReport report)
Parameters
reportTunnelReport
Remarks
Public so what the screen looks like can be checked without an account to ask.