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; } }
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; } }
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; } }