Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.ExtLibs/HeuristicLab.Netron/3.0.2672.12446/HeuristicLab.Netron-3.0.2672.12446/Ants.cs @ 15325

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

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

File size: 3.0 KB
Line 
1#region License Information
2//This end-user license agreement applies to the following software;
3
4//The Netron Diagramming Library
5//Cobalt.IDE
6//Xeon webserver
7//Neon UI Library
8
9//Copyright (C) 2007, Francois M.Vanderseypen, The Netron Project & The Orbifold
10
11//This program is free software; you can redistribute it and/or
12//modify it under the terms of the GNU General Public License
13//as published by the Free Software Foundation; either version 2
14//of the License, or (at your option) any later version.
15
16//This program is distributed in the hope that it will be useful,
17//but WITHOUT ANY WARRANTY; without even the implied warranty of
18//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19//GNU General Public License for more details.
20
21//You should have received a copy of the GNU General Public License
22//along with this program; if not, write to the Free Software
23//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
24
25
26//http://www.fsf.org/licensing/licenses/gpl.html
27
28//http://www.fsf.org/licensing/licenses/gpl-faq.html
29#endregion
30
31using System.Drawing;
32using System.Drawing.Drawing2D;
33using Netron.Diagramming.Core;
34
35namespace HeuristicLab.Netron {
36  internal static class AntsFactory {
37    private static RectAnts mRectangular;
38    public readonly static Pen Pen = new Pen(Color.Black, 1f);
39    static AntsFactory() {
40      Pen.DashStyle = DashStyle.Dash;
41    }
42    public static IAnts GetAnts(object pars, AntTypes type) {
43      switch (type) {
44        case AntTypes.Rectangle:
45          if (mRectangular == null)
46            mRectangular = new RectAnts();
47          Point[] points = (Point[])pars;
48          mRectangular.Start = points[0];
49          mRectangular.End = points[1];
50          return mRectangular;
51        default:
52          return null;
53      }
54    }
55
56    internal class RectAnts : AbstractAnt {
57      public RectAnts(Point s, Point e)
58        : this() {
59        this.Start = s;
60        this.End = e;
61
62      }
63
64      public RectAnts()
65        : base() {
66        Pen.DashStyle = DashStyle.Dash;
67      }
68
69      public override void Paint(Graphics g) {
70        if (g == null)
71          return;
72        g.DrawRectangle(AntsFactory.Pen, Start.X, Start.Y, End.X - Start.X, End.Y - Start.Y);
73
74      }
75    }
76
77    internal abstract class AbstractAnt : IAnts {
78      private Point mStart;
79      public Point Start {
80        get {
81          return mStart;
82        }
83        set {
84          mStart = value;
85        }
86      }
87      private Point mEnd;
88      public Point End {
89        get {
90          return mEnd;
91        }
92        set {
93          mEnd = value;
94        }
95      }
96
97      public Rectangle Rectangle {
98        get { return new Rectangle(mStart.X, mStart.Y, mEnd.X - mStart.X, mEnd.Y - mStart.Y); }
99        set {
100          mStart = new Point(value.X, value.Y);
101          mEnd = new Point(value.Right, value.Bottom);
102        }
103      }
104
105      public abstract void Paint(Graphics g);
106    }
107  }
108  internal enum AntTypes {
109    Rectangle
110  }
111}
Note: See TracBrowser for help on using the repository browser.