예제 #1
0
		/// <summary>
		/// Adds servers etc to the treeview node previously identified as the Entire Network node.
		/// </summary>
		/// <param name="entireNetworkNode"></param>
		private static void ExpandEntireNetworkNode(TreeNode entireNetworkNode)
		{
			// First test that we haven't already expanded this node, by seeing if the first node
			// is our dummy placeholder:
			if (entireNetworkNode.FirstNode.Text != DummyEntireNetworkChildName)
				return;

			entireNetworkNode.FirstNode.Remove();

			var servers = new ServerEnum(ServerEnum.ResourceScope.RESOURCE_GLOBALNET,
				ServerEnum.ResourceType.RESOURCETYPE_DISK, ServerEnum.ResourceUsage.RESOURCEUSAGE_ALL,
				ServerEnum.ResourceDisplayType.RESOURCEDISPLAYTYPE_NETWORK, "");

			foreach (string server in servers)
			{
				var serverNameBeforeBar = server.Substring(0, server.IndexOf("|", 1));

				if (server.IndexOf("NETWORK", 1) > 0)
				{
					var networkNode = new TreeNode
										{
											Tag = serverNameBeforeBar,
											Text = serverNameBeforeBar,
											ImageIndex = 15,
											SelectedImageIndex = 15
										};
					entireNetworkNode.Nodes.Add(networkNode);
				}
				else
				{
					var myNetworkNode = new TreeNode
											{
												Tag = serverNameBeforeBar,
												Text = serverNameBeforeBar,
												ImageIndex = 16,
												SelectedImageIndex = 16
											};
					entireNetworkNode.LastNode.Nodes.Add(myNetworkNode);

					// Add dummy placeholder node for Micorosoft Windows Network (to make "+" box appear):
					var dummyNode = new TreeNode
										{
											Tag = DummyMicrosoftWindowsNetworkName,
											Text = DummyMicrosoftWindowsNetworkName,
											ImageIndex = 12,
											SelectedImageIndex = 12
										};
					myNetworkNode.Nodes.Add(dummyNode);
				}
			}
		}
예제 #2
0
		/// <summary>
		/// Adds servers etc to the treeview node previously identified as a child of the Microsoft Windows Network node.
		/// </summary>
		/// <param name="microsoftWindowsNetworkChildNode"></param>
		private static void ExpandMicrosoftWindowsNetworkChildNode(TreeNode microsoftWindowsNetworkChildNode)
		{
			// Check if the first child node is our dummy placeholder:
			if (microsoftWindowsNetworkChildNode.FirstNode.Text == DummyMicrosoftWindowsNetworkName)
			{
				// Remove dummy and add real data:
				microsoftWindowsNetworkChildNode.FirstNode.Remove();

				var serverPath = microsoftWindowsNetworkChildNode.Text;

				var servers = new ServerEnum(ServerEnum.ResourceScope.RESOURCE_GLOBALNET,
					ServerEnum.ResourceType.RESOURCETYPE_DISK, ServerEnum.ResourceUsage.RESOURCEUSAGE_ALL,
					ServerEnum.ResourceDisplayType.RESOURCEDISPLAYTYPE_SERVER, serverPath);

				foreach (string server in servers)
				{
					if (server.EndsWith("-share"))
						continue;

					var serverNode = new TreeNode
										{
											Tag = server,
											Text = server.Substring(2),
											ImageIndex = 12,
											SelectedImageIndex = 12
										};
					microsoftWindowsNetworkChildNode.Nodes.Add(serverNode);

					// Look for child (share) servers:
					foreach (var shareServer in servers.Cast<string>().Where(shareServer => shareServer.EndsWith("-share")))
					{
						if (server.Length <= shareServer.Length)
						{
							try
							{
								if (shareServer.StartsWith(server + Path.DirectorySeparatorChar))
								{
									var childServerNode = new TreeNode
															{
																Tag = shareServer.Substring(0, shareServer.Length - 6),  // Server name minus "-share"
																Text = shareServer.Substring(server.Length + 1, shareServer.Length - server.Length - 7),
																ImageIndex = 28,
																SelectedImageIndex = 28
															};
									serverNode.Nodes.Add(childServerNode);
								}
							}
							catch (ArgumentOutOfRangeException)
							{
							}
						}
					} // Next child server
				} // Next server
			} //End if first child node is our dummy placeholder
		}