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));
     }
 }
Exemple #2
0
 public void HandleDoubleClick()
 {
     if (selectedItems.Count == 1)
     {
         IEventHandlerService ehs = clickedOn.Services.GetService <IEventHandlerService>();
         if (ehs != null)
         {
             DesignItemProperty defaultEvent = ehs.GetDefaultEvent(clickedOn);
             if (defaultEvent != null)
             {
                 ehs.CreateEventHandler(defaultEvent);
             }
         }
     }
 }
Exemple #3
0
        // This helper function will return true if any other MouseHandler (say TabOrder UI) is active, in which case we should not handle any Mouse Messages.. Since the TabOrder UI is pre-Whidbey when the TabOrder UI is up,  It adds a new Overlay (a window) to the DesignerFrame (something similar to AdornerWindow).  This UI is a transaparent control which has overrides foir Mouse Messages. It listens for all mouse messages through the IMouseHandler interface instead of using the new  BehaviorService. Hence we have to special case this scenario. (CONTROL DESIGNER ALSO DOES THIS).
        private bool MouseHandlerPresent(ToolStripItem item)
        {
            IMouseHandler mouseHandler = null;

            if (_eventSvc is null)
            {
                _eventSvc = (IEventHandlerService)item.Site.GetService(typeof(IEventHandlerService));
            }

            if (_eventSvc != null)
            {
                mouseHandler = (IMouseHandler)_eventSvc.GetHandler(typeof(IMouseHandler));
            }

            return(mouseHandler != null);
        }
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (this.region != null)
         {
             this.region.Dispose();
             this.region = null;
         }
         if (this.host != null)
         {
             IOverlayService service = (IOverlayService)this.host.GetService(typeof(IOverlayService));
             if (service != null)
             {
                 service.RemoveOverlay(this);
             }
             IEventHandlerService service2 = (IEventHandlerService)this.host.GetService(typeof(IEventHandlerService));
             if (service2 != null)
             {
                 service2.PopHandler(this);
             }
             IMenuCommandService service3 = (IMenuCommandService)this.host.GetService(typeof(IMenuCommandService));
             if (service3 != null)
             {
                 foreach (MenuCommand command in this.newCommands)
                 {
                     service3.RemoveCommand(command);
                 }
             }
             IComponentChangeService service4 = (IComponentChangeService)this.host.GetService(typeof(IComponentChangeService));
             if (service4 != null)
             {
                 service4.ComponentAdded   -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentRemoved -= new ComponentEventHandler(this.OnComponentAddRemove);
                 service4.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
             }
             IHelpService service5 = (IHelpService)this.host.GetService(typeof(IHelpService));
             if (service5 != null)
             {
                 service5.RemoveContextAttribute("Keyword", "TabOrderView");
             }
             this.host = null;
         }
     }
     base.Dispose(disposing);
 }
        public void Commit()
        {
            if (Text != ValueString)
            {
                if (string.IsNullOrEmpty(Text))
                {
                    PropertyNode.Reset();
                    return;
                }
                PropertyNode.Value = Text;
            }
            IEventHandlerService s = PropertyNode.Services.GetService <IEventHandlerService>();

            if (s != null)
            {
                s.CreateEventHandler(PropertyNode.FirstProperty);
            }
        }
        protected virtual void WndProc(ref Message m)
        {
            IMouseHandler handler = null;
            if ((m.Msg == 0x84) && !this.inHitTest)
            {
                this.inHitTest = true;
                Point point = new Point((short) System.Design.NativeMethods.Util.LOWORD((int) ((long) m.LParam)), (short) System.Design.NativeMethods.Util.HIWORD((int) ((long) m.LParam)));
                try
                {
                    this.liveRegion = this.GetHitTest(point);
                }
                catch (Exception exception)
                {
                    this.liveRegion = false;
                    if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                    {
                        throw;
                    }
                }
                this.inHitTest = false;
            }
            bool flag = m.Msg == 0x7b;
            if (this.liveRegion && (this.IsMouseMessage(m.Msg) || flag))
            {
                if (m.Msg == 0x7b)
                {
                    inContextMenu = true;
                }
                try
                {
                    this.DefWndProc(ref m);
                }
                finally
                {
                    if (m.Msg == 0x7b)
                    {
                        inContextMenu = false;
                    }
                    if (m.Msg == 0x202)
                    {
                        this.OnMouseDragEnd(true);
                    }
                }
                return;
            }
            int x = 0;
            int y = 0;
            if ((((m.Msg >= 0x200) && (m.Msg <= 0x20a)) || ((m.Msg >= 160) && (m.Msg <= 0xa9))) || (m.Msg == 0x20))
            {
                if (this.eventSvc == null)
                {
                    this.eventSvc = (IEventHandlerService) this.GetService(typeof(IEventHandlerService));
                }
                if (this.eventSvc != null)
                {
                    handler = (IMouseHandler) this.eventSvc.GetHandler(typeof(IMouseHandler));
                }
            }
            if ((m.Msg >= 0x200) && (m.Msg <= 0x20a))
            {
                System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
                    x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam)),
                    y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam))
                };
                System.Design.NativeMethods.MapWindowPoints(m.HWnd, IntPtr.Zero, pt, 1);
                x = pt.x;
                y = pt.y;
            }
            else if ((m.Msg >= 160) && (m.Msg <= 0xa9))
            {
                x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam));
                y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam));
            }
            MouseButtons none = MouseButtons.None;
            switch (m.Msg)
            {
                case 0x1f:
                    this.OnMouseDragEnd(true);
                    this.DefWndProc(ref m);
                    return;

                case 0x20:
                    goto Label_0A82;

                case 0x3d:
                    if (-4 == ((int) ((long) m.LParam)))
                    {
                        Guid refiid = new Guid("{618736E0-3C3D-11CF-810C-00AA00389B71}");
                        try
                        {
                            IAccessible accessibilityObject = this.AccessibilityObject;
                            if (accessibilityObject == null)
                            {
                                m.Result = IntPtr.Zero;
                            }
                            else
                            {
                                IntPtr iUnknownForObject = Marshal.GetIUnknownForObject(accessibilityObject);
                                try
                                {
                                    m.Result = System.Design.UnsafeNativeMethods.LresultFromObject(ref refiid, m.WParam, iUnknownForObject);
                                }
                                finally
                                {
                                    Marshal.Release(iUnknownForObject);
                                }
                            }
                            return;
                        }
                        catch (Exception exception2)
                        {
                            throw exception2;
                        }
                    }
                    this.DefWndProc(ref m);
                    return;

                case 15:
                    if (OleDragDropHandler.FreezePainting)
                    {
                        System.Design.NativeMethods.ValidateRect(m.HWnd, IntPtr.Zero);
                        return;
                    }
                    if (this.Control != null)
                    {
                        System.Design.NativeMethods.RECT rc = new System.Design.NativeMethods.RECT();
                        IntPtr hrgn = System.Design.NativeMethods.CreateRectRgn(0, 0, 0, 0);
                        System.Design.NativeMethods.GetUpdateRgn(m.HWnd, hrgn, false);
                        System.Design.NativeMethods.GetUpdateRect(m.HWnd, ref rc, false);
                        Region region = Region.FromHrgn(hrgn);
                        Rectangle empty = Rectangle.Empty;
                        try
                        {
                            if (this.thrownException == null)
                            {
                                this.DefWndProc(ref m);
                            }
                            using (Graphics graphics2 = Graphics.FromHwnd(m.HWnd))
                            {
                                if (m.HWnd != this.Control.Handle)
                                {
                                    System.Design.NativeMethods.POINT point3 = new System.Design.NativeMethods.POINT {
                                        x = 0,
                                        y = 0
                                    };
                                    System.Design.NativeMethods.MapWindowPoints(m.HWnd, this.Control.Handle, point3, 1);
                                    graphics2.TranslateTransform((float) -point3.x, (float) -point3.y);
                                    System.Design.NativeMethods.MapWindowPoints(m.HWnd, this.Control.Handle, ref rc, 2);
                                }
                                empty = new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
                                using (PaintEventArgs args2 = new PaintEventArgs(graphics2, empty))
                                {
                                    graphics2.Clip = region;
                                    if (this.thrownException == null)
                                    {
                                        this.OnPaintAdornments(args2);
                                    }
                                    else
                                    {
                                        System.Design.UnsafeNativeMethods.PAINTSTRUCT lpPaint = new System.Design.UnsafeNativeMethods.PAINTSTRUCT();
                                        System.Design.UnsafeNativeMethods.BeginPaint(m.HWnd, ref lpPaint);
                                        this.PaintException(args2, this.thrownException);
                                        System.Design.UnsafeNativeMethods.EndPaint(m.HWnd, ref lpPaint);
                                    }
                                }
                            }
                        }
                        finally
                        {
                            region.Dispose();
                            System.Design.NativeMethods.DeleteObject(hrgn);
                        }
                        if (this.OverlayService == null)
                        {
                            return;
                        }
                        empty.Location = this.Control.PointToScreen(empty.Location);
                        this.OverlayService.InvalidateOverlays(empty);
                    }
                    return;

                case 5:
                    if (this.thrownException != null)
                    {
                        this.Control.Invalidate();
                    }
                    this.DefWndProc(ref m);
                    return;

                case 7:
                    if ((this.host != null) && (this.host.RootComponent != null))
                    {
                        IRootDesigner designer = this.host.GetDesigner(this.host.RootComponent) as IRootDesigner;
                        if (designer == null)
                        {
                            return;
                        }
                        ViewTechnology[] supportedTechnologies = designer.SupportedTechnologies;
                        if (supportedTechnologies.Length <= 0)
                        {
                            return;
                        }
                        System.Windows.Forms.Control view = designer.GetView(supportedTechnologies[0]) as System.Windows.Forms.Control;
                        if (view == null)
                        {
                            return;
                        }
                        view.Focus();
                    }
                    return;

                case 1:
                    this.DefWndProc(ref m);
                    if (m.HWnd == this.Control.Handle)
                    {
                        this.OnCreateHandle();
                    }
                    return;

                case 0x85:
                case 0x86:
                    if (m.Msg != 0x86)
                    {
                        if (this.thrownException == null)
                        {
                            this.DefWndProc(ref m);
                        }
                        break;
                    }
                    this.DefWndProc(ref m);
                    break;

                case 0x7b:
                    if (!inContextMenu)
                    {
                        x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam));
                        y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam));
                        ToolStripKeyboardHandlingService service2 = (ToolStripKeyboardHandlingService) this.GetService(typeof(ToolStripKeyboardHandlingService));
                        bool flag2 = false;
                        if (service2 != null)
                        {
                            flag2 = service2.OnContextMenu(x, y);
                        }
                        if (flag2)
                        {
                            return;
                        }
                        if ((x == -1) && (y == -1))
                        {
                            Point position = Cursor.Position;
                            x = position.X;
                            y = position.Y;
                        }
                        this.OnContextMenu(x, y);
                    }
                    return;

                case 160:
                case 0x200:
                    if ((((int) ((long) m.WParam)) & 1) != 0)
                    {
                        none = MouseButtons.Left;
                    }
                    else if ((((int) ((long) m.WParam)) & 2) != 0)
                    {
                        none = MouseButtons.Right;
                        this.toolPassThrough = false;
                    }
                    else
                    {
                        this.toolPassThrough = false;
                    }
                    if ((this.lastMoveScreenX != x) || (this.lastMoveScreenY != y))
                    {
                        if (this.toolPassThrough)
                        {
                            System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam));
                            return;
                        }
                        if (handler != null)
                        {
                            handler.OnMouseMove(base.Component, x, y);
                        }
                        else if (none == MouseButtons.Left)
                        {
                            this.OnMouseDragMove(x, y);
                        }
                    }
                    this.lastMoveScreenX = x;
                    this.lastMoveScreenY = y;
                    if (m.Msg == 0x200)
                    {
                        this.BaseWndProc(ref m);
                    }
                    return;

                case 0xa1:
                case 0xa4:
                case 0x201:
                case 0x204:
                    if ((m.Msg == 0xa4) || (m.Msg == 0x204))
                    {
                        none = MouseButtons.Right;
                    }
                    else
                    {
                        none = MouseButtons.Left;
                    }
                    System.Design.NativeMethods.SendMessage(this.Control.Handle, 7, 0, 0);
                    if ((none == MouseButtons.Left) && this.IsDoubleClick(x, y))
                    {
                        if (handler != null)
                        {
                            handler.OnMouseDoubleClick(base.Component);
                            return;
                        }
                        this.OnMouseDoubleClick();
                        return;
                    }
                    this.toolPassThrough = false;
                    if (!this.EnableDragRect && (none == MouseButtons.Left))
                    {
                        if (this.toolboxSvc == null)
                        {
                            this.toolboxSvc = (IToolboxService) this.GetService(typeof(IToolboxService));
                        }
                        if ((this.toolboxSvc != null) && (this.toolboxSvc.GetSelectedToolboxItem((IDesignerHost) this.GetService(typeof(IDesignerHost))) != null))
                        {
                            this.toolPassThrough = true;
                        }
                    }
                    else
                    {
                        this.toolPassThrough = false;
                    }
                    if (this.toolPassThrough)
                    {
                        System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam));
                        return;
                    }
                    if (handler != null)
                    {
                        handler.OnMouseDown(base.Component, none, x, y);
                    }
                    else if (none == MouseButtons.Left)
                    {
                        this.OnMouseDragBegin(x, y);
                    }
                    else if (none == MouseButtons.Right)
                    {
                        ISelectionService service = (ISelectionService) this.GetService(typeof(ISelectionService));
                        if (service != null)
                        {
                            service.SetSelectedComponents(new object[] { base.Component }, SelectionTypes.Click);
                        }
                    }
                    this.lastMoveScreenX = x;
                    this.lastMoveScreenY = y;
                    return;

                case 0xa2:
                case 0xa5:
                case 0x202:
                case 0x205:
                    if ((m.Msg == 0xa5) || (m.Msg == 0x205))
                    {
                        none = MouseButtons.Right;
                    }
                    else
                    {
                        none = MouseButtons.Left;
                    }
                    if (handler != null)
                    {
                        handler.OnMouseUp(base.Component, none);
                    }
                    else
                    {
                        if (this.toolPassThrough)
                        {
                            System.Design.NativeMethods.SendMessage(this.Control.Parent.Handle, m.Msg, m.WParam, (IntPtr) this.GetParentPointFromLparam(m.LParam));
                            this.toolPassThrough = false;
                            return;
                        }
                        if (none == MouseButtons.Left)
                        {
                            this.OnMouseDragEnd(false);
                        }
                    }
                    this.toolPassThrough = false;
                    this.BaseWndProc(ref m);
                    return;

                case 0xa3:
                case 0xa6:
                case 0x203:
                case 0x206:
                    if ((m.Msg == 0xa6) || (m.Msg == 0x206))
                    {
                        none = MouseButtons.Right;
                    }
                    else
                    {
                        none = MouseButtons.Left;
                    }
                    if (none == MouseButtons.Left)
                    {
                        if (handler != null)
                        {
                            handler.OnMouseDoubleClick(base.Component);
                            return;
                        }
                        this.OnMouseDoubleClick();
                    }
                    return;

                case 0xa7:
                case 0xa8:
                case 0xa9:
                case 0x207:
                case 520:
                case 0x209:
                case 0x20a:
                case 0x2a0:
                case 0x2a2:
                    return;

                case 0x2a1:
                    if (handler == null)
                    {
                        this.OnMouseHover();
                        return;
                    }
                    handler.OnMouseHover(base.Component);
                    return;

                case 0x2a3:
                    this.OnMouseLeave();
                    this.BaseWndProc(ref m);
                    return;

                case 0x318:
                {
                    using (Graphics graphics = Graphics.FromHdc(m.WParam))
                    {
                        using (PaintEventArgs args = new PaintEventArgs(graphics, this.Control.ClientRectangle))
                        {
                            this.DefWndProc(ref m);
                            this.OnPaintAdornments(args);
                        }
                        return;
                    }
                }
                default:
                    if (m.Msg == System.Design.NativeMethods.WM_MOUSEENTER)
                    {
                        this.OnMouseEnter();
                        this.BaseWndProc(ref m);
                    }
                    else if ((m.Msg < 0x100) || (m.Msg > 0x108))
                    {
                        this.DefWndProc(ref m);
                    }
                    return;
            }
            if (((this.OverlayService == null) || (this.Control == null)) || (!(this.Control.Size != this.Control.ClientSize) || (this.Control.Parent == null)))
            {
                return;
            }
            Rectangle rectangle2 = new Rectangle(this.Control.Parent.PointToScreen(this.Control.Location), this.Control.Size);
            Rectangle rectangle3 = new Rectangle(this.Control.PointToScreen(Point.Empty), this.Control.ClientSize);
            using (Region region2 = new Region(rectangle2))
            {
                region2.Exclude(rectangle3);
                this.OverlayService.InvalidateOverlays(region2);
                return;
            }
            Label_0A82:
            if (this.liveRegion)
            {
                this.DefWndProc(ref m);
            }
            else if (handler != null)
            {
                handler.OnSetCursor(base.Component);
            }
            else
            {
                this.OnSetCursor();
            }
        }
 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;
 }
 public override void Initialize(IComponent component)
 {
     base.Initialize(component);
     this.inheritanceService = new InheritanceService();
     ISite provider = component.Site;
     IContainer container = null;
     IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     IExtenderProviderService ex = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService));
     if (ex != null)
     {
         this.designerExtenders = new DesignerExtenders(ex);
     }
     if (host != null)
     {
         this.eventHandlerService = new EventHandlerService(null);
         this.selectionUIService = new SelectionUIService(host);
         host.AddService(typeof(IInheritanceService), this.inheritanceService);
         host.AddService(typeof(IEventHandlerService), this.eventHandlerService);
         host.AddService(typeof(ISelectionUIService), this.selectionUIService);
         this.compositionUI = new CompositionUI(this, provider);
         host.AddService(typeof(ComponentTray), this.compositionUI);
         IComponentChangeService service2 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
         if (service2 != null)
         {
             service2.ComponentAdded += new ComponentEventHandler(this.OnComponentAdded);
             service2.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
         }
         ISelectionService service3 = (ISelectionService) this.GetService(typeof(ISelectionService));
         if (service3 != null)
         {
             service3.SetSelectedComponents(new object[] { component }, SelectionTypes.Auto);
         }
     }
     if (provider != null)
     {
         this.commandSet = new CompositionCommandSet(this.compositionUI, provider);
         container = provider.Container;
     }
     this.pbrsFwd = new PbrsForward(this.compositionUI, provider);
     this.inheritanceService.AddInheritedComponents(component, container);
     IServiceContainer service = (IServiceContainer) this.GetService(typeof(IServiceContainer));
     if (service != null)
     {
         this.delegateFilterService = (ITypeDescriptorFilterService) this.GetService(typeof(ITypeDescriptorFilterService));
         if (this.delegateFilterService != null)
         {
             service.RemoveService(typeof(ITypeDescriptorFilterService));
         }
         service.AddService(typeof(ITypeDescriptorFilterService), this);
     }
 }
        /// <include file='doc\TabOrder.uex' path='docs/doc[@for="TabOrder.Dispose"]/*' />
        /// <devdoc>
        ///     Called when it is time for the tab order UI to go away.
        /// </devdoc>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (region != null)
                {
                    region.Dispose();
                    region = null;
                }

                if (host != null)
                {
                    IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));
                    if (os != null)
                    {
                        os.RemoveOverlay(this);
                    }

                    IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));
                    if (ehs != null)
                    {
                        ehs.PopHandler(this);
                    }

                    IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));
                    if (mcs != null)
                    {
                        foreach (MenuCommand mc in newCommands)
                        {
                            mcs.RemoveCommand(mc);
                        }
                    }

                    ISelectionUIService seluisvc = (ISelectionUIService)host.GetService(typeof(ISelectionUIService));
                    if (seluisvc != null)
                    {
                        seluisvc.Visible = true;
                    }

                    // We sync add, remove and change events so we remain in sync with any nastiness that the
                    // form may pull on us.
                    //
                    IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));
                    if (cs != null)
                    {
                        cs.ComponentAdded   -= new ComponentEventHandler(this.OnComponentAddRemove);
                        cs.ComponentRemoved -= new ComponentEventHandler(this.OnComponentAddRemove);
                        cs.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
                    }

                    IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));
                    if (hs != null)
                    {
                        hs.RemoveContextAttribute("Keyword", "TabOrderView");
                    }

                    host = null;
                }
            }
            base.Dispose(disposing);
        }
