[1240] | 1 | using System;
|
---|
| 2 | using System.Drawing;
|
---|
[636] | 3 | using System.Windows.Forms;
|
---|
[1964] | 4 | using HeuristicLab.Visualization.Drawing;
|
---|
[636] | 5 |
|
---|
| 6 | namespace HeuristicLab.Visualization.Test {
|
---|
| 7 | public partial class MainForm : Form {
|
---|
[1240] | 8 | private readonly Canvas canvas;
|
---|
| 9 |
|
---|
[636] | 10 | public MainForm() {
|
---|
| 11 | InitializeComponent();
|
---|
| 12 |
|
---|
[1240] | 13 | canvas = canvasUI.Canvas;
|
---|
[636] | 14 |
|
---|
| 15 | CreateLeftWorldShape();
|
---|
| 16 | CreateMiddleCompositeShape();
|
---|
| 17 | CreateRightWorldShape();
|
---|
| 18 | CreateSimpleRectangleShape();
|
---|
| 19 |
|
---|
| 20 | canvasUI.Invalidate();
|
---|
| 21 | }
|
---|
| 22 |
|
---|
| 23 | private void CreateSimpleRectangleShape() {
|
---|
| 24 | // simple rectangle shape
|
---|
[1038] | 25 | RectangleShape rect7 = new RectangleShape(5, 5, 50, 50, Color.Black);
|
---|
[1240] | 26 | canvas.AddShape(rect7);
|
---|
[636] | 27 | }
|
---|
| 28 |
|
---|
| 29 | private void CreateRightWorldShape() {
|
---|
| 30 | // right world shape
|
---|
[1240] | 31 | WorldShape rightWorld = new WorldShape();
|
---|
| 32 | rightWorld.ClippingArea = new RectangleD(-1, -1, 1, 1);
|
---|
| 33 | rightWorld.BoundingBox = new RectangleD(600, 10, 780, 600);
|
---|
[636] | 34 |
|
---|
| 35 | double x1 = -3;
|
---|
| 36 | double y1 = -3;
|
---|
| 37 |
|
---|
| 38 | for (int i = 0; i < 10000; i++) {
|
---|
[1038] | 39 | RectangleShape rect = new RectangleShape(x1, y1, x1 + 0.3, y1 + 0.3, Color.Maroon);
|
---|
[725] | 40 | x1 += 0.4;
|
---|
| 41 | y1 += 0.4;
|
---|
[636] | 42 | rightWorld.AddShape(rect);
|
---|
| 43 | }
|
---|
| 44 |
|
---|
[1240] | 45 | canvas.AddShape(rightWorld);
|
---|
[636] | 46 | }
|
---|
| 47 |
|
---|
| 48 | private void CreateMiddleCompositeShape() {
|
---|
| 49 | // middle composite shape
|
---|
| 50 | CompositeShape middleComp = new CompositeShape();
|
---|
| 51 |
|
---|
[1038] | 52 | RectangleShape rect5 = new RectangleShape(400, 10, 500, 300, Color.Navy);
|
---|
| 53 | RectangleShape rect6 = new RectangleShape(510, 310, 580, 590, Color.Magenta);
|
---|
[636] | 54 |
|
---|
| 55 | middleComp.AddShape(rect5);
|
---|
| 56 | middleComp.AddShape(rect6);
|
---|
| 57 |
|
---|
[1240] | 58 | canvas.AddShape(middleComp);
|
---|
[636] | 59 | }
|
---|
| 60 |
|
---|
| 61 | private void CreateLeftWorldShape() {
|
---|
| 62 | // left world shape
|
---|
[1240] | 63 | WorldShape leftWorld = new WorldShape();
|
---|
| 64 | leftWorld.ClippingArea = new RectangleD(0, 0, 1000, 1000);
|
---|
| 65 | leftWorld.BoundingBox = new RectangleD(10, 10, 380, 590);
|
---|
[636] | 66 |
|
---|
[1038] | 67 | RectangleShape fillRect = new RectangleShape(0, 0, 1000, 1000, Color.LightBlue);
|
---|
[636] | 68 |
|
---|
[1038] | 69 | RectangleShape rect1 = new RectangleShape(100, 100, 500, 500, Color.Red);
|
---|
| 70 | RectangleShape rect2 = new RectangleShape(800, -200, 1200, 500, Color.Green);
|
---|
[636] | 71 |
|
---|
| 72 | CompositeShape comp1 = new CompositeShape();
|
---|
| 73 |
|
---|
[1038] | 74 | RectangleShape rect3 = new RectangleShape(510, 580, 590, 700, Color.Blue);
|
---|
| 75 | RectangleShape rect4 = new RectangleShape(600, 710, 800, 900, Color.Orange);
|
---|
[636] | 76 |
|
---|
| 77 | comp1.AddShape(rect3);
|
---|
| 78 | comp1.AddShape(rect4);
|
---|
| 79 |
|
---|
| 80 | leftWorld.AddShape(fillRect);
|
---|
| 81 | leftWorld.AddShape(rect1);
|
---|
| 82 | leftWorld.AddShape(rect2);
|
---|
| 83 | leftWorld.AddShape(comp1);
|
---|
| 84 |
|
---|
[1240] | 85 | canvas.AddShape(leftWorld);
|
---|
[636] | 86 | }
|
---|
[725] | 87 |
|
---|
[1240] | 88 | private void legendButton_Click(object sender, EventArgs e) {
|
---|
[865] | 89 | LegendForm form = new LegendForm();
|
---|
| 90 | form.Show();
|
---|
| 91 | }
|
---|
[636] | 92 | }
|
---|
| 93 | } |
---|