Esempio n. 1
0
        private void LoadTree()
        {
            LabelSelectionTree.BeginUpdate();
            LabelSelectionTree.Nodes.Clear();
            var groups = this.labels.Labels
                         .GroupBy(l => l.InstanceName)
                         .OrderBy(g => g.Key);

            foreach (var group in groups)
            {
                string groupName = string.IsNullOrEmpty(group.Key)
                    ? Properties.Resources.ModuleLabelListGlobal
                    : group.Key;
                LabelSelectionTree.Nodes.Add(new TreeNode(
                                                 groupName,
                                                 group.OrderBy(mlbl => mlbl.Name)
                                                 .Select(mlbl => new TreeNode(mlbl.Name)
                {
                    // Windows's TreeView has a bug where the node's visual
                    // width is based on the owning TreeView.Font rather
                    // than TreeNode.Font, so to ensure there's enough space,
                    // we have to make the default bold and then override it
                    // for non-bold nodes.
                    NodeFont = new Font(LabelSelectionTree.Font, FontStyle.Regular),
                    Tag      = mlbl
                })
                                                 .ToArray()
                                                 ));
            }
            LabelSelectionTree.ExpandAll();
            LabelSelectionTree.EndUpdate();
        }
Esempio n. 2
0
        private void LoadTree()
        {
            LabelSelectionTree.BeginUpdate();
            LabelSelectionTree.Nodes.Clear();
            var groups = this.labels.Labels
                         .GroupBy(l => l.InstanceName)
                         .OrderBy(g => g.Key == null)
                         .ThenBy(g => g.Key);

            foreach (var group in groups)
            {
                string groupName = string.IsNullOrEmpty(group.Key)
                    ? Properties.Resources.ModuleLabelListGlobal
                    : group.Key;
                LabelSelectionTree.Nodes.Add(new TreeNode(
                                                 groupName,
                                                 group.Select(mlbl => new TreeNode(mlbl.Name)
                {
                    // Windows's TreeView has a bug where the node's visual
                    // width is based on the owning TreeView.Font rather
                    // than TreeNode.Font, so to ensure there's enough space,
                    // we have to make the default bold and then override it
                    // for non-bold nodes.
                    NodeFont = new Font(LabelSelectionTree.Font, FontStyle.Regular),
                    Tag      = mlbl
                })
                                                 .ToArray()
                                                 ));
            }
            EnableDisableUpDownButtons();
            if (currentlyEditing != null)
            {
                LabelSelectionTree.BeforeSelect -= LabelSelectionTree_BeforeSelect;
                // Select the new node representing the label we're editing
                LabelSelectionTree.SelectedNode = LabelSelectionTree.Nodes.Cast <TreeNode>()
                                                  .SelectMany(nd => nd.Nodes.Cast <TreeNode>())
                                                  .FirstOrDefault(nd => nd.Tag as ModuleLabel == currentlyEditing);
                LabelSelectionTree.BeforeSelect += LabelSelectionTree_BeforeSelect;
            }
            LabelSelectionTree.ExpandAll();
            LabelSelectionTree.EndUpdate();
        }
Esempio n. 3
0
        private void LoadTree()
        {
            LabelSelectionTree.BeginUpdate();
            LabelSelectionTree.Nodes.Clear();
            var groups = this.labels.Labels
                         .GroupBy(l => l.InstanceName)
                         .OrderBy(g => g.Key);

            foreach (var group in groups)
            {
                string groupName = string.IsNullOrEmpty(group.Key)
                    ? Properties.Resources.ModuleLabelListGlobal
                    : group.Key;
                var gnd = LabelSelectionTree.Nodes.Add(groupName);
                gnd.NodeFont = new Font(LabelSelectionTree.Font, FontStyle.Bold);
                foreach (ModuleLabel mlbl in group.OrderBy(l => l.Name))
                {
                    var lblnd = gnd.Nodes.Add(mlbl.Name);
                    lblnd.Tag = mlbl;
                }
            }
            LabelSelectionTree.ExpandAll();
            LabelSelectionTree.EndUpdate();
        }