using System.IO;
using System.Reflection;
using System.Windows.Forms;
namespace Netron.Diagramming.Core {
///
/// Pallet of cursors
///
/// You can define your own cursors or change the existing ones by dropping a cursor file in the Resources directory
/// and set the compile flag to 'embedded resource'.
///
///
public static class CursorPalette {
#region Fields
///
/// The root namespace.
///
private const string NameSpace = "Netron.Diagramming.Core";
static Cursor myDrawRectangle = GetCursor("DrawRectangle.cur");
static Cursor myDrawEllipse = GetCursor("DrawEllipse.cur");
static Cursor myPan = GetCursor("Pan.cur");
///
/// the grip cursor
///
private static Cursor mGrip = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Grip.cur"));
///
/// the add cursor
///
private static Cursor mAdd = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Add.cur"));
///
/// the cross cursor
///
private static Cursor mCross = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Cross.cur"));
///
/// the move cursor
///
private static Cursor mMove = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Move.cur"));
///
/// the selection cursor
///
private static Cursor mSelection = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Selection.cur"));
///
/// the select cursor
///
private static Cursor mSelect = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Select.cur"));
///
/// the drop text cursor
///
private static Cursor mDropText = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropText.cur"));
///
/// the drop shape cursor
///
private static Cursor mDropShape = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropShape.cur"));
///
/// the drop image cursor
///
private static Cursor mDropImage = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropImage.cur"));
#endregion
#region Properties
// ------------------------------------------------------------------
///
/// Gets the cursor used when drawing a rectangle.
///
// ------------------------------------------------------------------
public static Cursor DrawRectangle {
get {
return myDrawRectangle;
}
}
// ------------------------------------------------------------------
///
/// Gets the cursor used when drawing an ellipse.
///
// ------------------------------------------------------------------
public static Cursor DrawEllipse {
get {
return myDrawEllipse;
}
}
///
/// Gets the drop-image cursor to reflect the creation of a new image-shape by dragdrop onto the canvas.
///
/// The drop-image cursor.
public static Cursor DropImage {
get {
return mDropImage;
}
}
///
/// Gets the drop-text cursor to reflect the creation of a new text-shape by dragdrop onto the canvas.
///
/// The drop-text cursor.
public static Cursor DropText {
get {
return mDropText;
}
}
///
/// Gets the drop-shape cursor to reflect the creation of a new shape by dragdrop onto the canvas.
///
/// The drop-shape cursor.
public static Cursor DropShape {
get {
return mDropShape;
}
}
///
/// Gets the grip cursor to reflect the creation of a (new) connection .
///
/// The grip.
public static Cursor Grip {
get {
return mGrip;
}
}
///
/// Gets the add to reflect the creation of a (new) drawing shape.
///
/// The add.
public static Cursor Add {
get {
return mAdd;
}
}
///
/// Gets the cross cursor.
///
/// The cross.
public static Cursor Cross {
get {
return mCross;
}
}
///
/// Gets the move cursor to reflect the motion of a selection over the canvas.
///
/// The move.
public static Cursor Move {
get {
return mMove;
}
}
///
/// Gets the pan cursor to reflect the action of panning canvas.
///
/// The move.
public static Cursor Pan {
get {
return myPan;
}
}
///
/// Gets the selection cursor to reflect the process of selection shapes by dragging over the canvas.
///
/// The selection.
public static Cursor Selection {
get {
return mSelection;
}
}
///
/// Gets the select cursor to reflect to motion and selection of a single connector ().
///
/// The select.
public static Cursor Select {
get {
return mSelect;
}
}
#endregion
#region Methods
// ------------------------------------------------------------------
///
/// Gets the image from the embedded resources for the specified
/// filename.
///
/// string: The filename from the embedded
/// resources.
/// Image
// ------------------------------------------------------------------
static Cursor GetCursor(string filename) {
return new Cursor(GetStream(filename));
}
// ------------------------------------------------------------------
///
/// Returns a Stream from the manifest resources for the specified
/// filename.
///
/// string
/// Stream
// ------------------------------------------------------------------
public static Stream GetStream(string filename) {
return Assembly.GetExecutingAssembly().GetManifestResourceStream(
NameSpace +
".Resources." +
filename);
}
#endregion
}
}