Exemple #10
0
 [Import] public IpScanner(IEventHandlerService eventHandlerService)
 {
     _eventHandlerService = eventHandlerService;
     FoundServers         = new ReadOnlyObservableCollection <string>(_foundServers);
 }
 protected override void Dispose(bool disposing)
 {
     if (disposing && (this.controls != null))
     {
         IExtenderProviderService service = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService));
         bool enabled = System.ComponentModel.CompModSwitches.CommonDesignerServices.Enabled;
         if (service != null)
         {
             service.RemoveExtenderProvider(this);
         }
         IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
         if ((this.eventHandlerService != null) && (host != null))
         {
             host.RemoveService(typeof(IEventHandlerService));
             this.eventHandlerService = null;
         }
         IComponentChangeService service2 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
         if (service2 != null)
         {
             service2.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
         }
         TypeDescriptor.Refreshed -= new RefreshEventHandler(this.OnComponentRefresh);
         SystemEvents.DisplaySettingsChanged -= new EventHandler(this.OnSystemSettingChanged);
         SystemEvents.InstalledFontsChanged -= new EventHandler(this.OnSystemSettingChanged);
         SystemEvents.UserPreferenceChanged -= new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);
         IMenuCommandService menuService = this.MenuService;
         if (menuService != null)
         {
             menuService.RemoveCommand(this.menucmdArrangeIcons);
             menuService.RemoveCommand(this.menucmdLineupIcons);
             menuService.RemoveCommand(this.menucmdLargeIcons);
         }
         if (this.privateCommandSet != null)
         {
             this.privateCommandSet.Dispose();
             if (host != null)
             {
                 host.RemoveService(typeof(ISelectionUIService));
             }
         }
         this.selectionUISvc = null;
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.Dispose();
             this.inheritanceUI = null;
         }
         this.serviceProvider = null;
         this.controls.Clear();
         this.controls = null;
         if (this.glyphManager != null)
         {
             this.glyphManager.Dispose();
             this.glyphManager = null;
         }
     }
     base.Dispose(disposing);
 }
