Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HL-3.2-MonoMigration/HeuristicLab.Visualization.Test/MainForm.cs @ 1610

Last change on this file since 1610 was 636, checked in by mstoeger, 16 years ago

Create test application for HeuristicLab.Visualization (#295)

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