Free cookie consent management tool by TermsFeed Policy Generator

source: tags/3.3.2/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Styling/CursorPalette.cs @ 13398

Last change on this file since 13398 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 7.0 KB
Line 
1using System.IO;
2using System.Reflection;
3using System.Windows.Forms;
4namespace Netron.Diagramming.Core {
5  /// <summary>
6  /// Pallet of cursors
7  /// <remarks>
8  /// You can define your own cursors or change the existing ones by dropping a cursor file in the Resources directory
9  /// and set the compile flag to 'embedded resource'.
10  /// </remarks>
11  /// </summary>
12  public static class CursorPalette {
13    #region Fields
14    /// <summary>
15    /// The root namespace.
16    /// </summary>
17    private const string NameSpace = "Netron.Diagramming.Core";
18
19
20    static Cursor myDrawRectangle = GetCursor("DrawRectangle.cur");
21    static Cursor myDrawEllipse = GetCursor("DrawEllipse.cur");
22    static Cursor myPan = GetCursor("Pan.cur");
23
24    /// <summary>
25    /// the grip cursor
26    /// </summary>
27    private static Cursor mGrip = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Grip.cur"));
28    /// <summary>
29    /// the add cursor
30    /// </summary>
31    private static Cursor mAdd = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Add.cur"));
32    /// <summary>
33    /// the cross cursor
34    /// </summary>
35    private static Cursor mCross = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Cross.cur"));
36    /// <summary>
37    /// the move cursor
38    /// </summary>
39    private static Cursor mMove = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Move.cur"));
40    /// <summary>
41    /// the selection cursor
42    /// </summary>
43    private static Cursor mSelection = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Selection.cur"));
44    /// <summary>
45    /// the select cursor
46    /// </summary>
47    private static Cursor mSelect = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.Select.cur"));
48    /// <summary>
49    /// the drop text cursor
50    /// </summary>
51    private static Cursor mDropText = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropText.cur"));
52    /// <summary>
53    /// the drop shape cursor
54    /// </summary>
55    private static Cursor mDropShape = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropShape.cur"));
56    /// <summary>
57    /// the drop image cursor
58    /// </summary>
59    private static Cursor mDropImage = new Cursor(Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpace + ".Resources.DropImage.cur"));
60
61
62    #endregion
63
64    #region Properties
65
66    // ------------------------------------------------------------------
67    /// <summary>
68    /// Gets the cursor used when drawing a rectangle.
69    /// </summary>
70    // ------------------------------------------------------------------
71    public static Cursor DrawRectangle {
72      get {
73        return myDrawRectangle;
74      }
75    }
76
77    // ------------------------------------------------------------------
78    /// <summary>
79    /// Gets the cursor used when drawing an ellipse.
80    /// </summary>
81    // ------------------------------------------------------------------
82    public static Cursor DrawEllipse {
83      get {
84        return myDrawEllipse;
85      }
86    }
87
88    /// <summary>
89    /// Gets the drop-image cursor to reflect the creation of a new image-shape by dragdrop onto the canvas.
90    /// </summary>
91    /// <value>The drop-image cursor.</value>
92    public static Cursor DropImage {
93      get {
94        return mDropImage;
95      }
96    }
97    /// <summary>
98    /// Gets the drop-text cursor to reflect the creation of a new text-shape by dragdrop onto the canvas.
99    /// </summary>
100    /// <value>The drop-text cursor.</value>
101    public static Cursor DropText {
102      get {
103        return mDropText;
104      }
105    }
106    /// <summary>
107    /// Gets the drop-shape cursor to reflect the creation of a new shape by dragdrop onto the canvas.
108    /// </summary>
109    /// <value>The drop-shape cursor.</value>
110    public static Cursor DropShape {
111      get {
112        return mDropShape;
113      }
114    }
115    /// <summary>
116    /// Gets the grip cursor to reflect the creation of a (new) connection .
117    /// </summary>
118    /// <value>The grip.</value>
119    public static Cursor Grip {
120      get {
121        return mGrip;
122      }
123    }
124    /// <summary>
125    /// Gets the add to reflect the creation of a (new) drawing shape.
126    /// </summary>
127    /// <value>The add.</value>
128    public static Cursor Add {
129      get {
130        return mAdd;
131      }
132    }
133
134    /// <summary>
135    /// Gets the cross cursor.
136    /// </summary>
137    /// <value>The cross.</value>
138    public static Cursor Cross {
139      get {
140        return mCross;
141      }
142    }
143
144    /// <summary>
145    /// Gets the move cursor to reflect the motion of a selection over the canvas.
146    /// </summary>
147    /// <value>The move.</value>
148    public static Cursor Move {
149      get {
150        return mMove;
151      }
152    }
153
154    /// <summary>
155    /// Gets the pan cursor to reflect the action of panning canvas.
156    /// </summary>
157    /// <value>The move.</value>
158    public static Cursor Pan {
159      get {
160        return myPan;
161      }
162    }
163
164    /// <summary>
165    /// Gets the selection cursor to reflect the process of selection shapes by dragging over the canvas.
166    /// </summary>
167    /// <value>The selection.</value>
168    public static Cursor Selection {
169      get {
170        return mSelection;
171      }
172    }
173
174    /// <summary>
175    /// Gets the select cursor to reflect to motion and selection of a single connector (<see cref="ConnectorMoverTool"/>).
176    /// </summary>
177    /// <value>The select.</value>
178    public static Cursor Select {
179      get {
180        return mSelect;
181      }
182    }
183    #endregion
184
185    #region Methods
186
187    // ------------------------------------------------------------------
188    /// <summary>
189    /// Gets the image from the embedded resources for the specified
190    /// filename.
191    /// </summary>
192    /// <param name="filename">string: The filename from the embedded
193    /// resources.</param>
194    /// <returns>Image</returns>
195    // ------------------------------------------------------------------
196    static Cursor GetCursor(string filename) {
197      return new Cursor(GetStream(filename));
198    }
199
200    // ------------------------------------------------------------------
201    /// <summary>
202    /// Returns a Stream from the manifest resources for the specified
203    /// filename.
204    /// </summary>
205    /// <param name="filename">string</param>
206    /// <returns>Stream</returns>
207    // ------------------------------------------------------------------
208    public static Stream GetStream(string filename) {
209      return Assembly.GetExecutingAssembly().GetManifestResourceStream(
210          NameSpace +
211          ".Resources." +
212          filename);
213    }
214
215
216    #endregion
217
218  }
219}
Note: See TracBrowser for help on using the repository browser.