public ControlCommandSet(ISite site) : base(site)
 {
     this.statusCommandUI = new StatusCommandUI(site);
     this.commandSet = new CommandSet.CommandSetItem[] { 
         new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignLeft, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignTop, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusControlsOnlySelectionAndGrid), new EventHandler(this.OnMenuAlignToGrid), StandardCommands.AlignToGrid, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignBottom, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignHorizontalCenters, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignRight, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuAlignByPrimary), StandardCommands.AlignVerticalCenters, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusControlsOnlySelection), new EventHandler(this.OnMenuCenterSelection), StandardCommands.CenterHorizontally, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusControlsOnlySelection), new EventHandler(this.OnMenuCenterSelection), StandardCommands.CenterVertically, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.HorizSpaceConcatenate, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.HorizSpaceDecrease, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.HorizSpaceIncrease, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.HorizSpaceMakeEqual, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.VertSpaceConcatenate, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.VertSpaceDecrease, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.VertSpaceIncrease, true), 
         new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectNonContained), new EventHandler(this.OnMenuSpacingCommand), StandardCommands.VertSpaceMakeEqual, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuSizingCommand), StandardCommands.SizeToControl, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuSizingCommand), StandardCommands.SizeToControlWidth, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusMultiSelectPrimary), new EventHandler(this.OnMenuSizingCommand), StandardCommands.SizeToControlHeight, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusControlsOnlySelectionAndGrid), new EventHandler(this.OnMenuSizeToGrid), StandardCommands.SizeToGrid, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusZOrder), new EventHandler(this.OnMenuZOrderSelection), StandardCommands.BringToFront, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusZOrder), new EventHandler(this.OnMenuZOrderSelection), StandardCommands.SendToBack, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusShowGrid), new EventHandler(this.OnMenuShowGrid), StandardCommands.ShowGrid, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusSnapToGrid), new EventHandler(this.OnMenuSnapToGrid), StandardCommands.SnapToGrid, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAnyControls), new EventHandler(this.OnMenuTabOrder), StandardCommands.TabOrder, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusLockControls), new EventHandler(this.OnMenuLockControls), StandardCommands.LockControls, true), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeySizeWidthIncrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeySizeHeightIncrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeySizeWidthDecrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeySizeHeightDecrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeyNudgeWidthIncrease), 
         new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeyNudgeHeightIncrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeyNudgeWidthDecrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySize), MenuCommands.KeyNudgeHeightDecrease), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySelect), MenuCommands.KeySelectNext), new CommandSet.CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeySelect), MenuCommands.KeySelectPrevious)
      };
     if (base.MenuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             base.MenuService.AddCommand(this.commandSet[i]);
         }
     }
     IDesignerHost service = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (service != null)
     {
         Control rootComponent = service.RootComponent as Control;
         if (rootComponent != null)
         {
             this.baseControl = rootComponent;
         }
     }
 }
コード例 #2
0
 public CommandSet(ISite site)
 {
     this.site = site;
     this.eventService = (IEventHandlerService) site.GetService(typeof(IEventHandlerService));
     this.eventService.EventHandlerChanged += new EventHandler(this.OnEventHandlerChanged);
     IDesignerHost host = (IDesignerHost) site.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         host.Activated += new EventHandler(this.UpdateClipboardItems);
     }
     this.statusCommandUI = new StatusCommandUI(site);
     IUIService uiService = site.GetService(typeof(IUIService)) as IUIService;
     this.commandSet = new CommandSetItem[] {
         new CommandSetItem(this, new EventHandler(this.OnStatusDelete), new EventHandler(this.OnMenuDelete), StandardCommands.Delete, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCopy), new EventHandler(this.OnMenuCopy), StandardCommands.Copy, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusCut), new EventHandler(this.OnMenuCut), StandardCommands.Cut, uiService), new ImmediateCommandSetItem(this, new EventHandler(this.OnStatusPaste), new EventHandler(this.OnMenuPaste), StandardCommands.Paste, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusSelectAll), new EventHandler(this.OnMenuSelectAll), StandardCommands.SelectAll, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnMenuDesignerProperties), MenuCommands.DesignerProperties, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAlways), new EventHandler(this.OnKeyCancel), MenuCommands.KeyReverseCancel, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusPrimarySelection), new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveLeft, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyMoveRight, true), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeUp, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeDown, true, uiService), new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeLeft, true, uiService),
         new CommandSetItem(this, new EventHandler(this.OnStatusAnySelection), new EventHandler(this.OnKeyMove), MenuCommands.KeyNudgeRight, true, uiService)
      };
     this.selectionService = (ISelectionService) site.GetService(typeof(ISelectionService));
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     this.menuService = (IMenuCommandService) site.GetService(typeof(IMenuCommandService));
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.AddCommand(this.commandSet[i]);
         }
     }
     IDictionaryService service = site.GetService(typeof(IDictionaryService)) as IDictionaryService;
     if (service != null)
     {
         service.SetValue(typeof(CommandID), new CommandID(new Guid("BA09E2AF-9DF2-4068-B2F0-4C7E5CC19E2F"), 0));
     }
 }
