Exemple #1
0
        private async Task SaveActivity()
        {
            bool isCreatedSuccessfully = true;

            try
            {
                IsBusy = true;
                //TODO: Glenn - add more screen options to save
                await _stravaService.UploadActivityAsync(
                    _gpxFile,
                    Enum <ActivityRecording> .Parse(ActivityText) == ActivityRecording.Cycling?ActivityType.Ride : ActivityType.Run,
                    ActivityName,
                    false,
                    false);
            }
            catch (Exception)
            {
                isCreatedSuccessfully = false;
            }
            finally
            {
                IsBusy = false;
            }

            if (isCreatedSuccessfully)
            {
                await _messageBoxService.ShowAsync($"Activity '{ActivityName}' was created successfuly!", "Activity created");

                NavigationService.Navigate <MainPage>();
            }
            else
            {
                await _messageBoxService.ShowAsync($"Something went wrong while saving activity '{ActivityName}'.\nPlease try again.", "Something went wrong");
            }
        }
 /// <summary>
 /// Updates the univerity.
 /// </summary>
 private async void UpdateUniverity()
 {
     if (SelectedUniversity != null)
     {
         _navigationService.NavigateTo(typeof(EditUniversityPage), SelectedUniversity);
     }
     else
     {
         await _messageBoxService.ShowAsync("Select one university.", "SQLite Sample");
     }
 }
Exemple #3
0
 /// <summary>
 /// Deletes the student.
 /// </summary>
 public async Task DeleteStudentAsync()
 {
     if (SelectedStudent != null)
     {
         await _dataService.DeleteStudentAsync(SelectedStudent);
         await LoadData(University);
     }
     else
     {
         _messageBoxService.ShowAsync("Select one student.", "SQLite Sample");
     }
 }
        public static async Task HandleFailedSynced(SyncFailedEventArgs e, IMessageBoxService messageBoxService, INavigationService navigationService)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e));
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException(nameof(messageBoxService));
            }
            if (navigationService == null)
            {
                throw new ArgumentNullException(nameof(navigationService));
            }

            string message = e.Message ?? string.Empty;
            string details = null;

            if (e.Exception != null)
            {
                details = ExceptionExtension.BeautifyAsyncStacktrace(e.Exception.ToString());
            }

            if (!string.IsNullOrEmpty(message))
            {
                if (!string.IsNullOrEmpty(details))
                {
                    var result = await messageBoxService.ShowAsync(
                        StringResources.Sync_FailedMessage,
                        message,
                        new[] { StringResources.General_LabelOk, StringResources.General_LabelDetails });

                    if (result.ButtonIndex == 1)
                    {
                        details = string.Format("{0}\r\n{1}", message, details);
                        await messageBoxService.ShowAsync(StringResources.Message_Information, details);
                    }
                }
                else
                {
                    await messageBoxService.ShowAsync(StringResources.Message_Warning, message);
                }

                if (message.Equals(StringResources.Exchange_InvalidSyncKeyWorkaround))
                {
                    navigationService.FlyoutTo(ViewLocator.SyncAdvancedSyncSettingsPage);
                }
            }
        }
Exemple #5
0
        internal async void HandleException(Exception exception, bool startedByUser = false)
        {
            var errorMessage = ExceptionHandlerService.Instance.Handle(exception);


#if DEBUG
            MessageBoxService.Show(exception.ToString());
            return;
#endif

            if (startedByUser)
            {
                try
                {
                    await MessageBoxService.ShowAsync(errorMessage, AppResources.App_Error);
                }
                catch (Exception)
                {
                }
            }
            else
            {
                ShowErrorMessage(errorMessage);
            }
        }
        private async void OnBtnMail(object sender, RoutedEventArgs e)
        {
            ITrackingManager   trackingManager   = Ioc.Resolve <ITrackingManager>();
            IMessageBoxService messageBoxService = Ioc.Resolve <IMessageBoxService>();

            try
            {
                var email = new EmailMessage
                {
                    Subject = "2Day Logs",
                    Body    = "Logs are available as attachments"
                };

                await MailHelper.AddAttachment(email, "2day.db", "2day.db");

                await MailHelper.AddAttachment(email, LogService.Filename, "logs.txt");

                await EmailManager.ShowComposeNewEmailAsync(email);
            }
            catch (Exception ex)
            {
                string message = "Error while sending logs by email: " + ex;
                trackingManager.Exception(ex, message);
                messageBoxService.ShowAsync(StringResources.General_LabelError, message);
            }
        }