Exemple #12
0
        /// <include file='doc\CompositionDesigner.uex' path='docs/doc[@for="ComponentDocumentDesigner.Initialize"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Initializes the designer with the specified component.</para>
        /// </devdoc>
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            inheritanceService = new InheritanceService();

            ISite      site      = component.Site;
            IContainer container = null;

            IDesignerHost            host = (IDesignerHost)GetService(typeof(IDesignerHost));
            IExtenderProviderService exps = (IExtenderProviderService)GetService(typeof(IExtenderProviderService));

            if (exps != null)
            {
                designerExtenders = new DesignerExtenders(exps);
            }

            Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || host != null, "IDesignerHost not found");
            if (host != null)
            {
                eventHandlerService = new EventHandlerService(null);
                selectionUIService  = new SelectionUIService(host);

                host.AddService(typeof(IInheritanceService), inheritanceService);
                host.AddService(typeof(IEventHandlerService), eventHandlerService);
                host.AddService(typeof(ISelectionUIService), selectionUIService);

                compositionUI = new CompositionUI(this, site);

                host.AddService(typeof(ComponentTray), compositionUI);

                IComponentChangeService cs = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                Debug.Assert(!CompModSwitches.CommonDesignerServices.Enabled || cs != null, "IComponentChangeService not found");
                if (cs != null)
                {
                    cs.ComponentAdded   += new ComponentEventHandler(OnComponentAdded);
                    cs.ComponentRemoved += new ComponentEventHandler(OnComponentRemoved);
                }

                // Select this component.
                //
                ISelectionService ss = (ISelectionService)GetService(typeof(ISelectionService));
                if (ss != null)
                {
                    ss.SetSelectedComponents(new object[] { component }, SelectionTypes.Normal);
                }
            }

            // Set up our menu command set
            //
            if (site != null)
            {
                commandSet = new CompositionCommandSet(compositionUI, site);
                container  = site.Container;
            }

            this.pbrsFwd = new PbrsForward(compositionUI, site);

            // Hook up our inheritance service and do a scan for inherited components.
            //
            inheritanceService.AddInheritedComponents(component, container);

            // Hook yourself up to the ITypeDescriptorFilterService so we can hide the
            // location property on all components being added to the designer.
            //
            IServiceContainer serviceContainer = (IServiceContainer)GetService(typeof(IServiceContainer));

            if (serviceContainer != null)
            {
                delegateFilterService = (ITypeDescriptorFilterService)GetService(typeof(ITypeDescriptorFilterService));
                if (delegateFilterService != null)
                {
                    serviceContainer.RemoveService(typeof(ITypeDescriptorFilterService));
                }

                serviceContainer.AddService(typeof(ITypeDescriptorFilterService), this);
            }
        }
