Exemplo n.º 1
0
        public async void Load(int offset = 0)
        {
            if (_lastOffset == offset || IsLoading)
            {
                return;
            }

            _lastOffset = offset;
            IsLoading   = true;

            _messenger.Publish(new LoadingChangedMessage(this, true));
            try
            {
                List <Pattern> items = await _client.Top(offset);

                foreach (var pattern in items)
                {
                    Items.Add(pattern);
                }
            }
            finally
            {
                IsLoading = false;
                _messenger.Publish(new LoadingChangedMessage(this, false));
            }
        }
        private void Error(MvxLocationError error)
        {
            var message = new LocationMessage(this, -1, -1, true, error.Code.ToString());

            _watcher.Stop();
            _messenger.Publish(message);
        }
        private async void SignInWebBrowserControlScriptNotify(object sender, NotifyEventArgs e)
        {
            BrowserSignInControl.ScriptNotify -= SignInWebBrowserControlScriptNotify;
            GdProgress.Visibility              = Visibility.Visible;
            try
            {
                var rswt = await RequestSecurityTokenResponse.FromJSONAsync(e.Value);

                _messageHub.Publish(rswt == null
                    ? new RequestTokenMessage(this)
                {
                    TokenResponse = null
                }
                    : new RequestTokenMessage(this)
                {
                    TokenResponse = rswt
                });
            }
            catch (Exception)
            {
                _timeoutTimer.Stop();
                _messageHub.Publish(new RequestTokenMessage(this)
                {
                    TokenResponse = null
                });
            }
        }
Exemplo n.º 4
0
        public override void ViewAppeared()
        {
            var new_title = new ViewTitleMessage(this, AppStrings.Location);

            _messenger.Publish(new_title);
            _messenger.Publish(new UpdateLocMessage(this));
        }
Exemplo n.º 5
0
        public void AddOrUpdate(Example exm)
        {
            bool newItem = false;
            var  realm   = Realm.GetInstance();

            if (string.IsNullOrWhiteSpace(exm.Id))
            {
                exm.Id  = Guid.NewGuid().ToString();
                newItem = true;
            }

            realm.Write(() =>
            {
                realm.Add(exm, update: true);
            });

            if (newItem)
            {
                _messageService.Publish(new ExampleChangedMessage(this, exm.Id, GlobalConstants.Action.Add));
            }
            else
            {
                _messageService.Publish(new ExampleChangedMessage(this, exm.Id, GlobalConstants.Action.Update));
            }
        }
Exemplo n.º 6
0
        public async void Load(int id)
        {
            _messenger.Publish(new LoadingChangedMessage(this, true));
            try
            {
                _pattern = await _client.Get(id);

                if (_pattern != null)
                {
                    Title      = _pattern.Title;
                    ByUserName = _pattern.ByUserName;
                    ImageUrl   = _pattern.ImageUrl;
                    Url        = _pattern.Url;
                    RaisePropertyChanged(() => IsFavorite);
                    RaisePropertyChanged(() => IsLoading);
                }
                else
                {
                    // TODO: error?
                }
            }
            finally
            {
                _messenger.Publish(new LoadingChangedMessage(this, false));
            }
        }
Exemplo n.º 7
0
        private void ShowOnMapExecuted(string fromOrToPortal)
        {
            if (IsBusy)
            {
                return;
            }

            switch (fromOrToPortal)
            {
            case "From":
                if (LinkAssignment?.FromPortal != null)
                {
                    _messenger.Publish(new ShowPortalOnMapMessage(this, LinkAssignment.FromPortal));
                }

                CloseCommand.Execute();
                break;

            case "To":
                if (LinkAssignment?.ToPortal != null)
                {
                    _messenger.Publish(new ShowPortalOnMapMessage(this, LinkAssignment.ToPortal));
                }

                CloseCommand.Execute();
                break;
            }
        }
