Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/SendToFrontTool.cs @ 16462

Last change on this file since 16462 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 1.6 KB
Line 
1using System.Collections;
2using System.Collections.Generic;
3namespace Netron.Diagramming.Core {
4  /// <summary>
5  /// Group tool
6  /// </summary>
7  class SendToFrontTool : AbstractTool {
8
9    #region Fields
10
11    #endregion
12
13    #region Constructor
14    /// <summary>
15    /// Initializes a new instance of the <see cref="T:SendToFrontTool"/> class.
16    /// </summary>
17    /// <param name="name">The name of the tool.</param>
18    public SendToFrontTool(string name)
19      : base(name) {
20    }
21    #endregion
22
23    #region Methods
24
25    /// <summary>
26    /// Called when the tool is activated.
27    /// </summary>
28    protected override void OnActivateTool() {
29      if (this.Controller.Model.Selection.SelectedItems != null && this.Controller.Model.Selection.SelectedItems.Count > 0) {
30        #region Preparation of the ordering
31        //the items have to be moved in the order of the Paintables
32        //Usually this is a good moment to make a little drawing or example
33        //to see how things function.
34
35        SortedList<int, IDiagramEntity> list = new SortedList<int, IDiagramEntity>();
36        foreach (IDiagramEntity entity in this.Controller.Model.Selection.FlattenedSelectionItems) {
37          //the addition will automatically put the item in increasing order
38          list.Add(this.Controller.Model.Paintables.IndexOf(entity), entity);
39        }
40        #endregion
41        //send them backwards
42        for (int k = 0; k < list.Count; k++) {
43          this.Controller.Model.SendToFront(list.Values[k]);
44        }
45      }
46      DeactivateTool();
47    }
48
49    #endregion
50
51
52  }
53
54}
Note: See TracBrowser for help on using the repository browser.