Пример #1
0
        private void RefreshNode(ComTypeTreeNode node)
        {
            SetImageIndex(node);

            if (node is ComTypeLibraryTreeNode)
            {
                ComTypeLibraryTreeNode comTypeLibraryTreeNode = (ComTypeLibraryTreeNode)node;
                ComTypeLibrary         comTypeLibrary         = comTypeLibraryTreeNode.ComTypeLibrary;

                foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                {
                    if (comTypeInfo.IsHidden)
                    {
                        continue;
                    }

                    ComTypeInfoTreeNode comTypeInfoTreeNode = new ComTypeInfoTreeNode(comTypeInfo);
                    comTypeLibraryTreeNode.Nodes.Add(comTypeInfoTreeNode);
                    RefreshNode(comTypeInfoTreeNode);
                }
            }
            else if (node is ComTypeInfoTreeNode)
            {
                ComTypeInfoTreeNode comTypeInfoTreeNode = (ComTypeInfoTreeNode)node;
                ComTypeInfo         comTypeInfo         = comTypeInfoTreeNode.ComTypeInfo;

                foreach (ComImplementedTypeInfo comImplementedTypeInfo in comTypeInfo.ImplementedTypes)
                {
                    ComTypeInfoTreeNode impComTypeInfoTreeNode = new ComTypeInfoTreeNode(comImplementedTypeInfo.ComTypeInfo);
                    comTypeInfoTreeNode.Nodes.Add(impComTypeInfoTreeNode);
                    RefreshNode(impComTypeInfoTreeNode);
                }
            }
        }
Пример #2
0
        private void SetImageIndex(ComTypeTreeNode comTypeTreeNode)
        {
            ComTypeLibraryTreeNode  comTypeLibraryTreeNode  = comTypeTreeNode as ComTypeLibraryTreeNode;
            ComTypeInfoTreeNode     comTypeInfoTreeNode     = comTypeTreeNode as ComTypeInfoTreeNode;
            ComFunctionInfoTreeNode comFunctionInfoTreeNode = comTypeTreeNode as ComFunctionInfoTreeNode;
            ComPropertyInfoTreeNode comPropertyInfoTreeNode = comTypeTreeNode as ComPropertyInfoTreeNode;
            ComVariableInfoTreeNode comVariableInfoTreeNode = comTypeTreeNode as ComVariableInfoTreeNode;

            if (comTypeLibraryTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodeNamespaceImageIndex;
            }
            else if (comTypeInfoTreeNode != null)
            {
                ComTypeInfo comTypeInfo = comTypeInfoTreeNode.ComTypeInfo;

                if (comTypeInfo.IsCoClass)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeClassImageIndex;
                }
                else if (comTypeInfo.IsDispatch)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeInterfaceImageIndex;
                }
                else if (comTypeInfo.IsInterface)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeInterfaceImageIndex;
                }
                else if (comTypeInfo.IsEnum)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeEnumImageIndex;
                }
                else if (comTypeInfo.IsAlias)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeAliasImageIndex;
                }
                else if (comTypeInfo.IsRecord)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeStructureImageIndex;
                }
            }
            else if (comFunctionInfoTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodeMethodImageIndex;
            }
            else if (comPropertyInfoTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodePropertyImageIndex;
            }
            else if (comVariableInfoTreeNode != null)
            {
                comVariableInfoTreeNode.ImageIndex = ComTypeNodeConstantImageIndex;
            }

            comTypeTreeNode.SelectedImageIndex = comTypeTreeNode.ImageIndex;
        }
Пример #3
0
 private void DrawNodeExpander(ComTypeTreeNode node, Graphics graphics, Rectangle rect)
 {
     if (node.IsExpanded)
     {
         graphics.DrawImage(Resources.Collapse_16x16, rect.X + 2, rect.Y + 2);
     }
     else
     {
         if (node.Nodes.Count > 0)
         {
             graphics.DrawImage(Resources.Expand_16x16, rect.X + 2, rect.Y + 2);
         }
     }
 }