Exemplo n.º 8
0
        // TODO: May want to do validation in here instead of ViewModel
        public void AddStuffToInbox(ItemOfStuff itemOfStuff)
        {
            _inboxRepository.AddStuffToInbox(itemOfStuff);

            // send msg to tell others there was stuff added
            // this can help properties in ViewModels stay updated

            _mvxMessenger.Publish(new InboxChangedMessage(this));
        }
Exemplo n.º 9
0
        public async Task <Counter> AddNewCounter(string name)
        {
            var counter = new Counter {
                Name = name
            };
            await _repository.Save(counter).ConfigureAwait(false);

            _messenger.Publish(new CountersChangedMessage(this));
            return(counter);
        }
Exemplo n.º 10
0
        public async void SelfTest()
        {
            var notification_true  = new AlertMessage(this, AlertType.notification, true);
            var notification_false = new AlertMessage(this, AlertType.notification, false);

            _messenger.Publish(notification_true);
            await Task.Delay(2000);

            _messenger.Publish(notification_true);
        }
Exemplo n.º 11
0
        public async Task <Counter> AddNewCounter(string account, string password)
        {
            var counter = new Counter {
                Account = account, Password = password
            };
            await repository.Save(counter).ConfigureAwait(false);

            messenger.Publish(new CountersChangedMessage(this));
            return(counter);
        }
Exemplo n.º 12
0
        public void AddItem_ShouldAddToStorageAndPublishCollectionChange()
        {
            var item = new Item {
                ItemName = "Name"
            };

            this.testee.Add(item);

            A.CallTo(() => storageService.Add(item)).MustHaveHappened();
            A.CallTo(() => messenger.Publish(A <CollectionChangedMessage> ._)).MustHaveHappened();
        }
Exemplo n.º 13
0
        public async Task UpdateOperation(string operationId)
        {
            var operationData = await _wasabeeApiV1Service.Operations_GetOperation(operationId);

            if (operationData != null)
            {
                await _operationsDatabase.SaveOperationModel(operationData);

                _mvxMessenger.Publish(new OperationDataChangedMessage(this, operationData));
            }
        }
Exemplo n.º 14
0
        //Implementing the ICountersService interface
        public async Task <Counter> AddNewCounter(string name)
        {
            //A new counter is created from a name, stored in the repository, then removed.
            var counter = new Counter {
                Name = name
            };
            await repository.Save(counter).ConfigureAwait(false);

            messenger.Publish(new CountersChangedMessage(this)); //Once a counter is saved, publish the message
            return(counter);
        }
Exemplo n.º 15
0
        public async Task <IEnumerable <Item> > EnqueueItems(List <int> ids)
        {
            var stopwatch = Stopwatch.StartNew();

            var(items, misses) = _cache.GetCachedItems(ids);

            var newItems = new List <Item>();

            var buffer     = new BufferBlock <int>();
            var downloader = new ActionBlock <int>(async id =>
            {
                var action = await _client.GetStringAsync($"item/{id}.json");
                // handle data here
                var storyItem = JsonConvert.DeserializeObject <Item>(action);
                newItems.Add(storyItem);
                var msg = new NewsItemMessage(this, storyItem);
                _messenger.Publish(msg);
            },
                                                   new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount
            });

            // notify TPL Dataflow to send messages from buffer to loader
            buffer.LinkTo(downloader, new DataflowLinkOptions {
                PropagateCompletion = true
            });

            foreach (var itemId in misses)
            {
                await buffer.SendAsync(itemId);
            }
            // queue is done
            buffer.Complete();

            // now it's safe to wait for completion of the downloader
            await downloader.Completion;

            var itemList = items.ToList();

            foreach (var item in itemList)
            {
                var msg = new NewsItemMessage(this, item);
                _messenger.Publish(msg);
            }

            _cache.AddItemsToCache(newItems);
            stopwatch.Stop();
            var ms = stopwatch.ElapsedMilliseconds;

            Debug.WriteLine("Queue completed in {0} ms", ms);


            return(itemList);
        }
Exemplo n.º 16
0
        public void Insert(Pattern pattern)
        {
            Pattern toInsert = _favorites.FirstOrDefault(p => p.Id == pattern.Id);

            if (toInsert == null)
            {
                _favorites.Add(pattern);
                Save();
                _messenger.Publish(new FavoritesChangedMessage(this));
            }
        }
