protected override void OnLoad(EventArgs e) { ISnapManagerHost owner = base.Owner as ISnapManagerHost; if (owner != null) { owner.SnapManager.AddSnapObstacle(this); } base.OnLoad(e); }
protected override void OnLoad(EventArgs e) { ISnapManagerHost smh = this.Owner as ISnapManagerHost; if (smh != null) { smh.SnapManager.AddSnapObstacle(this); } base.OnLoad(e); }
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); } } }
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); } } }
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); }
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); }
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); }