[2801] | 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 |
|
---|
| 31 | using System;
|
---|
[2781] | 32 | using System.Collections.Generic;
|
---|
| 33 | using System.Linq;
|
---|
| 34 | using System.Text;
|
---|
| 35 | using System.Drawing.Drawing2D;
|
---|
| 36 | using System.Drawing;
|
---|
| 37 | using Netron.Diagramming.Core;
|
---|
| 38 |
|
---|
| 39 | namespace HeuristicLab.Netron {
|
---|
| 40 | internal static class AntsFactory {
|
---|
| 41 | private static RectAnts mRectangular;
|
---|
| 42 | public readonly static Pen Pen = new Pen(Color.Black, 1f);
|
---|
| 43 | static AntsFactory() {
|
---|
| 44 | Pen.DashStyle = DashStyle.Dash;
|
---|
| 45 | }
|
---|
| 46 | public static IAnts GetAnts(object pars, AntTypes type) {
|
---|
| 47 | switch (type) {
|
---|
| 48 | case AntTypes.Rectangle:
|
---|
| 49 | if (mRectangular == null)
|
---|
| 50 | mRectangular = new RectAnts();
|
---|
| 51 | Point[] points = (Point[])pars;
|
---|
| 52 | mRectangular.Start = points[0];
|
---|
| 53 | mRectangular.End = points[1];
|
---|
| 54 | return mRectangular;
|
---|
| 55 | default:
|
---|
| 56 | return null;
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | internal class RectAnts : AbstractAnt {
|
---|
| 61 | public RectAnts(Point s, Point e)
|
---|
| 62 | : this() {
|
---|
| 63 | this.Start = s;
|
---|
| 64 | this.End = e;
|
---|
| 65 |
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | public RectAnts()
|
---|
| 69 | : base() {
|
---|
| 70 | Pen.DashStyle = DashStyle.Dash;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | public override void Paint(Graphics g) {
|
---|
| 74 | if (g == null)
|
---|
| 75 | return;
|
---|
| 76 | g.DrawRectangle(AntsFactory.Pen, Start.X, Start.Y, End.X - Start.X, End.Y - Start.Y);
|
---|
| 77 |
|
---|
| 78 | }
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | internal abstract class AbstractAnt : IAnts {
|
---|
| 82 | private Point mStart;
|
---|
| 83 | public Point Start {
|
---|
| 84 | get {
|
---|
| 85 | return mStart;
|
---|
| 86 | }
|
---|
| 87 | set {
|
---|
| 88 | mStart = value;
|
---|
| 89 | }
|
---|
| 90 | }
|
---|
| 91 | private Point mEnd;
|
---|
| 92 | public Point End {
|
---|
| 93 | get {
|
---|
| 94 | return mEnd;
|
---|
| 95 | }
|
---|
| 96 | set {
|
---|
| 97 | mEnd = value;
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | public Rectangle Rectangle {
|
---|
| 102 | get { return new Rectangle(mStart.X, mStart.Y, mEnd.X - mStart.X, mEnd.Y - mStart.Y); }
|
---|
| 103 | set {
|
---|
| 104 | mStart = new Point(value.X, value.Y);
|
---|
| 105 | mEnd = new Point(value.Right, value.Bottom);
|
---|
| 106 | }
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | public abstract void Paint(Graphics g);
|
---|
| 110 | }
|
---|
| 111 | }
|
---|
| 112 | internal enum AntTypes {
|
---|
| 113 | Rectangle
|
---|
| 114 | }
|
---|
| 115 | }
|
---|