/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void AddTopNodes() { Nodes.Clear(); // Add the current machine to the top of the list. NetworkTreeNode node = new NetworkTreeNode(); node.ImageIndex = node.SelectedImageIndex = 4; node.Text = NetworkTreeNode.GetDisplayName(Environment.MachineName); node.MachineName = Environment.MachineName; node.NodeType = NetworkTreeNode.NetResTreeNodeType.Machine; Nodes.Add(node); // Add a node that is the parent of the computer's in the user's domain // as well as the "Microsoft Terminal Services" node, and the "Web // Client Network". node = new NetworkTreeNode(); node.ImageIndex = node.SelectedImageIndex = 2; node.Text = LocalizationManager.GetString("DialogBoxes.OpenFw6ProjectDlg.MyNetworkPlacesText", "Network places in your area", "Used in the dialog for choosing an FW database"); node.NodeType = NetworkTreeNode.NetResTreeNodeType.PlacesInArea; Nodes.Add(node); node.Nodes.Add(NetworkTreeNode.NewDummyNode); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void OnBeforeExpand(TreeViewCancelEventArgs e) { NetworkTreeNode node = e.Node as NetworkTreeNode; if (node != null && !node.Populated) { node.PopulateChildren(); } base.OnBeforeExpand(e); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ internal void PopulateChildren() { if (Populated || NodeType == NetResTreeNodeType.Machine || NodeType == NetResTreeNodeType.Dummy) { return; } TreeView.FindForm().Cursor = Cursors.WaitCursor; Nodes.Clear(); NetworkTreeNode childNode; NETRESOURCE netRes = NetResource; // When the node being expanded is places near the user's computer, (which // is sort of like My Network Places) then add a node below it for the // entire network, then find the network resource for the same domain in // which the user's machine is a member. if (NodeType == NetResTreeNodeType.PlacesInArea) { childNode = new NetworkTreeNode(); childNode.NodeType = NetResTreeNodeType.Group; childNode.ImageIndex = childNode.SelectedImageIndex = 0; childNode.Nodes.Add(NewDummyNode); childNode.Text = LocalizationManager.GetString("DialogBoxes.OpenFw6ProjectDlg.EntireNetworkNode", "Entire network", "Text in the network tree used when trying to locate a FieldWorks project older than version 7.0."); Nodes.Add(childNode); netRes = FindSameDomainResource(null); } // Get all the network resources that are subordinate to the current node's. List <NETRESOURCE> netResources = GetChildResources(netRes); if (netResources != null && netResources.Count > 0) { foreach (NETRESOURCE nr in netResources) { if (string.IsNullOrEmpty(nr.lpRemoteName)) { continue; } childNode = new NetworkTreeNode(); childNode.NetResource = nr; childNode.Text = GetDisplayName(nr); if (nr.dwDisplayType == ResourceDisplayType.RESOURCEDISPLAYTYPE_SERVER) { childNode.ImageIndex = childNode.SelectedImageIndex = 4; childNode.MachineName = childNode.Text; childNode.NodeType = NetResTreeNodeType.Machine; } else { childNode.ImageIndex = childNode.SelectedImageIndex = (nr.dwDisplayType == ResourceDisplayType.RESOURCEDISPLAYTYPE_NETWORK ? 1 : 3); childNode.NodeType = NetResTreeNodeType.Group; childNode.Nodes.Add(NewDummyNode); } Nodes.Add(childNode); } } Populated = true; NetResource = null; TreeView.FindForm().Cursor = Cursors.Default; }