Exemple #7
0
        public async Task GetEpisodeDetails()
        {
            if (NavigationService.IsNetworkAvailable)
            {
                var index = SelectedEpisode.IndexNumber;
                if (SelectedEpisode != null && Episodes.IsNullOrEmpty())
                {
                    SetProgressBar(AppResources.SysTrayGettingEpisodeDetails);

                    try
                    {
                        if (string.IsNullOrEmpty(SelectedEpisode.SeriesId))
                        {
                            var episode = await ApiClient.GetItemAsync(SelectedEpisode.Id, AuthenticationService.Current.LoggedInUserId);

                            if (episode == null)
                            {
                                await _messageBox.ShowAsync(AppResources.ErrorEpisodeDetails);

                                NavigationService.GoBack();
                                return;
                            }

                            SelectedEpisode = episode;
                        }

                        var query = new EpisodeQuery
                        {
                            UserId   = AuthenticationService.Current.LoggedInUserId,
                            SeasonId = SelectedEpisode.SeasonId,
                            SeriesId = SelectedEpisode.SeriesId,
                            Fields   = new[]
                            {
                                ItemFields.ParentId,
                                ItemFields.Overview,
                                ItemFields.MediaSources,
                            }
                        };

                        //Log.Info("Getting episodes for Season [{0}] ({1}) of TV Show [{2}] ({3})", SelectedSeason.Name, SelectedSeason.Id, SelectedTvSeries.Name, SelectedTvSeries.Id);

                        var episodes = await ApiClient.GetEpisodesAsync(query);

                        Episodes = episodes.Items.OrderBy(x => x.IndexNumber).ToList();
                    }
                    catch (HttpException ex)
                    {
                        Utils.HandleHttpException("GetEpisodeDetails()", ex, NavigationService, Log);
                    }

                    SetProgressBar();
                }

                if (SelectedEpisode != null)
                {
                    SelectedEpisode = Episodes.FirstOrDefault(x => x.IndexNumber == index);
                    CanResume       = SelectedEpisode != null && SelectedEpisode.CanResume;
                }
            }
        }
        protected override void WireMessages()
        {
            Messenger.Default.Register <NotificationMessage>(this, m =>
            {
                if (m.Notification.Equals(Constants.Messages.ReaderViewLeftMsg))
                {
                    ShowFinishedScreen = false;
                    if (_readerTimer != null && _readerTimer.IsEnabled)
                    {
                        _readerTimer.Stop();
                    }

                    var wordsRead          = SelectedIndex * _settingsService.WordsAtATime;
                    var articleNotFinished = wordsRead < SelectedItem.WordCount;
                    if (articleNotFinished)
                    {
                        _roamingSettings.Set(SelectedItem.InternalId, wordsRead);
                    }
                    else
                    {
                        _roamingSettings.Remove(SelectedItem.InternalId);
                    }

                    SaveInProgressItems(wordsRead, !articleNotFinished);
                }
            });

            Messenger.Default.Register <ShareMessage>(this, async m =>
            {
                _shareOperation = (ShareOperation)m.Sender;
                if (_shareOperation.Data.Contains(StandardDataFormats.WebLink))
                {
                    var url     = await _shareOperation.Data.GetWebLinkAsync();
                    var message = new UriSchemeMessage(url.ToString(), true, SchemeType.Read);

                    await SaveItemFromExternal(message, async() =>
                    {
                        var title = _loader.GetString("ShareErrorTitle");
                        await _messageBox.ShowAsync(_loader.GetString("ShareErrorText"), title, new List <string> {
                            _loader.GetString("MessageBoxOk")
                        });
                        _shareOperation.ReportError(title);
                    });
                }
                else
                {
                    _shareOperation.ReportCompleted();
                }
            });

            Messenger.Default.Register <UriSchemeMessage>(this, async m =>
            {
                if (m.SchemeType != SchemeType.Read)
                {
                    return;
                }

                await SaveItemFromExternal(m);
            });
        }
Exemple #9
0
        private async void LogInCommandExec(string provider)
        {
            InProgress = true;
            Session session = null;

            switch (provider)
            {
            case Constants.FacebookProvider:
                if (!IsFacebookConnected)
                {
                    session = await sessionService.LoginAsync(provider);
                }
                else
                {
                    IsFacebookConnected = !applicationSettings.RemoveCredentials(provider);
                }
                break;

            case Constants.GoogleProvider:
                if (!IsGoogleConnected)
                {
                    session = await sessionService.LoginAsync(provider);
                }
                else
                {
                    IsGoogleConnected = !applicationSettings.RemoveCredentials(provider);
                }
                break;

            case Constants.MicrosoftProvider:
                if (!IsMicrosoftConnected)
                {
                    session = await sessionService.LoginAsync(provider);
                }
                else
                {
                    IsMicrosoftConnected = !applicationSettings.RemoveCredentials(provider);
                }
                break;
            }

            if (session == null)
            {
                return;
            }
            if (session.AccessToken == string.Empty)
            {
                await messageBoxService.ShowAsync("Something went wrong...", "Login Social Demo", new List <string> {
                    "Ok"
                });
            }
            else
            {
                InProgress = false;
                navigationService.Navigate <MainPage>(session);
                navigationService.RemoveBackEntry();
                navigationService.RemoveBackEntry();
            }
        }