Exemple #13
0
        /// <summary>
        ///  Creates a new tab order control that displays the tab order
        ///  UI for a form.
        /// </summary>
        public TabOrder(IDesignerHost host)
        {
            this.host = host;

            // Determine a font for us to use.
            //
            IUIService uisvc = (IUIService)host.GetService(typeof(IUIService));

            if (uisvc != null)
            {
                tabFont = (Font)uisvc.Styles["DialogFont"];
            }
            else
            {
                tabFont = DefaultFont;
            }

            tabFont = new Font(tabFont, FontStyle.Bold);

            // And compute the proper highlight dimensions.
            //
            selSize = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;

            // Colors and brushes...
            //
            drawString         = new StringBuilder(12);
            highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            highlightPen       = new Pen(SystemColors.Highlight);

            // The decimal separator
            //
            NumberFormatInfo formatInfo = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (formatInfo != null)
            {
                decimalSep = formatInfo.NumberDecimalSeparator;
            }
            else
            {
                decimalSep = ".";
            }

            tabProperties = new Hashtable();

            // Set up a NULL brush so we never try to invalidate the control.  This is
            // more efficient for what we're doing
            //
            SetStyle(ControlStyles.Opaque, true);

            // We're an overlay on top of the form
            //
            IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));

            Debug.Assert(os != null, "No overlay service -- tab order UI cannot be shown");
            if (os != null)
            {
                os.PushOverlay(this);
            }

            // Push a help keyword so the help system knows we're in place.
            //
            IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));

            if (hs != null)
            {
                hs.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }

            commands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyCancel),
                                MenuCommands.KeyCancel),

                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyDefaultAction),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveUp),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveDown),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveLeft),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveRight),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeySelectNext),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeySelectPrevious),
            };

            newCommands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyTabOrderSelect),
            };

            IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (mcs != null)
            {
                foreach (MenuCommand mc in newCommands)
                {
                    mcs.AddCommand(mc);
                }
            }

            // We also override keyboard, menu and mouse handlers.  Our override relies on the
            // above array of menu commands, so this must come after we initialize the array.
            //
            IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (ehs != null)
            {
                ehs.PushHandler(this);
            }

            // We sync add, remove and change events so we remain in sync with any nastiness that the
            // form may pull on us.
            //
            IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (cs != null)
            {
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
            }
        }
 private bool MouseHandlerPresent(ToolStripItem item)
 {
     IMouseHandler handler = null;
     if (this.eventSvc == null)
     {
         this.eventSvc = (IEventHandlerService) item.Site.GetService(typeof(IEventHandlerService));
     }
     if (this.eventSvc != null)
     {
         handler = (IMouseHandler) this.eventSvc.GetHandler(typeof(IMouseHandler));
     }
     return (handler != null);
 }
 public FintEventHandler(IEventHandlerService eventHandlerService)
 {
     _eventHandlerService = eventHandlerService;
 }
