示例#1
0
        protected override void OnLoad(EventArgs e)
        {
            ISnapManagerHost owner = base.Owner as ISnapManagerHost;

            if (owner != null)
            {
                owner.SnapManager.AddSnapObstacle(this);
            }
            base.OnLoad(e);
        }
示例#2
0
        protected override void OnLoad(EventArgs e)
        {
            ISnapManagerHost smh = this.Owner as ISnapManagerHost;

            if (smh != null)
            {
                smh.SnapManager.AddSnapObstacle(this);
            }

            base.OnLoad(e);
        }
示例#3
0
 private void UpdateParking()
 {
     if (((base.FormBorderStyle == FormBorderStyle.Fixed3D) || (base.FormBorderStyle == FormBorderStyle.FixedDialog)) || (((base.FormBorderStyle == FormBorderStyle.FixedSingle) || (base.FormBorderStyle == FormBorderStyle.FixedToolWindow)) || (base.FormBorderStyle == FormBorderStyle.SizableToolWindow)))
     {
         ISnapManagerHost owner = base.Owner as ISnapManagerHost;
         if (owner != null)
         {
             owner.SnapManager.ReparkObstacle(this);
         }
     }
 }
示例#4
0
        private void UpdateParking()
        {
            if (this.FormBorderStyle == FormBorderStyle.Fixed3D ||
                this.FormBorderStyle == FormBorderStyle.FixedDialog ||
                this.FormBorderStyle == FormBorderStyle.FixedSingle ||
                this.FormBorderStyle == FormBorderStyle.FixedToolWindow)
            {
                ISnapManagerHost ismh = this.Owner as ISnapManagerHost;

                if (ismh != null)
                {
                    SnapManager mySM = ismh.SnapManager;
                    mySM.ReparkObstacle(this);
                }
            }
        }
示例#5
0
        public static SnapManager FindMySnapManager(Control me)
        {
            if (!(me is ISnapObstacleHost))
            {
                throw new ArgumentException("must be called with a Control that implements ISnapObstacleHost");
            }
            ISnapManagerHost host = me as ISnapManagerHost;

            if (host == null)
            {
                host = me.FindForm() as ISnapManagerHost;
            }
            if (host != null)
            {
                return(host.SnapManager);
            }
            return(null);
        }
示例#6
0
        protected override void OnMoving(MovingEventArgs mea)
        {
            ISnapManagerHost owner = base.Owner as ISnapManagerHost;

            if (owner != null)
            {
                SnapManager snapManager = owner.SnapManager;
                if (!this.isMoving)
                {
                    this.movingCursorDelta = new Size(Cursor.Position.X - mea.Rectangle.X, Cursor.Position.Y - mea.Rectangle.Y);
                    this.isMoving          = true;
                }
                mea.Rectangle = new Rectangle(Cursor.Position.X - this.movingCursorDelta.Width, Cursor.Position.Y - this.movingCursorDelta.Height, mea.Rectangle.Width, mea.Rectangle.Height);
                this.snapObstacle.SetBounds(mea.Rectangle.ToRectInt32());
                PointInt32 newLocation = mea.Rectangle.Location.ToPointInt32();
                PointInt32 location    = snapManager.AdjustObstacleDestination(this.SnapObstacle, newLocation);
                RectInt32  bounds      = new RectInt32(location, mea.Rectangle.Size.ToSizeInt32());
                this.snapObstacle.SetBounds(bounds);
                mea.Rectangle = bounds.ToGdipRectangle();
            }
            base.OnMoving(mea);
        }
示例#7
0
        protected override void OnMoving(MovingEventArgs mea)
        {
            ISnapManagerHost snapHost = this.Owner as ISnapManagerHost;

            if (snapHost != null)
            {
                SnapManager sm = snapHost.SnapManager;

                // Make sure the window titlebar always follows a constant distance from the mouse cursor
                // Otherwise the window may "slip" as it snaps and unsnaps
                if (!this.moving)
                {
                    this.movingCursorDelta = new Size(
                        Cursor.Position.X - mea.Rectangle.X,
                        Cursor.Position.Y - mea.Rectangle.Y);

                    this.moving = true;
                }

                mea.Rectangle = new Rectangle(
                    Cursor.Position.X - this.movingCursorDelta.Width,
                    Cursor.Position.Y - this.movingCursorDelta.Height,
                    mea.Rectangle.Width,
                    mea.Rectangle.Height);

                this.snapObstacle.SetBounds(mea.Rectangle);

                Point     pt      = mea.Rectangle.Location;
                Point     newPt   = sm.AdjustObstacleDestination(this.SnapObstacle, pt);
                Rectangle newRect = new Rectangle(newPt, mea.Rectangle.Size);

                this.snapObstacle.SetBounds(newRect);

                mea.Rectangle = newRect;
            }

            base.OnMoving(mea);
        }