1 | using System;
|
---|
2 | using System.Windows.Forms;
|
---|
3 | using System.Drawing;
|
---|
4 | namespace Netron.Diagramming.Core
|
---|
5 | {
|
---|
6 | // ----------------------------------------------------------------------
|
---|
7 | /// <summary>
|
---|
8 | /// Interface of a controller
|
---|
9 | /// </summary>
|
---|
10 | // ----------------------------------------------------------------------
|
---|
11 | public interface IController : IUndoSupport
|
---|
12 | {
|
---|
13 | #region Events
|
---|
14 |
|
---|
15 | // ------------------------------------------------------------------
|
---|
16 | /// <summary>
|
---|
17 | /// Occurs when a page's ambience has changed.
|
---|
18 | /// </summary>
|
---|
19 | // ------------------------------------------------------------------
|
---|
20 | event EventHandler<AmbienceEventArgs> OnAmbienceChanged;
|
---|
21 |
|
---|
22 | // ------------------------------------------------------------------
|
---|
23 | /// <summary>
|
---|
24 | /// Occurs when the undo/redo history has changed
|
---|
25 | /// </summary>
|
---|
26 | // ------------------------------------------------------------------
|
---|
27 | event EventHandler<HistoryChangeEventArgs> OnHistoryChange;
|
---|
28 |
|
---|
29 | // ------------------------------------------------------------------
|
---|
30 | /// <summary>
|
---|
31 | /// Occurs when a tool is activated
|
---|
32 | /// </summary>
|
---|
33 | // ------------------------------------------------------------------
|
---|
34 | event EventHandler<ToolEventArgs> OnToolActivate;
|
---|
35 |
|
---|
36 | // ------------------------------------------------------------------
|
---|
37 | /// <summary>
|
---|
38 | /// Occurs when a tool is deactivated
|
---|
39 | /// </summary>
|
---|
40 | // ------------------------------------------------------------------
|
---|
41 | event EventHandler<ToolEventArgs> OnToolDeactivate;
|
---|
42 |
|
---|
43 | // ------------------------------------------------------------------
|
---|
44 | /// <summary>
|
---|
45 | /// Occurs when the something got selected and the properties of it
|
---|
46 | /// can/should be shown.
|
---|
47 | /// </summary>
|
---|
48 | // ------------------------------------------------------------------
|
---|
49 | event EventHandler<SelectionEventArgs> OnShowSelectionProperties;
|
---|
50 |
|
---|
51 | // ------------------------------------------------------------------
|
---|
52 | /// <summary>
|
---|
53 | /// Occurs when an entity is added.
|
---|
54 | /// <remarks>This event usually is bubbled from one of the
|
---|
55 | /// layers</remarks>
|
---|
56 | /// </summary>
|
---|
57 | // ------------------------------------------------------------------
|
---|
58 | event EventHandler<EntityEventArgs> OnEntityAdded;
|
---|
59 |
|
---|
60 | // ------------------------------------------------------------------
|
---|
61 | /// <summary>
|
---|
62 | /// Occurs when an entity is removed.
|
---|
63 | /// <remarks>This event usually is bubbled from one of the
|
---|
64 | /// layers</remarks>
|
---|
65 | /// </summary>
|
---|
66 | // ------------------------------------------------------------------
|
---|
67 | event EventHandler<EntityEventArgs> OnEntityRemoved;
|
---|
68 |
|
---|
69 | // ------------------------------------------------------------------
|
---|
70 | /// <summary>
|
---|
71 | /// Occurs when the controller receives a mouse-down notification of
|
---|
72 | /// the surface. This event is raised before the event is broadcasted
|
---|
73 | /// down to the tools.
|
---|
74 | /// </summary>
|
---|
75 | // ------------------------------------------------------------------
|
---|
76 | event EventHandler<MouseEventArgs> OnMouseDown;
|
---|
77 |
|
---|
78 | // ------------------------------------------------------------------
|
---|
79 | /// <summary>
|
---|
80 | /// Occurs when the diagram control is aksed to show the context menu
|
---|
81 | /// </summary>
|
---|
82 | // ------------------------------------------------------------------
|
---|
83 | event EventHandler<EntityMenuEventArgs> OnShowContextMenu;
|
---|
84 |
|
---|
85 | #endregion
|
---|
86 |
|
---|
87 | #region Properties
|
---|
88 |
|
---|
89 | // ------------------------------------------------------------------
|
---|
90 | /// <summary>
|
---|
91 | /// Gets or sets the model
|
---|
92 | /// </summary>
|
---|
93 | // ------------------------------------------------------------------
|
---|
94 | IModel Model { get; set;}
|
---|
95 |
|
---|
96 | // ------------------------------------------------------------------
|
---|
97 | /// <summary>
|
---|
98 | /// Gets or sets the view.
|
---|
99 | /// </summary>
|
---|
100 | /// <value>The view.</value>
|
---|
101 | // ------------------------------------------------------------------
|
---|
102 | IView View { get;set;}
|
---|
103 |
|
---|
104 | // ------------------------------------------------------------------
|
---|
105 | /// <summary>
|
---|
106 | /// Gets the currently active tool. This can be 'null'!!!
|
---|
107 | /// </summary>
|
---|
108 | // ------------------------------------------------------------------
|
---|
109 | ITool ActiveTool
|
---|
110 | {
|
---|
111 | get;
|
---|
112 | }
|
---|
113 |
|
---|
114 | // ------------------------------------------------------------------
|
---|
115 | /// <summary>
|
---|
116 | /// Gets the tools.
|
---|
117 | /// </summary>
|
---|
118 | /// <value>The tools.</value>
|
---|
119 | // ------------------------------------------------------------------
|
---|
120 | CollectionBase<ITool> Tools { get;}
|
---|
121 |
|
---|
122 | // ------------------------------------------------------------------
|
---|
123 | /// <summary>
|
---|
124 | /// Gets the undo manager.
|
---|
125 | /// </summary>
|
---|
126 | /// <value>The undo manager.</value>
|
---|
127 | // ------------------------------------------------------------------
|
---|
128 | UndoManager UndoManager { get;}
|
---|
129 |
|
---|
130 | // ------------------------------------------------------------------
|
---|
131 | /// <summary>
|
---|
132 | /// Gets the parent control.
|
---|
133 | /// </summary>
|
---|
134 | /// <value>The parent control.</value>
|
---|
135 | // ------------------------------------------------------------------
|
---|
136 | IDiagramControl ParentControl { get;}
|
---|
137 |
|
---|
138 | // ------------------------------------------------------------------
|
---|
139 | /// <summary>
|
---|
140 | /// Gets or sets a value indicating whether this
|
---|
141 | /// <see cref="T:IController"/> is enabled.
|
---|
142 | /// </summary>
|
---|
143 | /// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
|
---|
144 | // ------------------------------------------------------------------
|
---|
145 | bool Enabled
|
---|
146 | {
|
---|
147 | get;
|
---|
148 | set;
|
---|
149 | }
|
---|
150 |
|
---|
151 | #endregion
|
---|
152 |
|
---|
153 | #region Methods
|
---|
154 |
|
---|
155 | // ------------------------------------------------------------------
|
---|
156 | /// <summary>
|
---|
157 | /// Activates the text editor for the given text provider.
|
---|
158 | /// </summary>
|
---|
159 | /// <param name="textProvider">ITextProvider</param>
|
---|
160 | /// <returns>bool: True if sucessful, false if not.</returns>
|
---|
161 | // ------------------------------------------------------------------
|
---|
162 | bool ActivateTextEditor(ITextProvider textProvider);
|
---|
163 |
|
---|
164 | // ------------------------------------------------------------------
|
---|
165 | /// <summary>
|
---|
166 | /// Activates the tool.
|
---|
167 | /// </summary>
|
---|
168 | /// <param name="toolName">Name of the tool.</param>
|
---|
169 | // ------------------------------------------------------------------
|
---|
170 | void ActivateTool(string toolName);
|
---|
171 |
|
---|
172 | // ------------------------------------------------------------------
|
---|
173 | /// <summary>
|
---|
174 | /// Adds the tool.
|
---|
175 | /// </summary>
|
---|
176 | /// <param name="tool">The tool.</param>
|
---|
177 | // ------------------------------------------------------------------
|
---|
178 | void AddTool(ITool tool);
|
---|
179 |
|
---|
180 | // ------------------------------------------------------------------
|
---|
181 | /// <summary>
|
---|
182 | /// Deactivates the tool.
|
---|
183 | /// </summary>
|
---|
184 | /// <param name="tool">The tool.</param>
|
---|
185 | /// <returns>bool: True if successful.</returns>
|
---|
186 | // ------------------------------------------------------------------
|
---|
187 | bool DeactivateTool(ITool tool);
|
---|
188 |
|
---|
189 | // ------------------------------------------------------------------
|
---|
190 | /// <summary>
|
---|
191 | /// Deactivates all tools.
|
---|
192 | /// </summary>
|
---|
193 | /// <returns>bool: True if successful.</returns>
|
---|
194 | // ------------------------------------------------------------------
|
---|
195 | bool DeactivateAllTools();
|
---|
196 |
|
---|
197 | // ------------------------------------------------------------------
|
---|
198 | /// <summary>
|
---|
199 | /// Raises the OnShowSelectionProperties event.
|
---|
200 | /// </summary>
|
---|
201 | /// <param name="e">The
|
---|
202 | /// <see cref="T:Netron.Diagramming.Core.SelectionEventArgs"/>
|
---|
203 | /// instance containing the event data.</param>
|
---|
204 | // ------------------------------------------------------------------
|
---|
205 | void RaiseOnShowSelectionProperties(SelectionEventArgs e);
|
---|
206 |
|
---|
207 | // ------------------------------------------------------------------
|
---|
208 | /// <summary>
|
---|
209 | /// Suspends all tools
|
---|
210 | /// </summary>
|
---|
211 | // ------------------------------------------------------------------
|
---|
212 | void SuspendAllTools();
|
---|
213 |
|
---|
214 | // ------------------------------------------------------------------
|
---|
215 | /// <summary>
|
---|
216 | /// Unsuspends all tools.
|
---|
217 | /// </summary>
|
---|
218 | // ------------------------------------------------------------------
|
---|
219 | void UnsuspendAllTools();
|
---|
220 |
|
---|
221 | // ------------------------------------------------------------------
|
---|
222 | /// <summary>
|
---|
223 | /// Raises the OnShowContextMenu event
|
---|
224 | /// </summary>
|
---|
225 | /// <param name="e">EntityMenuEventArgs</param>
|
---|
226 | // ------------------------------------------------------------------
|
---|
227 | void RaiseOnShowContextMenu(EntityMenuEventArgs e);
|
---|
228 |
|
---|
229 | // ------------------------------------------------------------------
|
---|
230 | /// <summary>
|
---|
231 | /// Changes the paint style of the selected entities.
|
---|
232 | /// </summary>
|
---|
233 | /// <param name="paintStyle">IPaintStyle</param>
|
---|
234 | // ------------------------------------------------------------------
|
---|
235 | void ChangeStyle(IPaintStyle paintStyle);
|
---|
236 |
|
---|
237 | // ------------------------------------------------------------------
|
---|
238 | /// <summary>
|
---|
239 | /// Changes the pen style of the selected entities.
|
---|
240 | /// </summary>
|
---|
241 | /// <param name="penStyle">IPenStyle</param>
|
---|
242 | // ------------------------------------------------------------------
|
---|
243 | void ChangeStyle(IPenStyle penStyle);
|
---|
244 |
|
---|
245 | // ------------------------------------------------------------------
|
---|
246 | /// <summary>
|
---|
247 | /// Runs the specified activity. If no activity exists with the name
|
---|
248 | /// specified, then an exception is thrown.
|
---|
249 | /// </summary>
|
---|
250 | /// <param name="name">string: The name of the activity to run.</param>
|
---|
251 | // ------------------------------------------------------------------
|
---|
252 | void RunActivity(string name);
|
---|
253 |
|
---|
254 | // ------------------------------------------------------------------
|
---|
255 | /// <summary>
|
---|
256 | /// Selects all entities on the current page. The selection is
|
---|
257 | /// cleared first.
|
---|
258 | /// </summary>
|
---|
259 | // ------------------------------------------------------------------
|
---|
260 | void SelectAll();
|
---|
261 |
|
---|
262 | // ------------------------------------------------------------------
|
---|
263 | /// <summary>
|
---|
264 | /// Navigates to the next page. Nothing is performed if the last page
|
---|
265 | /// is currently selected and 'wrap' is false. If 'wrap' is true,
|
---|
266 | /// then the first page is selected.
|
---|
267 | /// </summary>
|
---|
268 | /// <param name="wrap">bool: Specifies if the collection is wrapped
|
---|
269 | /// when the end is reached.</param>
|
---|
270 | // ------------------------------------------------------------------
|
---|
271 | void GoForward(bool wrap);
|
---|
272 |
|
---|
273 | // ------------------------------------------------------------------
|
---|
274 | /// <summary>
|
---|
275 | /// Navigates to the previous page. Nothing is performed if the first
|
---|
276 | /// page is currently selected and 'wrap' is false. If 'wrap' is
|
---|
277 | /// true, then the last page is selected if the current page is the
|
---|
278 | /// first page.
|
---|
279 | /// </summary>
|
---|
280 | /// <param name="wrap">bool: Specifies if the collection is wrapped
|
---|
281 | /// when the start is reached.</param>
|
---|
282 | // ------------------------------------------------------------------
|
---|
283 | void GoBack(bool wrap);
|
---|
284 |
|
---|
285 | #endregion
|
---|
286 | }
|
---|
287 | }
|
---|