예제 #1
0
        private bool _selectionChanging;                   //we dont want the OnSelectionChanged to be recursively called.

        /// <summary>
        /// Constructor.  Here we query for necessary services and cache them for perf. reasons. We also hook to Component Added/Removed/Changed notifications so we can keep in sync when the designers' components change.  Also, we create our custom Adorner and add it to the BehaviorService.
        /// </summary>
        public SelectionManager(IServiceProvider serviceProvider, BehaviorService behaviorService)
        {
            _prevSelectionBounds  = null;
            _prevPrimarySelection = null;
            _behaviorService      = behaviorService;
            _serviceProvider      = serviceProvider;
            _selSvc       = (ISelectionService)serviceProvider.GetService(typeof(ISelectionService));
            _designerHost = (IDesignerHost)serviceProvider.GetService(typeof(IDesignerHost));
            if (_designerHost == null || _selSvc == null)
            {
                Debug.Fail("SelectionManager - Host or SelSvc is null, can't continue");
            }

            _rootComponent = (Control)_designerHost.RootComponent;
            //create and add both of our adorners, one for selection, one for bodies
            _selectionAdorner = new Adorner();
            _bodyAdorner      = new Adorner();
            behaviorService.Adorners.Add(_bodyAdorner);
            behaviorService.Adorners.Add(_selectionAdorner);//adding this will cause the adorner to get setup with a ptr to the beh.svc.
            _componentToDesigner = new Hashtable();
            // designeraction UI
            if (_designerHost.GetService(typeof(DesignerOptionService)) is DesignerOptionService options)
            {
                PropertyDescriptor p = options.Options.Properties["UseSmartTags"];
                if (p != null && p.PropertyType == typeof(bool) && (bool)p.GetValue(null))
                {
                    _designerActionUI = new DesignerActionUI(serviceProvider, _selectionAdorner);
                    behaviorService.DesignerActionUI = _designerActionUI;
                }
            }
        }
 internal DesignerActionBehavior(IServiceProvider serviceProvider, IComponent relatedComponent, DesignerActionListCollection actionLists, DesignerActionUI parentUI)
 {
     this.actionLists = actionLists;
     this.serviceProvider = serviceProvider;
     this.relatedComponent = relatedComponent;
     this.parentUI = parentUI;
 }
 internal BehaviorService(IServiceProvider serviceProvider, Control windowFrame)
 {
     this.serviceProvider = serviceProvider;
     this.adornerWindow = new AdornerWindow(this, windowFrame);
     IOverlayService service = (IOverlayService) serviceProvider.GetService(typeof(IOverlayService));
     if (service != null)
     {
         this.adornerWindowIndex = service.PushOverlay(this.adornerWindow);
     }
     this.dragEnterReplies = new Hashtable();
     this.adorners = new BehaviorServiceAdornerCollection(this);
     this.behaviorStack = new ArrayList();
     this.hitTestedGlyph = null;
     this.validDragArgs = null;
     this.actionPointer = null;
     this.trackMouseEvent = null;
     this.trackingMouseEvent = false;
     IMenuCommandService menuService = serviceProvider.GetService(typeof(IMenuCommandService)) as IMenuCommandService;
     IDesignerHost host = serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
     if ((menuService != null) && (host != null))
     {
         this.menuCommandHandler = new MenuCommandHandler(this, menuService);
         host.RemoveService(typeof(IMenuCommandService));
         host.AddService(typeof(IMenuCommandService), this.menuCommandHandler);
     }
     this.useSnapLines = false;
     this.queriedSnapLines = false;
     WM_GETALLSNAPLINES = System.Design.SafeNativeMethods.RegisterWindowMessage("WM_GETALLSNAPLINES");
     WM_GETRECENTSNAPLINES = System.Design.SafeNativeMethods.RegisterWindowMessage("WM_GETRECENTSNAPLINES");
     SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);
 }
 public SelectionManager(IServiceProvider serviceProvider, BehaviorService behaviorService)
 {
     this.behaviorService = behaviorService;
     this.serviceProvider = serviceProvider;
     this.selSvc = (ISelectionService) serviceProvider.GetService(typeof(ISelectionService));
     this.designerHost = (IDesignerHost) serviceProvider.GetService(typeof(IDesignerHost));
     if (this.designerHost != null)
     {
         ISelectionService selSvc = this.selSvc;
     }
     behaviorService.BeginDrag += new BehaviorDragDropEventHandler(this.OnBeginDrag);
     behaviorService.Synchronize += new EventHandler(this.OnSynchronize);
     this.selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     this.rootComponent = (Control) this.designerHost.RootComponent;
     this.selectionAdorner = new Adorner();
     this.bodyAdorner = new Adorner();
     behaviorService.Adorners.Add(this.bodyAdorner);
     behaviorService.Adorners.Add(this.selectionAdorner);
     this.componentToDesigner = new Hashtable();
     IComponentChangeService service = (IComponentChangeService) serviceProvider.GetService(typeof(IComponentChangeService));
     if (service != null)
     {
         service.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded);
         service.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
         service.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
     }
     this.designerHost.TransactionClosed += new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
     DesignerOptionService service2 = this.designerHost.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
     if (service2 != null)
     {
         PropertyDescriptor descriptor = service2.Options.Properties["UseSmartTags"];
         if (((descriptor != null) && (descriptor.PropertyType == typeof(bool))) && ((bool) descriptor.GetValue(null)))
         {
             this.designerActionUI = new DesignerActionUI(serviceProvider, this.selectionAdorner);
             behaviorService.DesignerActionUI = this.designerActionUI;
         }
     }
 }
 public DesignerActionToolStripDropDown(DesignerActionUI designerActionUI, IWin32Window mainParentWindow)
 {
     this._mainParentWindow = mainParentWindow;
     this._designerActionUI = designerActionUI;
 }
 public void Dispose()
 {
     if (this.designerHost != null)
     {
         this.designerHost.TransactionClosed -= new DesignerTransactionCloseEventHandler(this.OnTransactionClosed);
         this.designerHost = null;
     }
     if (this.serviceProvider != null)
     {
         IComponentChangeService service = (IComponentChangeService) this.serviceProvider.GetService(typeof(IComponentChangeService));
         if (service != null)
         {
             service.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded);
             service.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
             service.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
         }
         if (this.selSvc != null)
         {
             this.selSvc.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
             this.selSvc = null;
         }
         this.serviceProvider = null;
     }
     if (this.behaviorService != null)
     {
         this.behaviorService.Adorners.Remove(this.bodyAdorner);
         this.behaviorService.Adorners.Remove(this.selectionAdorner);
         this.behaviorService.BeginDrag -= new BehaviorDragDropEventHandler(this.OnBeginDrag);
         this.behaviorService.Synchronize -= new EventHandler(this.OnSynchronize);
         this.behaviorService = null;
     }
     if (this.selectionAdorner != null)
     {
         this.selectionAdorner.Glyphs.Clear();
         this.selectionAdorner = null;
     }
     if (this.bodyAdorner != null)
     {
         this.bodyAdorner.Glyphs.Clear();
         this.bodyAdorner = null;
     }
     if (this.designerActionUI != null)
     {
         this.designerActionUI.Dispose();
         this.designerActionUI = null;
     }
 }
예제 #7
0
 public DesignerActionToolStripDropDown(DesignerActionUI designerActionUI, IWin32Window mainParentWindow)
 {
     this._mainParentWindow = mainParentWindow;
     this._designerActionUI = designerActionUI;
 }