Пример #4
0
        private void SetImageIndex(ComTypeTreeNode comTypeTreeNode)
        {
            ComTypeLibraryTreeNode comTypeLibraryTreeNode = comTypeTreeNode as ComTypeLibraryTreeNode;
            ComTypeInfoTreeNode comTypeInfoTreeNode = comTypeTreeNode as ComTypeInfoTreeNode;
            ComFunctionInfoTreeNode comFunctionInfoTreeNode = comTypeTreeNode as ComFunctionInfoTreeNode;
            ComPropertyInfoTreeNode comPropertyInfoTreeNode = comTypeTreeNode as ComPropertyInfoTreeNode;
            ComVariableInfoTreeNode comVariableInfoTreeNode = comTypeTreeNode as ComVariableInfoTreeNode;

            if (comTypeLibraryTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodeNamespaceImageIndex;
            }
            else if (comTypeInfoTreeNode != null)
            {
                ComTypeInfo comTypeInfo = comTypeInfoTreeNode.ComTypeInfo;

                if (comTypeInfo.IsCoClass)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeClassImageIndex;
                }
                else if (comTypeInfo.IsDispatch)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeInterfaceImageIndex;
                }
                else if (comTypeInfo.IsInterface)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeInterfaceImageIndex;
                }
                else if (comTypeInfo.IsEnum)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeEnumImageIndex;
                }
                else if (comTypeInfo.IsAlias)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeAliasImageIndex;
                }
                else if (comTypeInfo.IsRecord)
                {
                    comTypeTreeNode.ImageIndex = ComTypeNodeStructureImageIndex;
                }
            }
            else if (comFunctionInfoTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodeMethodImageIndex;
            }
            else if (comPropertyInfoTreeNode != null)
            {
                comTypeTreeNode.ImageIndex = ComTypeNodePropertyImageIndex;
            }
            else if (comVariableInfoTreeNode != null)
            {
                comVariableInfoTreeNode.ImageIndex = ComTypeNodeConstantImageIndex;
            }

            comTypeTreeNode.SelectedImageIndex = comTypeTreeNode.ImageIndex;
        }
Пример #5
0
 private void SetImageIndex(ComTypeTreeNode[] comTypeTreeNodes)
 {
     foreach (ComTypeTreeNode comTypeTreeNode in comTypeTreeNodes)
     {
         SetImageIndex(comTypeTreeNode);
     }
 }
Пример #6
0
        private void RefreshNodesFiltered()
        {
            List<ComTypeTreeNode> list = new List<ComTypeTreeNode>();
            ComTypeTreeNode[] filterednodes = new ComTypeTreeNode[] { };
            int iFilter = 0;

            try
            {
                if (int.TryParse(_filter, out iFilter) == false)
                {
                    foreach (ComTypeLibrary comTypeLibrary in ComTypeManager.Instance.ComTypeLibraries)
                    {
                        foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                        {
                            if (comTypeInfo.IsHidden) continue;

                            list.Add(new ComTypeInfoTreeNode(comTypeInfo));

                            foreach (ComFunctionInfo comFunctionInfo in comTypeInfo.Methods)
                            {
                                list.Add(new ComFunctionInfoTreeNode(comFunctionInfo));
                            }

                            foreach (ComPropertyInfo comPropertyInfo in comTypeInfo.Properties)
                            {
                                list.Add(new ComPropertyInfoTreeNode(comPropertyInfo));
                            }

                            foreach (ComVariableInfo comVariableInfo in comTypeInfo.Variables)
                            {
                                list.Add(new ComVariableInfoTreeNode(comVariableInfo));
                            }
                        }
                    }

                    filterednodes = list.Where(x => x.Text.IndexOf(_filter, StringComparison.OrdinalIgnoreCase) >= 0).ToArray();
                }
                else
                {
                    foreach (ComTypeLibrary comTypeLibrary in ComTypeManager.Instance.ComTypeLibraries)
                    {
                        foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                        {
                            if (comTypeInfo.IsHidden) continue;

                            foreach (ComVariableInfo comVariableInfo in comTypeInfo.Variables)
                            {
                                list.Add(new ComVariableInfoTreeNode(comVariableInfo));
                            }
                        }
                    }

                    filterednodes = list.OfType<ComVariableInfoTreeNode>().Where(x => iFilter.Equals(x.ComVariableInfo.ConstantValue)).ToArray();
                }

                foreach (ComTypeTreeNode comTypeTreeNode in filterednodes)
                {
                    comTypeTreeNode.Text = comTypeTreeNode.FullText;
                    SetImageIndex(comTypeTreeNode);
                }
            }
            catch
            {
            }

            Nodes.Clear();
            Nodes.AddRange(filterednodes);
        }
