Esempio n. 1
0
        private void NotesList_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListViewItem lvi = WPFHelper.VisualLVUpwardSearch(e.OriginalSource as DependencyObject);

            if (lvi != null)
            {
                // click on item

                var cms = new ContextMenu
                {
                    Items =
                    {
                        new AutoActionMenuItem {
                            Header = "Export", AlephAction = "ExportNote", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "Duplicate", AlephAction = "DuplicateNote", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "Pin / Unpin", AlephAction = "PinUnpinNote", ParentAnchor = ParentAnchor
                        },
                        new Separator(),
                        new AutoActionMenuItem {
                            Header = "Delete", AlephAction = "DeleteNote", ParentAnchor = ParentAnchor
                        },
                    }
                };
                HierachicalNotesList.ContextMenu = null;
                WPFHelper.ExecDelayed(100, () => { HierachicalNotesList.ContextMenu = cms; cms.IsOpen = true; });
            }
            else
            {
                // click on free space

                var cms = new ContextMenu
                {
                    Items =
                    {
                        new AutoActionMenuItem {
                            Header = "New Note", AlephAction = "NewNote", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "New Note (from clipboard)", AlephAction = "NewNoteFromClipboard", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "New Note (from text file)", AlephAction = "NewNoteFromTextFile", ParentAnchor = ParentAnchor
                        },
                    }
                };
                HierachicalNotesList.ContextMenu = cms;
                cms.IsOpen = true;
            }
        }
Esempio n. 2
0
        private void FolderTreeView_OnPreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            TreeViewItem treeViewItem = WPFHelper.VisualTVUpwardSearch(e.OriginalSource as DependencyObject);

            if (treeViewItem != null)
            {
                treeViewItem.Focus();
                e.Handled = true;
            }

            if (treeViewItem != null)
            {
                // click on item

                var cms = new ContextMenu
                {
                    Items =
                    {
                        new AutoActionMenuItem {
                            Header = "Add subfolder", AlephAction = "AddSubFolder", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "Rename folder", AlephAction = "RenameFolder", ParentAnchor = ParentAnchor
                        },
                        new Separator(),
                        new AutoActionMenuItem {
                            Header = "Delete folder", AlephAction = "DeleteFolder", ParentAnchor = ParentAnchor
                        },
                    }
                };
                FolderTreeView.ContextMenu = null;
                WPFHelper.ExecDelayed(100, () => { FolderTreeView.ContextMenu = cms; cms.IsOpen = true; });
            }
            else
            {
                // click on free space

                var cms = new ContextMenu
                {
                    Items =
                    {
                        new AutoActionMenuItem {
                            Header = "Add subfolder", AlephAction = "AddSubFolder", ParentAnchor = ParentAnchor
                        },
                    }
                };
                FolderTreeView.ContextMenu = cms;
                cms.IsOpen = true;
            }
        }
Esempio n. 3
0
        private void NotesList_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var lvi = WPFHelper.VisualLVUpwardSearch(e.OriginalSource as DependencyObject);

            if (lvi != null)
            {
                // click on item

                var cms = NotesViewControlCommon.GetContextMenuNote(ParentAnchor);

                NotesList.ContextMenu = null;
                WPFHelper.ExecDelayed(50, () => { NotesList.ContextMenu = cms; cms.IsOpen = true; });
            }
            else
            {
                // click on free space

                var cms = NotesViewControlCommon.GetContextMenuEmpty(ParentAnchor);

                NotesList.ContextMenu = cms;
                cms.IsOpen            = true;
            }
        }
