|
|
|
|
@ -20,9 +20,42 @@ public abstract partial class TerminalViewModel : ObservableObject, ITerminalVie |
|
|
|
|
private readonly IMessenger messenger; |
|
|
|
|
private readonly IContext context; |
|
|
|
|
|
|
|
|
|
public abstract string Title { get; } |
|
|
|
|
public abstract TerminalViewType ViewType { get; } |
|
|
|
|
public ProtocolType ProtocolType { get; set; } |
|
|
|
|
|
|
|
|
|
private ProtocolType protocolType; |
|
|
|
|
|
|
|
|
|
public ProtocolType ProtocolType |
|
|
|
|
{ |
|
|
|
|
get { return this.protocolType; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
this.protocolType = value; |
|
|
|
|
this.UpdateTitle(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#region Title |
|
|
|
|
/// <summary> |
|
|
|
|
/// Terminal title, to allow user to distinguish between different terminals. |
|
|
|
|
/// </summary> |
|
|
|
|
[ObservableProperty] |
|
|
|
|
private string title = string.Empty; |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Update the Property <see cref="Title"/>. To be called when it was changed. |
|
|
|
|
/// </summary> |
|
|
|
|
private void UpdateTitle() |
|
|
|
|
{ |
|
|
|
|
if(this.CommunicationProtocol == null) |
|
|
|
|
{ |
|
|
|
|
this.Title = $"{ProtocolType}"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
this.Title = $"{ProtocolType} {this.CommunicationProtocol?.InstanceIdentifier}"; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
/// <summary> |
|
|
|
|
/// Holds communication data, meaning data that was sent to or received over the communication protocol. |
|
|
|
|
@ -48,7 +81,9 @@ public abstract partial class TerminalViewModel : ObservableObject, ITerminalVie |
|
|
|
|
get { return this.communicationProtocol; } |
|
|
|
|
set |
|
|
|
|
{ |
|
|
|
|
// store communication protocol |
|
|
|
|
this.communicationProtocol = value; |
|
|
|
|
|
|
|
|
|
// register communication protocol in the Communication Data View Model |
|
|
|
|
this.CommunicationData = new CommunicationDataViewModel(this.communicationProtocol, this.context); |
|
|
|
|
|
|
|
|
|
@ -126,6 +161,7 @@ public abstract partial class TerminalViewModel : ObservableObject, ITerminalVie |
|
|
|
|
if (CommunicationProtocol == null) { throw new Exception($"To call '{nameof(OnViewModelRequestedConnect)}()', CommunicationProtocol must not be null!"); } |
|
|
|
|
|
|
|
|
|
e.Success = this.CommunicationProtocol.Connect(e.Settings); |
|
|
|
|
this.UpdateTitle(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void OnViewModelRequestedDisconnect(object? sender, EventArgs e) |
|
|
|
|
|