Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
annotate FrmSelectSystem.cs @ 53:e6d0d9eababf
Fixes #163: Show unit cost on unit dialog
* Add a quick label with the points cost of the unit - can be moved and repositioned based on user feedback
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Wed, 16 Sep 2009 19:50:39 +0000 |
parents | 1576f669b3eb |
children |
rev | line source |
---|---|
36 | 1 // This file (FrmSelectSystem.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard. |
33 | 2 // |
36 | 3 // The file and the library/program it is in are licensed and distributed, without warranty, under the GNU Affero GPL license, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license. |
33 | 4 |
5 using System; | |
6 using System.IO; | |
7 using System.Drawing; | |
8 using System.ComponentModel; | |
9 using System.Windows.Forms; | |
10 using IBBoard; | |
11 using IBBoard.Lang; | |
12 using IBBoard.WarFoundry.API; | |
13 using IBBoard.Windows.Forms; | |
14 using IBBoard.WarFoundry.API.Objects; | |
15 using IBBoard.Windows.Forms.I18N; | |
16 | |
17 namespace IBBoard.WarFoundry | |
18 { | |
19 /// <summary> | |
20 /// Summary description for FrmSelectSystem. | |
21 /// </summary> | |
22 public class FrmSelectSystem : IBBoard.Windows.Forms.IBBForm | |
23 { | |
24 private System.Windows.Forms.ListBox lstSystems; | |
25 private IBBoard.Windows.Forms.IBBLabel lblSystemList; | |
26 /// <summary> | |
27 /// Required designer variable. | |
28 /// </summary> | |
29 private System.ComponentModel.Container components = null; | |
30 private IBBoard.Windows.Forms.IBBButton bttnCancel; | |
31 private IBBoard.Windows.Forms.IBBButton bttnSelectSystem; | |
32 private GameSystem selectedSystem; | |
33 | |
34 | |
35 public FrmSelectSystem() | |
36 { | |
37 // | |
38 // Required for Windows Form Designer support | |
39 // | |
40 InitializeComponent(); | |
41 | |
42 ControlTranslator.TranslateControl(this); | |
43 | |
44 lstSystems.Items.Clear(); | |
45 GameSystem[] systems = WarFoundryLoader.GetDefault().GetGameSystems(); | |
46 lstSystems.DataSource = systems; | |
47 lstSystems.DisplayMember = "Name"; | |
48 } | |
49 | |
50 /// <summary> | |
51 /// Clean up any resources being used. | |
52 /// </summary> | |
53 protected override void Dispose( bool disposing ) | |
54 { | |
55 if( disposing ) | |
56 { | |
57 if(components != null) | |
58 { | |
59 components.Dispose(); | |
60 } | |
61 } | |
62 base.Dispose( disposing ); | |
63 } | |
64 | |
65 #region Windows Form Designer generated code | |
66 /// <summary> | |
67 /// Required method for Designer support - do not modify | |
68 /// the contents of this method with the code editor. | |
69 /// </summary> | |
70 private void InitializeComponent() | |
29
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
71 { |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
72 this.lstSystems = new System.Windows.Forms.ListBox(); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
73 this.bttnSelectSystem = new IBBoard.Windows.Forms.IBBButton(); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
74 this.lblSystemList = new IBBoard.Windows.Forms.IBBLabel(); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
75 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton(); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
76 this.SuspendLayout(); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
77 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
78 // lstSystems |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
79 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
80 this.lstSystems.Location = new System.Drawing.Point(80, 8); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
81 this.lstSystems.Name = "lstSystems"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
82 this.lstSystems.Size = new System.Drawing.Size(216, 95); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
83 this.lstSystems.TabIndex = 0; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
84 this.lstSystems.DoubleClick += new System.EventHandler(this.lstSystems_DoubleClick); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
85 this.lstSystems.SelectedIndexChanged += new System.EventHandler(this.lstSystems_SelectedIndexChanged); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
86 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
87 // bttnSelectSystem |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
88 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
89 this.bttnSelectSystem.Enabled = false; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
90 this.bttnSelectSystem.FlatStyle = System.Windows.Forms.FlatStyle.System; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
91 this.bttnSelectSystem.Location = new System.Drawing.Point(192, 112); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
92 this.bttnSelectSystem.Name = "bttnSelectSystem"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
93 this.bttnSelectSystem.Size = new System.Drawing.Size(104, 24); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
94 this.bttnSelectSystem.TabIndex = 1; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
95 this.bttnSelectSystem.Text = "Select system"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
96 this.bttnSelectSystem.Click += new System.EventHandler(this.bttnSelectSystem_Click); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
97 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
98 // lblSystemList |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
99 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
100 this.lblSystemList.Location = new System.Drawing.Point(0, 8); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
101 this.lblSystemList.Name = "lblSystemList"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
102 this.lblSystemList.Size = new System.Drawing.Size(80, 80); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
103 this.lblSystemList.TabIndex = 2; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
104 this.lblSystemList.Text = "system list"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
105 this.lblSystemList.TextAlign = System.Drawing.ContentAlignment.TopRight; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
106 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
107 // bttnCancel |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
108 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
109 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
110 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
111 this.bttnCancel.Location = new System.Drawing.Point(8, 112); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
112 this.bttnCancel.Name = "bttnCancel"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
113 this.bttnCancel.Size = new System.Drawing.Size(80, 24); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
114 this.bttnCancel.TabIndex = 3; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
115 this.bttnCancel.Text = "Cancel"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
116 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
117 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
118 // FrmSelectSystem |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
119 // |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
120 this.AcceptButton = this.bttnSelectSystem; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
121 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
122 this.CancelButton = this.bttnCancel; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
123 this.ClientSize = new System.Drawing.Size(306, 142); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
124 this.ControlBox = false; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
125 this.Controls.Add(this.bttnCancel); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
126 this.Controls.Add(this.lblSystemList); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
127 this.Controls.Add(this.bttnSelectSystem); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
128 this.Controls.Add(this.lstSystems); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
129 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
130 this.Name = "FrmSelectSystem"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
131 this.ShowInTaskbar = false; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
132 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
133 this.Text = "FrmSelectSystem"; |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
134 this.ResumeLayout(false); |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
135 |
33 | 136 } |
137 #endregion | |
138 | |
139 private void lstSystems_SelectedIndexChanged(object sender, System.EventArgs e) | |
140 { | |
141 bttnSelectSystem.Enabled = (lstSystems.SelectedIndex>-1); | |
142 } | |
143 | |
144 private void bttnSelectSystem_Click(object sender, System.EventArgs e) | |
145 { | |
146 selectedSystem = (GameSystem) lstSystems.SelectedItem; | |
147 this.DialogResult = DialogResult.OK; | |
148 this.Close(); | |
149 } | |
150 | |
151 private void bttnCancel_Click(object sender, System.EventArgs e) | |
152 { | |
153 this.DialogResult = DialogResult.Cancel; | |
154 this.Close(); | |
155 } | |
156 | |
157 public GameSystem GameSystem | |
158 { | |
159 get { return selectedSystem; } | |
29
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
160 } |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
161 |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
162 private void lstSystems_DoubleClick(object sender, EventArgs e) |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
163 { |
f72a3da5059b
Re #88: Complete initial WinForms UI
IBBoard <dev@ibboard.co.uk>
parents:
24
diff
changeset
|
164 bttnSelectSystem_Click(null, null); |
33 | 165 } |
166 } | |
167 } |