示例#1
0
        private void FillNodes(Hierarchy <CodeNode> source, TreeNodeCollection dest, int level, IList <CodeNode> functions)
        {
            if (!source.HasChildren)
            {
                return;
            }

            var isSort    = Settings.SortingEnabled;
            var childrens = source.Children;

            if (isSort)
            {
                childrens.Sort((a1, a2) => string.Compare(a1.Item.Alias, a2.Item.Alias));
            }

            foreach (var item in childrens)
            {
                CodeNode node = item.Item;

                if (node.StartLine > _lastCodeLine)
                {
                    _lastCodeLine = node.StartLine;
                }

                CustomTreeNode treeNode = new CustomTreeNode(node.Alias);
                treeNode.CodeNode        = node;
                treeNode.ToolTipText     = CommentTipFormatter.FormatPlainTextComment(node.Comment);
                treeNode.StateImageIndex = GetImageIndex(node.NodeType);
                _sourceFileSpecificSettingsManager.RestoreMark(treeNode);
                dest.Add(treeNode);

                functions.Add(node);

                if (item.HasChildren)
                {
                    FillNodes(item, treeNode.Nodes, level + 1, functions);
                }

                var isExpanded = _expandedNodesManager.IsNoteExpanded(treeNode);
                if (isExpanded.HasValue)
                {
                    if (isExpanded.Value)
                    {
                        treeNode.Expand();
                    }
                }
                else
                {
                    if (Settings.AutoExpandAll)
                    {
                        treeNode.Expand();
                    }
                }
            }
        }
示例#2
0
		public bool? IsNoteExpanded(CustomTreeNode node)
		{
			var storage = ActiveStorage;
			var nodeKey = GetNodeKey(node);
			if (storage.ContainsKey(nodeKey))
			{
				return storage[nodeKey];
			}

			return null;
		}
示例#3
0
        public void RestoreMark(CustomTreeNode treeNode)
        {
            if (_currentDictionary == null)
            {
                return;
            }

            if (CurrentDictionary.ContainsKey(treeNode.Text))
            {
                SelectNode(CurrentDictionary[treeNode.Text], treeNode);
            }
        }
        private void timer2_Tick_1(object sender, EventArgs e)
        {
            try
            {
                if (_codeProvider != null && Settings.TrackActiveItem)
                {
                    int line;
                    int column;
                    _codeProvider.GetCursorPos(out line, out column);
                    if (line >= 0 && (line != _lastActiveLine || column != _lastActiveColumn))
                    {
                        CustomTreeNode hightLightNode = null;
                        ScanTreeView(node =>
                        {
                            bool sel = false;
                            if (node.CodeNode.StartLine <= line && line <= node.CodeNode.EndLine)
                            {
                                if (node.CodeNode.StartLine == node.CodeNode.EndLine)
                                {
                                    if (node.CodeNode.StartColumn <= column && column <= node.CodeNode.EndColumn)
                                    {
                                        sel = true;
                                    }
                                }
                                else
                                {
                                    sel = true;
                                }
                            }

                            if (sel)
                            {
                                if (hightLightNode != null && node.Level < hightLightNode.Level)
                                {
                                    return(true);       //Skip parent nodes
                                }

                                hightLightNode = node;
                            }

                            return(true);
                        }, treeView1.Nodes);
                        _lastActiveLine   = line;
                        _lastActiveColumn = column;
                        if (hightLightNode != null && treeView1.SelectedNode != hightLightNode)
                        {
                            treeView1.SelectedNode = hightLightNode;
                        }
                    }
                }
            }
            catch { }
        }
        private bool HideUnmarkedNodes(TreeNodeCollection nodes)
        {
            bool hasMarks = false;
            var  nodess   = nodes.Cast <CustomTreeNode>().ToArray();

            foreach (TreeNode tnode in nodess)
            {
                if (tnode == null)
                {
                    continue;
                }

                CustomTreeNode node = (CustomTreeNode)tnode;
                if (!string.IsNullOrEmpty(node.Tags))
                {
                    hasMarks = true;
                    continue;
                }

                if (node.Nodes.Count > 0)
                {
                    var hasChildMarks = HideUnmarkedNodes(node.Nodes);
                    if (hasChildMarks)
                    {
                        hasMarks = true;
                    }
                    else
                    {
                        node.Remove();
                    }
                }

                if (node.Nodes.Count == 0 && string.IsNullOrEmpty(node.Tags))
                {
                    node.Remove();
                }
            }

            return(hasMarks);
        }