Esempio n. 4
0
        public void OnAfterMigrate(Version versionFrom, Version versionTo)
        {
            #region 1.7.0
            if (versionFrom != default && versionFrom < new Version(1, 7, 0))
            {
                App.Logger.Info("MainWindow", $"Trigger Migration [[StandardNote.FullResync after 004]] by migration from {versionFrom} to {versionTo}");

                var guidStandardNotes = Guid.Parse("30d867a4-cbdc-45c5-950a-c119bf2f2845");

                if (Settings.ActiveAccount.Plugin.GetUniqueID() == guidStandardNotes && Settings.Accounts.Count(p => p.Plugin.GetUniqueID() == guidStandardNotes) == 1 && _viewmodel.Repository.Notes.All(n => n.IsLocalSaved && n.IsRemoteSaved))
                {
                    // Best case, the only SN account is active and all notes are saved & synced

                    WPFHelper.ExecDelayed(100, () => { _viewmodel.FullResync(false); });
                }
                else if (Settings.ActiveAccount.Plugin.GetUniqueID() == guidStandardNotes && _viewmodel.Repository.Notes.All(n => n.IsLocalSaved && n.IsRemoteSaved))
                {
                    // Medium case, the active account is SN and all notes are saved & synced, but there exist other SN accounts

                    WPFHelper.ExecDelayed(100, () => { _viewmodel.FullResync(false); });

                    System.Windows.MessageBox.Show(
                        this,
                        "It appears you are having one or more accounts that sync with StandardNotes.\nDue to changes with the StandardNotes API it is recommended to do a full resync of your data (via the [Edit] -> [Delete local data and sync new] menu option).\nThis is necessary for all StandardNotes accounts but only for this update. Failing to do so can result in sync problems",
                        "Important Notification about the StandardNotes plugin",
                        MessageBoxButton.OK,
                        MessageBoxImage.Exclamation,
                        MessageBoxResult.OK,
                        System.Windows.MessageBoxOptions.None);
                }
                else if (Settings.ActiveAccount.Plugin.GetUniqueID() == guidStandardNotes)
                {
                    // Bad case, the active account is SN, but some notes are not synced

                    var r = System.Windows.MessageBox.Show(
                        this,
                        "Due to an update in the StandardNotes API and an accompanying update of the StandardNotes plugin (v1.7.0) it is necessary to do a full resync of your data to prevent synchronization problems.\nThis will clear all your local data and download notes and tags from the StandardNotes server anew.\nIf all your data is synchronized (which it should always be) this won't change any notes or tags.\n\nIf you don't do that now you can always do the same action later via the menu item:\n[Edit] -> [Delete local data and sync new].",
                        "Important Notification about the StandardNotes plugin",
                        MessageBoxButton.OKCancel,
                        MessageBoxImage.Exclamation,
                        MessageBoxResult.OK,
                        System.Windows.MessageBoxOptions.None);

                    if (r == MessageBoxResult.OK)
                    {
                        WPFHelper.ExecDelayed(1000, () => { _viewmodel.FullResyncCommand.Execute(null); });
                    }
                }
                else if (Settings.Accounts.Any(p => p.Plugin.GetUniqueID() == guidStandardNotes))
                {
                    // There are some SN accounts - but they are not active

                    System.Windows.MessageBox.Show(
                        this,
                        "It appears you are having one or more accounts that sync with StandardNotes.\nDue to changes with the StandardNotes API it is recommended to do a full resync of your data (via the [Edit] -> [Delete local data and sync new] menu option).\nThis is necessary for all StandardNotes accounts but only for this update. Failing to do so can result in sync problems",
                        "Important Notification about the StandardNotes plugin",
                        MessageBoxButton.OK,
                        MessageBoxImage.Exclamation,
                        MessageBoxResult.OK,
                        System.Windows.MessageBoxOptions.None);
                }
                #endregion
            }
        }
Esempio n. 5
0
        private void NotesList_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            ListViewItem lvi = WPFHelper.VisualLVUpwardSearch(e.OriginalSource as DependencyObject);

            if (lvi != null)
            {
                // click on item

                var pin = MainWindow.Instance?.VM?.Repository?.SupportsPinning ?? false;
                var lck = MainWindow.Instance?.VM?.Repository?.SupportsLocking ?? false;

                var cms = new ContextMenu();

                cms.Items.Add(new AutoActionMenuItem {
                    Header = "Export", AlephAction = "ExportNote", ParentAnchor = ParentAnchor
                });
                cms.Items.Add(new AutoActionMenuItem {
                    Header = "Duplicate", AlephAction = "DuplicateNote", ParentAnchor = ParentAnchor
                });
                if (pin)
                {
                    cms.Items.Add(new AutoActionMenuItem {
                        Header = "Pin / Unpin", AlephAction = "PinUnpinNote", ParentAnchor = ParentAnchor
                    });
                }
                if (lck)
                {
                    cms.Items.Add(new AutoActionMenuItem {
                        Header = "Lock / Unlock", AlephAction = "LockUnlockNote", ParentAnchor = ParentAnchor
                    });
                }
                cms.Items.Add(new Separator());
                cms.Items.Add(new AutoActionMenuItem {
                    Header = "Delete", AlephAction = "DeleteNote", ParentAnchor = ParentAnchor
                });

                NotesList.ContextMenu = null;
                WPFHelper.ExecDelayed(50, () => { NotesList.ContextMenu = cms; cms.IsOpen = true; });
            }
            else
            {
                // click on free space

                var cms = new ContextMenu
                {
                    Items =
                    {
                        new AutoActionMenuItem {
                            Header = "New Note", AlephAction = "NewNote", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "New Note (from clipboard)", AlephAction = "NewNoteFromClipboard", ParentAnchor = ParentAnchor
                        },
                        new AutoActionMenuItem {
                            Header = "New Note (from text file)", AlephAction = "NewNoteFromTextFile", ParentAnchor = ParentAnchor
                        },
                    }
                };
                NotesList.ContextMenu = cms;
                cms.IsOpen            = true;
            }
        }