~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to samples/ComponentInspector/ComponentInspector.Core/Src/ObjectBrowser/TreeNodes/ComProgIdRootTreeNode.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// <file>
 
2
//     <copyright see="prj:///doc/copyright.txt"/>
 
3
//     <license see="prj:///doc/license.txt"/>
 
4
//     <owner name="Oakland Software Incorporated" email="general@oaklandsoftware.com"/>
 
5
//     <version>$Revision$</version>
 
6
// </file>
 
7
 
 
8
using System;
 
9
using Microsoft.Win32;
 
10
using NoGoop.Obj;
 
11
using NoGoop.Win32;
 
12
 
 
13
namespace NoGoop.ObjBrowser.TreeNodes
 
14
{
 
15
 
 
16
        internal class ComProgIdRootTreeNode : ComRootTreeNode
 
17
        {
 
18
 
 
19
        protected class ProgIdNode
 
20
        {
 
21
            internal BasicInfo          _info;
 
22
            internal String             _progId;
 
23
        }
 
24
 
 
25
 
 
26
        // Used to hold the progId between ProcessChild() and SortKey()
 
27
        protected String                _sortKey;
 
28
 
 
29
        internal ComProgIdRootTreeNode() : base()
 
30
                {
 
31
            SetPresInfo(PresentationMap.COM_FOLDER_APPID);
 
32
 
 
33
            _baseKey = Windows.KeyClassRoot;
 
34
            _progressName = "ProgId";
 
35
                }
 
36
 
 
37
        // Used to get the basic info that is used by this type
 
38
        // of node
 
39
        protected override Object ProcessChild(RegistryKey key,
 
40
                                                  String subKeyName)
 
41
        {
 
42
 
 
43
            // Eliminate the known keys and the file extensions
 
44
            if (subKeyName.StartsWith(".") ||
 
45
                subKeyName.Equals("CLSID") ||
 
46
                subKeyName.Equals("CID") ||
 
47
                subKeyName.Equals("AppId") ||
 
48
                subKeyName.Equals("Interface") ||
 
49
                subKeyName.Equals("TypeLib"))
 
50
                return null;
 
51
 
 
52
            ComClassInfo classInfo = null;
 
53
            _sortKey = subKeyName;
 
54
 
 
55
            ProgIdNode node = new ProgIdNode();
 
56
            node._progId = _sortKey;
 
57
            
 
58
            // See if there is a CLSID for this program id
 
59
            RegistryKey clsIdKey = 
 
60
                key.OpenSubKey("CLSID");
 
61
            if (clsIdKey != null)
 
62
            {
 
63
                String clsId = (String)clsIdKey.GetValue(null);
 
64
                if (clsId != null)
 
65
                {
 
66
                    RegistryKey classKey = 
 
67
                        Windows.KeyCLSID.OpenSubKey(clsId);
 
68
                                
 
69
                    if (classKey != null)
 
70
                    {
 
71
                        classInfo = 
 
72
                            ComClassInfo.GetClassInfo(classKey, clsId);
 
73
                        node._info = classInfo;
 
74
                        classInfo.AddProgId(subKeyName);
 
75
                    }
 
76
                }
 
77
            }
 
78
 
 
79
            // Don't bother with it unless it refers to a class
 
80
            if (classInfo == null)
 
81
                return null;
 
82
            return node;
 
83
        }
 
84
 
 
85
        protected override Object GetSortKey(Object info)
 
86
        {
 
87
            return _sortKey;
 
88
        }
 
89
 
 
90
        // Allocates the correct type of node
 
91
        protected override BrowserTreeNode AllocateChildNode(Object obj)
 
92
        {
 
93
            if (_progress != null)
 
94
                _progress.UpdateProgress(1);
 
95
 
 
96
            ProgIdNode progIdNode = (ProgIdNode)obj;
 
97
            ComTypeTreeNode node = new ComTypeTreeNode(progIdNode._info, 
 
98
                                                       progIdNode._progId);
 
99
            node.IntermediateNodeTypes = null;
 
100
            return node;
 
101
        }
 
102
 
 
103
 
 
104
        // Determines is this node has children
 
105
        protected override bool HasChildren()
 
106
        {
 
107
            // Assume there are classes on the system
 
108
            return true;
 
109
        }
 
110
 
 
111
 
 
112
 
 
113
        public override String GetName()
 
114
                {
 
115
            return "ProgIds";
 
116
                }
 
117
 
 
118
        public override void GetDetailText()
 
119
                {
 
120
            base.GetDetailText();
 
121
                }
 
122
 
 
123
 
 
124
        }
 
125
 
 
126
}