private void ContentsTree_MouseDown(object sender, MouseEventArgs e) { CurrentContentsTreeMouseDownEvent = e; // save event info for later use MetaTreeNode mtn = QbContentsTreeCtl.GetMetaTreeNodeAt(QbContentsTreeCtl.PointToClient(Cursor.Position), out CurrentContentsTreeListNode); if (mtn == null || mtn.Target == null) { return; } CurrentContentsMetaTreeNode = mtn; if (e.Button != MouseButtons.Right) { return; // all done if other than right button } ContextMenuStrip ms = ContentsTreeContextMenus.GetNodeContextMenu(mtn); bool displayingSearchResults = (QbContentsTreeCtl.DisplayingAsList); ContentsTreeContextMenus.ShowInTreeMenuItem.Visible = displayingSearchResults; // if showing search results enable item to show in tree if (ms != null) { ms.Show(QbContentsTreeCtl, new System.Drawing.Point(e.X, e.Y)); } return; }
public void SetItemEnabledState( ToolStripMenuItem contentsCutQuery, ToolStripMenuItem contentsCopyQuery, ToolStripMenuItem contentsDeleteQuery, ToolStripMenuItem contentsRenameQuery, ToolStripMenuItem contentsAddQuery) { // set all to true or they will never be tested below contentsCutQuery.Enabled = contentsDeleteQuery.Enabled = contentsDeleteQuery.Enabled = contentsRenameQuery.Enabled = contentsCopyQuery.Enabled = contentsAddQuery.Enabled = true; foreach (TreeListNode node in QbContentsTreeCtl.TreeList.Selection) { // if any node in the selection turns the menu to false, it stays false MetaTreeNode mtn = QbContentsTreeCtl.GetMetaTreeNode(node); bool hasWriteAccess = Permissions.UserHasWriteAccess(SS.I.UserName, mtn.Target); if (contentsCutQuery.Enabled) { contentsCutQuery.Enabled = hasWriteAccess; } if (contentsDeleteQuery.Enabled) { contentsDeleteQuery.Enabled = hasWriteAccess; } if (contentsRenameQuery.Enabled) { contentsRenameQuery.Enabled = hasWriteAccess; } if (contentsCopyQuery.Enabled) { contentsCopyQuery.Enabled = hasWriteAccess || (MetaTreeNode.IsUserObjectNodeType(mtn.Type) && !MetaTreeNode.IsLeafNodeType(mtn.Type)); } if (contentsAddQuery.Enabled) { contentsAddQuery.Enabled = mtn.Type == MetaTreeNodeType.MetaTable || mtn.Type == MetaTreeNodeType.Annotation || mtn.Type == MetaTreeNodeType.CalcField; } } }
/// <summary> /// Search the contents tree /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ContentsFind_Click(object sender, EventArgs e) { SessionManager.LogCommandUsage("ContentsFind"); QbContentsTreeCtl.FindInContents(""); }
/// <summary> /// Show normal menu with specified node open and at top /// </summary> public void ShowNormal( string topNodeTarget) { QbContentsTreeCtl.ShowFullTree(topNodeTarget); return; }
/// <summary> /// Show normal menu with preferred project selected /// </summary> public void ShowNormal() { QbContentsTreeCtl.ShowFullTree(); return; }
private void ContentsTree_MouseClick(object sender, MouseEventArgs e) { CurrentContentsMetaTreeNodes = QbContentsTreeCtl.GetCurrentSelectedNodes(); }
private void ContentsTree_Click(object sender, EventArgs e) { MouseEventArgs me = e as MouseEventArgs; if (me == null) { return; } TreeListHitInfo hi = QbContentsTreeCtl.TreeList.CalcHitInfo(me.Location); if (hi == null || hi.Node == null) { QbContentsTreeCtl.TreeList.OptionsSelection.MultiSelect = false; return; } MetaTreeNode currentNode = QbContentsTreeCtl.GetMetaTreeNode(hi.Node); if (currentNode == null) { return; } if (string.IsNullOrEmpty(currentNode.Target)) { DisableMultiselect(hi.Node); return; } // support multiple selections until we find otherwise QbContentsTreeCtl.TreeList.OptionsSelection.MultiSelect = true; CurrentContentsMetaTreeNodes = QbContentsTreeCtl.GetCurrentSelectedNodes(); if (CurrentContentsMetaTreeNodes.Count() > 1) { // process multiple nodes bool enabled = false; // If the user selected all Data Objects than we will allow muliselect if (MetaTreeNode.IsDataTableNodeType(currentNode.Type)) { foreach (MetaTreeNode node in CurrentContentsMetaTreeNodes) { if (node == currentNode) { break; } enabled = MetaTreeNode.IsDataTableNodeType(node.Type); if (!enabled) { break; } } } // If the Data Object check above failed, enable multiselect if we have all User Objects that are leafe nodes (no folders). if (!enabled && MetaTreeNode.IsUserObjectNodeType(currentNode.Type) && MetaTreeNode.IsLeafNodeType(currentNode.Type)) { foreach (MetaTreeNode node in CurrentContentsMetaTreeNodes) { if (node == currentNode) { break; } enabled = MetaTreeNode.IsUserObjectNodeType(node.Type) && MetaTreeNode.IsLeafNodeType(node.Type); if (!enabled) { break; } } } // Invalid combination of nodes, disable multiselect. if (!enabled) { DisableMultiselect(hi.Node); //MessageBox.Show("Multiselection is supported only for the following combinations\r\n\u2022 Lists, Queries, Annotation Tables, Calc Fields (Cut, Copy, Paste, Delete)\r\n\u2022 Data Tables, Anotation Tables, Calc Fields (Add to a Query)"); } } else { //process single node if ((currentNode.Type == MetaTreeNodeType.Url || currentNode.Type == MetaTreeNodeType.Action) && CurrentContentsTreeMouseDownEvent.Button != MouseButtons.Right) { ExecuteNodeAction(currentNode); // if url send command on 1st click } } }