protected override bool GetHitTest(Point point)
 {
     ListView component = (ListView) base.Component;
     if (component.View == System.Windows.Forms.View.Details)
     {
         Point point2 = this.Control.PointToClient(point);
         IntPtr handle = component.Handle;
         IntPtr ptr2 = System.Design.NativeMethods.ChildWindowFromPointEx(handle, point2.X, point2.Y, 1);
         if ((ptr2 != IntPtr.Zero) && (ptr2 != handle))
         {
             IntPtr hWndTo = System.Design.NativeMethods.SendMessage(handle, 0x101f, IntPtr.Zero, IntPtr.Zero);
             if (ptr2 == hWndTo)
             {
                 System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
                     x = point.X,
                     y = point.Y
                 };
                 System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, hWndTo, pt, 1);
                 this.hdrhit.pt_x = pt.x;
                 this.hdrhit.pt_y = pt.y;
                 System.Design.NativeMethods.SendMessage(hWndTo, 0x1206, IntPtr.Zero, this.hdrhit);
                 if (this.hdrhit.flags == 4)
                 {
                     return true;
                 }
             }
         }
     }
     return false;
 }
        protected override bool GetHitTest(Point point)
        {
            ListView component = (ListView)base.Component;

            if (component.View == System.Windows.Forms.View.Details)
            {
                Point  point2 = this.Control.PointToClient(point);
                IntPtr handle = component.Handle;
                IntPtr ptr2   = System.Design.NativeMethods.ChildWindowFromPointEx(handle, point2.X, point2.Y, 1);
                if ((ptr2 != IntPtr.Zero) && (ptr2 != handle))
                {
                    IntPtr hWndTo = System.Design.NativeMethods.SendMessage(handle, 0x101f, IntPtr.Zero, IntPtr.Zero);
                    if (ptr2 == hWndTo)
                    {
                        System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
                            x = point.X,
                            y = point.Y
                        };
                        System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, hWndTo, pt, 1);
                        this.hdrhit.pt_x = pt.x;
                        this.hdrhit.pt_y = pt.y;
                        System.Design.NativeMethods.SendMessage(hWndTo, 0x1206, IntPtr.Zero, this.hdrhit);
                        if (this.hdrhit.flags == 4)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
 public Point ControlToAdornerWindow(Control c)
 {
     if (c.Parent == null)
     {
         return Point.Empty;
     }
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
         x = c.Left,
         y = c.Top
     };
     System.Design.NativeMethods.MapWindowPoints(c.Parent.Handle, this.toolStripAdornerWindow.Handle, pt, 1);
     return new Point(pt.x, pt.y);
 }
Exemplo n.º 4
0
 public Point ControlToAdornerWindow(Control c)
 {
     if (c.Parent == null)
     {
         return(Point.Empty);
     }
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
         x = c.Left,
         y = c.Top
     };
     System.Design.NativeMethods.MapWindowPoints(c.Parent.Handle, this.toolStripAdornerWindow.Handle, pt, 1);
     return(new Point(pt.x, pt.y));
 }
 protected override void OnMouseDragEnd(bool cancel)
 {
     if (this.mouseDragBase == ControlDesigner.InvalidPoint)
     {
         base.OnMouseDragEnd(cancel);
     }
     else
     {
         Rectangle mouseDragOffset = this.mouseDragOffset;
         ToolboxItem mouseDragTool = this.mouseDragTool;
         Point mouseDragBase = this.mouseDragBase;
         this.mouseDragOffset = Rectangle.Empty;
         this.mouseDragBase = ControlDesigner.InvalidPoint;
         this.mouseDragTool = null;
         this.Control.Capture = false;
         Cursor.Clip = Rectangle.Empty;
         if (!mouseDragOffset.IsEmpty && (this.graphics != null))
         {
             Rectangle rect = new Rectangle(mouseDragOffset.X - this.adornerWindowToScreenOffset.X, mouseDragOffset.Y - this.adornerWindowToScreenOffset.Y, mouseDragOffset.Width, mouseDragOffset.Height);
             int num = FrameWidth(this.mouseDragFrame);
             this.graphics.SetClip(rect);
             using (Region region = new Region(rect))
             {
                 region.Exclude(Rectangle.Inflate(rect, -num, -num));
                 base.BehaviorService.Invalidate(region);
             }
             this.graphics.ResetClip();
         }
         if (this.graphics != null)
         {
             this.graphics.Dispose();
             this.graphics = null;
         }
         if (this.dragManager != null)
         {
             this.dragManager.OnMouseUp();
             this.dragManager = null;
         }
         IEventHandlerService service = (IEventHandlerService) this.GetService(typeof(IEventHandlerService));
         if ((service != null) && (this.escapeHandler != null))
         {
             service.PopHandler(this.escapeHandler);
             this.escapeHandler = null;
         }
         if ((this.statusCommandUI != null) && !mouseDragOffset.IsEmpty)
         {
             System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(mouseDragBase.X, mouseDragBase.Y);
             System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, this.Control.Handle, pt, 1);
             if (this.statusCommandUI != null)
             {
                 this.statusCommandUI.SetStatusInformation(new Rectangle(pt.x, pt.y, mouseDragOffset.Width, mouseDragOffset.Height));
             }
         }
         if (mouseDragOffset.IsEmpty && !cancel)
         {
             if (mouseDragTool != null)
             {
                 try
                 {
                     this.CreateTool(mouseDragTool, mouseDragBase);
                     if (this.toolboxService != null)
                     {
                         this.toolboxService.SelectedToolboxItemUsed();
                     }
                 }
                 catch (Exception exception)
                 {
                     if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                     {
                         throw;
                     }
                     base.DisplayError(exception);
                 }
             }
         }
         else if (!cancel)
         {
             if (mouseDragTool != null)
             {
                 try
                 {
                     Size size = new Size(DesignerUtils.MinDragSize.Width * 2, DesignerUtils.MinDragSize.Height * 2);
                     if (mouseDragOffset.Width < size.Width)
                     {
                         mouseDragOffset.Width = size.Width;
                     }
                     if (mouseDragOffset.Height < size.Height)
                     {
                         mouseDragOffset.Height = size.Height;
                     }
                     this.CreateTool(mouseDragTool, mouseDragOffset);
                     if (this.toolboxService != null)
                     {
                         this.toolboxService.SelectedToolboxItemUsed();
                     }
                     return;
                 }
                 catch (Exception exception2)
                 {
                     if (System.Windows.Forms.ClientUtils.IsCriticalException(exception2))
                     {
                         throw;
                     }
                     base.DisplayError(exception2);
                     return;
                 }
             }
             ISelectionService service2 = null;
             service2 = (ISelectionService) this.GetService(typeof(ISelectionService));
             if (service2 != null)
             {
                 object[] components = this.GetComponentsInRect(mouseDragOffset, true, false);
                 if (components.Length > 0)
                 {
                     service2.SetSelectedComponents(components);
                 }
             }
         }
     }
 }
 protected override void OnMouseDragMove(int x, int y)
 {
     if ((this.toolboxItemSnapLineBehavior != null) && this.toolboxItemSnapLineBehavior.IsPushed)
     {
         base.BehaviorService.PopBehavior(this.toolboxItemSnapLineBehavior);
         this.toolboxItemSnapLineBehavior.IsPushed = false;
     }
     if (!this.GetOleDragHandler().Dragging && (this.mouseDragBase != ControlDesigner.InvalidPoint))
     {
         Rectangle mouseDragOffset = this.mouseDragOffset;
         this.mouseDragOffset.X = this.mouseDragBase.X;
         this.mouseDragOffset.Y = this.mouseDragBase.Y;
         this.mouseDragOffset.Width = x - this.mouseDragBase.X;
         this.mouseDragOffset.Height = y - this.mouseDragBase.Y;
         if (((this.dragManager == null) && this.ParticipatesWithSnapLines) && ((this.mouseDragTool != null) && base.BehaviorService.UseSnapLines))
         {
             this.dragManager = new DragAssistanceManager(base.Component.Site);
         }
         if (this.dragManager != null)
         {
             Rectangle dragBounds = new Rectangle(this.mouseDragBase.X - this.adornerWindowToScreenOffset.X, this.mouseDragBase.Y - this.adornerWindowToScreenOffset.Y, x - this.mouseDragBase.X, y - this.mouseDragBase.Y);
             Point point = this.dragManager.OnMouseMove(dragBounds, this.GenerateNewToolSnapLines(dragBounds));
             this.mouseDragOffset.Width += point.X;
             this.mouseDragOffset.Height += point.Y;
             this.dragManager.RenderSnapLinesInternal();
         }
         if (this.mouseDragOffset.Width < 0)
         {
             this.mouseDragOffset.X += this.mouseDragOffset.Width;
             this.mouseDragOffset.Width = -this.mouseDragOffset.Width;
         }
         if (this.mouseDragOffset.Height < 0)
         {
             this.mouseDragOffset.Y += this.mouseDragOffset.Height;
             this.mouseDragOffset.Height = -this.mouseDragOffset.Height;
         }
         if (this.mouseDragTool != null)
         {
             this.mouseDragOffset = this.Control.RectangleToClient(this.mouseDragOffset);
             this.mouseDragOffset = this.GetUpdatedRect(Rectangle.Empty, this.mouseDragOffset, true);
             this.mouseDragOffset = this.Control.RectangleToScreen(this.mouseDragOffset);
         }
         if (this.graphics == null)
         {
             this.graphics = base.BehaviorService.AdornerWindowGraphics;
         }
         if (!this.mouseDragOffset.IsEmpty && (this.graphics != null))
         {
             Rectangle rect = new Rectangle(this.mouseDragOffset.X - this.adornerWindowToScreenOffset.X, this.mouseDragOffset.Y - this.adornerWindowToScreenOffset.Y, this.mouseDragOffset.Width, this.mouseDragOffset.Height);
             using (Region region = new Region(rect))
             {
                 int num = FrameWidth(this.mouseDragFrame);
                 region.Exclude(Rectangle.Inflate(rect, -num, -num));
                 if (!mouseDragOffset.IsEmpty)
                 {
                     mouseDragOffset.X -= this.adornerWindowToScreenOffset.X;
                     mouseDragOffset.Y -= this.adornerWindowToScreenOffset.Y;
                     using (Region region2 = new Region(mouseDragOffset))
                     {
                         region2.Exclude(Rectangle.Inflate(mouseDragOffset, -num, -num));
                         base.BehaviorService.Invalidate(region2);
                     }
                 }
                 DesignerUtils.DrawFrame(this.graphics, region, this.mouseDragFrame, this.Control.BackColor);
             }
         }
         if (this.statusCommandUI != null)
         {
             System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(this.mouseDragOffset.X, this.mouseDragOffset.Y);
             System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, this.Control.Handle, pt, 1);
             if (this.statusCommandUI != null)
             {
                 this.statusCommandUI.SetStatusInformation(new Rectangle(pt.x, pt.y, this.mouseDragOffset.Width, this.mouseDragOffset.Height));
             }
         }
     }
 }
 public Point AdornerWindowPointToScreen(Point p)
 {
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(p.X, p.Y);
     System.Design.NativeMethods.MapWindowPoints(this.toolStripAdornerWindow.Handle, IntPtr.Zero, pt, 1);
     return new Point(pt.x, pt.y);
 }
 protected override void WndProc(ref Message m)
 {
     if (m.Msg == BehaviorService.WM_GETALLSNAPLINES)
     {
         this.behaviorService.TestHook_GetAllSnapLines(ref m);
     }
     else if (m.Msg == BehaviorService.WM_GETRECENTSNAPLINES)
     {
         this.behaviorService.TestHook_GetRecentSnapLines(ref m);
     }
     int msg = m.Msg;
     if (msg != 15)
     {
         if (msg != 0x84)
         {
             if (msg == 0x215)
             {
                 base.WndProc(ref m);
                 this.behaviorService.OnLoseCapture();
                 return;
             }
             base.WndProc(ref m);
             return;
         }
     }
     else
     {
         IntPtr hrgn = System.Design.NativeMethods.CreateRectRgn(0, 0, 0, 0);
         System.Design.NativeMethods.GetUpdateRgn(m.HWnd, hrgn, true);
         System.Design.NativeMethods.RECT rc = new System.Design.NativeMethods.RECT();
         System.Design.NativeMethods.GetUpdateRect(m.HWnd, ref rc, true);
         Rectangle clipRect = new Rectangle(rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top);
         try
         {
             using (Region region = Region.FromHrgn(hrgn))
             {
                 this.DefWndProc(ref m);
                 using (Graphics graphics = Graphics.FromHwnd(m.HWnd))
                 {
                     using (PaintEventArgs args = new PaintEventArgs(graphics, clipRect))
                     {
                         graphics.Clip = region;
                         this.behaviorService.PropagatePaint(args);
                     }
                     return;
                 }
             }
         }
         finally
         {
             System.Design.NativeMethods.DeleteObject(hrgn);
         }
     }
     Point pt = new Point((short) System.Design.NativeMethods.Util.LOWORD((int) ((long) m.LParam)), (short) System.Design.NativeMethods.Util.HIWORD((int) ((long) m.LParam)));
     System.Design.NativeMethods.POINT point2 = new System.Design.NativeMethods.POINT {
         x = 0,
         y = 0
     };
     System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, base.Handle, point2, 1);
     pt.Offset(point2.x, point2.y);
     if (this.behaviorService.PropagateHitTest(pt) && !this.ProcessingDrag)
     {
         m.Result = (IntPtr) (-1);
     }
     else
     {
         m.Result = (IntPtr) 1;
     }
 }
