Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Persistence Test/HeuristicLab.Visualization.Test/3.2/MainForm.cs @ 4492

Last change on this file since 4492 was 1964, checked in by mstoeger, 16 years ago

moved the canvas and the basic types of shapes to their own namespace. #498

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