コード例 #3
0
 internal ResizeBehavior(IServiceProvider serviceProvider)
 {
     this.serviceProvider = serviceProvider;
     this.dragging = false;
     this.pushedBehavior = false;
     this.lastSnapOffset = Point.Empty;
     this.didSnap = false;
     this.statusCommandUI = new StatusCommandUI(serviceProvider);
 }
 public ToolboxItemSnapLineBehavior(IServiceProvider serviceProvider, BehaviorService behaviorService)
 {
     this.serviceProvider = serviceProvider;
     this.behaviorService = behaviorService;
     this.designer = null;
     this.isPushed = false;
     this.lastRectangle = Rectangle.Empty;
     this.lastOffset = Point.Empty;
     this.statusCommandUI = new StatusCommandUI(serviceProvider);
     this.targetAllowsDragBox = true;
     this.targetAllowsSnapLines = true;
 }
コード例 #5
0
 public override void Initialize(IComponent component)
 {
     PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(component.GetType());
     PropertyDescriptor descriptor = properties["Visible"];
     if (((descriptor == null) || (descriptor.PropertyType != typeof(bool))) || !descriptor.ShouldSerializeValue(component))
     {
         this.Visible = true;
     }
     else
     {
         this.Visible = (bool) descriptor.GetValue(component);
     }
     PropertyDescriptor descriptor2 = properties["Enabled"];
     if (((descriptor2 == null) || (descriptor2.PropertyType != typeof(bool))) || !descriptor2.ShouldSerializeValue(component))
     {
         this.Enabled = true;
     }
     else
     {
         this.Enabled = (bool) descriptor2.GetValue(component);
     }
     this.initializing = true;
     base.Initialize(component);
     this.initializing = false;
     this.host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     DockingAttribute attribute = (DockingAttribute) TypeDescriptor.GetAttributes(base.Component)[typeof(DockingAttribute)];
     if ((attribute != null) && (attribute.DockingBehavior != DockingBehavior.Never))
     {
         this.dockingAction = new DockingActionList(this);
         DesignerActionService service = this.GetService(typeof(DesignerActionService)) as DesignerActionService;
         if (service != null)
         {
             service.Add(base.Component, this.dockingAction);
         }
     }
     this.dataBindingsCollectionChanged = new CollectionChangeEventHandler(this.DataBindingsCollectionChanged);
     this.Control.DataBindings.CollectionChanged += this.dataBindingsCollectionChanged;
     this.Control.ControlAdded += new ControlEventHandler(this.OnControlAdded);
     this.Control.ControlRemoved += new ControlEventHandler(this.OnControlRemoved);
     this.Control.ParentChanged += new EventHandler(this.OnParentChanged);
     this.Control.SizeChanged += new EventHandler(this.OnSizeChanged);
     this.Control.LocationChanged += new EventHandler(this.OnLocationChanged);
     this.DesignerTarget = new DesignerWindowTarget(this);
     if (this.Control.IsHandleCreated)
     {
         this.OnCreateHandle();
     }
     if ((base.Inherited && (this.host != null)) && (this.host.RootComponent != component))
     {
         this.inheritanceUI = (InheritanceUI) this.GetService(typeof(InheritanceUI));
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.AddInheritedControl(this.Control, this.InheritanceAttribute.InheritanceLevel);
         }
     }
     if (((this.host == null) || (this.host.RootComponent != component)) && this.ForceVisible)
     {
         this.Control.Visible = true;
     }
     this.Control.Enabled = true;
     this.Control.EnabledChanged += new EventHandler(this.OnEnabledChanged);
     this.AllowDrop = this.Control.AllowDrop;
     this.statusCommandUI = new StatusCommandUI(component.Site);
 }
 public override void Dispose()
 {
     if (base.MenuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             base.MenuService.RemoveCommand(this.commandSet[i]);
             this.commandSet[i].Dispose();
         }
     }
     if (this.tabOrder != null)
     {
         this.tabOrder.Dispose();
         this.tabOrder = null;
     }
     this.statusCommandUI = null;
     base.Dispose();
 }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     if (this.Control is ScrollableControl)
     {
         ((ScrollableControl) this.Control).Scroll += new ScrollEventHandler(this.OnScroll);
     }
     base.EnableDragDrop(true);
     IDesignerHost service = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (service != null)
     {
         this.componentChangeSvc = (IComponentChangeService) service.GetService(typeof(IComponentChangeService));
         if (this.componentChangeSvc != null)
         {
             this.componentChangeSvc.ComponentRemoving += new ComponentEventHandler(this.OnComponentRemoving);
             this.componentChangeSvc.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
         }
     }
     this.statusCommandUI = new StatusCommandUI(component.Site);
 }
