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>
9
using System.Collections;
10
using System.Windows.Forms;
12
using NoGoop.Controls;
14
using NoGoop.ObjBrowser.Panels;
16
namespace NoGoop.ObjBrowser.TreeNodes
18
internal class ComTypeLibTreeNode : BrowserTreeNode, IConvertableTreeNode, IFavoriteTreeNode
20
protected TypeLibrary _typeLib;
21
public int HelpContext {
23
return _typeLib.HelpContext;
27
public String HelpFile {
29
return _typeLib.HelpFile;
33
public HelpNavigator HelpNavigator {
35
return HelpNavigator.Topic;
39
internal TypeLibrary TypeLib {
45
internal ComTypeLibTreeNode(TypeLibrary typeLib)
48
_typeLib.TreeNode = this;
49
SetPresInfo(_typeLib.PresInfo);
53
public override String GetSearchNameString()
55
return _typeLib.GetSearchNameString();
58
public override int GetImageIndex()
60
return _typeLib.GetImageIndex();
63
public override ICollection GetSearchChildren()
65
return _typeLib.GetSearchChildren();
68
public override bool HasSearchChildren(ISearcher searcher)
70
return _typeLib.HasSearchChildren(searcher);
73
// Gets the objects to iterate over to make the child nodes
74
protected override ICollection GetChildren()
76
return _typeLib.Members;
79
// Allocates the correct type of node
80
protected override BrowserTreeNode AllocateChildNode(Object obj)
82
return new ComTypeTreeNode((BasicInfo)obj);
85
// Determines is this node has children
86
protected override bool HasChildren()
88
// Lets assume there are children without asking,
89
// because asking causes the type library to actually
90
// be opened, and we don't want to take the performance
95
public override bool HasConvert()
97
return !_typeLib.Converted;
100
public override bool HasRegister()
102
return !_typeLib.Registered;
105
public override bool HasUnregister()
107
return _typeLib.Registered;
110
public override bool HasClose()
112
// We allow only unregistered typelibs to be closed.
113
return !_typeLib.Registered;
116
public override bool HasRemoveFavorite()
118
// Unregistered type libs in the favs section will
119
// have the close option
120
return Parent == ComSupport.FavoriteTypeLibNode && _typeLib.Registered;
123
public override void RemoveLogicalNode()
127
base.RemoveLogicalNode();
128
} catch (Exception ex) {
130
"Error closing " + GetName(),
131
MessageBoxIcon.Error);
135
public override void Select()
137
// We should check for this, because its quick to do and
138
// if one of these exists, they we will get all of the
139
// right information in the detail text.
140
_typeLib.CheckForPrimaryInteropAssy();
144
public override bool ExpandNode()
146
// Do the conversion automatically
147
if (ComponentInspectorProperties.AutoConvertTypeLibs) {
148
// Returns false if failed, then expansion should not
150
if (!DoConvertInternal())
151
return base.ExpandNode();
153
// Returns true if this is made a favorite for the
154
// first time, and the expansion should be cancelled
155
if (MakeFavorite(true))
157
return base.ExpandNode();
160
public void DoConvert()
165
// Returns false if failed
166
protected bool DoConvertInternal()
169
// This will convert it if necessary
170
_typeLib.TranslateTypeLib();
171
// Conversion will have caused detail panel information
176
} catch (Exception ex) {
178
"Error converting " + GetName(),
179
MessageBoxIcon.Error);
184
public void DoRegister()
189
// No need to invalidate sinces its considered
190
// a favorite for now
191
} catch (Exception ex) {
193
"Error registering " + GetName(),
194
MessageBoxIcon.Error);
198
public void DoUnregister()
201
_typeLib.Unregister();
202
ComSupport.RegisteredTypeLibNode.InvalidateNode();
203
} catch (Exception ex) {
205
"Error Unregistering " + GetName(),
206
MessageBoxIcon.Error);
210
public void DoRemoveFavorite()
213
// Call superclass to not close the typelib
214
base.RemoveLogicalNode();
216
// This goes back into the registered tree now
217
ComSupport.RegisteredTypeLibNode.InvalidateNode();
218
} catch (Exception ex) {
220
"Error Removing Favorite " + GetName(),
221
MessageBoxIcon.Error);
225
// Return true if this is being made a favorite, which
226
// should cause the expansion of the original node to be cancelled
227
protected bool MakeFavorite(bool doExpand)
229
if (_typeLib.Registered && !HasRemoveFavorite()) {
230
// This may already be a favorite, since it got
231
// moved there when it was translated (if it was just
233
BrowserTreeNode foundNode = ComSupport.FindTypeLib(_typeLib.Key, ComSupport.FavoriteTypeLibNode);
234
if (foundNode == null) {
235
// Not in the favorites, put it there
236
foundNode = new ComTypeLibTreeNode(_typeLib);
237
ComSupport.FavoriteTypeLibNode.AddLogicalNode(foundNode);
239
_typeLib.RememberMe();
242
foundNode.PointToNode();
243
// Cancel expansion of original node
250
public override String GetName()
252
return _typeLib.GetName(BasicInfo.PREFER_DESCRIPTION);
255
public override void GetDetailText()
257
base.GetDetailText();
258
if (_typeLib != null)
259
_typeLib.GetDetailText(TypeLibrary.SHOW_ASSY);