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