Exemplo n.º 1
0
        protected override async void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (this.DataContext == null)
            {
                string taskIdString = "";
                if (NavigationContext.QueryString.TryGetValue("id", out taskIdString))
                {
                    this.IsEnabled = false;
                    //Lade bekannten Task.
                    SystemTrayHelper.ShowProgress(this, Localization.Strings.MainPageProgressIndicatorLoggingIn, 1);
                    await App.DataManager.LogInTask;
                    SystemTrayHelper.ShowProgress(this, Localization.Strings.TaskPageProgressIndicatorLoadingTask, 1);
                    var task = await App.DataManager.GetTask(taskIdString);

                    SystemTrayHelper.HideProgress(this);
                    if (task != null)
                    {
                        this.DataContext = new TaskPageViewModel(App.DataManager, task);
                        this.IsEnabled   = true;
                    }
                    else
                    {
                        if (System.Diagnostics.Debugger.IsAttached) //Fehler, selbst online existiert der Task nicht
                        {
                            System.Diagnostics.Debugger.Break();
                        }
                        Controls.SafeMessageBox.Show(Localization.Strings.TaskPageNotFoundMessage, "");
                        isRemoved = true;
                        this.NavigationService.GoBack();
                        return;
                    }
                }
                else //Neuer Task wurde erstellt.
                {
                    if (NavigationContext.QueryString.TryGetValue("copy", out taskIdString))
                    {
                        this.DataContext = TaskPageViewModel.CreateTask(App.DataManager, taskIdString);
                    }
                    else
                    {
                        this.DataContext = TaskPageViewModel.CreateTask(App.DataManager);
                    }
                }
            }

            SetupAppBar();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Aktualisiert das SystemTray gemäß dem was der DataManager grade macht.
        /// </summary>
        private async void DoSystemTrayStuff()
        {
            SystemTrayHelper.ShowProgress(this, Localization.Strings.MainPageProgressIndicatorLoggingIn, 0.5);
            if (App.DataManager.LogInTask != null)
            {
                await App.DataManager.LogInTask;
            }

            SystemTrayHelper.ShowProgress(this, Localization.Strings.MainPageProgressIndicatorUploading, 0.5);
            if (App.DataManager.SyncUploadTask != null)
            {
                await App.DataManager.SyncUploadTask;
            }

            SystemTrayHelper.ShowProgress(this, Localization.Strings.MainPageProgressIndicatorSyncing, 0.5);
            if (App.DataManager.SyncDownloadTask != null)
            {
                await App.DataManager.SyncDownloadTask;
            }

            SystemTrayHelper.Hide(this);
        }