You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
using Common;
|
|
using Common.AppSettings;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using MultiTerm.Core.Model;
|
|
using MultiTerm.Core.Types;
|
|
|
|
namespace MultiTerm.Core.ViewModel;
|
|
|
|
public partial class SendReceiveViewModel : TerminalViewModel
|
|
{
|
|
public override TerminalViewType ViewType => TerminalViewType.SendReceive;
|
|
|
|
/// <summary>
|
|
/// Send data model.
|
|
/// </summary>
|
|
[ObservableProperty]
|
|
private MultiFormatString sendableData = new();
|
|
|
|
/// <summary>
|
|
/// Constructor.
|
|
/// </summary>
|
|
/// <param name="appSettings"></param>
|
|
public SendReceiveViewModel(IAppSettingsProvider appSettings, IMessenger messenger, IContext context) : base(appSettings, messenger, context) { }
|
|
|
|
/// <summary>
|
|
/// Send command.
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void Send()
|
|
{
|
|
// send data
|
|
bool successfullySent = this.SendToCommunicationProtocol(this.SendableData.GetBytes());
|
|
|
|
if (successfullySent)
|
|
{
|
|
// clear textbox
|
|
this.SendableData.Clear();
|
|
}
|
|
}
|
|
}
|
|
|