Table of Contents

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

servers ObservableCollection<ServerViewModel>
appSettings AppSettings
settingsService AppSettingsService
owner Func<Window>
configure Func<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

string

AgentBrush

public IBrush AgentBrush { get; }

Property Value

IBrush

AgentText

public string AgentText { get; }

Property Value

string

AllGood

public bool AllGood { get; }

Property Value

bool

CanRetryAgent

public bool CanRetryAgent { get; }

Property Value

bool

ConnectCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.Connect().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ConnectCommand { get; }

Property Value

IAsyncRelayCommand

ConnectText

public string ConnectText { get; }

Property Value

string

DisconnectCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.Disconnect().

[ExcludeFromCodeCoverage]
public IRelayCommand DisconnectCommand { get; }

Property Value

IRelayCommand

ErrorText

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

Property Value

string

HasError

public bool HasError { get; }

Property Value

bool

HasStoredConnection

True when the connect flow has saved something — which is what Disconnect forgets.

public bool HasStoredConnection { get; }

Property Value

bool

HasSuggestions

public bool HasSuggestions { get; }

Property Value

bool

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

bool

IsLoading

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

Property Value

bool

IsNotConnected

public bool IsNotConnected { get; }

Property Value

bool

LastRead

[ExcludeFromCodeCoverage]
public DateTime? LastRead { get; set; }

Property Value

DateTime?

LastReadText

public string LastReadText { get; }

Property Value

string

OpenWebCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.OpenWeb().

[ExcludeFromCodeCoverage]
public IRelayCommand OpenWebCommand { get; }

Property Value

IRelayCommand

RefreshCommand

Gets an IAsyncRelayCommand instance wrapping RefreshAsync().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand RefreshCommand { get; }

Property Value

IAsyncRelayCommand

RetryAgentCommand

Gets an IRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.RetryAgent().

[ExcludeFromCodeCoverage]
public IRelayCommand RetryAgentCommand { get; }

Property Value

IRelayCommand

Rows

public ObservableCollection<TunnelRowViewModel> Rows { get; }

Property Value

ObservableCollection<TunnelRowViewModel>

ServiceText

public string ServiceText { get; }

Property Value

string

ShowAgent

public bool ShowAgent { get; }

Property Value

bool

ShowEmpty

The table's empty state, shown only once the account has actually answered.

public bool ShowEmpty { get; }

Property Value

bool

ShowService

The system service of an agent the user installed, to start and stop it from here.

public bool ShowService { get; }

Property Value

bool

Suggestions

public ObservableCollection<TunnelSuggestionViewModel> Suggestions { get; }

Property Value

ObservableCollection<TunnelSuggestionViewModel>

SummaryBrush

public IBrush SummaryBrush { get; }

Property Value

IBrush

SummaryText

public string SummaryText { get; }

Property Value

string

ToggleServiceCommand

Gets an IAsyncRelayCommand instance wrapping McServerLauncher.ViewModels.TunnelsViewModel.ToggleService().

[ExcludeFromCodeCoverage]
public IAsyncRelayCommand ToggleServiceCommand { get; }

Property Value

IAsyncRelayCommand

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

Task

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

Task

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

server ServerViewModel
oldName string

Returns

Task

ShowReport(TunnelReport)

Puts a reading of the account on screen: the table, the suggestions and the summary.

public void ShowReport(TunnelReport report)

Parameters

report TunnelReport

Remarks

Public so what the screen looks like can be checked without an account to ask.