Changeset 4068 for trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/SendToBackTool.cs
- Timestamp:
- 07/22/10 00:44:01 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/SendToBackTool.cs
r2868 r4068 1 using System;2 using System.Diagnostics;3 1 using System.Collections; 4 using System.Drawing;5 using System.Windows.Forms;6 2 using System.Collections.Generic; 7 namespace Netron.Diagramming.Core 8 { 3 namespace Netron.Diagramming.Core { 4 /// <summary> 5 /// Group tool 6 /// </summary> 7 class SendToBackTool : AbstractTool { 8 9 #region Fields 10 11 #endregion 12 13 #region Constructor 9 14 /// <summary> 10 /// Group tool15 /// Initializes a new instance of the <see cref="T:SendToBackTool"/> class. 11 16 /// </summary> 12 class SendToBackTool : AbstractTool 13 { 17 /// <param name="name">The name of the tool.</param> 18 public SendToBackTool(string name) 19 : base(name) { 20 } 21 #endregion 14 22 15 #region Fields 16 17 #endregion 23 #region Methods 18 24 19 #region Constructor 20 /// <summary> 21 /// Initializes a new instance of the <see cref="T:SendToBackTool"/> class. 22 /// </summary> 23 /// <param name="name">The name of the tool.</param> 24 public SendToBackTool(string name) 25 : base(name) 26 { 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 inverse 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); 27 39 } 28 40 #endregion 41 //send them backwards 42 for (int k = list.Count - 1; k >= 0; k--) { 43 this.Controller.Model.SendToBack(list.Values[k]); 44 } 45 } 46 DeactivateTool(); 47 } 29 48 30 #region Methods 31 32 /// <summary> 33 /// Called when the tool is activated. 34 /// </summary> 35 protected override void OnActivateTool() 36 { 37 if (this.Controller.Model.Selection.SelectedItems != null && this.Controller.Model.Selection.SelectedItems.Count > 0) 38 { 39 #region Preparation of the ordering 40 //the items have to be moved in the inverse order of the Paintables 41 //Usually this is a good moment to make a little drawing or example 42 //to see how things function. 43 44 SortedList<int, IDiagramEntity> list = new SortedList<int, IDiagramEntity>(); 45 foreach (IDiagramEntity entity in this.Controller.Model.Selection.FlattenedSelectionItems) 46 { 47 //the addition will automatically put the item in increasing order 48 list.Add(this.Controller.Model.Paintables.IndexOf(entity), entity); 49 } 50 #endregion 51 //send them backwards 52 for(int k = list.Count-1; k>=0; k--) 53 { 54 this.Controller.Model.SendToBack(list.Values[k]); 55 } 56 } 57 DeactivateTool(); 58 } 59 60 #endregion 49 #endregion 61 50 62 51 63 52 } 64 53 65 54 }
Note: See TracChangeset
for help on using the changeset viewer.