/// <summary> /// Corrects the object's size and sizing point if the size becomes negative. /// </summary> /// <param name="e">Current mouse state.</param> /// <para>Typically you don't need to use or override this method.</para> /// <para>This method is called by the FastReport designer to check if the object's size becomes negative /// when resizing the object by the mouse. Method must correct the object's size and/or position to /// make it positive, also change the sizing point if needed.</para> public virtual void CheckNegativeSize(FRMouseEventArgs e) { if (Width < 0 && Height < 0) { e.SizingPoint = SizingPointHelper.SwapDiagonally(e.SizingPoint); Bounds = new RectangleF(Right, Bottom, -Width, -Height); } else if (Width < 0) { e.SizingPoint = SizingPointHelper.SwapHorizontally(e.SizingPoint); Bounds = new RectangleF(Right, Top, -Width, Height); } else if (Height < 0) { e.SizingPoint = SizingPointHelper.SwapVertically(e.SizingPoint); Bounds = new RectangleF(Left, Bottom, Width, -Height); } else { return; } Cursor.Current = SizingPointHelper.ToCursor(e.SizingPoint); }
/// <summary> /// Handles MouseMove event that occurs when the user moves the mouse in the designer. /// </summary> /// <remarks> /// <para>This method is called when the user moves the mouse in the designer. The /// standard implementation does the following:</para> /// <list type="bullet"> /// <item> /// if mouse button is not pressed, check that mouse pointer is inside one of /// the selection points returned by the <see cref="GetSelectionPoints"/> /// method and set the <b>e.SizingPoint</b> member to the corresponding sizing /// point; /// </item> /// <item>if mouse button is pressed, and <b>e.SizingPoint</b> member is not /// <b>SizingPoint.None</b>, resize the object.</item> /// </list> /// </remarks> /// <param name="e">Current mouse state.</param> public virtual void HandleMouseMove(FRMouseEventArgs e) { if (!IsSelected) { return; } if (e.Button == MouseButtons.None) { PointF point = new PointF(e.X, e.Y); e.SizingPoint = SizingPoint.None; SelectionPoint[] selectionPoints = GetSelectionPoints(); foreach (SelectionPoint pt in selectionPoints) { if (PointInSelectionPoint(pt.X, pt.Y, point)) { e.SizingPoint = pt.SizingPoint; break; } } if (e.SizingPoint != SizingPoint.None) { e.Handled = true; e.Mode = WorkspaceMode2.Size; e.Cursor = SizingPointHelper.ToCursor(e.SizingPoint); } } else if (!IsParentSelected) { if (e.Mode == WorkspaceMode2.Move) { Left += e.Delta.X; Top += e.Delta.Y; } else if (e.Mode == WorkspaceMode2.Size) { switch (e.SizingPoint) { case SizingPoint.LeftTop: Left += e.Delta.X; Width -= e.Delta.X; Top += e.Delta.Y; Height -= e.Delta.Y; break; case SizingPoint.LeftBottom: Left += e.Delta.X; Width -= e.Delta.X; Height += e.Delta.Y; break; case SizingPoint.RightTop: Width += e.Delta.X; Top += e.Delta.Y; Height -= e.Delta.Y; break; case SizingPoint.RightBottom: Width += e.Delta.X; Height += e.Delta.Y; break; case SizingPoint.TopCenter: Top += e.Delta.Y; Height -= e.Delta.Y; break; case SizingPoint.BottomCenter: Height += e.Delta.Y; break; case SizingPoint.LeftCenter: Left += e.Delta.X; Width -= e.Delta.X; break; case SizingPoint.RightCenter: Width += e.Delta.X; break; } CheckNegativeSize(e); } CheckParent(false); } }