Exemple #10
0
        async void ShowMessageBox()
        {
            IMessageBoxService dialogService = ServiceContainer.GetService <IMessageBoxService>();
            var           buttons            = (MessageButton)Enum.Parse(typeof(MessageButton), SelectedMessageDialogButtons);
            MessageResult result             = await dialogService.ShowAsync(Message, Title, buttons);

            Output = result.ToString();
        }
Exemple #11
0
        public static async Task <MessageResult> ShowAsync(this IMessageBoxService service, string messageBoxText, string caption, MessageButton button, MessageResult defaultResult, MessageResult cancelResult)
        {
            VerifyService(service);
            var       buttons   = UICommand.GenerateFromMessageButton(button, GetLocalizer(service), defaultResult, cancelResult);
            UICommand uicommand = await service.ShowAsync(messageBoxText, caption, buttons);

            return((MessageResult)uicommand.Id);
        }
Exemple #12
0
        public void TryGoingBack()
        {
            if (!IsUploading)
            {
                if (_navigationService.CanGoBack)
                {
                    _navigationService.GoBack();
                }

                return;
            }

            _messageBoxService.ShowAsync(Resources.ErrorStillUploadingBack, Resources.ErrorTitle, new List <string> {
                Resources.Ok
            });
        }
        private async void OnRunUnderLockChanged()
        {
            if (_ignoreRunUnderLockChanged)
            {
                return;
            }

            var result = await _messageBox.ShowAsync(AppResources.ErrorPlayUnderLock, AppResources.ErrorPleaseRestart, new List <string> {
                AppResources.LabelRestartNow, AppResources.LabelLater
            });

            App.SpecificSettings.PlayVideosUnderLock = RunUnderLock;

            if (result == 0)
            {
                _applicationSettings.Set(Constants.Settings.SpecificSettings, App.SpecificSettings);

                Application.Current.Terminate();
            }
        }
        public static async Task CheckWarningBeforeSync(IWorkbook workbook, ISynchronizationManager syncManager, IMessageBoxService messageBoxService, IPlatformService platformService)
        {
            if (workbook == null)
            {
                throw new ArgumentNullException("workbook");
            }
            if (syncManager == null)
            {
                throw new ArgumentNullException("syncManager");
            }
            if (messageBoxService == null)
            {
                throw new ArgumentNullException("messageBoxService");
            }
            if (platformService == null)
            {
                throw new ArgumentNullException("platformService");
            }

            // check if context warning has already been shown
            if (!workbook.Settings.GetValue <bool>(CoreSettings.SyncWarningContextNotSupported))
            {
                if (workbook.Contexts.Count > 0 && !syncManager.ActiveProviderSupportFeature(SyncFeatures.Context))
                {
                    // show warning
                    var result = await messageBoxService.ShowAsync(
                        StringResources.Dialog_TitleConfirmation,
                        StringResources.Dialog_SyncContextsNotSupported,
                        DialogButton.YesNo);

                    if (result == DialogResult.Yes)
                    {
                        await platformService.OpenWebUri(Constants.HelpPageChooseSyncAddress);
                    }

                    workbook.Settings.SetValue(CoreSettings.SyncWarningContextNotSupported, true);
                }
            }
        }
Exemple #15
0
        private async void OnStravaStatusEvent(object sender, Services.StravaServiceEventArgs e)
        {
            switch (e.Status)
            {
            case StravaServiceStatus.Success:
                _stravaService.StatusEvent -= OnStravaStatusEvent;

                //Remove the current 'login page' back entry and navigate to the main page
                NavigationService.Navigate <MainPage>();
                NavigationService.RemoveBackEntry();

                IsBusy = false;
                break;

            case StravaServiceStatus.Failed:
                IsBusy = false;

                //TODO: Glenn - Add more text value through resources
                await _messageBoxService.ShowAsync("Something happend...", "Error");

                break;
            }
        }
Exemple #16
0
 public static async Task <MessageResult> ShowAsync(this IMessageBoxService service, string messageBoxText)
 {
     return(await service.ShowAsync(messageBoxText, string.Empty));
 }
Exemple #17
0
 public static async Task <MessageResult> ShowAsync(this IMessageBoxService service, string messageBoxText, string caption, MessageButton button, MessageResult defaultResult)
 {
     return(await service.ShowAsync(messageBoxText, caption, button, defaultResult, MessageResult.OK));
 }