enhancements in ProtocolConnectionSettings, renamed to ViewModel

master
Jonas Arnold 3 years ago
parent 517dd057da
commit e7b3e33f9e
  1. 1
      MultiTerm.Core/MultiTerm.Core.csproj
  2. 2
      MultiTerm.Protocols/CommunicationProtocol.cs
  3. 2
      MultiTerm.Protocols/ICommunicationProtocol.cs
  4. 6
      MultiTerm.Protocols/MultiTerm.Protocols.csproj
  5. 9
      MultiTerm.Protocols/ProtocolConnectionSettings.cs
  6. 40
      MultiTerm.Protocols/ProtocolConnectionSettingsViewModel.cs

@ -16,6 +16,7 @@
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
<ProjectReference Include="..\MultiTerm.Protocols\MultiTerm.Protocols.csproj" />
</ItemGroup>
</Project>

@ -6,7 +6,7 @@ public abstract class CommunicationProtocol : ICommunicationProtocol
{
public string NewlineSequenceOnSend { get; set; }
public string NewlineOnReceivedSequence { get; set; }
public ProtocolConnectionSettings? ConnectionSettings { get; set; }
public ProtocolConnectionSettingsViewModel? ConnectionSettings { get; set; }
protected ILogger logger;
private CancellationTokenSource cancellationTokenSource;

@ -8,7 +8,7 @@ public interface ICommunicationProtocol
/// <summary>
/// Contains settings that are required to connect using this communication protocol.
/// </summary>
ProtocolConnectionSettings? ConnectionSettings { get; }
ProtocolConnectionSettingsViewModel? ConnectionSettings { get; }
/// <summary>
/// Newline sequence to add on the end when sending a message using <see cref="SendBytes(byte[])"/>.

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -6,6 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common\Common.csproj" />
</ItemGroup>

@ -1,9 +0,0 @@
namespace MultiTerm.Protocols;
/// <summary>
/// Class that represents all connection settings for a specific <see cref="CommunicationProtocol"/>.
/// </summary>
public abstract class ProtocolConnectionSettings
{
public event EventHandler ConnectRequested;
}

@ -0,0 +1,40 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
namespace MultiTerm.Protocols;
/// <summary>
/// Class that represents all connection settings for a specific <see cref="CommunicationProtocol"/>.
/// Can be bound to UI using MVVM pattern.
/// </summary>
public abstract partial class ProtocolConnectionSettingsViewModel : ObservableObject
{
/// <summary>
/// Event that is thrown when the user requested to connect to the device with the entered settings.
/// </summary>
public event EventHandler? ConnectRequested;
/// <summary>
/// Event that is thrown when the user requested to disconnect from the device.
/// </summary>
public event EventHandler? DisconnectRequested;
/// <summary>
/// Indicates wether the settings can currently be edited.
/// </summary>
public bool AreEditable;
[ObservableProperty]
private string connectDisconnectButtonText = "Connect";
/// <summary>
/// Binding to Connect/Disconnect button.
/// Button text is provided in <see cref="ConnectDisconnectButtonText"/>
/// </summary>
[RelayCommand]
private void ConnectDisconnect()
{
}
}
Loading…
Cancel
Save