Exemple #16
0
 /// <summary>
 /// Constructeur.
 /// </summary>
 /// <param name="repositoryService">Service de gestion des sources de données.</param>
 /// <param name="eventHandlerService">Service de gestion des intercepteurs d'évènements.</param>
 public EventService(IRepositoryService repositoryService, IEventHandlerService eventHandlerService)
 {
     this.repositoryService   = repositoryService;
     this.eventHandlerService = eventHandlerService;
 }
Exemple #17
0
 public RepositoryService(TeclynApi teclyn, IIocContainer iocContainer, IEventHandlerService eventHandlerService)
 {
     this.teclyn              = teclyn;
     this.iocContainer        = iocContainer;
     this.eventHandlerService = eventHandlerService;
 }
        public TabOrder(IDesignerHost host)
        {
            this.host = host;
            IUIService service = (IUIService)host.GetService(typeof(IUIService));

            if (service != null)
            {
                this.tabFont = (Font)service.Styles["DialogFont"];
            }
            else
            {
                this.tabFont = Control.DefaultFont;
            }
            this.tabFont            = new Font(this.tabFont, FontStyle.Bold);
            this.selSize            = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;
            this.drawString         = new StringBuilder(12);
            this.highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            this.highlightPen       = new Pen(SystemColors.Highlight);
            NumberFormatInfo format = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (format != null)
            {
                this.decimalSep = format.NumberDecimalSeparator;
            }
            else
            {
                this.decimalSep = ".";
            }
            this.tabProperties = new Hashtable();
            base.SetStyle(ControlStyles.Opaque, true);
            IOverlayService service2 = (IOverlayService)host.GetService(typeof(IOverlayService));

            if (service2 != null)
            {
                service2.PushOverlay(this);
            }
            IHelpService service3 = (IHelpService)host.GetService(typeof(IHelpService));

            if (service3 != null)
            {
                service3.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }
            this.commands    = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveUp), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveDown), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveLeft), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveRight), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeySelectNext), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeySelectPrevious) };
            this.newCommands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyTabOrderSelect) };
            IMenuCommandService service4 = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (service4 != null)
            {
                foreach (MenuCommand command in this.newCommands)
                {
                    service4.AddCommand(command);
                }
            }
            IEventHandlerService service5 = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (service5 != null)
            {
                service5.PushHandler(this);
            }
            IComponentChangeService service6 = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (service6 != null)
            {
                service6.ComponentAdded   += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentRemoved += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
        }
 public CommandSetItem(CommandSet commandSet, EventHandler statusHandler, EventHandler invokeHandler, CommandID id, bool optimizeStatus, IUIService uiService)
     : base(invokeHandler, id)
 {
     this.uiService = uiService;
     this.eventService = commandSet.eventService;
     this.statusHandler = statusHandler;
     if (optimizeStatus && (statusHandler != null))
     {
         this.commandSet = commandSet;
         lock (typeof(CommandSet.CommandSetItem))
         {
             if (commandStatusHash == null)
             {
                 commandStatusHash = new Hashtable();
             }
         }
         StatusState state = commandStatusHash[statusHandler] as StatusState;
         if (state == null)
         {
             state = new StatusState();
             commandStatusHash.Add(statusHandler, state);
         }
         state.refCount++;
     }
 }
