protected override void OnMouseDown(MouseEventArgs e) { base.OnMouseDown(e); if (e.Button == MouseButtons.Left) { resizeType = ResizeMouseAt(e); if (resizeType != DNDResizeType.None) { _resizeDelta = MousePosition; _resizeOriginal = Size; _resizePosition = PointToScreen(Point.Zero); } else { // Move then. if (Movable) { if (e.Location.Y < HeaderHeight) { _windowMoveDelta = e.Location; _windowMove = true; } } } } }
public DNDResizeType ResizeMouseAt(MouseEventArgs e) { DNDResizeType r_type = DNDResizeType.None; if (Resizable) { if (ResizeIcon == false) { // Resize. r_type = DNDResizeType.None; // Left side. if (e.X < _resizeOffset) { r_type = DNDResizeType.Left; if (e.Y < _resizeOffset) { r_type = DNDResizeType.LeftUp; } else if (e.Y > Height - _resizeOffset) { r_type = DNDResizeType.LeftDown; } } else if (e.X > Width - _resizeOffset) { // Right side. r_type = DNDResizeType.Right; if (e.Y < _resizeOffset) { r_type = DNDResizeType.RightUp; } else if (e.Y > Height - _resizeOffset) { r_type = DNDResizeType.RightDown; } } else if (e.Y < _resizeOffset) { r_type = DNDResizeType.Up; } else if (e.Y > Height - _resizeOffset) { r_type = DNDResizeType.Down; } } else { var resizeIcon = ApplicationBehaviour.Resources.Images.FormResize; if (resizeIcon != null) { if (new Rectangle(Width - resizeIcon.width - 4, Height - resizeIcon.height - 4, resizeIcon.width + 4, resizeIcon.height + 4).Contains(e.Location)) { r_type = DNDResizeType.RightDown; } } } } return(r_type); }
public void SetResize(DNDResizeType resize) { resizeType = resize; _resizeDelta = MousePosition; _resizeOriginal = Size; _resizePosition = PointToScreen(Point.Zero); }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (_windowMove) { Location = PointToScreen(e.Location) - _windowMoveDelta; } else { _resizeShow = ResizeMouseAt(e); } }
private void _Application_UpClick(object sender, MouseEventArgs e) { _windowMove = false; resizeType = DNDResizeType.None; }