Exemplo n.º 17
0
 private void AddFood()
 {
     if (!FoodId.HasValue)
     {
         messenger.Publish(new FoodAddedMessage(this, Name, Temperature.Value, Time.Value));
     }
     else
     {
         messenger.Publish(new FoodEditedMessage(this, FoodId.Value, Name, Temperature.Value, Time.Value));
     }
     CloseDialog?.Invoke();
 }
Exemplo n.º 18
0
        private async Task DoStartTrackingCommand(bool restore = false)
        {
            try
            {
                IsBusy = true;

                IsTracking = true;
                if (!restore)
                {
                    if (!await CheckConditions())
                    {
                        IsBusy = IsTracking = false;
                        return;
                    }

                    var selectedTime = TimeSpan.FromMinutes(SelectedTime.Minutes);
                    _timeEnd = DateTime.Now + selectedTime;
                    var result = await _sendPositionService.GetToken(Position, SelectedTime.Minutes, Address, _lastAccuracy);

                    IsBusy = false;
                    if (!result.IsError)
                    {
                        Token        = result.Result.PublicToken;
                        PrivateToken = result.Result.PrivateToken;
                        StartCountdown();

                        SaveCurrentState();

                        _messenger.Publish(new StartTrackingMessage(this, Token, SelectedTime.Minutes));
                    }
                    else
                    {
                        await PresentErrorAndStopTracking(result.ErrorMessage);
                    }
                }
                else
                {
                    StartCountdown();
                    int duration = (_timeEnd - DateTime.Now).Minutes;
                    _messenger.Publish(new StartTrackingMessage(this, Token, duration));
                }
            }
            catch (Exception e)
            {
#if DEBUG
                await PresentErrorAndStopTracking(e.Message);
#else
                await PresentErrorAndStopTracking(AppResources.ShareStartError);
#endif
            }
            IsBusy = false;
        }
        private async void OpenChallengeDetailsScreenWithURL(string url)
        {
            var response = await SL.Manager.GetChallengeByUrl(url);

            if (response != null && response.Challenge != null)
            {
                var  challenge  = response.Challenge;
                bool isAssigned = true;
                if (challenge.TypeCode == ChallengesConstants.ChallengeItb && !isAssigned)
                {
                    _alertService.ShowOkCancelMessage("Action error", "You have not been assigned this challenge!", null, null, false);
                    return;
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeInvite && (challenge.TypeCodeDisplayName == ChallengesConstants.ChallengeInviteToBuyDisplayNames || challenge.TypeCodeDisplayName == ChallengesConstants.ChallengeInviteToJoinDisplayNames))//ITJ
                {
                    await _navigationService.Navigate <InviteViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeMC || challenge.TypeCode == ChallengesConstants.ChallengeSignUp)
                {
                    await _navigationService.Navigate <MultipleChoiceViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeInsta)
                {
                    await _navigationService.Navigate <InstagramViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeCheckin)
                {
                    await _navigationService.Navigate <CheckInViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeShare && challenge.TypeCodeDisplayName == ChallengesConstants.ChallengeTwitterDisplayNames)
                {
                    await _navigationService.Navigate <TwitterViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeShare && challenge.TypeCodeDisplayName == ChallengesConstants.ChallengeFacebookDisplayNames)
                {
                    await _navigationService.Navigate <FacebookViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeCollateralTracking)
                {
                    await _navigationService.Navigate <CollateralTrackingViewModel>();
                }
                if (challenge.TypeCode == ChallengesConstants.ChallengeFBEngagement)
                {
                    await _navigationService.Navigate <FBEngagementViewModel>();
                }
                _messenger.Publish(new MessangerChallengeModel(this, challenge));
            }
            else
            {
                _alertService.ShowOkCancelMessage(string.Empty, "This challenge has not been assigned to you.", null, null, false);
            }
        }
