Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Visualization.Test/MainForm.cs @ 1055

Last change on this file since 1055 was 1045, checked in by bspisic, 16 years ago

#424
Did some code refactoring (created concrete MouseEventListeners)

File size: 2.9 KB
Line 
1using System.Drawing;
2using System.Windows.Forms;
3
4namespace HeuristicLab.Visualization.Test {
5  public partial class MainForm : Form {
6    public MainForm() {
7      InitializeComponent();
8
9      canvasUI.MainCanvas.WorldShape = new WorldShape(new RectangleD(0, 0, 800, 600), new RectangleD(0, 0, 800, 600));
10
11      CreateLeftWorldShape();
12      CreateMiddleCompositeShape();
13      CreateRightWorldShape();
14      CreateSimpleRectangleShape();
15
16      canvasUI.Invalidate();
17    }
18
19    private void CreateSimpleRectangleShape() {
20      WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
21      // simple rectangle shape
22      RectangleShape rect7 = new RectangleShape(5, 5, 50, 50, Color.Black);
23      mainWorld.AddShape(rect7);
24    }
25
26    private void CreateRightWorldShape() {
27      WorldShape mainWorld = canvasUI.MainCanvas.WorldShape;
28      // right world shape
29      WorldShape rightWorld = new WorldShape(new RectangleD(-1, -1, 1, 1), new RectangleD(600, 10, 780, 600));
30
31      double x1 = -3;
32      double y1 = -3;
33
34      for (int i = 0; i < 10000; i++) {
35        RectangleShape rect = new RectangleShape(x1, y1, x1 + 0.3, y1 + 0.3, Color.Maroon);
36        x1 += 0.4;
37        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, Color.Navy);
50      RectangleShape rect6 = new RectangleShape(510, 310, 580, 590, 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, Color.LightBlue);
64
65      RectangleShape rect1 = new RectangleShape(100, 100, 500, 500, Color.Red);
66      RectangleShape rect2 = new RectangleShape(800, -200, 1200, 500, Color.Green);
67
68      CompositeShape comp1 = new CompositeShape();
69
70      RectangleShape rect3 = new RectangleShape(510, 580, 590, 700, Color.Blue);
71      RectangleShape rect4 = new RectangleShape(600, 710, 800, 900, 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    private void legendButton_Click(object sender, System.EventArgs e) {
85      LegendForm form = new LegendForm();
86      form.Show();
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.