private void list_MouseDown(object sender, MouseEventArgs e) { ListBox lbSender = sender as ListBox; Rectangle lastSelectedBounds = lbSender.GetItemRectangle(this.selectedIndex); this.selectedIndex = lbSender.IndexFromPoint(e.X, e.Y); lbSender.SelectedIndex = this.selectedIndex; lbSender.Invalidate(lastSelectedBounds); lbSender.Invalidate(lbSender.GetItemRectangle(this.selectedIndex)); if (this.selectedIndex != 0) { if (e.Clicks == 2) { IToolboxUser tbu = this.host.GetDesigner(this.host.RootComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked((ToolboxItem)lbSender.Items[this.selectedIndex]); } } else if (e.Clicks < 2) { ToolboxItem tbi = lbSender.Items[this.selectedIndex] as ToolboxItem; IToolboxService tbs = ((IServiceProvider)this.host).GetService(typeof(IToolboxService)) as IToolboxService; DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { lbSender.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } } }
/// <summary> /// Handles the Drag event which raises a DoDragDrop event used by the /// DesignSurface to drag items from the Toolbox to the DesignSurface. /// If the currently selected item is the pointer item then the drag drop /// operation is not started. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnItemDrag(object sender, ItemDragEventArgs e) { if (e.Button == MouseButtons.Left && e.Item.GetType() == typeof(ListViewItem)) { ToolboxItem lItem = (e.Item as ListViewItem).Tag as ToolboxItem; if (lItem.TypeName != NameConsts.Pointer) { mIsDragging = true; IToolboxService lToolboxService = mToolboxService as IToolboxService; object lDataObject = lToolboxService.SerializeToolboxItem(lItem); DrawingTool lTool = lItem.CreateComponents().FirstOrDefault() as DrawingTool; lTool.CreatePersistence(); Rectangle lRect = lTool.SurroundingRect; using (DragImage image = new DragImage(lTool.DefaultImage, lRect.Width / 2, lRect.Height / 2)) { DoDragDrop(lDataObject, DragDropEffects.All); } mIsDragging = false; } } }
private void list_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { try { ListBox lbSender = sender as ListBox; Rectangle lastSelectedBounds = lbSender.GetItemRectangle(0); try { lastSelectedBounds = lbSender.GetItemRectangle(selectedIndex); } catch (Exception ex) { ex.ToString(); } selectedIndex = lbSender.IndexFromPoint(e.X, e.Y); // change our selection lbSender.SelectedIndex = selectedIndex; lbSender.Invalidate(lastSelectedBounds); // clear highlight from last selection lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex)); // highlight new one if (selectedIndex != 0) { SelectItemChangedFunction((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex])); if (e.Clicks == 2) { CreateToolboxItemFunction(); IDesignerHost idh = (IDesignerHost)this.DesignerHost.GetService(typeof(IDesignerHost)); IToolboxUser tbu = idh.GetDesigner(idh.RootComponent as IComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked((System.Drawing.Design.ToolboxItem)(lbSender.Items[selectedIndex])); } } else if (e.Clicks < 2) { System.Drawing.Design.ToolboxItem tbi = lbSender.Items[selectedIndex] as System.Drawing.Design.ToolboxItem; IToolboxService tbs = this; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { lbSender.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } catch (Exception ex) { ex.ToString(); } }
private void listBar1_MouseDown(object sender, MouseEventArgs e) { ListBarItem selected = thisMouseTrack.GetValue(listBar1) as ListBarItem; if (selected == null) { return; } else { deselectAll(); selected.Selected = true; selectedIndex = listBar1.SelectedGroup.Items.IndexOf(selected); //deselectAll(); } if (selectedIndex != 0) { // If this is a double-click, then the user wants to add the selected component // to the default location on the designer, with the default size. We call // ToolPicked on the current designer (as a IToolboxUser) to place the tool. // The IToolboxService calls SelectedToolboxItemUsed(), which calls this control's // SelectPointer() method. // if (e.Clicks == 2) { IToolboxUser tbu = host.GetDesigner(host.RootComponent) as IToolboxUser; if (tbu != null) { //tbu.ToolPicked((ToolboxItem)(lbSender.Items[selectedIndex])); tbu.ToolPicked((ToolboxItem)(listBar1.SelectedGroup.SelectedItem.Tag)); } SelectPointer(); } // Otherwise this is either a single click or a drag. Either way, we do the same // thing: start a drag--if this is just a single click, then the drag will // abort as soon as there's a MouseUp event. // else if (e.Clicks < 2) { //ToolboxItem tbi = lbSender.Items[selectedIndex] as ToolboxItem; ToolboxItem tbi = listBar1.SelectedGroup.SelectedItem.Tag as ToolboxItem; IToolboxService tbs = ((IServiceContainer)host).GetService(typeof(IToolboxService)) as IToolboxService; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { (sender as Control).DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
/// This method handles a MouseDown event, which might be one of three things: /// 1) the start of a single click /// 2) the start of a drag /// 3) the start of a second of two consecutive clicks (double-click) private void list_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { // Regardless of which kind of click this is, we need to change the selection. // First we grab the bounds of the old selected tool so that we can de-higlight it. // ListBox lbSender = sender as ListBox; Rectangle lastSelectedBounds = lbSender.GetItemRectangle(selectedIndex); selectedIndex = lbSender.IndexFromPoint(e.X, e.Y); // change our selection lbSender.SelectedIndex = selectedIndex; lbSender.Invalidate(lastSelectedBounds); // clear highlight from last selection lbSender.Invalidate(lbSender.GetItemRectangle(selectedIndex)); // highlight new one if (selectedIndex != 0) { // If this is a double-click, then the user wants to add the selected component // to the default location on the designer, with the default size. We call // ToolPicked on the current designer (as a IToolboxUser) to place the tool. // The IToolboxService calls SelectedToolboxItemUsed(), which calls this control's // SelectPointer() method. // if (e.Clicks == 2) { IToolboxUser tbu = host.GetDesigner(host.RootComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked((ToolboxItem)(lbSender.Items[selectedIndex])); } } // Otherwise this is either a single click or a drag. Either way, we do the same // thing: start a drag--if this is just a single click, then the drag will // abort as soon as there's a MouseUp event. // else if (e.Clicks < 2) { ToolboxItem tbi = lbSender.Items[selectedIndex] as ToolboxItem; IToolboxService tbs = ((IServiceContainer)host).GetService(typeof(IToolboxService)) as IToolboxService; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; try { lbSender.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
void navBarControl_LinkPressed(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { SelectedToolboxItem = (System.Drawing.Design.ToolboxItem)e.Link.Item.Tag; IToolboxService tbs = this; DataObject d = tbs.SerializeToolboxItem(SelectedToolboxItem) as DataObject; try { this.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } SelectedToolboxItem = null; }
public void ToolBoxItemButtonMouseDown(System.Windows.Forms.MouseEventArgs e, System.Drawing.Design.ToolboxItem toolboxItem) { if (toolboxItem == null) { return; } if (this.DesignerHost == null) { return; } if (e.Clicks == 2) { IDesignerHost idh = (IDesignerHost)this.DesignerHost.GetService(typeof(IDesignerHost)); IToolboxUser tbu = idh.GetDesigner(idh.RootComponent as IComponent) as IToolboxUser; if (tbu != null) { tbu.ToolPicked(toolboxItem); } } else if (e.Clicks < 2) { IToolboxService tbs = this; // The IToolboxService serializes ToolboxItems by packaging them in DataObjects. DataObject d = tbs.SerializeToolboxItem(toolboxItem) as DataObject; try { this.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
void itemList_MouseMove(object sender, MouseEventArgs e) { if (e.Button != MouseButtons.Left || itemList.SelectedIndex <= 0 || itemList.SelectedIndex != nSelectedIndex) { bPrepareDrag = false; } if (bPrepareDrag) { if (Math.Abs(e.X - x0) > 3 || Math.Abs(e.Y - y0) > 3) { ToolboxItem tbi = itemList.Items[itemList.SelectedIndex] as ToolboxItem; xToolboxItem xt = tbi as xToolboxItem; InterfaceVOB vob = ((IServiceContainer)toolbox.Host).GetService(typeof(InterfaceVOB)) as InterfaceVOB; IToolboxService tbs = ((IServiceContainer)toolbox.Host).GetService(typeof(IToolboxService)) as IToolboxService; if (tbs == null) { if (vob == null) { bool b = true; TraceLogClass log = new TraceLogClass(); log.Log("service InterfaceVOB not available", ref b); } else { PassData data = new PassData(); vob.SendNotice(enumVobNotice.GetToolbox, data); tbs = data.Data as IToolboxService; } } if (tbs != null) { bool bCanDrop = true; if (vob != null) { if (xt != null) { if (xt.Properties != null && xt.Properties.Contains("ClassId")) { ToolboxItemXType.SelectedToolboxClassId = (UInt32)(xt.Properties["ClassId"]); ToolboxItemXType.SelectedToolboxType = null; ToolboxItemXType.SelectedToolboxTypeKey = null; ToolboxItemXType.SelectedToolboxClassName = (string)(xt.Properties["DisplayName"]); } else { PassData pd = new PassData(); pd.Key = xt.Type; pd.Data = true; pd.Attributes = xt.Properties; vob.SendNotice(enumVobNotice.ObjectCanCreate, pd); bCanDrop = (bool)pd.Data; if (bCanDrop && pd.Attributes != null) { ToolboxItem tx0 = pd.Attributes as ToolboxItem; if (tx0 != null) { tbi = tx0; } } } } } if (bCanDrop) { try { DataObject d = tbs.SerializeToolboxItem(tbi) as DataObject; toolbox.HideToolBox(this, null); itemList.DoDragDrop(d, DragDropEffects.Copy); } catch (Exception ex) { bool b = true; TraceLogClass log = new TraceLogClass(); log.Log(this.FindForm(), ex, ref b); } } } } } }
public FireflyComponentBrowser() : base(null) { // Set the window title reading it from the resources. this.Caption = "Firefly Toolbox"; // Set the image that will appear on the tab of the window frame // when docked with an other window // The resource ID correspond to the one defined in the resx file // while the Index is the offset in the bitmap strip. Each image in // the strip being 16x16. this.BitmapResourceID = 301; this.BitmapIndex = 1; control = new MyControl(); Panel p = new Panel(); p.BorderStyle = BorderStyle.None; p.Dock = DockStyle.Fill; p.BackColor = SystemColors.ControlDark; System.Windows.Forms.TreeView treeView = new TreeView(); ImageListManager imageList = new ImageListManager(); imageList.SetToTreeView(treeView); //treeView.Dock = DockStyle.Fill; treeView.Anchor = AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom; treeView.BorderStyle = BorderStyle.None; uint cookie = 0; Cmd addSelectedControlToToolBox = delegate { try { IToolboxService toolboxService = (IToolboxService)this.GetService(typeof(IToolboxService)); toolboxService.AddToolboxItem((ToolboxItem)treeView.SelectedNode.Tag, toolboxService.SelectedCategory ?? "General"); } catch { } }; ToolStrip toolStrip = new ToolStrip(); toolStrip.GripStyle = ToolStripGripStyle.Hidden; //toolStrip.Dock = DockStyle.Top; ProfessionalColorTable professionalColorTable = new ProfessionalColorTable(); professionalColorTable.UseSystemColors = true; ToolStripProfessionalRenderer toolStripRenderer = new ToolStripProfessionalRenderer(professionalColorTable); toolStripRenderer.RoundedEdges = false; toolStrip.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; toolStrip.Renderer = toolStripRenderer; control.Controls.Add(p); toolStrip.AutoSize = false; toolStrip.Bounds = new Rectangle(1, 0, p.Width - 2, toolStrip.Height + 1); treeView.Bounds = new Rectangle(1, toolStrip.Height + 1, p.Width - 2, p.Height - toolStrip.Height - 2); // p.Padding = new Padding(1,0,1,1); // treeView.Margin = new Padding(0, 1, 0, 0); p.Controls.Add(treeView); p.Controls.Add(toolStrip); imageList.Add("Assembly", Resources.Assembly); imageList.Add("Namespace", Resources.Namespace); Bitmap bmp = Resources.AddToFavoritesHS; ToolStripButton addToToolBoxButton = new ToolStripButton(bmp); addToToolBoxButton.ToolTipText = "Add to tool box"; addToToolBoxButton.ImageTransparentColor = System.Drawing.Color.Black; toolStrip.Items.Add(addToToolBoxButton); addToToolBoxButton.Click += delegate { addSelectedControlToToolBox(); }; ContextMenuStrip contextMenu = new ContextMenuStrip(); ToolStripMenuItem addToToolBoxMenuItem = new ToolStripMenuItem("&Add to tool box", bmp); addToToolBoxMenuItem.ImageTransparentColor = System.Drawing.Color.Black; addToToolBoxMenuItem.Click += delegate { addSelectedControlToToolBox(); }; contextMenu.Items.Add(addToToolBoxMenuItem); ToolStripMenuItem about = new ToolStripMenuItem("A&bout"); about.Click += delegate { new AboutBox().ShowDialog(); }; contextMenu.Items.Add(new ToolStripSeparator()); contextMenu.Items.Add(about); treeView.BeforeSelect += delegate(object sender, TreeViewCancelEventArgs e) { addToToolBoxButton.Enabled = e.Node.Tag != null; addToToolBoxMenuItem.Enabled = e.Node.Tag != null; }; treeView.ContextMenuStrip = contextMenu; treeView.MouseDown += delegate(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right) { TreeNode node = treeView.HitTest(e.Location).Node; if (node != null) { treeView.SelectedNode = node; if (treeView.SelectedNode.Tag != null) { contextMenu.Show(treeView, e.Location); } } } }; SelectionHandler selectionHandler = new SelectionHandler(treeView); treeView.KeyDown += delegate(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Apps && treeView.SelectedNode.Tag != null) { contextMenu.Show(treeView, 0, 0); } }; bool reloading = false; System.Windows.Forms.ToolStripProgressBar progress = new ToolStripProgressBar(); progress.Visible = false; progress.Height = 10; progress.ProgressBar.Height = 10; System.Windows.Forms.ToolStripLabel loading = new ToolStripLabel(); loading.Text = "Loading..."; loading.Visible = false; Thread theThread = null; Bitmap bmp1 = Resources.Refresh; ToolStripButton refreshButton = new ToolStripButton(bmp1); refreshButton.ToolTipText = "Refresh"; refreshButton.ImageTransparentColor = System.Drawing.Color.Black; toolStrip.Items.Add(refreshButton); Action <bool> end = delegate(bool treeEnabled) { reloading = false; DoOnUIThread(delegate() { progress.Visible = false; loading.Visible = false; refreshButton.Enabled = true; treeView.Enabled = treeEnabled; }); selectionHandler.EndLoading(); theThread = null; }; Action <string> reportMessage = delegate(string message) { IVsOutputWindow outWindow = GetService(typeof(SVsOutputWindow)) as IVsOutputWindow; if (outWindow != null) { Guid generalWindowGuid = Microsoft.VisualStudio.VSConstants.GUID_OutWindowGeneralPane; IVsOutputWindowPane windowPane; outWindow.GetPane(ref generalWindowGuid, out windowPane); windowPane.OutputString(message); } }; Action <Exception> reportException = delegate(Exception ex) { reportMessage(string.Format("{0}\n\n{1}\n", ex.Message, ex.StackTrace)); }; Action <bool> reloadTree = delegate(bool forceRefresh) { if (reloading) { return; } reloading = true; EnvDTE.DTE dte = (EnvDTE.DTE)GetService(typeof(EnvDTE.DTE)); IDesignerHost designerHost = GetActiveDesigner(dte); if (designerHost == null) { end(false); return; } IToolboxService toolboxService = (IToolboxService)designerHost.GetService( typeof(IToolboxService)); Type rootBaseType = null; try { if (designerHost.RootComponent == null) { end(false); return; } rootBaseType = designerHost.RootComponent.GetType(); } catch { end(false); return; } if (!forceRefresh && _lastDesignedType != typeof(object)) { end(_lastDesignedType == rootBaseType); return; } _lastDesignedType = rootBaseType; DoOnUIThread(delegate() { progress.Visible = true; loading.Visible = true; refreshButton.Enabled = false; progress.Value = 1; treeView.Nodes.Clear(); }); selectionHandler.Reloadion(); theThread = new Thread( delegate() { lock (reloadLock) { try { VSLangProj.VSProject proj = (VSLangProj.VSProject)dte.ActiveDocument.ProjectItem.ContainingProject.Object; string projectOutputFileName = System.IO.Path.Combine( proj.Project.ConfigurationManager. ActiveConfiguration .Properties.Item("OutputPath").Value. ToString(), proj.Project.Properties.Item("OutputFileName"). Value. ToString ()); string fullProjectOutputFileName = System.IO.Path.IsPathRooted(projectOutputFileName) ? projectOutputFileName : System.IO.Path.Combine( System.IO.Path.GetDirectoryName( proj.Project.FileName), projectOutputFileName); AddAssembly addAssembly = delegate(string assemblyPath, bool publicTypesOnly) { AppDomainSetup ads = new AppDomainSetup(); ads.ApplicationBase = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); AppDomain appDomainForAssemblyLoading = AppDomain.CreateDomain( "AppDomainForAssemblyLoading", null, ads); System.Collections.Generic.SortedDictionary <string, System.Collections.Generic.SortedDictionary <string, TreeNode> > nodes = new System.Collections.Generic.SortedDictionary <string, System.Collections.Generic.SortedDictionary <string, TreeNode> >(); AssemblyName assemblyName = null; try { assemblyName = ((AssemblyNameProxy) appDomainForAssemblyLoading.CreateInstanceAndUnwrap( typeof(AssemblyNameProxy).Assembly.FullName, typeof(AssemblyNameProxy).FullName)).GetAssemblyName(assemblyPath); ResolveEventHandler resolve = delegate(object sender, ResolveEventArgs args) { return(args.Name == Assembly.GetExecutingAssembly().FullName ? Assembly.GetExecutingAssembly() : null); }; AppDomain.CurrentDomain.AssemblyResolve += resolve; AssemblyLoader assemblyLoader = (AssemblyLoader) appDomainForAssemblyLoading.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(AssemblyLoaderClass).FullName); AppDomain.CurrentDomain.AssemblyResolve -= resolve; assemblyLoader.DoOnTypes(assemblyName, System.IO.Path.GetDirectoryName(fullProjectOutputFileName), new AssemblyLoaderClientClass( delegate(string typeNamespace, ToolboxItem item) { try { if (toolboxService.IsSupported(toolboxService.SerializeToolboxItem(item), designerHost)) { item.Lock(); System.Windows.Forms.TreeNode node = new TreeNode(); DoOnUIThread( delegate() { node = new TreeNode(item.DisplayName); node.Tag = item; imageList.Add(item.TypeName, item.Bitmap); node.ImageIndex = imageList.GetImageIndexFor(item.TypeName); node.SelectedImageIndex = imageList.GetImageIndexFor(item.TypeName); }); System.Collections.Generic.SortedDictionary <string, TreeNode> componentNodes; if (!nodes.TryGetValue(typeNamespace, out componentNodes)) { componentNodes = new System.Collections.Generic.SortedDictionary < string, TreeNode>(); nodes.Add(typeNamespace, componentNodes); } componentNodes.Add(item.DisplayName, node); } } catch (Exception e) { try { reportMessage( string.Format( "Firefly Toolbox error - Exception occured on load of " + item.TypeName + " the exception is:\n" + e)); } catch { } } }), publicTypesOnly); } catch (Exception e) { try { DoOnUIThread( delegate() { System.Windows.Forms.TreeNode node = new TreeNode(); node.Text = "Error loading " + assemblyName + " - " + e.ToString(); treeView.Nodes.Add(node); }); reportMessage( string.Format( "Firefly Toolbox error - Exception occured on load of " + assemblyName.ToString() + " the exception is:\n" + e)); ReflectionTypeLoadException le = e as ReflectionTypeLoadException; if (le != null) { foreach (Exception ie in le.LoaderExceptions) { reportMessage( string.Format( "loader exception exception exception is:\n" + ie)); } } } catch { } } finally { AppDomain.Unload(appDomainForAssemblyLoading); } if (nodes.Count > 0) { DoOnUIThread( delegate { treeView.BeginUpdate(); try { System.Windows.Forms.TreeNode assemblyNode = new TreeNode(assemblyName.Name); assemblyNode.ImageIndex = imageList.GetImageIndexFor("Assembly"); assemblyNode.SelectedImageIndex = imageList.GetImageIndexFor("Assembly"); treeView.Nodes.Add(assemblyNode); foreach (System.Collections.Generic.KeyValuePair <string, System.Collections.Generic.SortedDictionary <string, TreeNode> > pair in nodes) { TreeNode namespaceNode = new TreeNode(pair.Key); namespaceNode.ImageIndex = imageList.GetImageIndexFor("Namespace"); namespaceNode.SelectedImageIndex = imageList.GetImageIndexFor("Namespace"); assemblyNode.Nodes.Add(namespaceNode); foreach (TreeNode n in pair.Value.Values) { namespaceNode.Nodes.Add(n); selectionHandler.Loaded(n); } imageList.CommitToUi(); } } finally { treeView.EndUpdate(); if (treeView.SelectedNode != null) { treeView.Update(); treeView.Select(); } } }); } }; System.Collections.Generic.SortedDictionary <string, Cmd> addAssemblies = new System.Collections.Generic.SortedDictionary <string, Cmd>(); if (System.IO.File.Exists(fullProjectOutputFileName)) { addAssemblies[Path.GetFileName(fullProjectOutputFileName)] = delegate { addAssembly(fullProjectOutputFileName, false); }; } foreach ( VSLangProj.Reference reference in proj.References) { string path = reference.Path; addAssemblies[Path.GetFileName(path)] = delegate { addAssembly(path, true); }; } DoOnUIThread( delegate() { progress.ProgressBar.Maximum = addAssemblies.Count + 1; }); foreach (Cmd cmd in addAssemblies.Values) { cmd(); DoOnUIThread( delegate() { try { progress.ProgressBar.Value++; } catch { } }); } } catch (Exception ex) { if (!(ex is ThreadAbortException)) { reportException(ex); } } finally { end(true); } } }); theThread.Start(); }; loading.Click += delegate { reloading = false; theThread.Abort(); end(true); }; refreshButton.Click += delegate { reloadTree(true); }; toolStrip.Items.Add(progress); toolStrip.Items.Add(loading); mySelectionListener listener = new mySelectionListener(treeView, delegate() { reloadTree(false); }); control.Load += delegate { IVsMonitorSelection monitor = (IVsMonitorSelection)GetService(typeof(IVsMonitorSelection)); monitor.AdviseSelectionEvents(listener, out cookie); reloadTree(false); }; control.Disposed += delegate { IVsMonitorSelection monitor = (IVsMonitorSelection)GetService(typeof(IVsMonitorSelection)); monitor.UnadviseSelectionEvents(cookie); }; treeView.ItemDrag += delegate(object sender, ItemDragEventArgs e) { IToolboxService toolboxService = (IToolboxService)this.GetService(typeof(IToolboxService)); System.Windows.Forms.TreeNode node = (System.Windows.Forms.TreeNode)e.Item; if (node.Tag == null) { return; } System.Windows.Forms.DataObject dataObject = toolboxService.SerializeToolboxItem( (ToolboxItem)node.Tag) as System.Windows.Forms.DataObject; treeView.DoDragDrop(dataObject, System.Windows.Forms.DragDropEffects.All); }; }