private void FileListView_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; FileItem clicked = FileListView.GetItemAt(e.Location) as FileItem; ContextMenuStripEx menu = new ContextMenuStripEx(); if (clicked == null) { SelectedInfo.ShowDiffs(); if (Working != null) { menu.Items.Add(new ToolStripMenuItem("Create Folder", StorageRes.Folder, new EventHandler(Folder_Create))); menu.Show(FileListView, e.Location); } return; } // add to storage, lock, unlock, restore, delete bool firstLoop = true; List<ToolStripMenuItem> potentialMenus = new List<ToolStripMenuItem>(); foreach (FileItem item in FileListView.SelectedItems) { if (item.Text.CompareTo("..") == 0) continue; // create list of items to add, intersect with current list, first run is free potentialMenus.Clear(); // add if (IsLocal && item.Temp) potentialMenus.Add(MenuAdd); // lock / unlock if (!item.Temp) if (item.IsFolder) { if (item.Folder.Details.IsFlagged(StorageFlags.Unlocked)) potentialMenus.Add(MenuLock); else potentialMenus.Add(MenuUnlock); } else if (item.Details != null) { if (item.IsUnlocked()) potentialMenus.Add(MenuLock); else potentialMenus.Add(MenuUnlock); } // details if (!item.Temp && FileListView.SelectedItems.Count == 1) potentialMenus.Add(MenuDetails); // delete / restore if (IsLocal && !item.Temp) if (item.IsFolder) { if (item.Folder.Details.IsFlagged(StorageFlags.Archived)) potentialMenus.Add(MenuRestore); potentialMenus.Add(MenuDelete); } else if (item.Details != null) { if (item.Details.IsFlagged(StorageFlags.Archived)) potentialMenus.Add(MenuRestore); potentialMenus.Add(MenuDelete); } // initial list if (firstLoop) { foreach (ToolStripMenuItem potential in potentialMenus) menu.Items.Add(potential); firstLoop = false; continue; } // intersect both ways foreach (ToolStripMenuItem potential in potentialMenus) if (!menu.Items.Contains(potential)) menu.Items.Remove(potential); List<ToolStripMenuItem> selfRemove = new List<ToolStripMenuItem>(); foreach (ToolStripMenuItem current in menu.Items) if (!potentialMenus.Contains(current)) selfRemove.Add(current); foreach (ToolStripMenuItem current in selfRemove) menu.Items.Remove(current); } // place '-' before restore or delete int i = 0; bool separator = false; foreach (ToolStripMenuItem item in menu.Items) { if (item.Text == "Restore" || item.Text == "Delete") { separator = true; break; } i++; } if (separator && i > 0) menu.Items.Insert(i, new ToolStripSeparator()); if (menu.Items.Count > 0) { LastSelectedView = FileListView; menu.Show(FileListView, e.Location); } }
private void FolderTreeView_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; FolderNode node = FolderTreeView.GetNodeAt(e.Location) as FolderNode; if (node == null) return; ContextMenuStripEx menu = new ContextMenuStripEx(); if (!node.Temp) { if (node.Details.IsFlagged(StorageFlags.Unlocked)) menu.Items.Add(MenuLock); else menu.Items.Add(MenuUnlock); } else menu.Items.Add(MenuAdd); // remove in web interface\ if (node != RootFolder && !node.Temp) menu.Items.Add(MenuDetails); if (IsLocal && node != RootFolder && !node.Temp) { menu.Items.Add("-"); if (node.Details.IsFlagged(StorageFlags.Archived)) menu.Items.Add(MenuRestore); menu.Items.Add(MenuDelete); } if (menu.Items.Count > 0) { LastSelectedView = FolderTreeView; menu.Show(FolderTreeView, e.Location); } }
private void GoalTree_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; GoalNode node = GoalTree.GetNodeAt(e.Location) as GoalNode; if (node == null) return; ContextMenuStripEx menu = new ContextMenuStripEx(); bool owned = IsOwned(node); bool root = false; GoalNode parent = node.ParentNode() as GoalNode; if (parent == null && node.Goal.Person == Core.UserID && Head.Person == Core.UserID) root = true; if(owned) { menu.Items.Add(new GoalMenuItem("Edit", node.Goal, null, Goal_Edit)); menu.Items.Add(new GoalMenuItem("View Schedule", node.Goal, PlanRes.Schedule.ToBitmap(), Goal_Schedule)); menu.Items.Add("-"); } if(root) menu.Items.Add(new GoalMenuItem("Archive", node.Goal, PlanRes.archive, Goal_Archive)); if(owned) menu.Items.Add(new GoalMenuItem("Delete", node.Goal, PlanRes.delete, Goal_Delete)); if(!owned) menu.Items.Add(new GoalMenuItem("Details", node.Goal, PlanRes.details, Goal_View)); menu.Show(GoalTree, e.Location); }
private void PlanList_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; PlanListItem clicked = PlanList.GetItemAt(e.Location) as PlanListItem; if (clicked == null) return; ContextMenuStripEx menu = new ContextMenuStripEx(); if (Selected.Person == Core.UserID) { menu.Items.Add(new PlanMenuItem("Edit", clicked.Item, null, Plan_Edit)); menu.Items.Add("-"); menu.Items.Add(new PlanMenuItem("Delete", clicked.Item, PlanRes.delete, Plan_Delete)); } else menu.Items.Add(new PlanMenuItem("Details", clicked.Item, PlanRes.details, Plan_View)); menu.Show(PlanList, e.Location); }
private void TransferList_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; TreeListNode node = TransferList.GetNodeAt(e.Location) as TreeListNode; if (node == null || node.GetType() != typeof(TransferNode)) return; ContextMenuStripEx menu = new ContextMenuStripEx(); TransferNode transfer = node as TransferNode; menu.Items.Add(new ToolStripMenuItem("Copy Hash to Clipboaard", null, (s, o) => { Clipboard.SetText(Utilities.ToBase64String(transfer.Transfer.Details.Hash)); })); menu.Show(TransferList, e.Location); }
private void BlockRow_MouseClick(object sender, MouseEventArgs e) { foreach (BlockArea area in BlockAreas) if (area.Local && area.Rect.Contains(e.Location)) { if (View.SelectedBlock != area.Block) { View.SelectedBlock = area.Block; View.RefreshRows(); View.SetDetails(area.Block); } break; } if (e.Button != MouseButtons.Right) return; // create details menu // if local create edit/delete menu ContextMenuStripEx menu = new ContextMenuStripEx(); ToolStripMenuItem details = new ToolStripMenuItem("Details"); string indent = ""; int lastLevel = -1; foreach (BlockArea area in BlockAreas) if (area.Rect.Contains(e.Location)) { if (lastLevel == -1) lastLevel = area.Level; if (area.Level > lastLevel) { lastLevel = area.Level; indent += " "; } details.DropDownItems.Add(new BlockMenuItem(indent + area.Block.Title, area.Block, null, new EventHandler(RClickView))); if (area.Local) { if (UserID != View.Core.UserID) menu.Items.Add(new BlockMenuItem("Details", area.Block, PlanRes.details, new EventHandler(RClickView))); else { menu.Items.Add(new BlockMenuItem("Edit", area.Block, null, new EventHandler(RClickEdit))); menu.Items.Add(new BlockMenuItem("Delete", area.Block, PlanRes.delete, new EventHandler(RClickDelete))); } } } if (details.DropDownItems.Count > 0) menu.Items.Add(details); foreach (BlockArea area in GoalAreas) if (area.Rect.Contains(e.Location)) { menu.Items.Add(new BlockMenuItem("View Goal", area.Goal, PlanRes.Goals.ToBitmap(), new EventHandler(RClickGoal))); break; } if (menu.Items.Count > 0) menu.Show(this, e.Location); }
private void MessageView_MouseClick(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Right) return; MessageNode item = MessageView.GetNodeAt(e.Location) as MessageNode; if (item == null) return; ContextMenuStripEx menu = new ContextMenuStripEx(); if (item.Message.Header.TargetID == Core.UserID) menu.Items.Add(new MessageMenuItem(item.Message, "Reply", null, new EventHandler(Message_Reply))); menu.Items.Add(new MessageMenuItem(item.Message, "Forward", null, new EventHandler(Message_Forward))); menu.Items.Add("-"); menu.Items.Add(new MessageMenuItem(item.Message, "Delete", MailRes.delete, new EventHandler(Message_Delete))); menu.Show(MessageView, e.Location); }
private void CommandTree_MouseClick(object sender, MouseEventArgs e) { // this gets right click to select item TreeListNode clicked = CommandTree.GetNodeAt(e.Location) as TreeListNode; if (clicked == null) return; // project menu if (clicked == CommandTree.ProjectNode && e.Button == MouseButtons.Right) { ContextMenuStripEx menu = new ContextMenuStripEx(); if (CommandTree.Project != 0) { if (Trust.LocalTrust.Links.ContainsKey(CommandTree.Project)) menu.Items.Add("Leave Project", InterfaceRes.project_remove, new EventHandler(OnProjectLeave)); else menu.Items.Add("Join Project", InterfaceRes.project_add, new EventHandler(OnProjectJoin)); } // FillManageMenu(manage.Items, CommandTree.Project); if (menu.Items.Count > 0) menu.Show(CommandTree, e.Location); return; } if (clicked.GetType() != typeof(LinkNode)) return; LinkNode item = clicked as LinkNode; // right click menu if (e.Button != MouseButtons.Right) return; // menu ContextMenuStripEx treeMenu = new ContextMenuStripEx(); // select if (!SideMode) treeMenu.Items.Add("Select", InterfaceRes.star, TreeMenu_Select); // views List<MenuItemInfo> quickMenus = new List<MenuItemInfo>(); List<MenuItemInfo> extMenus = new List<MenuItemInfo>(); foreach (IServiceUI service in UI.Services.Values) { if (service is TrustUI || service is BuddyUI) continue; service.GetMenuInfo(InterfaceMenuType.Quick, quickMenus, item.Link.UserID, CommandTree.Project); service.GetMenuInfo(InterfaceMenuType.External, extMenus, item.Link.UserID, CommandTree.Project); } if (quickMenus.Count > 0 || extMenus.Count > 0) if (treeMenu.Items.Count > 0) treeMenu.Items.Add("-"); foreach (MenuItemInfo info in quickMenus) treeMenu.Items.Add(new OpMenuItem(item.Link.UserID, CommandTree.Project, info.Path, info)); if (extMenus.Count > 0) { ToolStripMenuItem viewItem = new ToolStripMenuItem("Views", InterfaceRes.views); foreach (MenuItemInfo info in extMenus) viewItem.DropDownItems.SortedAdd(new OpMenuItem(item.Link.UserID, CommandTree.Project, info.Path, info)); treeMenu.Items.Add(viewItem); } // add trust/buddy menu at bottom under separator quickMenus.Clear(); UI.Services[ServiceIDs.Trust].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, item.Link.UserID, CommandTree.Project); UI.Services[ServiceIDs.Buddy].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, item.Link.UserID, CommandTree.Project); if (quickMenus.Count > 0) { if (treeMenu.Items.Count > 0) treeMenu.Items.Add("-"); foreach (MenuItemInfo info in quickMenus) treeMenu.Items.Add(new OpMenuItem(item.Link.UserID, CommandTree.Project, info.Path, info)); } // show if (treeMenu.Items.Count > 0) treeMenu.Show(CommandTree, e.Location); }
private void BuddyList_MouseClick(object sender, MouseEventArgs e) { if (!Interactive) return; // this gets right click to select item BuddyItem clicked = GetItemAt(e.Location) as BuddyItem; if (clicked != null && clicked.User != 0) Core.Locations.Research(clicked.User); // right click menu if (e.Button != MouseButtons.Right) return; // menu ContextMenuStripEx treeMenu = new ContextMenuStripEx(); if (clicked == null || clicked.User == 0) { if (clicked == null || !clicked.GroupLabel) // blank space clicked, or a buddy/offline label treeMenu.Items.Add(new ToolStripMenuItem("Add Buddy", BuddyRes.buddy_add, Menu_AddBuddy)); else treeMenu.Items.Add(new ToolStripMenuItem("Remove Group", BuddyRes.group_remove, Menu_RemoveGroup)); treeMenu.Show(this, e.Location); return; } uint project = 0; // views List<MenuItemInfo> quickMenus = new List<MenuItemInfo>(); List<MenuItemInfo> extMenus = new List<MenuItemInfo>(); foreach (var service in UI.Services.Values) { if (service is TrustService || service is BuddyService) continue; service.GetMenuInfo(InterfaceMenuType.Quick, quickMenus, clicked.User, project); service.GetMenuInfo(InterfaceMenuType.External, extMenus, clicked.User, project); } foreach (MenuItemInfo info in quickMenus) treeMenu.Items.Add(new OpMenuItem(clicked.User, project, info.Path, info)); if (extMenus.Count > 0) { ToolStripMenuItem viewItem = new ToolStripMenuItem("Views", InterfaceRes.views); foreach (MenuItemInfo info in extMenus) viewItem.DropDownItems.SortedAdd(new OpMenuItem(clicked.User, project, info.Path, info)); //crit add project specific views treeMenu.Items.Add(viewItem); } if (treeMenu.Items.Count > 0) treeMenu.Items.Add("-"); treeMenu.Items.Add(new ToolStripMenuItem("Add to Group", BuddyRes.group_add, Menu_AddGroup)); if (clicked.User != Core.UserID) // if not self treeMenu.Items.Add(new ToolStripMenuItem("Remove Buddy", BuddyRes.buddy_remove, Menu_RemoveBuddy)); // add trust options at bottom quickMenus.Clear(); UI.Services[ServiceIDs.Buddy].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, clicked.User, project); if (UI.Services.ContainsKey(ServiceIDs.Trust)) UI.Services[ServiceIDs.Trust].GetMenuInfo(InterfaceMenuType.Quick, quickMenus, clicked.User, project); foreach (MenuItemInfo info in quickMenus) treeMenu.Items.Add(new OpMenuItem(clicked.User, project, info.Path, info)); // show if (treeMenu.Items.Count > 0) treeMenu.Show(this, e.Location); }