Пример #1
0
        private void fillFiltersTree()
        {
            foreach (var node in treeViewFilter.Nodes[0].Nodes.Cast <TreeNode>().ToArray())
            {
                node.Remove();
            }
            imageListStates.Images.Clear();
            imageListStates.Images.Add(@"Root", Resources.Servers);
            treeViewFilter.Nodes[0].ImageKey         = @"Root";
            treeViewFilter.Nodes[0].SelectedImageKey = @"Root";
            var statuses = Enum.GetValues(typeof(ELinkStatus)).Cast <ELinkStatus>().
                           GroupBy(HostViewModel.GetStatusText).ToArray();

            foreach (var status in statuses)
            {
                imageListStates.Images.Add(status.Key, HostViewModel.GetStatusIcon(status.First()));
            }
            var nodes = statuses.Select(g => new TreeNode(g.Key, imageListStates.Images.IndexOfKey(g.Key),
                                                          imageListStates.Images.IndexOfKey(g.Key))
            {
                Tag = g.ToArray()
            }).ToArray();

            treeViewFilter.Nodes[0].Nodes.AddRange(nodes);
            treeViewFilter.ExpandAll();
            treeViewFilter.SelectedNode = treeViewFilter.Nodes[0];
        }