1 | using System;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Drawing.Drawing2D;
|
---|
4 | using System.Windows.Forms;
|
---|
5 | namespace Netron.Diagramming.Core {
|
---|
6 | // ----------------------------------------------------------------------
|
---|
7 | /// <summary>
|
---|
8 | /// The interface of the "View" in the Model - View - Controller
|
---|
9 | /// framework. The drawing of the diagram is handled by the View.
|
---|
10 | /// </summary>
|
---|
11 | // ----------------------------------------------------------------------
|
---|
12 | public interface IView {
|
---|
13 | #region Events
|
---|
14 | /// <summary>
|
---|
15 | /// Occurs when the cursor is changed and the surface is supposed to set the cursor accordingly.
|
---|
16 | /// </summary>
|
---|
17 | event EventHandler<CursorEventArgs> OnCursorChange;
|
---|
18 |
|
---|
19 | event EventHandler<ColorEventArgs> OnBackColorChange;
|
---|
20 | #endregion
|
---|
21 |
|
---|
22 | #region Properties
|
---|
23 |
|
---|
24 | // ------------------------------------------------------------------
|
---|
25 | /// <summary>
|
---|
26 | /// Gets or sets if the grid is to be drawn.
|
---|
27 | /// </summary>
|
---|
28 | // ------------------------------------------------------------------
|
---|
29 | bool ShowGrid {
|
---|
30 | get;
|
---|
31 | set;
|
---|
32 | }
|
---|
33 |
|
---|
34 | // ------------------------------------------------------------------
|
---|
35 | /// <summary>
|
---|
36 | /// Gets or sets if all shape's connectors should be shown.
|
---|
37 | /// </summary>
|
---|
38 | // ------------------------------------------------------------------
|
---|
39 | bool ShowConnectors {
|
---|
40 | get;
|
---|
41 | set;
|
---|
42 | }
|
---|
43 |
|
---|
44 | Rectangle HorizontalRulerBounds { get; }
|
---|
45 | Rectangle VerticalRulerBounds { get; }
|
---|
46 | MeasurementsUnit RulerUnits { get; }
|
---|
47 | /// <summary>
|
---|
48 | /// Get the transformation matrix of the view
|
---|
49 | /// </summary>
|
---|
50 | Matrix ViewMatrix { get; }
|
---|
51 |
|
---|
52 | // ------------------------------------------------------------------
|
---|
53 | /// <summary>
|
---|
54 | /// Gets or sets the current cursor.
|
---|
55 | /// </summary>
|
---|
56 | /// <value>The current cursor.</value>
|
---|
57 | // ------------------------------------------------------------------
|
---|
58 | Cursor CurrentCursor { get; set; }
|
---|
59 |
|
---|
60 | /// <summary>
|
---|
61 | /// Gets the ghost.
|
---|
62 | /// </summary>
|
---|
63 | /// <value>The ghost.</value>
|
---|
64 | IGhost Ghost { get; }
|
---|
65 |
|
---|
66 | /// <summary>
|
---|
67 | /// Gets the ants.
|
---|
68 | /// </summary>
|
---|
69 | /// <value>The ants.</value>
|
---|
70 | IAnts Ants {
|
---|
71 | get;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /// <summary>
|
---|
75 | /// Gets or sets the model.
|
---|
76 | /// </summary>
|
---|
77 | /// <value>The model.</value>
|
---|
78 | IModel Model { get; set; }
|
---|
79 |
|
---|
80 | /// <summary>
|
---|
81 | /// Gets or sets the tracker.
|
---|
82 | /// </summary>
|
---|
83 | /// <value>The tracker.</value>
|
---|
84 | ITracker Tracker { get; set; }
|
---|
85 |
|
---|
86 | /// <summary>
|
---|
87 | /// Scales the diagram.
|
---|
88 | /// </summary>
|
---|
89 | /// <value>The scale.</value>
|
---|
90 | SizeF Magnification { get; set; }
|
---|
91 |
|
---|
92 | /// <summary>
|
---|
93 | /// Pans the view with the given shift.
|
---|
94 | /// </summary>
|
---|
95 | /// <value>The pan.</value>
|
---|
96 | Point Origin { get; set; }
|
---|
97 |
|
---|
98 | /// <summary>
|
---|
99 | /// Gets or sets whether the rulers are visible.
|
---|
100 | /// </summary>
|
---|
101 | bool ShowRulers { get; set; }
|
---|
102 |
|
---|
103 | // ------------------------------------------------------------------
|
---|
104 | /// <summary>
|
---|
105 | /// Gets or sets if the page's title is drawn when 'ShowPage' is set
|
---|
106 | /// to true.
|
---|
107 | /// </summary>
|
---|
108 | // ------------------------------------------------------------------
|
---|
109 | bool ShowPageTitle {
|
---|
110 | get;
|
---|
111 | set;
|
---|
112 | }
|
---|
113 |
|
---|
114 | // ------------------------------------------------------------------
|
---|
115 | /// <summary>
|
---|
116 | /// Gets or sets the size of the page in thousandths of an inch.
|
---|
117 | /// </summary>
|
---|
118 | // ------------------------------------------------------------------
|
---|
119 | Size PageSize {
|
---|
120 | get;
|
---|
121 | set;
|
---|
122 | }
|
---|
123 |
|
---|
124 | // ------------------------------------------------------------------
|
---|
125 | /// <summary>
|
---|
126 | /// Gets or sets if each page is rendered and printed in landscape
|
---|
127 | /// orientation.
|
---|
128 | /// </summary>
|
---|
129 | // ------------------------------------------------------------------
|
---|
130 | bool Landscape {
|
---|
131 | get;
|
---|
132 | set;
|
---|
133 | }
|
---|
134 |
|
---|
135 | /// <summary>
|
---|
136 | /// Gets the graphics object of the surface.
|
---|
137 | /// </summary>
|
---|
138 | /// <value>The graphics.</value>
|
---|
139 | Graphics Graphics {
|
---|
140 | get;
|
---|
141 | }
|
---|
142 |
|
---|
143 | #endregion
|
---|
144 |
|
---|
145 | #region Methods
|
---|
146 |
|
---|
147 | #region View to device
|
---|
148 | Point ViewToDevice(PointF point);
|
---|
149 | Size ViewToDevice(SizeF szView);
|
---|
150 | PointF ViewToDeviceF(PointF ptView);
|
---|
151 | Rectangle ViewToDevice(RectangleF rcView);
|
---|
152 | void ViewToDevice(PointF[] viewPts, out Point[] devicePts);
|
---|
153 | SizeF ViewToDeviceF(SizeF szView);
|
---|
154 | RectangleF ViewToDeviceF(RectangleF rcView);
|
---|
155 | #endregion
|
---|
156 |
|
---|
157 | #region World to view
|
---|
158 | PointF WorldToView(PointF ptWorld);
|
---|
159 | RectangleF WorldToView(RectangleF rectangle);
|
---|
160 | void WorldToView(PointF[] worldPts, out PointF[] viewPts);
|
---|
161 | SizeF WorldToView(SizeF szWorld);
|
---|
162 | #endregion
|
---|
163 |
|
---|
164 | #region Device to view
|
---|
165 | PointF DeviceToView(Point ptDevice);
|
---|
166 | void DeviceToView(Point[] devicePts, out PointF[] viewPts);
|
---|
167 | RectangleF DeviceToView(Rectangle rcDevice);
|
---|
168 | SizeF DeviceToView(Size szDevice);
|
---|
169 | #endregion
|
---|
170 |
|
---|
171 | #region View to world
|
---|
172 | PointF ViewToWorld(PointF ptView);
|
---|
173 | RectangleF ViewToWorld(RectangleF rcView);
|
---|
174 | Rectangle ViewToWorld(Rectangle rcView);
|
---|
175 | SizeF ViewToWorld(SizeF szView);
|
---|
176 | void ViewToWorld(PointF[] viewPts, out PointF[] worldPts);
|
---|
177 | #endregion
|
---|
178 |
|
---|
179 | // ------------------------------------------------------------------
|
---|
180 | /// <summary>
|
---|
181 | /// Sets the magnification and origin of the diagram such that
|
---|
182 | /// all entities in the current page are in view.
|
---|
183 | /// </summary>
|
---|
184 | // ------------------------------------------------------------------
|
---|
185 | void ZoomFit();
|
---|
186 |
|
---|
187 | // ------------------------------------------------------------------
|
---|
188 | /// <summary>
|
---|
189 | /// Zooms the diagram control to the area specified.
|
---|
190 | /// </summary>
|
---|
191 | /// <param name="area">Rectangle: The area to zoom.</param>
|
---|
192 | // ------------------------------------------------------------------
|
---|
193 | void ZoomArea(Rectangle area);
|
---|
194 |
|
---|
195 | // ------------------------------------------------------------------
|
---|
196 | /// <summary>
|
---|
197 | /// Invalidates this instance.
|
---|
198 | /// </summary>
|
---|
199 | // ------------------------------------------------------------------
|
---|
200 | void Invalidate();
|
---|
201 |
|
---|
202 | // ------------------------------------------------------------------
|
---|
203 | /// <summary>
|
---|
204 | /// Invalidates the specified rectangle.
|
---|
205 | /// </summary>
|
---|
206 | /// <param name="rectangle">The rectangle.</param>
|
---|
207 | // ------------------------------------------------------------------
|
---|
208 | void Invalidate(System.Drawing.Rectangle rectangle);
|
---|
209 |
|
---|
210 | // ------------------------------------------------------------------
|
---|
211 | /// <summary>
|
---|
212 | /// Paints the specified g.
|
---|
213 | /// </summary>
|
---|
214 | /// <param name="g">The g.</param>
|
---|
215 | // ------------------------------------------------------------------
|
---|
216 | void Paint(System.Drawing.Graphics g);
|
---|
217 |
|
---|
218 | // ------------------------------------------------------------------
|
---|
219 | /// <summary>
|
---|
220 | /// Paints the background.
|
---|
221 | /// </summary>
|
---|
222 | /// <param name="g">The g.</param>
|
---|
223 | // ------------------------------------------------------------------
|
---|
224 | void PaintBackground(System.Drawing.Graphics g);
|
---|
225 |
|
---|
226 | // ------------------------------------------------------------------
|
---|
227 | /// <summary>
|
---|
228 | /// Sets the type of the background.
|
---|
229 | /// </summary>
|
---|
230 | /// <param name="type">The type.</param>
|
---|
231 | // ------------------------------------------------------------------
|
---|
232 | void SetBackgroundType(CanvasBackgroundTypes type);
|
---|
233 |
|
---|
234 | // ------------------------------------------------------------------
|
---|
235 | /// <summary>
|
---|
236 | /// Resets the ghost.
|
---|
237 | /// </summary>
|
---|
238 | // ------------------------------------------------------------------
|
---|
239 | void ResetGhost();
|
---|
240 |
|
---|
241 | // ------------------------------------------------------------------
|
---|
242 | /// <summary>
|
---|
243 | /// Resets the ants.
|
---|
244 | /// </summary>
|
---|
245 | // ------------------------------------------------------------------
|
---|
246 | void ResetAnts();
|
---|
247 |
|
---|
248 | // ------------------------------------------------------------------
|
---|
249 | /// <summary>
|
---|
250 | /// Resets the tracker. The tracker is the selection frame drawn
|
---|
251 | /// around selected entities and allows then to be moved and/or
|
---|
252 | /// resized.
|
---|
253 | /// </summary>
|
---|
254 | // ------------------------------------------------------------------
|
---|
255 | void ResetTracker();
|
---|
256 |
|
---|
257 | // ------------------------------------------------------------------
|
---|
258 | /// <summary>
|
---|
259 | /// Hides the tracker. The tracker is the selection frame drawn
|
---|
260 | /// around selected entities and allows then to be moved and/or
|
---|
261 | /// resized.
|
---|
262 | /// </summary>
|
---|
263 | // ------------------------------------------------------------------
|
---|
264 | void HideTracker();
|
---|
265 |
|
---|
266 | // ------------------------------------------------------------------
|
---|
267 | /// <summary>
|
---|
268 | /// Paints the ghost rectangle.
|
---|
269 | /// </summary>
|
---|
270 | /// <param name="start">The start.</param>
|
---|
271 | /// <param name="end">The end.</param>
|
---|
272 | // ------------------------------------------------------------------
|
---|
273 | void PaintGhostRectangle(Point start, Point end);
|
---|
274 |
|
---|
275 | // ------------------------------------------------------------------
|
---|
276 | /// <summary>
|
---|
277 | /// Paints a ghost line.
|
---|
278 | /// </summary>
|
---|
279 | /// <param name="start">The start.</param>
|
---|
280 | /// <param name="end">The end.</param>
|
---|
281 | // ------------------------------------------------------------------
|
---|
282 | void PaintGhostLine(Point start, Point end);
|
---|
283 |
|
---|
284 | // ------------------------------------------------------------------
|
---|
285 | /// <summary>
|
---|
286 | /// Paints a ghost multi-line
|
---|
287 | /// </summary>
|
---|
288 | /// <param name="cureveType">Type of the cureve.</param>
|
---|
289 | /// <param name="points">The points.</param>
|
---|
290 | // ------------------------------------------------------------------
|
---|
291 | void PaintGhostLine(MultiPointType cureveType, Point[] points);
|
---|
292 |
|
---|
293 | // ------------------------------------------------------------------
|
---|
294 | /// <summary>
|
---|
295 | /// Paints the ghost ellipse.
|
---|
296 | /// </summary>
|
---|
297 | /// <param name="start">The start.</param>
|
---|
298 | /// <param name="end">The end.</param>
|
---|
299 | // ------------------------------------------------------------------
|
---|
300 | void PaintGhostEllipse(Point start, Point end);
|
---|
301 |
|
---|
302 | // ------------------------------------------------------------------
|
---|
303 | /// <summary>
|
---|
304 | /// Paints the ants rectangle.
|
---|
305 | /// </summary>
|
---|
306 | /// <param name="ltPoint">The lt point.</param>
|
---|
307 | /// <param name="rbPoint">The rb point.</param>
|
---|
308 | // ------------------------------------------------------------------
|
---|
309 | void PaintAntsRectangle(Point ltPoint, Point rbPoint);
|
---|
310 |
|
---|
311 | // ------------------------------------------------------------------
|
---|
312 | /// <summary>
|
---|
313 | /// Paints the tracker.
|
---|
314 | /// </summary>
|
---|
315 | /// <param name="rectangle">The rectangle.</param>
|
---|
316 | /// <param name="showHandles">if set to <c>true</c> shows the
|
---|
317 | /// handles.</param>
|
---|
318 | // ------------------------------------------------------------------
|
---|
319 | void PaintTracker(Rectangle rectangle, bool showHandles);
|
---|
320 |
|
---|
321 | // ------------------------------------------------------------------
|
---|
322 | /// <summary>
|
---|
323 | /// Attaches to model.
|
---|
324 | /// </summary>
|
---|
325 | /// <param name="model">The model.</param>
|
---|
326 | // ------------------------------------------------------------------
|
---|
327 | void AttachToModel(IModel model);
|
---|
328 |
|
---|
329 | // ------------------------------------------------------------------
|
---|
330 | /// <summary>
|
---|
331 | /// Shows the tracker.
|
---|
332 | /// </summary>
|
---|
333 | // ------------------------------------------------------------------
|
---|
334 | void ShowTracker();
|
---|
335 |
|
---|
336 | // ------------------------------------------------------------------
|
---|
337 | /// <summary>
|
---|
338 | /// Suspends the invalidation of the view, which means that the
|
---|
339 | /// Invalidate() method calls from any entity will be discarded until
|
---|
340 | /// Resume() has been called.
|
---|
341 | /// </summary>
|
---|
342 | // ------------------------------------------------------------------
|
---|
343 | void Suspend();
|
---|
344 |
|
---|
345 | // ------------------------------------------------------------------
|
---|
346 | /// <summary>
|
---|
347 | /// Resumes the invalidation of the view.
|
---|
348 | /// </summary>
|
---|
349 | // ------------------------------------------------------------------
|
---|
350 | void Resume();
|
---|
351 |
|
---|
352 | #endregion
|
---|
353 |
|
---|
354 | }
|
---|
355 | }
|
---|