Esempio n. 1
0
        private async void OnDeleteMenuFlyoutItemClick(object sender, RoutedEventArgs e)
        {
            var isContinue = await MainPage.WarnFullSyncIfNeeded();

            if (!isContinue)
            {
                return;
            }
            collection.ModSchema();

            if (selectedTag == null)
            {
                return;
            }

            if (CheckIfSystemTag(selectedTag.Name))
            {
                await ShowInvaildActionMessage();

                return;
            }

            var noteList = collection.FindNotes("tag:" + selectedTag.Name);

            if (!confirmDialog.IsNotAskAgain())
            {
                confirmDialog.Message = String.Format(REMOVE_TAGS_MESSAGE, selectedTag.Name, noteList.Count);
                await confirmDialog.ShowAsync();

                if (confirmDialog.IsRightButtonClick())
                {
                    return;
                }
            }

            collection.Tags.RemoveTagFromNotesAndCollection(noteList, selectedTag.Name);
            selectedTag.Visibility = Visibility.Collapsed;
            ViewModel.Tags.Remove(selectedTag);
            selectedTag = null;
        }
Esempio n. 2
0
        private async Task <bool?> AskForceSyncInOneDirection()
        {
            await CloseSyncStateDialog();

            ThreeOptionsDialog dialog = new ThreeOptionsDialog();

            dialog.Message = "Your current collection has been modified without syncing to the server first." +
                             " As a result, some of your changes will be lost.\n\n"
                             + "Choosing \"Download\" will replace your current collection with the one from the server."
                             + " (A backup will also be created.)\n\n"
                             + "Choosing \"Upload\" will upload your current collection to the server.\n\n"
                             + "(If in doubt, choose \"Download\" as you can restore your data from the backup.)";
            dialog.Title = "Out of Sync";
            dialog.LeftButton.Content   = "Download";
            dialog.MiddleButton.Content = "Upload";
            dialog.RightButton.Content  = "Cancel";
            await dialog.ShowAsync();

            await dialog.WaitForDialogClosed();

            syncStateDialog.Show(MainPage.UserPrefs.IsReadNightMode);
            return(dialog.ThreeStateChoose);
        }
Esempio n. 3
0
        private async Task ConfirmAndStartFullSync()
        {
            var fullSyncclient = new FullSyncer(mainPage.Collection, hostKey);

            fullSyncclient.OnHttpProgressEvent += OnServerHttpProgressEvent;
            ThreeOptionsDialog dialog = new ThreeOptionsDialog();

            dialog.Title   = "Full Sync Direction";
            dialog.Message = "Your collection has been modified in a way that a full sync is required.\n"
                             + "\"Download\" will download the collection from the sever and replace your current one. Unsynced changes will be lost.\n"
                             + "\"Upload\" will upload your current collection to the server. Unsynced changes on OTHER devices will be lost.";
            dialog.LeftButton.Content   = "Download";
            dialog.MiddleButton.Content = "Upload";
            await dialog.ShowAsync();

            await dialog.WaitForDialogClosed();

            if (dialog.IsLeftButtonClick())
            {
                await MainPage.BackupDatabase();
                await DownloadFullDatabase(fullSyncclient);
            }
            else if (dialog.IsMiddleButtonClick())
            {
                var isContinue = await UIHelper.AskUserConfirmation("UPLOAD your collection to the server?");

                if (isContinue)
                {
                    await UploadFullDatabase(fullSyncclient);
                }
            }

            SetSyncLabel("Finished.");
            await Task.Delay(250);

            await WaitForCloseSyncStateDialog();
        }