Exemplo n.º 20
0
        public HomeViewModel(IDeviceService deviceService, IShareService shareService, ISettings settings,
                             ILocationService locationService, IMvxMessenger messenger, ISendPositionService sendPositionService, IPopupService popupService, ITimerService timer)
        {
            _deviceService       = deviceService;
            _shareService        = shareService;
            _settings            = settings;
            _locationService     = locationService;
            _messenger           = messenger;
            _sendPositionService = sendPositionService;
            _popupService        = popupService;
            _timer = timer;

            Title         = "TrackMe";
            PossibleTimes = new PossibleTimeProvider().GetPossibleTimes().ToObservable();
            SelectedTime  = new PossibleTime(240);

            _deviceService.LocationStatusChanged += (sender, args) =>
            {
                GpsStatus = args.Status;

                if (!_locationService.IsWatching && args.Status == LocationStatus.Started)
                {
                    _locationService.StartWatching();
                }
            };
            GpsStatus                  = _deviceService.LocationStatus;
            _locationMessageToken      = _messenger.Subscribe <LocationMessage>(GotLocation);
            _requestStartTrackingToken = _messenger.Subscribe <RequestStartTrackingMessage>(OnRequestStartTracking);
            _messenger.Subscribe <CloseAppMessage>(message =>
            {
                _messenger.Publish(new StopTrackingMessage(this, true, Token, PrivateToken, _timeEnd));
            });

            TrackConnectionStatus();
        }
Exemplo n.º 21
0
        public TestViewModel(IMvxMessenger messenger)
        {
            _messenger = messenger;

            _receivedTokenDisposable = _messenger.Subscribe<TokenChangedMessage>(msg =>
            {
                if(msg == null) return;
                var token = msg.NewToken;
                if(token == null) return;

                Issuer = token.Issuer;
                Audience = token.Audience;
                IdentityProvider = token.IdentityProvider;
                ExpiresOn = token.ExpiresOn;
                RawToken = token.RawToken;
            });

            _loggedInTokenDisposable =
                _messenger.Subscribe<LoggedInMessage>(async msg =>
                    {
                        //Validate token here, i.e. call your Web Service
                        await Task.Delay(2000);
                        //Calling this immediately, can result in nothing happening
                        //MvxAndroidTask might still be "showing".
                        _messenger.Publish(new CloseSelfMessage(this) {Close = true});
                    });
        }
        private async void EditTeamNameExecuted()
        {
            LoggingService.Trace("Executing TeamDetailsViewModel.EditTeamNameCommand");

            var promptResult = await _userDialogs.PromptAsync(new PromptConfig()
            {
                InputType  = InputType.Name,
                OkText     = "Ok",
                CancelText = "Cancel",
                Title      = "Change team name",
            });

            if (promptResult.Ok && !string.IsNullOrWhiteSpace(promptResult.Text))
            {
                var result = await _wasabeeApiV1Service.Teams_RenameTeam(Team.Id, promptResult.Text);

                if (result)
                {
                    RefreshCommand.Execute();
                    _messenger.Publish(new MessageFor <TeamsListViewModel>(this));
                }
                else
                {
                    _userDialogs.Toast("Rename failed");
                }
            }
        }
Exemplo n.º 23
0
        public async Task <Counter> AddNewCounter(string name)
        {
            var counter = new Counter {
                Name = name
            };
            await repository.Save(counter).ConfigureAwait(false);

            messenger.Publish(new CountersChangedMessage(this));

            var props = new Dictionary <string, string>();

            props.Add("Counter Name", name);
            Analytics.TrackEvent("Add new counter", props);

            return(counter);
        }
Exemplo n.º 24
0
        private void _onLocation(MvxGeoLocation location)
        {
            _isAvailable = true;

            if (LocationHelper.IsLocationTimestampRecent(location.Timestamp.LocalDateTime) == false)
            {
                return;
            }

            if (LocationHelper.FilterForAccuracy(location.Coordinates.Accuracy.Value, 10) == false)
            {
                return;
            }

            _currentLocation = location;

            var message = new LocationMessage(this,
                                              location.Coordinates.Longitude,
                                              location.Coordinates.Latitude,
                                              location.Coordinates.Speed,
                                              location.Coordinates.Heading,
                                              location.Coordinates.HeadingAccuracy,
                                              location.Timestamp.LocalDateTime);

            _messenger.Publish(message);
        }