Exemple #20
0
 public EventService(IDependencyResolver dependencyResolver, ITeclynApi teclynApi, ITeclynContext teclynContext, ITimeService timeService, IEventHandlerService eventHandlerService)
 {
     this._dependencyResolver  = dependencyResolver;
     this._teclynApi           = teclynApi;
     this._teclynContext       = teclynContext;
     this._timeService         = timeService;
     this._eventHandlerService = eventHandlerService;
 }
Exemple #21
0
 public EventService(ITeclynContext teclynContext, TimeService timeService, RepositoryService repositoryService, IEventHandlerService eventHandlerService)
 {
     this.teclynContext       = teclynContext;
     this.timeService         = timeService;
     this.repositoryService   = repositoryService;
     this.eventHandlerService = eventHandlerService;
 }
 public ComponentTray(IDesigner mainDesigner, IServiceProvider serviceProvider)
 {
     this.AutoScroll = true;
     this.mainDesigner = mainDesigner;
     this.serviceProvider = serviceProvider;
     this.AllowDrop = true;
     this.Text = "ComponentTray";
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true);
     this.controls = new ArrayList();
     IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     IExtenderProviderService service = (IExtenderProviderService) this.GetService(typeof(IExtenderProviderService));
     if (service != null)
     {
         service.AddExtenderProvider(this);
     }
     if ((this.GetService(typeof(IEventHandlerService)) == null) && (host != null))
     {
         this.eventHandlerService = new EventHandlerService(this);
         host.AddService(typeof(IEventHandlerService), this.eventHandlerService);
     }
     IMenuCommandService menuService = this.MenuService;
     if (menuService != null)
     {
         this.menucmdArrangeIcons = new MenuCommand(new EventHandler(this.OnMenuArrangeIcons), StandardCommands.ArrangeIcons);
         this.menucmdLineupIcons = new MenuCommand(new EventHandler(this.OnMenuLineupIcons), StandardCommands.LineupIcons);
         this.menucmdLargeIcons = new MenuCommand(new EventHandler(this.OnMenuShowLargeIcons), StandardCommands.ShowLargeIcons);
         this.menucmdArrangeIcons.Checked = this.AutoArrange;
         this.menucmdLargeIcons.Checked = this.ShowLargeIcons;
         menuService.AddCommand(this.menucmdArrangeIcons);
         menuService.AddCommand(this.menucmdLineupIcons);
         menuService.AddCommand(this.menucmdLargeIcons);
     }
     IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
     if (service3 != null)
     {
         service3.ComponentRemoved += new ComponentEventHandler(this.OnComponentRemoved);
     }
     IUIService service4 = this.GetService(typeof(IUIService)) as IUIService;
     if (service4 != null)
     {
         System.Drawing.Color info;
         if (service4.Styles["ArtboardBackground"] is System.Drawing.Color)
         {
             info = (System.Drawing.Color) service4.Styles["ArtboardBackground"];
         }
         else if (service4.Styles["VsColorDesignerTray"] is System.Drawing.Color)
         {
             info = (System.Drawing.Color) service4.Styles["VsColorDesignerTray"];
         }
         else if (service4.Styles["HighlightColor"] is System.Drawing.Color)
         {
             info = (System.Drawing.Color) service4.Styles["HighlightColor"];
         }
         else
         {
             info = SystemColors.Info;
         }
         if (service4.Styles["VsColorPanelText"] is System.Drawing.Color)
         {
             this.ForeColor = (System.Drawing.Color) service4.Styles["VsColorPanelText"];
         }
         this.BackColor = info;
         this.Font = (Font) service4.Styles["DialogFont"];
     }
     ISelectionService selSvc = (ISelectionService) this.GetService(typeof(ISelectionService));
     if (selSvc != null)
     {
         selSvc.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     SystemEvents.DisplaySettingsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.InstalledFontsChanged += new EventHandler(this.OnSystemSettingChanged);
     SystemEvents.UserPreferenceChanged += new UserPreferenceChangedEventHandler(this.OnUserPreferenceChanged);
     TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnComponentRefresh);
     BehaviorService behaviorSvc = this.GetService(typeof(BehaviorService)) as BehaviorService;
     if (behaviorSvc != null)
     {
         this.glyphManager = new ComponentTrayGlyphManager(selSvc, behaviorSvc);
     }
 }
        public ObservableCollectionNotifier(IEventHandlerService eventHandlerService)
        {
            _eventHandlerService = eventHandlerService ?? NotifyHelper.EventHandlerService;

            H.Initialize(this);
        }