예제 #1
0
        public RemoteViewModel(IRemoteView view, IRemoteService remoteService)
        {
            _remoteService = remoteService;

            View             = view;
            View.DataContext = this;

            SendCommand = new DelegateCommand <EventKey?>(cmd =>
            {
                if (cmd.HasValue)
                {
                    _remoteService.SendAsync(GetIp(), new EventModel(EventType.KeyPress, cmd.Value));
                }
            }, cmd => Connected);

            BackspaceCommand = new DelegateCommand(() =>
            {
                _remoteService.SendAsync(GetIp(), new EventModel(EventType.KeyPress, EventKey.Backspace));
            }, () => Connected);

            Connected = true;
        }
        public RemoteViewModel(IRemoteView view, IEventAggregator eventAggregator)
        {
            View             = view;
            View.DataContext = this;

            _eventAggregator = eventAggregator;

            SendCommand = new DelegateCommand <EventKey?>(cmd =>
            {
                if (cmd.HasValue)
                {
                    _eventAggregator.GetEvent <SendCommandEvent>().Publish(new EventModel(EventType.KeyPress, cmd.Value));
                }
            }, cmd => Connected);

            BackspaceCommand = new DelegateCommand(() =>
            {
                _eventAggregator.GetEvent <SendCommandEvent>().Publish(new EventModel(EventType.KeyPress, EventKey.Backspace));
            }, () => Connected);

            _eventAggregator.GetEvent <ConnectEvent>().Subscribe(ip => Connected     = true, ThreadOption.UIThread);
            _eventAggregator.GetEvent <DisconnectEvent>().Subscribe(obj => Connected = false, ThreadOption.UIThread);
        }
예제 #3
0
 internal RemotePresenter(IRemoteView view) : base(view)
 {
     _view = view;
     _view.RemoteInitialized += RemoteInitialized;
     _view.TestRemote        += async(s, e) => { await TestRemote(s, e as EventArgs <IRemoteSettings>); };
 }