Exemplo n.º 9
0
 public Point AdornerWindowPointToScreen(Point p)
 {
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(p.X, p.Y);
     System.Design.NativeMethods.MapWindowPoints(this.toolStripAdornerWindow.Handle, IntPtr.Zero, pt, 1);
     return(new Point(pt.x, pt.y));
 }
 public virtual int ShowContextMenu(int dwID, System.Design.NativeMethods.POINT pt, object pcmdtReserved, object pdispReserved)
 {
     return(0);
 }
 internal Point GetOffsetToClientArea()
 {
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(0, 0);
     System.Design.NativeMethods.MapWindowPoints(this.Control.Handle, this.Control.Parent.Handle, pt, 1);
     Point location = this.Control.Location;
     if (this.Control.IsMirrored != this.Control.Parent.IsMirrored)
     {
         location.Offset(this.Control.Width, 0);
     }
     return new Point(Math.Abs((int) (pt.x - location.X)), pt.y - location.Y);
 }
 public static extern int ClientToScreen(HandleRef hWnd, [In, Out] System.Design.NativeMethods.POINT pt);
Exemplo n.º 13
0
        public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
        {
            if (!this.pushedBehavior)
            {
                return(false);
            }
            bool flag = Control.ModifierKeys == Keys.Alt;

            if (flag && (this.dragManager != null))
            {
                this.dragManager.EraseSnapLines();
            }
            if (flag || !mouseLoc.Equals(this.lastMouseLoc))
            {
                if (this.lastMouseAbs != null)
                {
                    System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y);
                    System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), pt);
                    if ((pt.x == this.lastMouseAbs.x) && (pt.y == this.lastMouseAbs.y))
                    {
                        return(true);
                    }
                }
                if (!this.dragging)
                {
                    if ((Math.Abs((int)(this.initialPoint.X - mouseLoc.X)) <= (DesignerUtils.MinDragSize.Width / 2)) && (Math.Abs((int)(this.initialPoint.Y - mouseLoc.Y)) <= (DesignerUtils.MinDragSize.Height / 2)))
                    {
                        return(false);
                    }
                    this.InitiateResize();
                    this.dragging = true;
                }
                if ((this.resizeComponents == null) || (this.resizeComponents.Length == 0))
                {
                    return(false);
                }
                PropertyDescriptor descriptor  = null;
                PropertyDescriptor descriptor2 = null;
                PropertyDescriptor descriptor3 = null;
                PropertyDescriptor descriptor4 = null;
                if (this.initialResize)
                {
                    descriptor  = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Width"];
                    descriptor2 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Height"];
                    descriptor3 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Top"];
                    descriptor4 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Left"];
                    if ((descriptor != null) && !typeof(int).IsAssignableFrom(descriptor.PropertyType))
                    {
                        descriptor = null;
                    }
                    if ((descriptor2 != null) && !typeof(int).IsAssignableFrom(descriptor2.PropertyType))
                    {
                        descriptor2 = null;
                    }
                    if ((descriptor3 != null) && !typeof(int).IsAssignableFrom(descriptor3.PropertyType))
                    {
                        descriptor3 = null;
                    }
                    if ((descriptor4 != null) && !typeof(int).IsAssignableFrom(descriptor4.PropertyType))
                    {
                        descriptor4 = null;
                    }
                }
                Control resizeControl = this.resizeComponents[0].resizeControl as Control;
                this.lastMouseLoc = mouseLoc;
                this.lastMouseAbs = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y);
                System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), this.lastMouseAbs);
                int num  = Math.Max(resizeControl.MinimumSize.Height, 10);
                int num2 = Math.Max(resizeControl.MinimumSize.Width, 10);
                if (this.dragManager != null)
                {
                    bool flag2 = true;
                    bool shouldSnapHorizontally = true;
                    if ((((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None)) && (resizeControl.Height == num))
                    {
                        flag2 = false;
                    }
                    else if ((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && (resizeControl.Width == num2))
                    {
                        flag2 = false;
                    }
                    PropertyDescriptor descriptor5 = TypeDescriptor.GetProperties(resizeControl)["IntegralHeight"];
                    if (descriptor5 != null)
                    {
                        object obj2 = descriptor5.GetValue(resizeControl);
                        if ((obj2 is bool) && ((bool)obj2))
                        {
                            shouldSnapHorizontally = false;
                        }
                    }
                    if (!flag && flag2)
                    {
                        this.lastSnapOffset = this.dragManager.OnMouseMove(resizeControl, this.GenerateSnapLines(this.targetResizeRules, mouseLoc), ref this.didSnap, shouldSnapHorizontally);
                    }
                    else
                    {
                        this.dragManager.OnMouseMove(new Rectangle(-100, -100, 0, 0));
                    }
                    mouseLoc.X += this.lastSnapOffset.X;
                    mouseLoc.Y += this.lastSnapOffset.Y;
                }
                Rectangle rectangle = new Rectangle(this.resizeComponents[0].resizeBounds.X, this.resizeComponents[0].resizeBounds.Y, this.resizeComponents[0].resizeBounds.Width, this.resizeComponents[0].resizeBounds.Height);
                if (this.didSnap && (resizeControl.Parent != null))
                {
                    rectangle.Location = this.behaviorService.MapAdornerWindowPoint(resizeControl.Parent.Handle, rectangle.Location);
                    if (resizeControl.Parent.IsMirrored)
                    {
                        rectangle.Offset(-rectangle.Width, 0);
                    }
                }
                Rectangle empty     = Rectangle.Empty;
                Rectangle dragRect  = Rectangle.Empty;
                bool      flag4     = true;
                Color     backColor = (resizeControl.Parent != null) ? resizeControl.Parent.BackColor : Color.Empty;
                for (int i = 0; i < this.resizeComponents.Length; i++)
                {
                    Control   c            = this.resizeComponents[i].resizeControl as Control;
                    Rectangle bounds       = c.Bounds;
                    Rectangle rc           = bounds;
                    Rectangle resizeBounds = this.resizeComponents[i].resizeBounds;
                    Rectangle rect         = this.BehaviorService.ControlRectInAdornerWindow(c);
                    bool      flag5        = true;
                    System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, false, 0);
                    try
                    {
                        bool flag6 = false;
                        if ((c.Parent != null) && c.Parent.IsMirrored)
                        {
                            flag6 = true;
                        }
                        BoundsSpecified none        = BoundsSpecified.None;
                        SelectionRules  resizeRules = this.resizeComponents[i].resizeRules;
                        if (((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.BottomSizeable) != SelectionRules.None))
                        {
                            int num4;
                            if (this.didSnap)
                            {
                                num4 = mouseLoc.Y - rectangle.Bottom;
                            }
                            else
                            {
                                num4 = AdjustPixelsForIntegralHeight(c, mouseLoc.Y - this.initialPoint.Y);
                            }
                            bounds.Height = Math.Max(num, resizeBounds.Height + num4);
                            none         |= BoundsSpecified.Height;
                        }
                        if (((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.TopSizeable) != SelectionRules.None))
                        {
                            int num5;
                            if (this.didSnap)
                            {
                                num5 = rectangle.Y - mouseLoc.Y;
                            }
                            else
                            {
                                num5 = AdjustPixelsForIntegralHeight(c, this.initialPoint.Y - mouseLoc.Y);
                            }
                            none         |= BoundsSpecified.Height;
                            bounds.Height = Math.Max(num, resizeBounds.Height + num5);
                            if ((bounds.Height != num) || ((bounds.Height == num) && (rc.Height != num)))
                            {
                                none    |= BoundsSpecified.Y;
                                bounds.Y = Math.Min((int)(resizeBounds.Bottom - num), (int)(resizeBounds.Y - num5));
                            }
                        }
                        if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && !flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && flag6))
                        {
                            none |= BoundsSpecified.Width;
                            int x = this.initialPoint.X;
                            if (this.didSnap)
                            {
                                x = !flag6 ? rectangle.Right : rectangle.Left;
                            }
                            bounds.Width = Math.Max(num2, resizeBounds.Width + (!flag6 ? (mouseLoc.X - x) : (x - mouseLoc.X)));
                        }
                        if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && !flag6))
                        {
                            none |= BoundsSpecified.Width;
                            int num7 = this.initialPoint.X;
                            if (this.didSnap)
                            {
                                num7 = !flag6 ? rectangle.Left : rectangle.Right;
                            }
                            int num8 = !flag6 ? (num7 - mouseLoc.X) : (mouseLoc.X - num7);
                            bounds.Width = Math.Max(num2, resizeBounds.Width + num8);
                            if ((bounds.Width != num2) || ((bounds.Width == num2) && (rc.Width != num2)))
                            {
                                none    |= BoundsSpecified.X;
                                bounds.X = Math.Min((int)(resizeBounds.Right - num2), (int)(resizeBounds.X - num8));
                            }
                        }
                        if (!this.parentGridSize.IsEmpty)
                        {
                            bounds = this.AdjustToGrid(bounds, this.targetResizeRules);
                        }
                        if ((((none & BoundsSpecified.Width) == BoundsSpecified.Width) && this.dragging) && (this.initialResize && (descriptor != null)))
                        {
                            descriptor.SetValue(this.resizeComponents[i].resizeControl, bounds.Width);
                        }
                        if ((((none & BoundsSpecified.Height) == BoundsSpecified.Height) && this.dragging) && (this.initialResize && (descriptor2 != null)))
                        {
                            descriptor2.SetValue(this.resizeComponents[i].resizeControl, bounds.Height);
                        }
                        if ((((none & BoundsSpecified.X) == BoundsSpecified.X) && this.dragging) && (this.initialResize && (descriptor4 != null)))
                        {
                            descriptor4.SetValue(this.resizeComponents[i].resizeControl, bounds.X);
                        }
                        if ((((none & BoundsSpecified.Y) == BoundsSpecified.Y) && this.dragging) && (this.initialResize && (descriptor3 != null)))
                        {
                            descriptor3.SetValue(this.resizeComponents[i].resizeControl, bounds.Y);
                        }
                        if (this.dragging)
                        {
                            c.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height, none);
                            empty = this.BehaviorService.ControlRectInAdornerWindow(c);
                            if (c.Equals(resizeControl))
                            {
                                dragRect = empty;
                            }
                            if (c.Bounds == rc)
                            {
                                flag5 = false;
                            }
                            if (c.Bounds != bounds)
                            {
                                flag4 = false;
                            }
                        }
                        if ((c == this.primaryControl) && (this.statusCommandUI != null))
                        {
                            this.statusCommandUI.SetStatusInformation(c);
                        }
                    }
                    finally
                    {
                        System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, true, 0);
                        if (flag5)
                        {
                            Control parent = c.Parent;
                            if (parent != null)
                            {
                                c.Invalidate(true);
                                parent.Invalidate(rc, true);
                                parent.Update();
                            }
                            else
                            {
                                c.Refresh();
                            }
                        }
                        if (!empty.IsEmpty)
                        {
                            using (Region region = new Region(empty))
                            {
                                region.Exclude(Rectangle.Inflate(empty, -2, -2));
                                if (flag5)
                                {
                                    using (Region region2 = new Region(rect))
                                    {
                                        region2.Exclude(Rectangle.Inflate(rect, -2, -2));
                                        this.BehaviorService.Invalidate(region2);
                                    }
                                }
                                if (!this.captureLost)
                                {
                                    using (Graphics graphics = this.BehaviorService.AdornerWindowGraphics)
                                    {
                                        if ((this.lastResizeRegion != null) && !this.lastResizeRegion.Equals(region, graphics))
                                        {
                                            this.lastResizeRegion.Exclude(region);
                                            this.BehaviorService.Invalidate(this.lastResizeRegion);
                                            this.lastResizeRegion.Dispose();
                                            this.lastResizeRegion = null;
                                        }
                                        DesignerUtils.DrawResizeBorder(graphics, region, backColor);
                                    }
                                    if (this.lastResizeRegion == null)
                                    {
                                        this.lastResizeRegion = region.Clone();
                                    }
                                }
                            }
                        }
                    }
                }
                if ((flag4 && !flag) && (this.dragManager != null))
                {
                    this.dragManager.RenderSnapLinesInternal(dragRect);
                }
                this.initialResize = false;
            }
            return(true);
        }
 public Point ScreenToAdornerWindow(Point p)
 {
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
         x = p.X,
         y = p.Y
     };
     System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, this.adornerWindow.Handle, pt, 1);
     return new Point(pt.x, pt.y);
 }
 public Point MapAdornerWindowPoint(IntPtr handle, Point pt)
 {
     System.Design.NativeMethods.POINT point = new System.Design.NativeMethods.POINT {
         x = pt.X,
         y = pt.Y
     };
     System.Design.NativeMethods.MapWindowPoints(handle, this.adornerWindow.Handle, point, 1);
     return new Point(point.x, point.y);
 }
 private bool ProcessMouseMessage(IntPtr hWnd, int msg, int x, int y)
 {
     if (!this.processingMessage)
     {
         new NamedPermissionSet("FullTrust").Assert();
         foreach (BehaviorService.AdornerWindow window in BehaviorService.AdornerWindow.AdornerWindowList)
         {
             this.currentAdornerWindow = window;
             IntPtr handle = window.DesignerFrame.Handle;
             if (window.ProcessingDrag || ((hWnd != handle) && System.Design.SafeNativeMethods.IsChild(new HandleRef(this, handle), new HandleRef(this, hWnd))))
             {
                 int num;
                 System.Design.UnsafeNativeMethods.GetWindowThreadProcessId(new HandleRef(null, hWnd), out num);
                 if (num != this.thisProcessID)
                 {
                     return false;
                 }
                 try
                 {
                     this.processingMessage = true;
                     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
                         x = x,
                         y = y
                     };
                     System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, window.Handle, pt, 1);
                     Message m = Message.Create(hWnd, msg, IntPtr.Zero, (IntPtr) MAKELONG(pt.y, pt.x));
                     if (m.Msg == 0x201)
                     {
                         this.lastLButtonDownTimeStamp = System.Design.UnsafeNativeMethods.GetMessageTime();
                     }
                     else if ((m.Msg == 0x203) && (System.Design.UnsafeNativeMethods.GetMessageTime() == this.lastLButtonDownTimeStamp))
                     {
                         return true;
                     }
                     if (!window.WndProcProxy(ref m, pt.x, pt.y))
                     {
                         return true;
                     }
                     break;
                 }
                 finally
                 {
                     this.processingMessage = false;
                 }
             }
         }
     }
     return false;
 }
 protected override void OnDragDrop(DragEventArgs de)
 {
     base.OnDragDrop(de);
     bool flag = false;
     System.Windows.Forms.ToolStrip toolStrip = this.ToolStrip;
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(de.X, de.Y);
     System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, toolStrip.Handle, pt, 1);
     Point point2 = new Point(pt.x, pt.y);
     if (this.ToolStrip.Orientation == Orientation.Horizontal)
     {
         if (this.ToolStrip.RightToLeft == RightToLeft.Yes)
         {
             if (point2.X >= toolStrip.Items[0].Bounds.X)
             {
                 flag = true;
             }
         }
         else if (point2.X <= toolStrip.Items[0].Bounds.X)
         {
             flag = true;
         }
     }
     else if (point2.Y <= toolStrip.Items[0].Bounds.Y)
     {
         flag = true;
     }
     ToolStripItemDataObject data = de.Data as ToolStripItemDataObject;
     if ((data != null) && (data.Owner == toolStrip))
     {
         string str;
         ArrayList dragComponents = data.DragComponents;
         ToolStripItem primarySelection = data.PrimarySelection;
         int index = -1;
         bool flag2 = de.Effect == DragDropEffects.Copy;
         if (dragComponents.Count == 1)
         {
             string componentName = TypeDescriptor.GetComponentName(dragComponents[0]);
             if ((componentName == null) || (componentName.Length == 0))
             {
                 componentName = dragComponents[0].GetType().Name;
             }
             str = System.Design.SR.GetString(flag2 ? "BehaviorServiceCopyControl" : "BehaviorServiceMoveControl", new object[] { componentName });
         }
         else
         {
             str = System.Design.SR.GetString(flag2 ? "BehaviorServiceCopyControls" : "BehaviorServiceMoveControls", new object[] { dragComponents.Count });
         }
         DesignerTransaction transaction = this.host.CreateTransaction(str);
         try
         {
             IComponentChangeService service = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
             if (service != null)
             {
                 service.OnComponentChanging(toolStrip, TypeDescriptor.GetProperties(toolStrip)["Items"]);
             }
             if (flag2)
             {
                 if (primarySelection != null)
                 {
                     index = dragComponents.IndexOf(primarySelection);
                 }
                 if (this.KeyboardHandlingService != null)
                 {
                     this.KeyboardHandlingService.CopyInProgress = true;
                 }
                 dragComponents = DesignerUtils.CopyDragObjects(dragComponents, base.Component.Site) as ArrayList;
                 if (this.KeyboardHandlingService != null)
                 {
                     this.KeyboardHandlingService.CopyInProgress = false;
                 }
                 if (index != -1)
                 {
                     primarySelection = dragComponents[index] as ToolStripItem;
                 }
             }
             if ((de.Effect == DragDropEffects.Move) || flag2)
             {
                 for (int i = 0; i < dragComponents.Count; i++)
                 {
                     if (flag)
                     {
                         toolStrip.Items.Insert(0, dragComponents[i] as ToolStripItem);
                     }
                     else
                     {
                         toolStrip.Items.Add(dragComponents[i] as ToolStripItem);
                     }
                 }
                 ToolStripDropDownItem component = primarySelection as ToolStripDropDownItem;
                 if (component != null)
                 {
                     ToolStripMenuItemDesigner designer = this.host.GetDesigner(component) as ToolStripMenuItemDesigner;
                     if (designer != null)
                     {
                         designer.InitializeDropDown();
                     }
                 }
                 this.SelectionService.SetSelectedComponents(new IComponent[] { primarySelection }, SelectionTypes.Click | SelectionTypes.Replace);
             }
             if (service != null)
             {
                 service.OnComponentChanged(toolStrip, TypeDescriptor.GetProperties(toolStrip)["Items"], null, null);
             }
             if (flag2 && (service != null))
             {
                 service.OnComponentChanging(toolStrip, TypeDescriptor.GetProperties(toolStrip)["Items"]);
                 service.OnComponentChanged(toolStrip, TypeDescriptor.GetProperties(toolStrip)["Items"], null, null);
             }
             base.BehaviorService.SyncSelection();
         }
         catch
         {
             if (transaction != null)
             {
                 transaction.Cancel();
                 transaction = null;
             }
         }
         finally
         {
             if (transaction != null)
             {
                 transaction.Commit();
                 transaction = null;
             }
         }
     }
 }
 protected virtual bool OnKeyCancel(object sender)
 {
     bool flag = false;
     if ((this.BehaviorService != null) && this.BehaviorService.HasCapture)
     {
         this.BehaviorService.OnLoseCapture();
         return true;
     }
     IToolboxService service = (IToolboxService) this.GetService(typeof(IToolboxService));
     if ((service == null) || (service.GetSelectedToolboxItem((IDesignerHost) this.GetService(typeof(IDesignerHost))) == null))
     {
         return flag;
     }
     service.SelectedToolboxItemUsed();
     System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT();
     System.Design.NativeMethods.GetCursorPos(pt);
     IntPtr hWnd = System.Design.NativeMethods.WindowFromPoint(pt.x, pt.y);
     if (hWnd != IntPtr.Zero)
     {
         System.Design.NativeMethods.SendMessage(hWnd, 0x20, hWnd, (IntPtr) 1);
     }
     else
     {
         Cursor.Current = Cursors.Default;
     }
     return true;
 }
        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();
            }
        }
            protected override void WndProc(ref Message m)
            {
                switch (m.Msg)
                {
                    case 0x20:
                        this.OnSetCursor();
                        return;

                    case 0x7b:
                    {
                        int x = System.Design.NativeMethods.Util.SignedLOWORD((int) ((long) m.LParam));
                        int y = System.Design.NativeMethods.Util.SignedHIWORD((int) ((long) m.LParam));
                        if ((x == -1) && (y == -1))
                        {
                            Point mousePosition = Control.MousePosition;
                            x = mousePosition.X;
                            y = mousePosition.Y;
                        }
                        this.OnContextMenu(x, y);
                        return;
                    }
                    case 0x84:
                        if (this.tray.glyphManager != null)
                        {
                            Point p = new Point((short) System.Design.NativeMethods.Util.LOWORD((int) ((long) m.LParam)), (short) System.Design.NativeMethods.Util.HIWORD((int) ((long) m.LParam)));
                            System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT {
                                x = 0,
                                y = 0
                            };
                            System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, base.Handle, pt, 1);
                            p.Offset(pt.x, pt.y);
                            p.Offset(base.Location.X, base.Location.Y);
                            this.tray.glyphManager.GetHitTest(p);
                        }
                        base.WndProc(ref m);
                        return;
                }
                base.WndProc(ref m);
            }
 public override bool OnMouseMove(Glyph g, MouseButtons button, Point mouseLoc)
 {
     if (!this.pushedBehavior)
     {
         return false;
     }
     bool flag = Control.ModifierKeys == Keys.Alt;
     if (flag && (this.dragManager != null))
     {
         this.dragManager.EraseSnapLines();
     }
     if (flag || !mouseLoc.Equals(this.lastMouseLoc))
     {
         if (this.lastMouseAbs != null)
         {
             System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y);
             System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), pt);
             if ((pt.x == this.lastMouseAbs.x) && (pt.y == this.lastMouseAbs.y))
             {
                 return true;
             }
         }
         if (!this.dragging)
         {
             if ((Math.Abs((int) (this.initialPoint.X - mouseLoc.X)) <= (DesignerUtils.MinDragSize.Width / 2)) && (Math.Abs((int) (this.initialPoint.Y - mouseLoc.Y)) <= (DesignerUtils.MinDragSize.Height / 2)))
             {
                 return false;
             }
             this.InitiateResize();
             this.dragging = true;
         }
         if ((this.resizeComponents == null) || (this.resizeComponents.Length == 0))
         {
             return false;
         }
         PropertyDescriptor descriptor = null;
         PropertyDescriptor descriptor2 = null;
         PropertyDescriptor descriptor3 = null;
         PropertyDescriptor descriptor4 = null;
         if (this.initialResize)
         {
             descriptor = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Width"];
             descriptor2 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Height"];
             descriptor3 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Top"];
             descriptor4 = TypeDescriptor.GetProperties(this.resizeComponents[0].resizeControl)["Left"];
             if ((descriptor != null) && !typeof(int).IsAssignableFrom(descriptor.PropertyType))
             {
                 descriptor = null;
             }
             if ((descriptor2 != null) && !typeof(int).IsAssignableFrom(descriptor2.PropertyType))
             {
                 descriptor2 = null;
             }
             if ((descriptor3 != null) && !typeof(int).IsAssignableFrom(descriptor3.PropertyType))
             {
                 descriptor3 = null;
             }
             if ((descriptor4 != null) && !typeof(int).IsAssignableFrom(descriptor4.PropertyType))
             {
                 descriptor4 = null;
             }
         }
         Control resizeControl = this.resizeComponents[0].resizeControl as Control;
         this.lastMouseLoc = mouseLoc;
         this.lastMouseAbs = new System.Design.NativeMethods.POINT(mouseLoc.X, mouseLoc.Y);
         System.Design.UnsafeNativeMethods.ClientToScreen(new HandleRef(this, this.behaviorService.AdornerWindowControl.Handle), this.lastMouseAbs);
         int num = Math.Max(resizeControl.MinimumSize.Height, 10);
         int num2 = Math.Max(resizeControl.MinimumSize.Width, 10);
         if (this.dragManager != null)
         {
             bool flag2 = true;
             bool shouldSnapHorizontally = true;
             if ((((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None)) && (resizeControl.Height == num))
             {
                 flag2 = false;
             }
             else if ((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) || ((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && (resizeControl.Width == num2))
             {
                 flag2 = false;
             }
             PropertyDescriptor descriptor5 = TypeDescriptor.GetProperties(resizeControl)["IntegralHeight"];
             if (descriptor5 != null)
             {
                 object obj2 = descriptor5.GetValue(resizeControl);
                 if ((obj2 is bool) && ((bool) obj2))
                 {
                     shouldSnapHorizontally = false;
                 }
             }
             if (!flag && flag2)
             {
                 this.lastSnapOffset = this.dragManager.OnMouseMove(resizeControl, this.GenerateSnapLines(this.targetResizeRules, mouseLoc), ref this.didSnap, shouldSnapHorizontally);
             }
             else
             {
                 this.dragManager.OnMouseMove(new Rectangle(-100, -100, 0, 0));
             }
             mouseLoc.X += this.lastSnapOffset.X;
             mouseLoc.Y += this.lastSnapOffset.Y;
         }
         Rectangle rectangle = new Rectangle(this.resizeComponents[0].resizeBounds.X, this.resizeComponents[0].resizeBounds.Y, this.resizeComponents[0].resizeBounds.Width, this.resizeComponents[0].resizeBounds.Height);
         if (this.didSnap && (resizeControl.Parent != null))
         {
             rectangle.Location = this.behaviorService.MapAdornerWindowPoint(resizeControl.Parent.Handle, rectangle.Location);
             if (resizeControl.Parent.IsMirrored)
             {
                 rectangle.Offset(-rectangle.Width, 0);
             }
         }
         Rectangle empty = Rectangle.Empty;
         Rectangle dragRect = Rectangle.Empty;
         bool flag4 = true;
         Color backColor = (resizeControl.Parent != null) ? resizeControl.Parent.BackColor : Color.Empty;
         for (int i = 0; i < this.resizeComponents.Length; i++)
         {
             Control c = this.resizeComponents[i].resizeControl as Control;
             Rectangle bounds = c.Bounds;
             Rectangle rc = bounds;
             Rectangle resizeBounds = this.resizeComponents[i].resizeBounds;
             Rectangle rect = this.BehaviorService.ControlRectInAdornerWindow(c);
             bool flag5 = true;
             System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, false, 0);
             try
             {
                 bool flag6 = false;
                 if ((c.Parent != null) && c.Parent.IsMirrored)
                 {
                     flag6 = true;
                 }
                 BoundsSpecified none = BoundsSpecified.None;
                 SelectionRules resizeRules = this.resizeComponents[i].resizeRules;
                 if (((this.targetResizeRules & SelectionRules.BottomSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.BottomSizeable) != SelectionRules.None))
                 {
                     int num4;
                     if (this.didSnap)
                     {
                         num4 = mouseLoc.Y - rectangle.Bottom;
                     }
                     else
                     {
                         num4 = AdjustPixelsForIntegralHeight(c, mouseLoc.Y - this.initialPoint.Y);
                     }
                     bounds.Height = Math.Max(num, resizeBounds.Height + num4);
                     none |= BoundsSpecified.Height;
                 }
                 if (((this.targetResizeRules & SelectionRules.TopSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.TopSizeable) != SelectionRules.None))
                 {
                     int num5;
                     if (this.didSnap)
                     {
                         num5 = rectangle.Y - mouseLoc.Y;
                     }
                     else
                     {
                         num5 = AdjustPixelsForIntegralHeight(c, this.initialPoint.Y - mouseLoc.Y);
                     }
                     none |= BoundsSpecified.Height;
                     bounds.Height = Math.Max(num, resizeBounds.Height + num5);
                     if ((bounds.Height != num) || ((bounds.Height == num) && (rc.Height != num)))
                     {
                         none |= BoundsSpecified.Y;
                         bounds.Y = Math.Min((int) (resizeBounds.Bottom - num), (int) (resizeBounds.Y - num5));
                     }
                 }
                 if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && !flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && flag6))
                 {
                     none |= BoundsSpecified.Width;
                     int x = this.initialPoint.X;
                     if (this.didSnap)
                     {
                         x = !flag6 ? rectangle.Right : rectangle.Left;
                     }
                     bounds.Width = Math.Max(num2, resizeBounds.Width + (!flag6 ? (mouseLoc.X - x) : (x - mouseLoc.X)));
                 }
                 if (((((this.targetResizeRules & SelectionRules.RightSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.RightSizeable) != SelectionRules.None)) && flag6) || ((((this.targetResizeRules & SelectionRules.LeftSizeable) != SelectionRules.None) && ((resizeRules & SelectionRules.LeftSizeable) != SelectionRules.None)) && !flag6))
                 {
                     none |= BoundsSpecified.Width;
                     int num7 = this.initialPoint.X;
                     if (this.didSnap)
                     {
                         num7 = !flag6 ? rectangle.Left : rectangle.Right;
                     }
                     int num8 = !flag6 ? (num7 - mouseLoc.X) : (mouseLoc.X - num7);
                     bounds.Width = Math.Max(num2, resizeBounds.Width + num8);
                     if ((bounds.Width != num2) || ((bounds.Width == num2) && (rc.Width != num2)))
                     {
                         none |= BoundsSpecified.X;
                         bounds.X = Math.Min((int) (resizeBounds.Right - num2), (int) (resizeBounds.X - num8));
                     }
                 }
                 if (!this.parentGridSize.IsEmpty)
                 {
                     bounds = this.AdjustToGrid(bounds, this.targetResizeRules);
                 }
                 if ((((none & BoundsSpecified.Width) == BoundsSpecified.Width) && this.dragging) && (this.initialResize && (descriptor != null)))
                 {
                     descriptor.SetValue(this.resizeComponents[i].resizeControl, bounds.Width);
                 }
                 if ((((none & BoundsSpecified.Height) == BoundsSpecified.Height) && this.dragging) && (this.initialResize && (descriptor2 != null)))
                 {
                     descriptor2.SetValue(this.resizeComponents[i].resizeControl, bounds.Height);
                 }
                 if ((((none & BoundsSpecified.X) == BoundsSpecified.X) && this.dragging) && (this.initialResize && (descriptor4 != null)))
                 {
                     descriptor4.SetValue(this.resizeComponents[i].resizeControl, bounds.X);
                 }
                 if ((((none & BoundsSpecified.Y) == BoundsSpecified.Y) && this.dragging) && (this.initialResize && (descriptor3 != null)))
                 {
                     descriptor3.SetValue(this.resizeComponents[i].resizeControl, bounds.Y);
                 }
                 if (this.dragging)
                 {
                     c.SetBounds(bounds.X, bounds.Y, bounds.Width, bounds.Height, none);
                     empty = this.BehaviorService.ControlRectInAdornerWindow(c);
                     if (c.Equals(resizeControl))
                     {
                         dragRect = empty;
                     }
                     if (c.Bounds == rc)
                     {
                         flag5 = false;
                     }
                     if (c.Bounds != bounds)
                     {
                         flag4 = false;
                     }
                 }
                 if ((c == this.primaryControl) && (this.statusCommandUI != null))
                 {
                     this.statusCommandUI.SetStatusInformation(c);
                 }
             }
             finally
             {
                 System.Design.UnsafeNativeMethods.SendMessage(c.Handle, 11, true, 0);
                 if (flag5)
                 {
                     Control parent = c.Parent;
                     if (parent != null)
                     {
                         c.Invalidate(true);
                         parent.Invalidate(rc, true);
                         parent.Update();
                     }
                     else
                     {
                         c.Refresh();
                     }
                 }
                 if (!empty.IsEmpty)
                 {
                     using (Region region = new Region(empty))
                     {
                         region.Exclude(Rectangle.Inflate(empty, -2, -2));
                         if (flag5)
                         {
                             using (Region region2 = new Region(rect))
                             {
                                 region2.Exclude(Rectangle.Inflate(rect, -2, -2));
                                 this.BehaviorService.Invalidate(region2);
                             }
                         }
                         if (!this.captureLost)
                         {
                             using (Graphics graphics = this.BehaviorService.AdornerWindowGraphics)
                             {
                                 if ((this.lastResizeRegion != null) && !this.lastResizeRegion.Equals(region, graphics))
                                 {
                                     this.lastResizeRegion.Exclude(region);
                                     this.BehaviorService.Invalidate(this.lastResizeRegion);
                                     this.lastResizeRegion.Dispose();
                                     this.lastResizeRegion = null;
                                 }
                                 DesignerUtils.DrawResizeBorder(graphics, region, backColor);
                             }
                             if (this.lastResizeRegion == null)
                             {
                                 this.lastResizeRegion = region.Clone();
                             }
                         }
                     }
                 }
             }
         }
         if ((flag4 && !flag) && (this.dragManager != null))
         {
             this.dragManager.RenderSnapLinesInternal(dragRect);
         }
         this.initialResize = false;
     }
     return true;
 }
 protected override void OnDragOver(DragEventArgs e)
 {
     this.ProcessingDrag = true;
     if (!IsLocalDrag(e))
     {
         this.behaviorService.validDragArgs = e;
         System.Design.NativeMethods.POINT pt = new System.Design.NativeMethods.POINT();
         System.Design.NativeMethods.GetCursorPos(pt);
         System.Design.NativeMethods.MapWindowPoints(IntPtr.Zero, base.Handle, pt, 1);
         Point point2 = new Point(pt.x, pt.y);
         this.behaviorService.PropagateHitTest(point2);
     }
     this.behaviorService.OnDragOver(e);
 }