private void AddDevices(IDeviceCollection devices, TreeNodeCollection treeNodes) { foreach (Device device in devices) { TreeNode tn = new TreeNode(); tn.Text = device.Name; tn.Tag = device; string strImageKey = device.DeviceType.Code + ((int)device.State).ToString(); if (this.img.Images.ContainsKey(strImageKey) == false) { this.img.Images.Add(strImageKey, device.GetIcon16()); } tn.ImageKey = strImageKey; tn.SelectedImageKey = strImageKey; if (device.Children.Count > 0) { tn.Nodes.Add(""); } treeNodes.Add(tn); } }
/// <summary> /// A valid device collection must specify all of Name, Server and Site. /// </summary> /// <param name="dc"></param> /// <returns></returns> private bool IsValidDeviceCollection(IDeviceCollection dc) { return (dc != null) && !string.IsNullOrEmpty(dc.Name) && !string.IsNullOrEmpty(dc.Server) && !string.IsNullOrEmpty(dc.Site); }