Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/Netron.Diagramming.Core-3.0.2672.12446/Tools/ComplexRectangleTool.cs @ 2768

Last change on this file since 2768 was 2768, checked in by mkommend, 14 years ago

added solution folders and sources for the netron library (ticket #867)

File size: 2.1 KB
Line 
1using System;
2using System.Drawing;
3
4namespace Netron.Diagramming.Core
5{
6    /// <summary>
7    /// Tool to draw complex rectangles on the canvas
8    /// </summary>
9    public class ComplexRectangleTool : AbstractDrawingTool
10    {
11        #region Fields
12
13        #endregion
14
15        #region Properties
16
17        #endregion
18
19        #region Constructor
20        public ComplexRectangleTool() : base("ComplexRectangle Tool")
21        {
22        }
23        public ComplexRectangleTool(string name): base(name)
24        {
25
26        }
27        #endregion
28
29        #region Methods
30        protected override void OnMouseMove(System.Windows.Forms.MouseEventArgs e)
31        {
32            base.OnMouseMove(e);
33            if (IsActive && started)
34            {
35                Point point = new Point(e.X, e.Y);               
36
37                Controller.View.PaintGhostRectangle(startingPoint, point);
38
39                Controller.View.Invalidate(System.Drawing.Rectangle.Inflate(Controller.View.Ghost.Rectangle,20,20));
40            }
41        }
42
43
44        /// <summary>
45        /// This method will be called when the user has finished drawing a ghost rectangle or bundle
46        /// and initiates the actual creation of a bundle and the addition to the model via the appropriate command.
47        /// </summary>
48        protected override void GhostDrawingComplete()
49        {
50
51            try
52            {
53                ComplexRectangle shape = new ComplexRectangle(this.Controller.Model);
54                shape.Width = (int) Rectangle.Width;
55                shape.Height = (int) Rectangle.Height;
56                AddShapeCommand cmd = new AddShapeCommand(this.Controller, shape, new Point((int) Rectangle.X, (int)Rectangle.Y));
57                this.Controller.UndoManager.AddUndoCommand(cmd);
58                cmd.Redo();
59            }
60            catch
61            {
62                base.Controller.DeactivateTool(this);
63                Controller.View.Invalidate();
64                throw;
65            }
66
67            //base.Controller.DeactivateTool(this);
68        }
69
70
71        #endregion
72    }
73
74}
Note: See TracBrowser for help on using the repository browser.