Last change
on this file since 13398 was
4068,
checked in by swagner, 14 years ago
|
Sorted usings and removed unused usings in entire solution (#1094)
|
File size:
1.5 KB
|
Line | |
---|
1 |
|
---|
2 | namespace Netron.Diagramming.Core {
|
---|
3 | public class DeleteTool : AbstractTool {
|
---|
4 | /// <summary>
|
---|
5 | /// Constructor.
|
---|
6 | /// </summary>
|
---|
7 | /// <param name="toolName"></param>
|
---|
8 | public DeleteTool(string toolName)
|
---|
9 | : base(toolName) {
|
---|
10 | }
|
---|
11 |
|
---|
12 | protected override void OnActivateTool() {
|
---|
13 | base.OnActivateTool();
|
---|
14 |
|
---|
15 | DeleteCommand cmd;
|
---|
16 |
|
---|
17 | if (this.Controller.Model.Selection.SelectedItems.Count > 0) {
|
---|
18 | // If any one entity in the selction can't be deleted,
|
---|
19 | // remove it from the selection.
|
---|
20 | for (int i = 0; i < this.Controller.Model.Selection.SelectedItems.Count; i++) {
|
---|
21 | IDiagramEntity entity = this.Controller.Model.Selection.SelectedItems[i];
|
---|
22 | if (entity.AllowDelete == false) {
|
---|
23 | this.Controller.Model.Selection.SelectedItems.Remove(entity);
|
---|
24 | i--;
|
---|
25 | }
|
---|
26 | }
|
---|
27 | cmd = new DeleteCommand(
|
---|
28 | this.Controller,
|
---|
29 | this.Controller.Model.Selection.SelectedItems.Copy());
|
---|
30 | this.Controller.UndoManager.AddUndoCommand(cmd);
|
---|
31 |
|
---|
32 | // Alert each entity that they're about to be deleted.
|
---|
33 | foreach (IDiagramEntity entity in this.Controller.Model.Selection.SelectedItems) {
|
---|
34 | entity.OnBeforeDelete(cmd);
|
---|
35 | }
|
---|
36 |
|
---|
37 | cmd.Redo();
|
---|
38 |
|
---|
39 | // Alert each entity that they have been deleted.
|
---|
40 | foreach (IDiagramEntity entity in this.Controller.Model.Selection.SelectedItems) {
|
---|
41 | entity.OnAfterDelete(cmd);
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | DeactivateTool();
|
---|
46 | }
|
---|
47 | }
|
---|
48 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.