using System;
using System.Windows.Forms;
namespace FastReport
{
partial class ReportComponentBase
{
#region Properties
///
/// This event occurs when the user moves the mouse over the object in the preview window.
///
public event MouseEventHandler MouseMove;
///
/// This event occurs when the user releases the mouse button in the preview window.
///
public event MouseEventHandler MouseUp;
///
/// This event occurs when the user clicks the mouse button in the preview window.
///
public event MouseEventHandler MouseDown;
///
/// This event occurs when the mouse enters the object's bounds in the preview window.
///
public event EventHandler MouseEnter;
///
/// This event occurs when the mouse leaves the object's bounds in the preview window.
///
public event EventHandler MouseLeave;
#endregion
#region Public Methods
///
/// Copies event handlers from another similar object.
///
/// The object to copy handlers from.
public virtual void AssignPreviewEvents(Base source)
{
ReportComponentBase src = source as ReportComponentBase;
if (src == null)
return;
Click = src.Click;
MouseMove = src.MouseMove;
MouseUp = src.MouseUp;
MouseDown = src.MouseDown;
MouseEnter = src.MouseEnter;
MouseLeave = src.MouseLeave;
}
internal void ApplyHoverStyle()
{
ApplyStyle(HoverStyle);
}
///
/// This method fires the MouseMove event and the script code connected to the MouseMoveEvent.
///
/// Event data.
public virtual void OnMouseMove(MouseEventArgs e)
{
if (MouseMove != null)
MouseMove(this, e);
InvokeEvent(MouseMoveEvent, e);
}
///
/// This method fires the MouseUp event and the script code connected to the MouseUpEvent.
///
/// Event data.
public virtual void OnMouseUp(MouseEventArgs e)
{
if (MouseUp != null)
MouseUp(this, e);
InvokeEvent(MouseUpEvent, e);
}
///
/// This method fires the MouseDown event and the script code connected to the MouseDownEvent.
///
/// Event data.
public virtual void OnMouseDown(MouseEventArgs e)
{
if (MouseDown != null)
MouseDown(this, e);
InvokeEvent(MouseDownEvent, e);
}
///
/// This method fires the MouseEnter event and the script code connected to the MouseEnterEvent.
///
/// Event data.
public virtual void OnMouseEnter(EventArgs e)
{
if (!String.IsNullOrEmpty(HoverStyle))
{
SaveStyle();
ApplyHoverStyle();
if (Page != null)
Page.Refresh();
}
if (MouseEnter != null)
MouseEnter(this, e);
InvokeEvent(MouseEnterEvent, e);
}
///
/// This method fires the MouseLeave event and the script code connected to the MouseLeaveEvent.
///
/// Event data.
public virtual void OnMouseLeave(EventArgs e)
{
if (!String.IsNullOrEmpty(HoverStyle))
{
RestoreStyle();
if (Page != null)
Page.Refresh();
}
if (MouseLeave != null)
MouseLeave(this, e);
InvokeEvent(MouseLeaveEvent, e);
}
///
/// This method is fired when the user scrolls the mouse in the preview window.
///
/// Event data.
public virtual void OnMouseWheel(MouseEventArgs e)
{
}
///
/// Gets the object's context menu when right-clicked in the preview window.
///
/// Null reference if object does not have a menu.
public virtual ContextMenuStrip GetPreviewContextMenu()
{
return null;
}
#endregion
}
}