Пример #7
0
        private void RefreshNode(ComTypeTreeNode node)
        {
            SetImageIndex(node);

            if (node is ComTypeLibraryTreeNode)
            {
                ComTypeLibraryTreeNode comTypeLibraryTreeNode = (ComTypeLibraryTreeNode)node;
                ComTypeLibrary comTypeLibrary = comTypeLibraryTreeNode.ComTypeLibrary;

                foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                {
                    if (comTypeInfo.IsHidden) continue;

                    ComTypeInfoTreeNode comTypeInfoTreeNode = new ComTypeInfoTreeNode(comTypeInfo);
                    comTypeLibraryTreeNode.Nodes.Add(comTypeInfoTreeNode);
                    RefreshNode(comTypeInfoTreeNode);
                }
            }
            else if (node is ComTypeInfoTreeNode)
            {
                ComTypeInfoTreeNode comTypeInfoTreeNode = (ComTypeInfoTreeNode)node;
                ComTypeInfo comTypeInfo = comTypeInfoTreeNode.ComTypeInfo;

                foreach (ComImplementedTypeInfo comImplementedTypeInfo in comTypeInfo.ImplementedTypes)
                {
                    ComTypeInfoTreeNode impComTypeInfoTreeNode = new ComTypeInfoTreeNode(comImplementedTypeInfo.ComTypeInfo);
                    comTypeInfoTreeNode.Nodes.Add(impComTypeInfoTreeNode);
                    RefreshNode(impComTypeInfoTreeNode);
                }
            }
        }
Пример #8
0
 private void DrawNodeExpander(ComTypeTreeNode node, Graphics graphics, Rectangle rect)
 {
     if (node.IsExpanded)
     {
         graphics.DrawImage(Resources.Collapse_16x16, rect.X + 2, rect.Y + 2);
     }
     else
     {
         if (node.Nodes.Count > 0)
         {
             graphics.DrawImage(Resources.Expand_16x16, rect.X + 2, rect.Y + 2);
         }
     }
 }
Пример #9
0
        private void RefreshNodesFiltered()
        {
            List <ComTypeTreeNode> list = new List <ComTypeTreeNode>();

            ComTypeTreeNode[] filterednodes = new ComTypeTreeNode[] { };
            int iFilter = 0;

            try
            {
                if (int.TryParse(_filter, out iFilter) == false)
                {
                    foreach (ComTypeLibrary comTypeLibrary in ComTypeManager.Instance.ComTypeLibraries)
                    {
                        foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                        {
                            if (comTypeInfo.IsHidden)
                            {
                                continue;
                            }

                            list.Add(new ComTypeInfoTreeNode(comTypeInfo));

                            foreach (ComFunctionInfo comFunctionInfo in comTypeInfo.Methods)
                            {
                                list.Add(new ComFunctionInfoTreeNode(comFunctionInfo));
                            }

                            foreach (ComPropertyInfo comPropertyInfo in comTypeInfo.Properties)
                            {
                                list.Add(new ComPropertyInfoTreeNode(comPropertyInfo));
                            }

                            foreach (ComVariableInfo comVariableInfo in comTypeInfo.Variables)
                            {
                                list.Add(new ComVariableInfoTreeNode(comVariableInfo));
                            }
                        }
                    }

                    filterednodes = list.Where(x => x.Text.IndexOf(_filter, StringComparison.OrdinalIgnoreCase) >= 0).ToArray();
                }
                else
                {
                    foreach (ComTypeLibrary comTypeLibrary in ComTypeManager.Instance.ComTypeLibraries)
                    {
                        foreach (ComTypeInfo comTypeInfo in comTypeLibrary.ComTypeInfos)
                        {
                            if (comTypeInfo.IsHidden)
                            {
                                continue;
                            }

                            foreach (ComVariableInfo comVariableInfo in comTypeInfo.Variables)
                            {
                                list.Add(new ComVariableInfoTreeNode(comVariableInfo));
                            }
                        }
                    }

                    filterednodes = list.OfType <ComVariableInfoTreeNode>().Where(x => iFilter.Equals(x.ComVariableInfo.ConstantValue)).ToArray();
                }

                foreach (ComTypeTreeNode comTypeTreeNode in filterednodes)
                {
                    comTypeTreeNode.Text = comTypeTreeNode.FullText;
                    SetImageIndex(comTypeTreeNode);
                }
            }
            catch
            {
            }

            Nodes.Clear();
            Nodes.AddRange(filterednodes);
        }
