private void MyMouseMove(object sender, MouseEventArgs e) { Control parent = (sender as Control).Parent; if (e.Button == MouseButtons.Left) { switch (this.m_MousePointPosition) { case SteeringControl.EnumMousePointPosition.MouseSizeRight: parent.Width = parent.Width + e.X - this.p1.X; this.p1.X = e.X; this.p1.Y = e.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeLeft: parent.Left = parent.Left + e.X - this.p.X; parent.Width -= e.X - this.p.X; break; case SteeringControl.EnumMousePointPosition.MouseSizeBottom: parent.Height = parent.Height + e.Y - this.p1.Y; this.p1.X = e.X; this.p1.Y = e.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeTop: parent.Top += e.Y - this.p.Y; parent.Height -= e.Y - this.p.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeTopLeft: parent.Left = parent.Left + e.X - this.p.X; parent.Top += e.Y - this.p.Y; parent.Width -= e.X - this.p.X; parent.Height -= e.Y - this.p.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeTopRight: parent.Top += e.Y - this.p.Y; parent.Width += e.X - this.p1.X; parent.Height -= e.Y - this.p.Y; this.p1.X = e.X; this.p1.Y = e.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeBottomLeft: parent.Left = parent.Left + e.X - this.p.X; parent.Width -= e.X - this.p.X; parent.Height = parent.Height + e.Y - this.p1.Y; this.p1.X = e.X; this.p1.Y = e.Y; break; case SteeringControl.EnumMousePointPosition.MouseSizeBottomRight: parent.Width = parent.Width + e.X - this.p1.X; parent.Height = parent.Height + e.Y - this.p1.Y; this.p1.X = e.X; this.p1.Y = e.Y; break; case SteeringControl.EnumMousePointPosition.MouseDrag: parent.Left = parent.Left + e.X - this.p.X; parent.Top = parent.Top + e.Y - this.p.Y; break; } if (parent.Width < 10) { parent.Width = 10; } if (parent.Height < 10) { parent.Height = 10; return; } } else { this.m_MousePointPosition = this.MousePointPosition(parent.Size, e); switch (this.m_MousePointPosition) { case SteeringControl.EnumMousePointPosition.MouseSizeNone: this.Cursor = Cursors.Arrow; return; case SteeringControl.EnumMousePointPosition.MouseSizeRight: this.Cursor = Cursors.SizeWE; return; case SteeringControl.EnumMousePointPosition.MouseSizeLeft: this.Cursor = Cursors.SizeWE; return; case SteeringControl.EnumMousePointPosition.MouseSizeBottom: this.Cursor = Cursors.SizeNS; return; case SteeringControl.EnumMousePointPosition.MouseSizeTop: this.Cursor = Cursors.SizeNS; return; case SteeringControl.EnumMousePointPosition.MouseSizeTopLeft: this.Cursor = Cursors.SizeNWSE; return; case SteeringControl.EnumMousePointPosition.MouseSizeTopRight: this.Cursor = Cursors.SizeNESW; break; case SteeringControl.EnumMousePointPosition.MouseSizeBottomLeft: this.Cursor = Cursors.SizeNESW; return; case SteeringControl.EnumMousePointPosition.MouseSizeBottomRight: this.Cursor = Cursors.SizeNWSE; return; case SteeringControl.EnumMousePointPosition.MouseDrag: this.Cursor = Cursors.SizeAll; return; default: return; } } }
private void MyMouseLeave(object sender, EventArgs e) { this.m_MousePointPosition = SteeringControl.EnumMousePointPosition.MouseSizeNone; this.Cursor = Cursors.Arrow; }