コード例 #8
0
 internal void GiveFeedback(object sender, GiveFeedbackEventArgs e)
 {
     this.lastEffect = e.Effect;
     if ((this.data.Target == null) || (e.Effect == DragDropEffects.None))
     {
         if (this.clearDragImageRect != this.dragImageRect)
         {
             this.ClearAllDragImages();
             this.clearDragImageRect = this.dragImageRect;
         }
         if (this.dragAssistanceManager != null)
         {
             this.dragAssistanceManager.EraseSnapLines();
         }
     }
     else
     {
         bool flag = false;
         Point mousePosition = Control.MousePosition;
         bool flag2 = Control.ModifierKeys == Keys.Alt;
         if (flag2 && (this.dragAssistanceManager != null))
         {
             this.dragAssistanceManager.EraseSnapLines();
         }
         if (this.data.Target.Equals(this.data.Source) && (this.lastEffect != DragDropEffects.Copy))
         {
             e.UseDefaultCursors = false;
             Cursor.Current = Cursors.Default;
         }
         else
         {
             e.UseDefaultCursors = true;
         }
         Control target = this.data.Target as Control;
         if ((mousePosition != this.lastFeedbackLocation) || (flag2 && (this.dragAssistanceManager != null)))
         {
             if (!this.data.Target.Equals(this.lastDropTarget))
             {
                 this.serviceProviderTarget = target.Site;
                 if (this.serviceProviderTarget == null)
                 {
                     return;
                 }
                 IDesignerHost service = (IDesignerHost) this.serviceProviderTarget.GetService(typeof(IDesignerHost));
                 if (service == null)
                 {
                     return;
                 }
                 this.targetAllowsSnapLines = true;
                 ControlDesigner designer = service.GetDesigner(target) as ControlDesigner;
                 if ((designer != null) && !designer.ParticipatesWithSnapLines)
                 {
                     this.targetAllowsSnapLines = false;
                 }
                 this.statusCommandUITarget = new StatusCommandUI(this.serviceProviderTarget);
                 if ((this.lastDropTarget == null) || (service != this.destHost))
                 {
                     if ((this.destHost != null) && (this.destHost != this.srcHost))
                     {
                         this.behaviorServiceTarget.EnableAllAdorners(true);
                     }
                     this.behaviorServiceTarget = (BehaviorService) this.serviceProviderTarget.GetService(typeof(BehaviorService));
                     if (this.behaviorServiceTarget == null)
                     {
                         return;
                     }
                     this.GetParentSnapInfo(target, this.behaviorServiceTarget);
                     if (service != this.srcHost)
                     {
                         this.DisableAdorners(this.serviceProviderTarget, this.behaviorServiceTarget, true);
                     }
                     this.ClearAllDragImages();
                     if (this.lastDropTarget != null)
                     {
                         for (int i = 0; i < this.dragObjects.Count; i++)
                         {
                             Control c = (Control) this.dragObjects[i];
                             Rectangle rect = this.behaviorServiceSource.ControlRectInAdornerWindow(c);
                             rect.Location = this.behaviorServiceSource.AdornerWindowPointToScreen(rect.Location);
                             rect.Location = this.behaviorServiceTarget.MapAdornerWindowPoint(IntPtr.Zero, rect.Location);
                             if (i == 0)
                             {
                                 if (this.dragImageRegion != null)
                                 {
                                     this.dragImageRegion.Dispose();
                                 }
                                 this.dragImageRegion = new Region(rect);
                             }
                             else
                             {
                                 this.dragImageRegion.Union(rect);
                             }
                         }
                     }
                     if (this.graphicsTarget != null)
                     {
                         this.graphicsTarget.Dispose();
                     }
                     this.graphicsTarget = this.behaviorServiceTarget.AdornerWindowGraphics;
                     flag = true;
                     this.destHost = service;
                 }
                 this.lastDropTarget = this.data.Target;
             }
             if (this.ShowHideDragControls(this.lastEffect == DragDropEffects.Copy) && !flag)
             {
                 flag = true;
             }
             if (flag && this.behaviorServiceTarget.UseSnapLines)
             {
                 if (this.dragAssistanceManager != null)
                 {
                     this.dragAssistanceManager.EraseSnapLines();
                 }
                 this.dragAssistanceManager = new DragAssistanceManager(this.serviceProviderTarget, this.graphicsTarget, this.dragObjects, null, this.lastEffect == DragDropEffects.Copy);
             }
             Point pt = new Point((mousePosition.X - this.initialMouseLoc.X) + this.dragComponents[this.primaryComponentIndex].originalControlLocation.X, (mousePosition.Y - this.initialMouseLoc.Y) + this.dragComponents[this.primaryComponentIndex].originalControlLocation.Y);
             pt = this.MapPointFromSourceToTarget(pt);
             Rectangle dragBounds = new Rectangle(pt.X, pt.Y, this.dragComponents[this.primaryComponentIndex].dragImage.Width, this.dragComponents[this.primaryComponentIndex].dragImage.Height);
             if (this.dragAssistanceManager != null)
             {
                 if (this.targetAllowsSnapLines && !flag2)
                 {
                     this.lastSnapOffset = this.dragAssistanceManager.OnMouseMove(dragBounds);
                 }
                 else
                 {
                     this.dragAssistanceManager.OnMouseMove(new Rectangle(-100, -100, 0, 0));
                 }
             }
             else if (!this.parentGridSize.IsEmpty)
             {
                 this.lastSnapOffset = this.AdjustToGrid(pt);
             }
             pt.X += this.lastSnapOffset.X;
             pt.Y += this.lastSnapOffset.Y;
             this.dragComponents[this.primaryComponentIndex].draggedLocation = this.MapPointFromTargetToSource(pt);
             Rectangle dragImageRect = this.dragImageRect;
             pt = new Point((mousePosition.X - this.initialMouseLoc.X) + this.originalDragImageLocation.X, (mousePosition.Y - this.initialMouseLoc.Y) + this.originalDragImageLocation.Y) {
                 X = pt.X + this.lastSnapOffset.X,
                 Y = pt.Y + this.lastSnapOffset.Y
             };
             this.dragImageRect.Location = pt;
             dragImageRect.Location = this.MapPointFromSourceToTarget(dragImageRect.Location);
             Rectangle a = this.dragImageRect;
             a.Location = this.MapPointFromSourceToTarget(a.Location);
             Region region = new Region(Rectangle.Union(a, dragImageRect));
             region.Exclude(a);
             using (Region region2 = this.dragImageRegion.Clone())
             {
                 region2.Translate((int) ((mousePosition.X - this.initialMouseLoc.X) + this.lastSnapOffset.X), (int) ((mousePosition.Y - this.initialMouseLoc.Y) + this.lastSnapOffset.Y));
                 region2.Complement(a);
                 region2.Union(region);
                 this.behaviorServiceTarget.Invalidate(region2);
             }
             region.Dispose();
             if (this.graphicsTarget != null)
             {
                 this.graphicsTarget.SetClip(a);
                 this.graphicsTarget.DrawImage(this.dragImage, a.X, a.Y);
                 this.graphicsTarget.ResetClip();
             }
             Control dragComponent = this.dragComponents[this.primaryComponentIndex].dragComponent as Control;
             if (dragComponent != null)
             {
                 Point p = this.behaviorServiceSource.AdornerWindowPointToScreen(this.dragComponents[this.primaryComponentIndex].draggedLocation);
                 p = target.PointToClient(p);
                 if (target.IsMirrored && dragComponent.IsMirrored)
                 {
                     p.Offset(-dragComponent.Width, 0);
                 }
                 if (this.statusCommandUITarget != null)
                 {
                     this.statusCommandUITarget.SetStatusInformation(dragComponent, p);
                 }
             }
             if (((this.dragAssistanceManager != null) && !flag2) && this.targetAllowsSnapLines)
             {
                 this.dragAssistanceManager.RenderSnapLinesInternal();
             }
             this.lastFeedbackLocation = mousePosition;
         }
         this.data.Target = null;
     }
 }
コード例 #9
0
 public virtual void Dispose()
 {
     if (this.menuService != null)
     {
         for (int i = 0; i < this.commandSet.Length; i++)
         {
             this.menuService.RemoveCommand(this.commandSet[i]);
             this.commandSet[i].Dispose();
         }
         this.menuService = null;
     }
     if (this.selectionService != null)
     {
         this.selectionService.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         this.selectionService = null;
     }
     if (this.eventService != null)
     {
         this.eventService.EventHandlerChanged -= new EventHandler(this.OnEventHandlerChanged);
         this.eventService = null;
     }
     IDesignerHost service = (IDesignerHost) this.site.GetService(typeof(IDesignerHost));
     if (service != null)
     {
         service.Activated -= new EventHandler(this.UpdateClipboardItems);
     }
     if (this.snapLineTimer != null)
     {
         this.snapLineTimer.Stop();
         this.snapLineTimer.Tick -= new EventHandler(this.OnSnapLineTimerExpire);
         this.snapLineTimer = null;
     }
     this.EndDragManager();
     this.statusCommandUI = null;
     this.site = null;
 }