private void _bAddRoot_Click(object sender, System.EventArgs e) { string defaultNodeName = GetNextDefaultNodeName(); System.Windows.Forms.TreeNode newNode = new System.Windows.Forms.TreeNode(defaultNodeName); MenuItemProperty menuItemProperty = new MenuItemProperty(); menuItemProperty.UniqueID = Utils.GetUniqueID("AME_"); menuItemProperty.Text = defaultNodeName; newNode.Tag = menuItemProperty; _tvMenu.Nodes.Add(newNode); _tvMenu.SelectedNode = GetLastNode(_tvMenu.Nodes); _tvMenu.Focus(); if (_bAddChild.Enabled == false) { _bAddChild.Enabled = true; } if (_bRemoveNode.Enabled == false) { _bRemoveNode.Enabled = true; } }
/// <summary> /// Initializes a new instance of the <see cref="TreeViewPropertyBuilderForm"/> class. /// </summary> /// <param name="treeView">The tree view.</param> public PropertyBuilderForm(ActiveUp.WebControls.TreeView treeView) { InitializeComponent(); _treeView = treeView; InitUI(); _tvTree.Focus(); this.ActiveControl = _tvTree; }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStr">选中节点文本</param> public static void SelectNode2Level(TreeView treeView, string selectStr) { treeView.CollapseAll(); treeView.Visible = true; treeView.Focus(); for (int i = 0; i < treeView.Nodes.Count; i++) { if (treeView.Nodes[i].Text == selectStr) { treeView.SelectedNode = treeView.Nodes[i];//选中 treeView.SelectedNode.Checked = true; return; } for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) { if (treeView.Nodes[i].Nodes[j].Text == selectStr) { treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 treeView.SelectedNode.Checked = true; treeView.Nodes[i].Expand();//展开父级 return; } } } }
string getMouseOverItem(int x, int y) { int ansW, ansH; System.Windows.Forms.TreeView li = LIST_items; getCharLoc(x, y, out ansW, out ansH); if (osd.usedPostion[ansW][ansH] != null && osd.usedPostion[ansW][ansH] != "") { string name = osd.usedPostion[ansW][ansH]; TreeNode[] tnArray = li.Nodes.Find(name, true); li.Focus(); li.SelectedNode = tnArray[0]; // выберем этот элемент в списке Panel thing = (Panel)tnArray[0].Tag; // левый верхний угол нашей фигуры thing.x, thing.y clickX = ansW - thing.x; //запомним куда ткнули clickY = ansH - thing.y; return(name); } return(""); }
void AddNodesToTree(TreeView tree,ServiceBusNode[] nodes) { string serviceNamespace = m_NamespaceTextBox.Text; if(tree.Nodes[0].Text == "Unspecified Namespace") { tree.Nodes.Clear(); } else { foreach(TreeNode domianNode in tree.Nodes) { if(domianNode.Text == serviceNamespace) { tree.Nodes.Remove(domianNode); break; } } } TreeNode newNamespaceNode = new NamespaceTreeNode(this,serviceNamespace); tree.Nodes.Add(newNamespaceNode); tree.SelectedNode = newNamespaceNode; tree.Focus(); foreach(ServiceBusNode node in nodes) { AddNode(newNamespaceNode,node); } }
void btnHideReport_Click(object sender, EventArgs e) { if (c1SsrsDocumentSource1.IsBusy) { return; } btnHideReport.Enabled = false; c1SsrsDocumentSource1.DocumentLocation = null; c1RibbonPreview1.Document = c1SsrsDocumentSource1; tvReports.Focus(); UpdateControls(); }
/// <summary> /// Processes the usage of keys to perform actions on the travel tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void DoKeys(object sender, System.Windows.Forms.KeyEventArgs e) { switch (e.KeyCode) { case Keys.F5: PrevSearchResult(); break; case Keys.F8: NextSearchResult(); break; case Keys.Left: if (sender.Equals(tItems)) { tCat.Focus(); } break; case Keys.Right: if (sender.Equals(tCat) && tItems.Nodes.Count > 0) { tItems.Focus(); } break; case Keys.Enter: if (sender.Equals(tCat)) { TreeNode node = tCat.SelectedNode; if (node != null) { if (node.IsExpanded) { node.Collapse(); } else { node.Expand(); } } } break; } }
/// <summary> /// Monitor keys for search results navigation /// </summary> public void DoKeys(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.F5) { ShowPrevResult(); e.Handled = true; } else if (e.KeyCode == Keys.F8) { ShowNextResult(); e.Handled = true; } else if (sender.Equals(tCat) && e.KeyCode == Keys.Right && tDeco.Nodes.Count > 0) { tDeco.Focus(); } else if (sender.Equals(tDeco) && e.KeyCode == Keys.Left) { tCat.Focus(); } else if (sender.Equals(tCat) && e.KeyCode == Keys.Enter) { TreeNode node = tCat.SelectedNode; if (node != null) { if (node.IsExpanded) { node.Collapse(); } else { node.Expand(); } } } }
private void textBoxBarkod_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { TreeNode tn; if ((tn = Utility.Engine.dat.FindInTree(ref treeView1, Utility.Engine.SqlTemizle(textBoxBarkod.Text.Replace("*", "")))) != null) { treeView1.SelectedNode = tn; treeView1.Focus(); } else { textBoxBarkod.SelectAll(); textBoxBarkod.Focus(); } } }
// Second pass private void TreeDragOver(object sender, DragEventArgs e) { //Stop this from happening when over a node that //is not allowed to be dropped on TreeNode node = tvPics.GetNodeAt(tvPics.PointToClient (new Point(e.X, e.Y))); if (node.Tag == null) { tvPics.Focus(); //Probelem with this is that it fires an event tvPics.SelectedNode = node; e.Effect = DragDropEffects.All; } else { e.Effect = DragDropEffects.None; } }
string getMouseOverItem(int x, int y) { int ansW, ansH; System.Windows.Forms.TreeView li = LIST_items; getCharLoc(x, y, out ansW, out ansH); if (osd.usedPostion[ansW][ansH] != null && osd.usedPostion[ansW][ansH] != "") { string name = osd.usedPostion[ansW][ansH]; TreeNode[] tnArray = li.Nodes.Find(name, true); li.Focus(); li.SelectedNode = tnArray[0]; // выберем этот элемент в списке /* * foreach(var thing in osd.scr[osd.panel_number].panelItems) { * if(thing!=null) { * if(thing.name==name) { * // левый верхний угол нашей фигуры thing.x, thing.y * clickX = ansW - thing.x; //запомним куда ткнули * clickY = ansH - thing.y; * break; * } * } * } * */ // /* Panel thing = (Panel)tnArray[0].Tag; // левый верхний угол нашей фигуры thing.x, thing.y clickX = ansW - thing.x; //запомним куда ткнули clickY = ansH - thing.y; //*/ //LIST_items.SelectedIndex = LIST_items.Items.IndexOf(usedPostion[ansW][ansH]); return(name); } return(""); }
private void butAdd_Click(object sender, System.EventArgs e) { if (!Security.IsAuthorized(Permissions.AutoNoteQuickNoteEdit)) { return; } long selectedDefNum = 0; if (treeNotes.SelectedNode?.Tag is Def) { selectedDefNum = ((Def)treeNotes.SelectedNode.Tag).DefNum; } else if (treeNotes.SelectedNode?.Tag is AutoNote) { selectedDefNum = ((AutoNote)treeNotes.SelectedNode.Tag).Category; } FormAutoNoteEdit FormA = new FormAutoNoteEdit(); FormA.IsNew = true; FormA.AutoNoteCur = new AutoNote() { Category = selectedDefNum }; FormA.ShowDialog(); if (FormA.DialogResult != DialogResult.OK) { return; } treeNotes.SelectedNode?.Expand(); //expanding an AutoNote has no effect, and if nothing selected nothing to expand AutoNoteL.FillListTree(treeNotes, _userOdCurPref); if ((FormA.AutoNoteCur?.AutoNoteNum ?? 0) > 0) //select the newly added note in the tree { treeNotes.SelectedNode = treeNotes.Nodes.OfType <TreeNode>().SelectMany(x => AutoNoteL.GetNodeAndChildren(x)).Where(x => x.Tag is AutoNote) .FirstOrDefault(x => ((AutoNote)x.Tag).AutoNoteNum == FormA.AutoNoteCur.AutoNoteNum); treeNotes.SelectedNode?.EnsureVisible(); treeNotes.Focus(); } }
private void listView1_ItemActivate(object sender, System.EventArgs e) { string myChild = ((ListView)sender).FocusedItem.Text; TreeNode sn = treeView1.SelectedNode; foreach (TreeNode tn in sn.Nodes) { if (tn.Text == myChild) { foreach (TreeNode child in tn.Nodes) { if (child.Tag == null) { child.Tag = true; //This folder is expanded. addFolders(child); } } treeView1.SelectedNode = tn; treeView1.Focus(); break; } } }
private void frmInputDemo_Load(object sender, System.EventArgs e) { m_lsvInPatientID.Visible = false; trvTime.Focus(); }
// map this to a callback private void tvControllers_AfterSelect(TreeView tvControllers) { tvControllers.invokeOnThread( () => { if (tvControllers.SelectedNode != null && tvControllers.SelectedNode.Tag != null) { if (tvControllers.SelectedNode.Tag is SpringMvcController) { showDetailsForSpringMvcController((SpringMvcController) tvControllers.SelectedNode.Tag); } else if (tvControllers.SelectedNode.Tag is ICirClass) { var cirClass = (ICirClass) tvControllers.SelectedNode.Tag; cirFunctionDetails.viewCirClass(cirClass); springMvcAutoBindClassesView.showClass(cirClass,springMvcMappings.cirData); showFindingsDetailsForSpringMvcController(cirClass.Signature); } tvControllers.Focus(); } }); }
/// <summary> /// This prevents selecting a application in another session from causing /// a temporary select of an incorrect app and the resultant screen updates. /// </summary> /// <summary> /// A session or application node has been selected in the sessions tree. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sessionsTree_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { processIsolatedAppUIEvent.Reset(); try { Session session = null; IHostedApplication app; // so we know if this is caused by an agent changing the app with the control // or if this is happening from some other event within CCF. bool hadFocus = sessionsTree.Focused; if (e.Node != null) { session = e.Node.Tag as Session; } if (session != null) { // go to the session selected in the explorer, let it pick which // app is highlighted. sessionManager.SetActiveSession(session.SessionID); } else { // go to the application selected in the session explorer app = e.Node.Tag as IHostedApplication; if (app != null && appsUI != null) { session = e.Node.Parent.Tag as Session; if (session != null) { session.FocusedApplication = app; // so app is selected sessionManager.SetActiveSession(session.SessionID); } // TODO LJZ bool isIsolated = session.AppHost.IsIsolatedApplication(app); bool isExtended = session.AppHost.IsExtendedApplication(app); if (isIsolated || isExtended) { IHostedAppUICommand appUICommand = app as IHostedAppUICommand; if (isIsolated) { FocusIsolatedApplication(appUICommand); } if (isExtended) { appUICommand.ShowForm(); } if (null != SEHostedAppSelected) { SEHostedAppSelected(app, new EventArgs()); } } else { appsUI.SelectApplication(app.ApplicationID); } // Return the focus to the newly selected node if we had the focus // to begin with. if (hadFocus) { sessionsTree.Focus(); } } } } catch (Exception eX) { Logging.Error(localize.SESSION_EXPLORER_MODULE_NAME, eX.Message); } finally { processIsolatedAppUIEvent.Set(); } }
private void FillListTree() { List <long> listExpandedDefNums = new List <long>(); if (treeNotes.Nodes.Count == 0 && _userOdCurPref != null) //if this is the fill on load, the node count will be 0, expanded node list from pref { listExpandedDefNums = _userOdCurPref.ValueString.Split(',').Where(x => x != "" && x != "0").Select(x => PIn.Long(x)).ToList(); } else //either not fill on load or no user pref, store the expanded node state to restore after filling tree //only defs (category folders) can be expanded or have children nodes { listExpandedDefNums = treeNotes.Nodes.OfType <TreeNode>().SelectMany(x => GetNodeAndChildren(x)) .Where(x => x.IsExpanded && x.Tag is Def).Select(x => ((Def)x.Tag).DefNum).ToList(); } TreeNode selectedNode = treeNotes.SelectedNode; TreeNode topNode = null; string topNodePath = treeNotes.TopNode?.FullPath; treeNotes.BeginUpdate(); treeNotes.Nodes.Clear(); //clear current tree contents _dictChildNodesForDefNum = Defs.GetDefsForCategory(DefCat.AutoNoteCats, true).GroupBy(x => x.ItemValue ?? "0") .ToDictionary(x => PIn.Long(x.Key), x => new NodeChildren() { ListChildDefNodes = x.Select(y => new TreeNode(y.ItemName, 0, 0) { Tag = y }).ToList() }); Dictionary <long, List <TreeNode> > dictDefNumAutoNotes = AutoNotes.GetDeepCopy().GroupBy(x => x.Category) .ToDictionary(x => x.Key, x => x.Select(y => new TreeNode(y.AutoNoteName, 1, 1) { Tag = y }).ToList()); foreach (KeyValuePair <long, List <TreeNode> > kvp in dictDefNumAutoNotes) { if (_dictChildNodesForDefNum.ContainsKey(kvp.Key)) { _dictChildNodesForDefNum[kvp.Key].ListAutoNoteNodes = kvp.Value; } else { _dictChildNodesForDefNum[kvp.Key] = new NodeChildren() { ListAutoNoteNodes = kvp.Value }; } } List <TreeNode> listNodes = new List <TreeNode>(); //all nodes to add to tree, categories and autonotes NodeChildren nodeChildren; if (_dictChildNodesForDefNum.TryGetValue(0, out nodeChildren)) { nodeChildren.ListChildDefNodes.ForEach(SetAllDescendantsForNode); listNodes.AddRange(nodeChildren.ListChildDefNodes); listNodes.AddRange(nodeChildren.ListAutoNoteNodes); } treeNotes.Nodes.AddRange(listNodes.OrderBy(x => x, new NodeSorter()).ToArray()); //add node list to tree, after sorting List <TreeNode> listNodesCur = listNodes.SelectMany(x => GetNodeAndChildren(x)).ToList(); //get flat list of all nodes, copy entire tree foreach (TreeNode nodeCur in listNodesCur) { if (!string.IsNullOrEmpty(topNodePath) && nodeCur.FullPath == topNodePath) { topNode = nodeCur; } if (nodeCur.Tag is Def && listExpandedDefNums.Contains(((Def)nodeCur.Tag).DefNum)) { nodeCur.Expand(); } if (selectedNode == null) { continue; } if (Equals(nodeCur, selectedNode)) { treeNotes.SelectedNode = nodeCur; } } treeNotes.TopNode = topNode; if (topNode == null && treeNotes.Nodes.Count > 0) { treeNotes.TopNode = treeNotes.SelectedNode ?? treeNotes.Nodes[0]; } treeNotes.EndUpdate(); treeNotes.Focus(); }