示例#6
0
		private string GetNodeKey(CustomTreeNode node)
		{
			return node.CodeNode.StartLine + "_(" + node.Text + ")";
		}
示例#7
0
		public void SetExpandedState(CustomTreeNode node)
		{
			ActiveStorage[GetNodeKey(node)] = node.IsExpanded;
		}
示例#8
0
        private void FillNodes(Hierarchy<CodeNode> source, TreeNodeCollection dest, int level, IList<CodeNode> functions)
        {
            if (!source.HasChildren)
            {
                return;
            }

            var isSort = Settings.SortingEnabled;
            var isHierarchy = true;
            var childrens = source.Children;
            if (isSort)
            {
                childrens.Sort((a1, a2) => string.Compare(a1.Item.Alias, a2.Item.Alias));
            }

            foreach (var item in childrens)
            {
                CodeNode node = item.Item;

                if (node.StartLine > _lastCodeLine)
                {
                    _lastCodeLine = node.StartLine;
                }

                CustomTreeNode treeNode = new CustomTreeNode(node.Alias);
                treeNode.CodeNode = node;
                treeNode.ToolTipText = CommentTipFormatter.FormatPlainTextComment(node.Comment);
                treeNode.StateImageIndex = GetImageIndex(node.NodeType);
                _marksManager.RestoreMark(treeNode);
                if (isHierarchy)
                {
                    dest.Add(treeNode);
                }
                else
                {
                    _tempTreeNodes.Add(treeNode);
                }

                functions.Add(node);

                if (item.HasChildren)
                {
                    FillNodes(item, treeNode.Nodes, level + 1, functions);
                }

                var isExpanded = _expandedNodesManager.IsNoteExpanded(treeNode);
                if (isExpanded.HasValue)
                {
                    if (isExpanded.Value)
                    {
                        treeNode.Expand();
                    }
                }
                else
                {
                    if (Settings.AutoExpandAll)
                    {
                        treeNode.Expand();
                    }
                }
            }
        }
示例#9
0
        private void SelectNode(string mark, CustomTreeNode treenode)
        {
            if (!string.IsNullOrEmpty(mark))
            {
                treenode.Tags = mark;

                switch (mark[0])
                {
                    case 'W':
                        treenode.ForeColor = Settings.Default.taggedFunction1Color;
                        treenode.NodeFont = Settings.Default.taggedFunction1Font;
                        break;
                    case 'B':
                        treenode.ForeColor = Settings.Default.taggedFunction2Color;
                        treenode.NodeFont = Settings.Default.taggedFunction2Font;
                        break;
                    case 'G':
                        treenode.ForeColor = Settings.Default.taggedFunction3Color;
                        treenode.NodeFont = Settings.Default.taggedFunction3Font;
                        break;
                    case 'O':
                        treenode.ForeColor = Settings.Default.taggedFunction4Color;
                        treenode.NodeFont = Settings.Default.taggedFunction4Font;
                        break;
                    case 'R':
                        treenode.ForeColor = Settings.Default.taggedFunction5Color;
                        treenode.NodeFont = Settings.Default.taggedFunction5Font;
                        break;
                    case 'S':
                        treenode.ForeColor = Settings.Default.taggedFunction6Color;
                        treenode.NodeFont = Settings.Default.taggedFunction6Font;
                        break;
                }
            }
            else
            {
                treenode.ForeColor = SystemColors.WindowText;
                treenode.NodeFont = null;
                treenode.Tags = null;
            }
        }
示例#10
0
        public void SetMark(string mark, CustomTreeNode treenode)
        {
            SelectNode(mark, treenode);

            if (!string.IsNullOrEmpty(mark))
            {
                CurrentDictionary[treenode.Text] = mark;
            }
            else
            {
                CurrentDictionary.Remove(treenode.Text);
            }

            Save();
        }