Beispiel #1
0
        public HomeViewModel(ITelephonyService telephonyService = null, IScreen hostScreen = null)
        {
            TelephonyService = telephonyService ?? Locator.Current.GetService<ITelephonyService>();

            HostScreen = hostScreen ?? Locator.Current.GetService<IScreen>();

            var canComposeSMS = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
            ComposeSMS = ReactiveCommand.CreateAsyncTask(canComposeSMS,
                async _ => { await TelephonyService.ComposeSMS(Recipient); });
            ComposeSMS.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to send SMS?", ex));

            var canComposeEmail = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
            ComposeEmail = ReactiveCommand.CreateAsyncTask(canComposeEmail, async _ =>
            {
                var email = new Email(Recipient);

                await TelephonyService.ComposeEmail(email);
            });
            ComposeEmail.ThrownExceptions.Subscribe(
                ex => UserError.Throw("The recipient is potentially not a well formed email address.", ex));

            var canMakePhoneCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
            MakePhoneCall = ReactiveCommand.CreateAsyncTask(canMakePhoneCall,
                async _ => { await TelephonyService.MakePhoneCall(Recipient); });
            MakePhoneCall.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to make phone calls?", ex));

            var canMakeVideoCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));
            MakeVideoCall = ReactiveCommand.CreateAsyncTask(canMakeVideoCall,
                async _ => { await TelephonyService.MakeVideoCall(Recipient); });
            MakeVideoCall.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to make video calls?", ex));
        }
Beispiel #2
0
        public PhoneViewModel(ITelephonyService telephonyService, ITargetingService targetingService, IEventAggregator eventAggregator)
        {
            EventAggregator       = eventAggregator;
            this.targetingService = targetingService;
            this.telephonyService = telephonyService;
            telephonyService.GetCallbacks().OnCallerConnect       += PhoneViewModel_OnCallerConnect;
            telephonyService.GetCallbacks().OnConnectionSucceeded += PhoneViewModel_OnConnectionSucceeded;
            telephonyService.GetCallbacks().OnServerDisconnect    += PhoneViewModel_OnServerDisconnect;

            _subscriptionToken = EventAggregator.GetEvent <FinishedInitializingEvent>().Subscribe(InitAfterLoad);


            this.GetDefaultCommands();
        }
Beispiel #3
0
        public HomeViewModel(ITelephonyService telephonyService = null, IScreen hostScreen = null)
        {
            TelephonyService = telephonyService ?? Locator.Current.GetService <ITelephonyService>();

            HostScreen = hostScreen ?? Locator.Current.GetService <IScreen>();

            var canComposeSMS = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));

            ComposeSMS = ReactiveCommand.CreateAsyncTask(canComposeSMS,
                                                         async _ => { await TelephonyService.ComposeSMS(Recipient); });
            ComposeSMS.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to send SMS?", ex));

            var canComposeEmail = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));

            ComposeEmail = ReactiveCommand.CreateAsyncTask(canComposeEmail, async _ =>
            {
                var email = new Email(Recipient);

                await TelephonyService.ComposeEmail(email);
            });
            ComposeEmail.ThrownExceptions.Subscribe(
                ex => UserError.Throw("The recipient is potentially not a well formed email address.", ex));

            var canMakePhoneCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));

            MakePhoneCall = ReactiveCommand.CreateAsyncTask(canMakePhoneCall,
                                                            async _ => { await TelephonyService.MakePhoneCall(Recipient); });
            MakePhoneCall.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to make phone calls?", ex));

            var canMakeVideoCall = this.WhenAny(x => x.Recipient, x => !string.IsNullOrWhiteSpace(x.Value));

            MakeVideoCall = ReactiveCommand.CreateAsyncTask(canMakeVideoCall,
                                                            async _ => { await TelephonyService.MakeVideoCall(Recipient); });
            MakeVideoCall.ThrownExceptions.Subscribe(
                ex => UserError.Throw("Does this device have the capability to make video calls?", ex));
        }
Beispiel #4
0
 public TelephonyController(ITelephonyService service)
 {
     _service = service;
 }