Exemplo n.º 25
0
        public override async void Prepare()
        {
            base.Prepare();

            var appEnvironnement = _preferences.Get(ApplicationSettingsConstants.AppEnvironnement, "unknown_env");
            var appVersion       = _versionTracking.CurrentVersion;

            DisplayVersion = appEnvironnement != "unknown_env" ? $"{appEnvironnement} - v{appVersion}" : $"v{appVersion}";
            LoggedUser     = _userSettingsService.GetIngressName();

            var selectedOpId = _preferences.Get(UserSettingsKeys.SelectedOp, string.Empty);

            if (!string.IsNullOrWhiteSpace(selectedOpId))
            {
                var op = await _operationsDatabase.GetOperationModel(selectedOpId);

                SelectedOpName = op == null ? "ERROR loading OP" : op.Name;
            }

            if (_preferences.Get(UserSettingsKeys.LiveLocationSharingEnabled, false))
            {
                _isLiveLocationSharingEnabled = true;
                _messenger.Publish(new LiveGeolocationTrackingMessage(this, Action.Start));
                await RaisePropertyChanged(() => IsLiveLocationSharingEnabled);
            }
        }
 public RunEntryViewModel(IMvxMessenger messenger, Run run)
 {
     _messenger             = messenger;
     Run                    = run;
     DisqualifySkierCommand =
         new MvxCommand <Run>(r => _messenger.Publish(new DisqualifySkierMessage(this, Run)));
 }
        private void ComposeEmailToProspect()
        {
            var activity = createAdHocActivity("Email", "Emailed from App");

            _navigationService.Navigate <AddActivityViewModel, Activity>(activity);
            var email = new EmailMessage()
            {
                EmailCallback = async(ok) =>
                {
                    if (!ok)
                    {
                        await _dialogService.ShowAlertAsync("Outlook could not be launched", "Error", "Ok");
                    }
                    else
                    {
                        //give them time as outlook will launch, so don't reload app upon their return
                        Messenger.Publish(new ExtendReloadTime(this)
                        {
                            ExtendMinutes = 5
                        });
                    }
                },
                ToEmailAddress = _prospect.Email.EmailAddress,
                Subject        = "",
                Body           = ""
            };

            _emailInteraction.Raise(email);
            Analytics.TrackEvent("Emailed From App", new Dictionary <string, string>
            {
                { "SalesAssociate", _prospect.ProspectCommunity.SalespersonAddressNumber.ToString() + " " + _prospect.ProspectCommunity.SalespersonName },
                { "Community", _prospect.ProspectCommunity.CommunityNumber + " " + _prospect.ProspectCommunity.Community.Description },
                { "User", _user.AddressBook.AddressNumber + " " + _user.AddressBook.Name },
            });
        }
 private void Load()
 {
     _messenger.Publish(new LoadingChangedMessage(this, true));
     try
     {
         List <Pattern> favorites = _favoritesService.All();
         foreach (var favorite in favorites)
         {
             Items.Add(favorite);
         }
     }
     finally
     {
         _messenger.Publish(new LoadingChangedMessage(this, false));
     }
 }
Exemplo n.º 29
0
        public void Init(RestaurantDetailViewModel.Navigation nav)
        {
            Item = _dataService.GetItem(nav.Id);

            _geoCoder.GeoCodeAddress(Item.Location, (double arg1, double arg2, Exception arg3) =>
            {
                if (arg3 == null)
                {
                    _messenger.Publish(new GeoCodingDoneMessage(this, arg1, arg2, false));
                }
                else
                {
                    _messenger.Publish(new GeoCodingDoneMessage(this, 0, 0, true));
                }
            });
        }