Пример #10
0
        //protected override void OnBeforeExpand(TreeViewCancelEventArgs e)
        //{
        //    Cursor.Current = Cursors.WaitCursor;
        //    BeginUpdate();

        //    if (e.Node.ImageIndex == ComTreeNodeClosedFolderImageIndex)
        //    {
        //        e.Node.ImageIndex = ComTreeNodeOpenFolderImageIndex;
        //        e.Node.SelectedImageIndex = e.Node.ImageIndex;
        //    }

        //    ComTypeTreeNode node = e.Node as ComTypeTreeNode;

        //    if (node != null)
        //    {
        //        if ((node.ComObject != null) || (node.Enumerable != null))
        //        {
        //            ComTypeTreeNode[] childNodes = BuildChildNodes(node);
        //            node.Nodes.Clear();
        //            node.Nodes.AddRange(childNodes);
        //        }
        //    }

        //    EndUpdate();
        //    Cursor.Current = Cursors.Default;
        //}

        protected override void OnDrawNode(DrawTreeNodeEventArgs e)
        {
            if (e.Node.IsVisible == false)
            {
                return;
            }

            ComTypeTreeNode node = e.Node as ComTypeTreeNode;

            if (node == null)
            {
                return;
            }

            Font            baseFont        = Font;
            Color           captionColor    = ForeColor;
            Color           caption2Color   = Color.Green;
            TextFormatFlags textFormatFlags = TextFormatFlags.Left | TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter;

            Rectangle rectNode     = node.Bounds;
            Rectangle rectExpander = new Rectangle(Indent * node.Level, rectNode.Y, ItemHeight, ItemHeight);
            Rectangle rectImage    = new Rectangle(rectExpander.X + rectExpander.Width, rectNode.Y, ItemHeight, ItemHeight);

            rectImage.X    = rectNode.X - rectImage.Width;
            rectExpander.X = rectNode.X - rectImage.Width - rectExpander.Width;

            DrawNodeExpander(node, e.Graphics, rectExpander);

            Rectangle rectSelected = rectImage;

            rectSelected.Width = e.Bounds.Width - rectImage.X;

            DrawNodeRectangle(e, rectSelected);

            Image nodeImage = null;

            if (ImageList != null)
            {
                int imageIndex = node.ImageIndex;
                if ((imageIndex == -1) && (ImageList.Images.Count > 0))
                {
                    imageIndex = 0;
                }

                if (imageIndex >= 0)
                {
                    nodeImage = ImageList.Images[imageIndex];
                }
            }

            if (nodeImage != null)
            {
                int z = ItemHeight - rectImage.Height;
                e.Graphics.DrawImage(nodeImage, rectImage.X + 2, rectImage.Y + 2);
            }

            Rectangle rectCaption = rectNode;

            rectCaption.Width = TextRenderer.MeasureText(node.Text, baseFont).Width;
            TextRenderer.DrawText(e.Graphics, node.Text, baseFont, rectCaption, captionColor, textFormatFlags);
        }