~ubuntu-branches/ubuntu/hardy/xcircuit/hardy

« back to all changes in this revision

Viewing changes to xccom2/zoomtest.cs

  • Committer: Bazaar Package Importer
  • Author(s): Aanjhan Ranganathan
  • Date: 2006-04-18 23:51:39 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060418235139-s49pkhwdzxvsxm5k
Tags: 3.4.21-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
using System;
 
2
using System.Windows.Forms;
 
3
 
 
4
namespace XCircuitTest
 
5
{
 
6
        public class ZoomTest : Form
 
7
        {
 
8
                private TextBox zoomtxt = null;
 
9
 
 
10
                public ZoomTest()
 
11
                {
 
12
                        System.Drawing.Size sz = new System.Drawing.Size(200,200);
 
13
                        ClientSize = sz;
 
14
                        FormBorderStyle = FormBorderStyle.FixedSingle;
 
15
                        Text = "Zoom .NET Control";
 
16
 
 
17
                        Button zoomin = new Button();
 
18
                        zoomin.Text = "Zoom In";
 
19
                        zoomin.Top = 10;
 
20
                        zoomin.Left = 10;
 
21
                        zoomin.Width = sz.Width-20;
 
22
                        zoomin.Click += new EventHandler(ZoomInClicked);
 
23
                        this.Controls.Add(zoomin);
 
24
 
 
25
                        Button zoomout = new Button();
 
26
                        zoomout.Text = "Zoom Out";
 
27
                        zoomout.Top = zoomin.Bottom+10;
 
28
                        zoomout.Left = zoomin.Left;
 
29
                        zoomout.Width = zoomin.Width;
 
30
                        zoomout.Click += new EventHandler(ZoomOutClicked);
 
31
                        this.Controls.Add(zoomout);
 
32
 
 
33
                        Button zoomview = new Button();
 
34
                        zoomview.Text = "Zoom To View";
 
35
                        zoomview.Top = zoomout.Bottom+10;
 
36
                        zoomview.Left = zoomin.Left;
 
37
                        zoomview.Width = zoomin.Width;
 
38
                        zoomview.Click += new EventHandler(ZoomViewClicked);
 
39
                        this.Controls.Add(zoomview);
 
40
 
 
41
                        Label zoomlab = new Label();
 
42
                        zoomlab.AutoSize = true;
 
43
                        zoomlab.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
 
44
                        zoomlab.Text = "Zoom:";
 
45
                        zoomlab.Left = zoomin.Left;
 
46
                        zoomlab.Top = zoomview.Bottom+20;
 
47
                        this.Controls.Add(zoomlab);
 
48
 
 
49
                        Button zoomapply = new Button();
 
50
                        zoomapply.Text = "Apply";
 
51
                        zoomapply.Left = sz.Width-10-zoomapply.Width;
 
52
                        zoomapply.Top = zoomlab.Top;
 
53
                        zoomapply.Click += new EventHandler(ZoomTxtChanged);
 
54
                        this.Controls.Add(zoomapply);
 
55
 
 
56
                        zoomtxt = new TextBox();
 
57
                        zoomtxt.Left = zoomlab.Right+10;
 
58
                        zoomtxt.Width = zoomapply.Left-zoomtxt.Left-10;
 
59
                        zoomtxt.Top = zoomlab.Top;
 
60
                        zoomtxt.Click += new EventHandler(UpdateZoomTxt);
 
61
                        this.Controls.Add(zoomtxt);
 
62
                        UpdateZoomTxt(null, null);
 
63
 
 
64
                        zoomlab.Top += (zoomapply.Height-zoomlab.Height)/2;
 
65
                        zoomtxt.Top += (zoomapply.Height-zoomtxt.Height)/2;
 
66
 
 
67
                        XCircuit.Application.ZoomChanged += new EventHandler(ZoomChanged);
 
68
                }
 
69
 
 
70
                protected override void OnClosed(EventArgs e)
 
71
                {
 
72
                        XCircuit.Application.ZoomChanged -= new EventHandler(ZoomChanged);
 
73
                        base.OnClosed(e);
 
74
                }
 
75
 
 
76
                private void ZoomInClicked(object sender, EventArgs args)
 
77
                {
 
78
                        XCircuit.Application.ZoomIn();
 
79
                }
 
80
 
 
81
                private void ZoomOutClicked(object sender, EventArgs args)
 
82
                {
 
83
                        XCircuit.Application.ZoomOut();
 
84
                }
 
85
 
 
86
                private void ZoomViewClicked(object sender, EventArgs args)
 
87
                {
 
88
                        XCircuit.Application.Zoom = "auto";
 
89
                }
 
90
 
 
91
                private void ZoomTxtChanged(object sender, EventArgs args)
 
92
                {
 
93
                        XCircuit.Application.Zoom = (float)Single.Parse(zoomtxt.Text);
 
94
                }
 
95
 
 
96
                private void UpdateZoomTxt(object sender, EventArgs args)
 
97
                {
 
98
                        zoomtxt.Text = XCircuit.Application.Zoom.ToString();
 
99
                }
 
100
 
 
101
                private void ZoomChanged(object sender, EventArgs args)
 
102
                {
 
103
                        Console.WriteLine("Zoom changed");
 
104
                        UpdateZoomTxt(null, null);
 
105
                }
 
106
 
 
107
                public static void XC_init()
 
108
                {
 
109
                        ZoomTest zt = new ZoomTest();
 
110
                        zt.Show();
 
111
                }
 
112
        }
 
113
}