Exemplo n.º 30
0
		public JabbrService()
		{
			Connections = new ObservableCollection<JabbrConnection> ();

			Settings = Mvx.Resolve<ISettingsService> ();
			Messenger = Mvx.Resolve<IMvxMessenger> ();

			Settings.Accounts.CollectionChanged += (sender, e) => {

				if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Remove)
				{
					foreach (Account a in e.OldItems)
					{
						var cons = Connections.Where(c => c.Account.Id == a.Id);

						if (cons != null)
							foreach (var con in cons)
								con.Client.Disconnect();
					}
				}
				else if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add)
				{
					foreach (Account a in e.NewItems)
					{
						if (Connections.Where(con => con.Account.Id == a.Id).Count() <= 0)
							AddClient(a);
					}
				}

				Messenger.Publish<AccountsChangedMessage>(new AccountsChangedMessage(this));
			};
		}
Exemplo n.º 31
0
 private void PublishChanges()
 {
     _messenger.Publish(new LoggedUserInfoChangedMessage(this,
                                                         user: MicrosoftGraphService.LoggedUser,
                                                         email: MicrosoftGraphService.LoggedUserEmail,
                                                         photo: MicrosoftGraphService.LoggedUserPhoto));
 }
Exemplo n.º 32
0
 public void LoadViewModelData(Results results)
 {
     if (results != null)
     {
         // dummy data
         _dummyCarouselViewModel = new List <DummyCarouselViewModel>();
         foreach (var verticalItem in results.VerticalTiles)
         {
             if (verticalItem != null)
             {
                 _dummyCarouselViewModel.Add(new DummyCarouselViewModel()
                 {
                     Title = string.Format("{0}", verticalItem.Title),
                     Tiles = InitTiles(verticalItem)
                 });
             }
         }
         _messenger.Publish(new CustomMessage(this, true));
         IsBusy = false;
     }
     else
     {
         //could not load data
         _loggingService.Log("Could not load data ");
     }
 }
Exemplo n.º 33
0
        public MainViewModel()
        {
            _ds = BettrFitDataSource.Instance;
            _messenger = Mvx.Resolve<IMvxMessenger>();

            _mapNav = new Dictionary<string, Type>();
            _mapNav.Add(menuNutritionPlan, typeof(NutritionPlanOverviewViewModel));
            _mapNav.Add(menuNutritiondiary, typeof(NutritionPlanMainViewModel));
            _mapNav.Add(menuGoals, typeof(GoalOverviewViewModel));
            _mapNav.Add(menuNutrition, typeof(NutritionPlanMainViewModel));
            _mapNav.Add(menuWeight, typeof(DailyDataOverviewViewModel));

            _mapNav.Add("Login", typeof(LoginViewModel));
            _mapNav.Add("Login mit Facebook", typeof(FirstViewModel));
            _mapNav.Add(CultureHelper.GetLocalString("Register|Registrieren"), typeof(RegisterViewModel));

            NavCommands = new ObservableCollection<NavEntry>();

            NavCommand = new MvxCommand<string>(OnNavCommand);

            LogoffCommand = new MvxCommand(OnLogoffCommand);
            RefreshCommand = new MvxCommand(OnRefreshCommand);
            ShowInfoCommand = new MvxCommand(OnShowInfo);
            FeedbackCommand = new MvxCommand(OnFeedbackCommand);
            ShakeCommand = new MvxCommand(()=>_messenger.Publish(new ShakeEvent(this)));

            ShowAGBCommand = new MvxCommand(OnShowAGB);

            _logintoken = _messenger.Subscribe<LoggedInEvent>(a => LoginChanged(a.LoggedIn));
            _synctoken = _messenger.Subscribe<SyncEvent>(a => RaisePropertyChanged("Sync"));
            _nonetworktoken = _messenger.SubscribeOnMainThread<NetworkEvent>(m =>
            {
                IsNetworkAvailable = m.IsAvailable;
            });

            LoginChanged(_ds.IsLoggedIn());

            //var client = WebService.Instance.WS;

            RaisePropertyChanged("Sync");

            IsNotRefreshing = true;
        }
