void Run() { TraceUtil.Init(); InitializeServices(); needsGettingStarted = ComponentInspectorProperties.ShowGettingStartedDialog; Application.EnableVisualStyles(); Application.Idle += new EventHandler(IdleHandler); objectBrowserForm = new ObjectBrowserForm(); // If a file was specified on the command line, open only // that, otherwise restore any previously opened assemblies if (fileToOpen != null) { objectBrowserForm.OpenFile(fileToOpen); } else { ComSupport.RestoreComEnvironment(); AssemblySupport.RestoreAssemblies(); } startupComplete = true; Application.Run(objectBrowserForm); }
/// <summary> /// Tries to open the specified file into the object browser. /// </summary> public bool OpenFile(string fileName) { Exception savedException = null; try { AssemblySupport.OpenFile(fileName); return(true); } catch (Exception ex) { savedException = ex; } try { ComSupport.OpenFile(fileName); return(true); } catch (Exception ex) { if (savedException == null) { savedException = ex; } } TraceUtil.WriteLineWarning(null, String.Concat("Error opening file ", fileName, ": " + savedException)); ErrorDialog.Show(savedException, "Error opening file " + fileName + "\n\n" + "The Inspector can only open .NET assemblies, ActiveX controls or ActiveX type libraries.", "Error opening file " + fileName, MessageBoxIcon.Error); return(false); }
ConstructorInfo FindConstructor(ConstructorInfo[] constructors) { ConstructorInfo constructor = null; if (constructors.Length > 1) { // Ask them to chose a constructor, if the // constructor requires parameters, then select // it and get out, otherwise go ahead. constructor = ConstructorDialog. GetConstructor(constructors); if (constructor != null && constructor.GetParameters().Length != 0) { AssemblySupport.SelectAssyTab(); MemberTreeNode.FindMember(constructor).PointToNode(); return(null); } } else { constructor = constructors[0]; } // This was cancelled if (constructor == null) { return(null); } // Since we need to get parameters, we can't finish // this operation now, we refer then to the constructor // that they should use and they can drag that // constructor where they want the object to do if (constructor.GetParameters().Length != 0) { BrowserTreeNode selNode = MemberTreeNode.FindMember(constructor); ErrorDialog. Show("Please select the constructor member " + "of this Type, fill in the parameters, " + "and then drag " + "the constructor to where you " + "want this object " + "to be created.", "Provide Parameters", MessageBoxIcon.Information); AssemblySupport.SelectAssyTab(); selNode.PointToNode(); return(null); } return(constructor); }
public ObjectBrowserForm() { _instance = this; using (SplashDialog splash = new SplashDialog()) { splash.SplashProductName = ".NET Component Inspector"; splash.Show(); Application.DoEvents(); InitializeComponent(); new System.Resources.ResourceManager(typeof(ObjectBrowser)); } Show(); AssemblySupport.AddCurrentAssemblies(); }
public ObjectBrowser(bool showStatusPanel, bool tabbedLayout) { TOP_OBJ_NAME = StringParser.Parse("${res:ComponentInspector.ObjectBrowser.TopLevelObjects}"); int start = Environment.TickCount; _objBrowser = this; InitTypeHandlers(); InitializeComponent(showStatusPanel, tabbedLayout); CreateControl(); // Create the designer host after everything is setup _designerHost = new DesignerHost(_objTree, _imagePanel.DesignPanel); AssemblySupport.AddCurrentAssemblies(); _helpFile = Directory.GetCurrentDirectory() + "\\CompInsp_" + "1" + ".chm"; int timeTaken = Environment.TickCount - start; }
protected void OpenClick(object sender, EventArgs e) { ListViewItem li = SelectedItems[0]; if (li.Tag != null) { FileInfo fi = (FileInfo)li.Tag; String fileName = fi.DirectoryName + "\\" + fi.Name; // The open mechanism will select the assembly tree // node whether or not it was actually opened (that is, // it might have been already opened) // Open can sometimes take a while Cursor save = Cursor.Current; Cursor.Current = Cursors.WaitCursor; AssemblySupport.OpenFile(fileName); Cursor.Current = save; } else { ErrorDialog.Show("Invalid GAC entry; cannot be opened", "Invalid GAC Entry", MessageBoxIcon.Error); } }
void InitializeComponent(bool showStatusPanel, bool tabbedLayout) { SuspendLayout(); CausesValidation = false; AutoScaleDimensions = new SizeF(6F, 13F); AutoScaleMode = AutoScaleMode.Font; Name = "ObjectBrowserControl"; Size = new Size(800, 700); // All of the dimensions are here int objTreeWidth = (int)(ClientSize.Width * 2 / WIDTH_UNITS); int assyTreeWidth = (int)(ClientSize.Width * 3 / WIDTH_UNITS); int paramsWidth = (int)(ClientSize.Width * 1 / WIDTH_UNITS); int imageWidth = (int)(ClientSize.Width * 2 / WIDTH_UNITS); int topHeight = (int)(ClientSize.Height * 2.5 / HEIGHT_UNITS); int bottomHeight = (int)(ClientSize.Height * 2.5 / HEIGHT_UNITS); int detailHeight = (int)(ClientSize.Height * 1 / HEIGHT_UNITS); int objTreeHeight = ClientSize.Height - detailHeight; // Contents of treePanel, on the left _objTree = new BrowserTree(TOP_OBJ_NAME); // Hook up the routines that get called when preferences change ComponentInspectorProperties.ShowPropertyAccessorMethodsChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowFieldsChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowPropertiesChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowMethodsChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowEventsChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowBaseClassesChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowPublicMembersOnlyChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowMemberCategoriesChanged += ObjectTreePreferencesChanged; ComponentInspectorProperties.ShowBaseCategoriesChanged += ObjectTreePreferencesChanged; ComponentInspectorProperties.CategoryThresholdChanged += ObjectTreePreferencesChanged; ComponentInspectorProperties.ShowBaseClassNamesChanged += ObjectTreeInvalidated; ComponentInspectorProperties.DisplayHexChanged += ObjectTreeInvalidated; ComponentInspectorProperties.ShowAssemblyPanelChanged += TabPanelChanged; ComponentInspectorProperties.ShowControlPanelChanged += TabPanelChanged; ComponentInspectorProperties.ShowGacPanelChanged += TabPanelChanged; ComponentInspectorProperties.TypeHandlerChanged += ObjectTreeInvalidated; ColumnHeader ch = new ColumnHeader(); ch.Text = StringParser.Parse("${res:ComponentInspector.ObjectBrowser.ValueColumnHeader}"); ch.TextAlign = HorizontalAlignment.Left; _objTree.Columns.Add(ch); _objTree.BorderStyle = BorderStyle.None; _objTree.AllowDrop = true; _objTree.IsObjectContainer = true; _objTree.IsDropTarget = true; _objTree.UseCompareTo = true; _objTree.GotFocus += new EventHandler(TreeFocused); UpdateObjectTreePreferences(); _objTree.SetupPanel(); _objTree.Panel.Dock = DockStyle.Fill; _objTree.Panel.Width = objTreeWidth; _objTree.Panel.Height = objTreeHeight; _objTree.Panel.BorderStyle = BorderStyle.None; _objTreePanel = new Panel(); _objTreePanel.Dock = DockStyle.Left; _objTreePanel.Width = _objTree.Panel.Width; // Note we add the parent, because the tree comes with a // panel that's the parent of the tree _objTreePanel.Controls.Add(_objTree.Panel); _objTreePanel.BorderStyle = BorderStyle.Fixed3D; new PanelLabel(_objTreePanel, StringParser.Parse("${res:ComponentInspector.ObjectBrowser.ObjectsTreePanel}")); // Image panel _imagePanel = NoGoop.ObjBrowser.ImagePanel.CreateImagePanel(objTreeWidth, !tabbedLayout); _imagePanel.WrapperPanel.Dock = DockStyle.Fill; // For text associated with each tree node _detailPanel = new DetailPanel(); _detailPanel.Dock = DockStyle.Bottom; _params = new ParamPanel(); _params.Dock = DockStyle.Fill; _params.Width = paramsWidth; _eventLog = new EventLogList(this); AssemblySupport.Init(); AssemblySupport.AssyTree.GotFocus += new EventHandler(TreeFocused); // Splitter between main tree and the rest, vertical Splitter mainSplitter = new Splitter(); mainSplitter.Dock = DockStyle.Left; mainSplitter.Width = Utils.SPLITTER_SIZE; Panel paramPanel = new Panel(); paramPanel.Dock = DockStyle.Left; paramPanel.Width = _params.Width; paramPanel.Controls.Add(_params); paramPanel.BorderStyle = BorderStyle.Fixed3D; new PanelLabel(paramPanel, StringParser.Parse("${res:ComponentInspector.ObjectBrowser.ParametersPanel}")); Splitter propImageSplitter = new Splitter(); propImageSplitter.Dock = DockStyle.Left; propImageSplitter.Width = Utils.SPLITTER_SIZE; // Contains the property panel and image panel Panel propImagePanel = new Panel(); propImagePanel.Dock = DockStyle.Top; propImagePanel.Height = topHeight; propImagePanel.Controls.Add(_imagePanel.WrapperPanel); propImagePanel.Controls.Add(propImageSplitter); propImagePanel.Controls.Add(paramPanel); // Splitter between node details and the rest _topTabSplitter = new Splitter(); _topTabSplitter.Dock = DockStyle.Top; _topTabSplitter.Height = Utils.SPLITTER_SIZE; GacList gacList = new GacList(); gacList.Width = assyTreeWidth; gacList.Dock = DockStyle.Fill; gacList.BorderStyle = BorderStyle.None; _gacTabPage = new TabPage(); _gacTabPage.Controls.Add(gacList); _gacTabPage.Text = "GAC"; _gacTabPage.BorderStyle = BorderStyle.None; // Object tab page. if (tabbedLayout) { _objTreeTabPage = new TabPage(); _objTreeTabPage.Controls.Add(_objTreePanel); _objTreeTabPage.Text = StringParser.Parse("${res:ComponentInspector.ObjectBrowser.ObjectsTreePanel}"); _objTreeTabPage.BorderStyle = BorderStyle.None; } // Not presently used _outputList = new OutputList(); _outputList.Width = assyTreeWidth; _outputList.Dock = DockStyle.Fill; _outputList.BorderStyle = BorderStyle.None; TabPage outputTabPage = new TabPage(); outputTabPage.Controls.Add(_outputList); outputTabPage.Text = StringParser.Parse("${res:ComponentInspector.ObjectBrowser.OutputTab}"); outputTabPage.BorderStyle = BorderStyle.None; _tabControl = new TabControl(); _tabControl.Dock = DockStyle.Fill; _tabControl.Width = assyTreeWidth; _tabControl.SelectedIndexChanged += new EventHandler(TabIndexChangedHandler); // Contains the property panel and image panel Panel tabPanel = new Panel(); tabPanel.Dock = DockStyle.Fill; if (tabbedLayout) { propImagePanel.Dock = DockStyle.Fill; } else { tabPanel.Controls.Add(_tabControl); tabPanel.Controls.Add(_topTabSplitter); } tabPanel.Controls.Add(propImagePanel); // All of the panels on the top _topPanel = new Panel(); _topPanel.Dock = DockStyle.Fill; _topPanel.Height = topHeight + bottomHeight; _topPanel.Controls.Add(tabPanel); _topPanel.Controls.Add(mainSplitter); if (tabbedLayout) { _tabControl.Dock = DockStyle.Left; _objTreePanel.Dock = DockStyle.Fill; _topPanel.Controls.Add(_tabControl); } else { _topPanel.Controls.Add(_objTreePanel); } if (!tabbedLayout) { _topBottomSplitter = new Splitter(); _topBottomSplitter.Dock = DockStyle.Bottom; _topBottomSplitter.Height = Utils.SPLITTER_SIZE; _topBottomSplitter.MinSize = detailHeight; } if (showStatusPanel) { _statusPanel = new StatusPanel(); _statusPanelLabel = new PanelLabel(_statusPanel); _statusPanelLabel.Dock = DockStyle.Top; } Controls.Add(_topPanel); if (showStatusPanel) { Controls.Add(_statusPanelLabel); } if (!tabbedLayout) { Controls.Add(_topBottomSplitter); Controls.Add(_detailPanel); } // To allow file dropping DragEnter += new DragEventHandler(DragEnterEvent); DragDrop += new DragEventHandler(DragDropEvent); DragOver += new DragEventHandler(DragOverEvent); AllowDrop = true; _objTree.BeginUpdate(); // Add top level nodes ArrayList tlList = new ArrayList(); ObjectInfo objInfo = ObjectInfoFactory.GetObjectInfo(false, tlList); objInfo.ObjectName = TOP_OBJ_NAME; BrowserTreeNode node = new ObjectTreeNode(false, objInfo); // Make sure this is the first node node.NodeOrder = 0; node.AllowDelete = false; _objTree.Nodes.Add(node); // Just for testing if (LocalPrefs.Get(LocalPrefs.DEV) != null) { tlList.Add(this); } _objTree.EndUpdate(); ComSupport.Init(); ComSupport.ComTree.GotFocus += new EventHandler(TreeFocused); SetTabPanels(); ResumeLayout(); }
internal static void AddAssy(Assembly assy, ICollection types) { lock (_assemblies) { // Don't add unless the tab is visible, because // the GetTypes() can take a long time (up to 10 // seconds in some cases) bool controlTreeShowing = ComponentInspectorProperties.ShowControlPanel; if (!controlTreeShowing) { _uptodate = false; return; } // Keep track of the assemblies we know about, don't // add the same one twice if (_assemblies[assy] == null) { _assemblies.Add(assy, assy); } else { return; } } if (types == null) { types = AssemblySupport.GetAssyTypes(assy); } foreach (Type t in types) { if (!(typeof(Control).IsAssignableFrom(t))) { continue; } String ns = t.Namespace; if (ns == null) { ns = ""; } bool found = false; NamespaceTreeNode n = null; for (int i = 0; i < _controlTree.Nodes.Count; i++) { n = (NamespaceTreeNode)_controlTree.Nodes[i]; if (n.Namespace.Equals(ns)) { found = true; n.InvalidateNode(); break; } } if (!found) { n = new NamespaceTreeNode(ns); _controlTree.Nodes.Add(n); } n.AddAssy(assy); } }