Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Utils/Styling/CursorPalette.cs @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

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