Exemplo n.º 34
0
        public DialogsViewModel(IUserDialogService dialogService, IMvxMessenger messenger) {
			this.dialogs = dialogService;
            this.backgroundToken = messenger.Subscribe<BackgroundAlert>(msg => 
                dialogService.Toast(msg.Message)
            );

            this.SendBackgroundAlert = new MvxCommand(() => 
                messenger.Publish(new BackgroundAlert(this, "Test"))
            );

            this.ActionSheet = new MvxCommand(() => 
                dialogService.ActionSheet(new ActionSheetConfig()
                    .SetTitle("Test Title")
                    .Add("Option 1", () => this.Result = "Option 1 Selected")
                    .Add("Option 2", () => this.Result = "Option 2 Selected")
                    .Add("Option 3", () => this.Result = "Option 3 Selected")
                    .Add("Option 4", () => this.Result = "Option 4 Selected")
                    .Add("Option 5", () => this.Result = "Option 5 Selected")
                    .Add("Option 6", () => this.Result = "Option 6 Selected")
                )
            );

            this.Alert = new MvxCommand(async () => {
                await dialogService.AlertAsync("Test alert", "Alert Title", "CHANGE ME!");
                this.Result = "Returned from alert!";
            });

            this.Confirm = new MvxCommand(async () => {
                var r = await dialogService.ConfirmAsync("Pick a choice", "Pick Title", "Yes", "No");
                var text = (r ? "Yes" : "No");
                this.Result = "Confirmation Choice: " + text;
            });

            this.Login = new MvxCommand(async () => {
                var r = await dialogService.LoginAsync(message: "Enter your user name & password below");
                this.Result = String.Format(
                    "Login {0} - User Name: {1} - Password: {2}",
                    r.Ok ? "Success" : "Cancelled",
                    r.LoginText,
                    r.Password
                );
            });

            this.Prompt = new MvxCommand(async () => {
                var r = await dialogService.PromptAsync("Enter a value");
                this.Result = r.Ok
                    ? "OK " + r.Text
                    : "Prompt Cancelled";
            });

            this.PromptSecure = new MvxCommand(async () => {
                var r = await dialogService.PromptAsync("Enter a value", inputType: InputType.Password);
                this.Result = r.Ok
                    ? "OK " + r.Text
                    : "Secure Prompt Cancelled";
            });

            this.Toast = new MvxCommand(() => {
                this.Result = "Toast Shown";
                dialogService.Toast("Test Toast", onClick: () => this.Result = "Toast Pressed");
            });

            this.Progress = new MvxCommand(async () => {
                var cancelled = false;

                using (var dlg = dialogService.Progress("Test Progress")) {
                    dlg.SetCancel(() => cancelled = true);
                    while (!cancelled && dlg.PercentComplete < 100) {
                        await Task.Delay(TimeSpan.FromMilliseconds(500));
                        dlg.PercentComplete += 2;
                    }
                }
                this.Result = (cancelled ? "Progress Cancelled" : "Progress Complete");
            });

            this.ProgressNoCancel = new MvxCommand(async () => {
                using (var dlg = dialogService.Progress("Progress (No Cancel)")) {
                    while (dlg.PercentComplete < 100) {
                        await Task.Delay(TimeSpan.FromSeconds(1));
                        dlg.PercentComplete += 20;
                    }
                }
            });

            this.Loading = new MvxCommand(async () => {
                var cancelSrc = new CancellationTokenSource();

                using (var dlg = dialogService.Loading("Test Progress")) {
                    dlg.SetCancel(cancelSrc.Cancel);

                    try { 
                        await Task.Delay(TimeSpan.FromSeconds(5), cancelSrc.Token);
                    }
                    catch { }
                }
                this.Result = (cancelSrc.IsCancellationRequested ? "Loading Cancelled" : "Loading Complete");
            });

            this.LoadingNoCancel = new MvxCommand(async () => {
                using (dialogService.Loading("Loading (No Cancel)")) 
                    await Task.Delay(TimeSpan.FromSeconds(3));

                this.Result = "Loading Complete";
            });
        }