1 | using System;
|
---|
2 | using System.Drawing;
|
---|
3 | using System.Windows.Forms;
|
---|
4 | namespace Netron.Diagramming.Core {
|
---|
5 | // ----------------------------------------------------------------------
|
---|
6 | /// <summary>
|
---|
7 | /// Interface of the surface or diagram control.
|
---|
8 | /// </summary>
|
---|
9 | // ----------------------------------------------------------------------
|
---|
10 | public interface IDiagramControl {
|
---|
11 | #region Events
|
---|
12 | /// <summary>
|
---|
13 | /// Occurs when a drag-and-drop operation is completed.
|
---|
14 | /// </summary>
|
---|
15 | event DragEventHandler DragDrop;
|
---|
16 | /// <summary>
|
---|
17 | /// Occurs when an object is dragged into the control's bounds.
|
---|
18 | /// </summary>
|
---|
19 | event DragEventHandler DragEnter;
|
---|
20 | /// <summary>
|
---|
21 | /// Occurs when an object is dragged out of the control's bounds.
|
---|
22 | /// </summary>
|
---|
23 | event EventHandler DragLeave;
|
---|
24 | /// <summary>
|
---|
25 | /// Occurs when an object is dragged over the control's bounds.
|
---|
26 | /// </summary>
|
---|
27 | event DragEventHandler DragOver;
|
---|
28 |
|
---|
29 | event GiveFeedbackEventHandler GiveFeedback;
|
---|
30 | /// <summary>
|
---|
31 | /// Occurs when the size of the canvas has changed
|
---|
32 | /// </summary>
|
---|
33 | /// <remarks>
|
---|
34 | /// This event is usually defined already in the Control or ScrollableControl class from which
|
---|
35 | /// the canvas inherits.
|
---|
36 | /// </remarks>
|
---|
37 | event EventHandler SizeChanged;
|
---|
38 | /// <summary>
|
---|
39 | /// Occurs when the mouse is pressed on the canvas
|
---|
40 | /// </summary>
|
---|
41 | /// <remarks>
|
---|
42 | /// This event is usually defined already in the Control or ScrollableControl class from which
|
---|
43 | /// the canvas inherits.
|
---|
44 | /// </remarks>
|
---|
45 | event MouseEventHandler MouseDown;
|
---|
46 | /// <summary>
|
---|
47 | /// Occurs when the mouse is released above the canvas
|
---|
48 | /// </summary>
|
---|
49 | /// <remarks>
|
---|
50 | /// This event is usually defined already in the Control or ScrollableControl class from which
|
---|
51 | /// the canvas inherits.
|
---|
52 | /// </remarks>
|
---|
53 | event MouseEventHandler MouseUp;
|
---|
54 | /// <summary>
|
---|
55 | /// Occurs when the mouse is moved over the canvas
|
---|
56 | /// </summary>
|
---|
57 | /// <remarks>
|
---|
58 | /// This event is usually defined already in the Control or ScrollableControl class from which
|
---|
59 | /// the canvas inherits.
|
---|
60 | /// </remarks>
|
---|
61 | event MouseEventHandler MouseMove;
|
---|
62 | /// <summary>
|
---|
63 | /// Occurs when the mouse pointer rests on the control.
|
---|
64 | /// </summary>
|
---|
65 | event EventHandler MouseHover;
|
---|
66 |
|
---|
67 | event MouseEventHandler MouseWheel;
|
---|
68 | /// <summary>
|
---|
69 | /// Occurs when a key is down
|
---|
70 | /// </summary>
|
---|
71 | event KeyEventHandler KeyDown;
|
---|
72 | /// <summary>
|
---|
73 | /// Occurs when a key is released
|
---|
74 | /// </summary>
|
---|
75 | event KeyEventHandler KeyUp;
|
---|
76 | /// <summary>
|
---|
77 | /// Occurs when a key is pressed
|
---|
78 | /// </summary>
|
---|
79 | event KeyPressEventHandler KeyPress;
|
---|
80 | /// <summary>
|
---|
81 | /// Occurs when a new diagram is started.
|
---|
82 | /// </summary>
|
---|
83 | event EventHandler OnNewDiagram;
|
---|
84 | #endregion
|
---|
85 |
|
---|
86 | #region Properties
|
---|
87 |
|
---|
88 | /// <summary>
|
---|
89 | /// Gets or sets the view.
|
---|
90 | /// </summary>
|
---|
91 | /// <value>The view.</value>
|
---|
92 | IView View {
|
---|
93 | get;
|
---|
94 | set;
|
---|
95 | }
|
---|
96 |
|
---|
97 | /// <summary>
|
---|
98 | /// Gets or sets the controller.
|
---|
99 | /// </summary>
|
---|
100 | /// <value>The controller.</value>
|
---|
101 | IController Controller {
|
---|
102 | get;
|
---|
103 | set;
|
---|
104 |
|
---|
105 | }
|
---|
106 |
|
---|
107 | /// <summary>
|
---|
108 | /// Gets or sets the Document
|
---|
109 | /// </summary>
|
---|
110 | Document Document {
|
---|
111 | get;
|
---|
112 | set;
|
---|
113 | }
|
---|
114 |
|
---|
115 | // ------------------------------------------------------------------
|
---|
116 | /// <summary>
|
---|
117 | /// Gets or sets if all shape's connectors should be shown.
|
---|
118 | /// </summary>
|
---|
119 | // ------------------------------------------------------------------
|
---|
120 | bool ShowConnectors {
|
---|
121 | get;
|
---|
122 | set;
|
---|
123 | }
|
---|
124 |
|
---|
125 | // ------------------------------------------------------------------
|
---|
126 | /// <summary>
|
---|
127 | /// Gets or sets the scroll position.
|
---|
128 | /// </summary>
|
---|
129 | // ------------------------------------------------------------------
|
---|
130 | Point AutoScrollPosition {
|
---|
131 | get;
|
---|
132 | set;
|
---|
133 | }
|
---|
134 |
|
---|
135 | // ------------------------------------------------------------------
|
---|
136 | /// <summary>
|
---|
137 | /// Gets the client rectangle.
|
---|
138 | /// </summary>
|
---|
139 | /// <value>The client rectangle.</value>
|
---|
140 | // ------------------------------------------------------------------
|
---|
141 | Rectangle ClientRectangle {
|
---|
142 | get;
|
---|
143 | }
|
---|
144 |
|
---|
145 | // ------------------------------------------------------------------
|
---|
146 | /// <summary>
|
---|
147 | /// Gets or sets the size of the diagram.
|
---|
148 | /// </summary>
|
---|
149 | /// <value>Size: The height and width.</value>
|
---|
150 | // ------------------------------------------------------------------
|
---|
151 | Size Size {
|
---|
152 | get;
|
---|
153 | set;
|
---|
154 | }
|
---|
155 |
|
---|
156 | // ------------------------------------------------------------------
|
---|
157 | /// <summary>
|
---|
158 | /// Gets or sets the minimum size of the autoscroll.
|
---|
159 | /// </summary>
|
---|
160 | /// <value>Size: The height and width.</value>
|
---|
161 | // ------------------------------------------------------------------
|
---|
162 | Size AutoScrollMinSize {
|
---|
163 | get;
|
---|
164 | set;
|
---|
165 | }
|
---|
166 |
|
---|
167 | #endregion
|
---|
168 |
|
---|
169 | #region Methods
|
---|
170 |
|
---|
171 | // ------------------------------------------------------------------
|
---|
172 | /// <summary>
|
---|
173 | /// Invalidates the specified rectangle.
|
---|
174 | /// </summary>
|
---|
175 | /// <param name="rectangle">The rectangle.</param>
|
---|
176 | // ------------------------------------------------------------------
|
---|
177 | void Invalidate(Rectangle rectangle);
|
---|
178 |
|
---|
179 | // ------------------------------------------------------------------
|
---|
180 | /// <summary>
|
---|
181 | /// Invalidates this instance.
|
---|
182 | /// </summary>
|
---|
183 | // ------------------------------------------------------------------
|
---|
184 | void Invalidate();
|
---|
185 |
|
---|
186 | // ------------------------------------------------------------------
|
---|
187 | /// <summary>
|
---|
188 | /// Focuses this instance.
|
---|
189 | /// </summary>
|
---|
190 | /// <returns></returns>
|
---|
191 | // ------------------------------------------------------------------
|
---|
192 | bool Focus();
|
---|
193 |
|
---|
194 | // ------------------------------------------------------------------
|
---|
195 | /// <summary>
|
---|
196 | /// Displays a PageSetupDialog so the user can specify how each
|
---|
197 | /// page is printed.
|
---|
198 | /// </summary>
|
---|
199 | // ------------------------------------------------------------------
|
---|
200 | void PageSetup();
|
---|
201 |
|
---|
202 | // ------------------------------------------------------------------
|
---|
203 | /// <summary>
|
---|
204 | /// Prints all pages of the diagram.
|
---|
205 | /// </summary>
|
---|
206 | // ------------------------------------------------------------------
|
---|
207 | void Print();
|
---|
208 |
|
---|
209 | // ------------------------------------------------------------------
|
---|
210 | /// <summary>
|
---|
211 | /// Print previews all pages of the diagram.
|
---|
212 | /// </summary>
|
---|
213 | // ------------------------------------------------------------------
|
---|
214 | void PrintPreview();
|
---|
215 |
|
---|
216 | // ------------------------------------------------------------------
|
---|
217 | /// <summary>
|
---|
218 | /// Displays an OpenFileDialog for the user to specify the diagram
|
---|
219 | /// to open.
|
---|
220 | /// </summary>
|
---|
221 | // ------------------------------------------------------------------
|
---|
222 | void Open();
|
---|
223 |
|
---|
224 | // ------------------------------------------------------------------
|
---|
225 | /// <summary>
|
---|
226 | /// Opens the specified path.
|
---|
227 | /// </summary>
|
---|
228 | /// <param name="path">The path.</param>
|
---|
229 | // ------------------------------------------------------------------
|
---|
230 | void Open(string path);
|
---|
231 |
|
---|
232 | // ------------------------------------------------------------------
|
---|
233 | /// <summary>
|
---|
234 | /// If the current filename (FileName property) is empty, the a
|
---|
235 | /// SaveFileDialog is displayed for the user to specify what to save
|
---|
236 | /// the diagram as. Otherwise, the current filename is used to save
|
---|
237 | /// the diagram.
|
---|
238 | /// </summary>
|
---|
239 | // ------------------------------------------------------------------
|
---|
240 | void Save();
|
---|
241 |
|
---|
242 | // ------------------------------------------------------------------
|
---|
243 | /// <summary>
|
---|
244 | /// Displays a SaveFileDialog regardless if there's an existing
|
---|
245 | /// filename so the user can save the diagram to a new location.
|
---|
246 | /// </summary>
|
---|
247 | // ------------------------------------------------------------------
|
---|
248 | void SaveAs();
|
---|
249 |
|
---|
250 | // ------------------------------------------------------------------
|
---|
251 | /// <summary>
|
---|
252 | /// Saves the diagram to the path specified.
|
---|
253 | /// </summary>
|
---|
254 | /// <param name="path">The path.</param>
|
---|
255 | // ------------------------------------------------------------------
|
---|
256 | void SaveAs(string path);
|
---|
257 |
|
---|
258 | // ------------------------------------------------------------------
|
---|
259 | /// <summary>
|
---|
260 | /// Creates a new document.
|
---|
261 | /// </summary>
|
---|
262 | // ------------------------------------------------------------------
|
---|
263 | void NewDocument();
|
---|
264 |
|
---|
265 | // ------------------------------------------------------------------
|
---|
266 | /// <summary>
|
---|
267 | /// Computes the location of the specified screen point into client
|
---|
268 | /// coordinates.
|
---|
269 | /// </summary>
|
---|
270 | /// <param name="p">Point</param>
|
---|
271 | /// <returns>Point</returns>
|
---|
272 | // ------------------------------------------------------------------
|
---|
273 | Point PointToClient(Point p);
|
---|
274 |
|
---|
275 | #endregion
|
---|
276 |
|
---|
277 | }
|
---|
278 | }
|
---|