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;
///
/// Send data model.
///
[ObservableProperty]
private MultiFormatString sendableData = new();
///
/// Constructor.
///
///
public SendReceiveViewModel(IAppSettingsProvider appSettings, IMessenger messenger, IContext context) : base(appSettings, messenger, context) { }
///
/// Send command.
///
[RelayCommand]
private void Send()
{
// send data
bool successfullySent = this.SendToCommunicationProtocol(this.SendableData.GetBytes());
if (successfullySent)
{
// clear textbox
this.SendableData.Clear();
}
}
}