using System.Windows.Forms;
using System.Drawing;
namespace FastReport.Utils
{
///
/// Specifies the main mode of the designer's workspace.
///
public enum WorkspaceMode1
{
///
/// Specifies selection mode.
///
Select,
///
/// Specifies insertion mode.
///
Insert,
///
/// Specifies drag-drop mode.
///
DragDrop
}
///
/// Specifies the additional mode of the designer's workspace.
///
public enum WorkspaceMode2
{
///
/// Specifies default mode.
///
None,
///
/// Indicates that user moves the selected objects.
///
Move,
///
/// Indicates that user resizes the selected objects.
///
Size,
///
/// Indicates that user draw the selection rectangle.
///
SelectionRect,
///
/// Specifies a custom mode handled by the object.
///
Custom
}
///
/// Provides a data for mouse events.
///
public class FRMouseEventArgs
{
///
/// The X mouse coordinate.
///
public float x;
///
/// The Y mouse coordinate.
///
public float y;
///
/// Current state of mouse buttons.
///
public MouseButtons button;
///
/// Current keyboard state.
///
public Keys modifierKeys;
///
/// Indicates that current object was handled the mouse message.
///
public bool handled;
///
/// The delta of the mouse movement.
///
public PointF delta;
///
/// The mouse wheel delta.
///
public int wheelDelta;
///
/// Current cursor shape.
///
public Cursor cursor;
///
/// Additional mode of the designer's workspace.
///
public WorkspaceMode2 mode;
///
/// Current sizing point if Mode is set to Size.
///
public SizingPoint sizingPoint;
///
/// Current selection rectangle if mode is set to SelectionRect.
///
public RectangleF selectionRect;
///
/// Active object that handles the mouse event.
///
public ComponentBase activeObject;
///
/// The source object of drag-drop operation.
///
public ComponentBase DragSource
{
get
{
if (dragSources != null && dragSources.Length > 0)
return dragSources[dragSources.Length - 1];
return null;
}
set
{
if (value != null)
dragSources = new ComponentBase[] { value };
else
dragSources = null;
}
}
///
/// Multiple sources objects of drag-drop operation.
///
public ComponentBase[] dragSources;
///
/// The target object of drag-drop operation.
///
public ComponentBase dragTarget;
///
/// The message to show when drag source is over the object.
///
public string dragMessage;
///
/// Additional data supplied and handled by report objects.
///
public object data;
}
///
/// Specifies the sizing point used to resize an object by mouse.
///
public enum SizingPoint
{
///
/// No sizing point.
///
None,
///
/// Specifies left-top sizing point.
///
LeftTop,
///
/// Specifies left-bottom sizing point.
///
LeftBottom,
///
/// Specifies right-top sizing point.
///
RightTop,
///
/// Specifies right-bottom sizing point.
///
RightBottom,
///
/// Specifies top-center sizing point.
///
TopCenter,
///
/// Specifies bottom-center sizing point.
///
BottomCenter,
///
/// Specifies left-center sizing point.
///
LeftCenter,
///
/// Specifies right-center sizing point.
///
RightCenter
}
internal static class SizingPointHelper
{
// sizing points and its numbers:
// LeftTop (1) TopCenter (5) RightTop (3)
//
// LeftCenter (7) RightCenter (8)
//
// LeftBottom (2) BottomCenter (6) RightBottom (4)
public static SizingPoint SwapDiagonally(SizingPoint p)
{
int[] swap = new int[] { 0, 4, 3, 2, 1, 5, 6, 7, 8 };
return (SizingPoint)swap[(int)p];
}
public static SizingPoint SwapHorizontally(SizingPoint p)
{
int[] swap = new int[] { 0, 3, 4, 1, 2, 5, 6, 8, 7 };
return (SizingPoint)swap[(int)p];
}
public static SizingPoint SwapVertically(SizingPoint p)
{
int[] swap = new int[] { 0, 2, 1, 4, 3, 6, 5, 7, 8 };
return (SizingPoint)swap[(int)p];
}
public static Cursor ToCursor(SizingPoint p)
{
Cursor[] cursors = new Cursor[] { Cursors.Default, Cursors.SizeNWSE, Cursors.SizeNESW, Cursors.SizeNESW,
Cursors.SizeNWSE, Cursors.SizeNS, Cursors.SizeNS, Cursors.SizeWE, Cursors.SizeWE };
return cursors[(int)p];
}
}
///
/// Specifies a selection point used to resize an object.
///
public class SelectionPoint
{
///
/// The X coordinate of the point.
///
public float x;
///
/// The Y coordinate of the point.
///
public float y;
///
/// The size mode.
///
public SizingPoint sizingPoint;
///
/// Initializes a new instance of the SelectionPoint class with specified location and size mode.
///
/// The X coordinate.
/// The Y coordinate.
/// Size mode.
public SelectionPoint(float x, float y, SizingPoint pt)
{
this.x = x;
this.y = y;
sizingPoint = pt;
}
}
}