annotate FrmNewUnit.cs @ 41:4fc87d6e6119

Re #117: Add percentage and number boxes to equipment item dialogs * Add events and value setting in EquipmentAmount widget * Hook up "value changed" event on new equipment form Also fixes adding side of re #114 (Enabling/disabling of "equip all" and number for equipment is wrong) by rebuilding everything
author IBBoard <dev@ibboard.co.uk>
date Sun, 06 Sep 2009 19:31:49 +0000
parents 6ab7ddc038f9
children 1576f669b3eb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
1 // This file (FrmNewUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard.
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
2 //
36
6ab7ddc038f9 Re #121: Move all code to AGPL
IBBoard <dev@ibboard.co.uk>
parents: 24
diff changeset
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.
24
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
4
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
5 using System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
6 using System.Drawing;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
7 using System.Collections;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
8 using System.ComponentModel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
9 using System.Windows.Forms;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
10 using IBBoard;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
11 using IBBoard.Lang;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
12 using IBBoard.Windows.Forms;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
13 using IBBoard.WarFoundry.API;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
14 using IBBoard.WarFoundry.API.Objects;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
15 using IBBoard.Windows.Forms.I18N;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
16
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
17 namespace IBBoard.WarFoundry
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
18 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
19 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
20 /// Summary description for FrmNewUnit.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
21 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
22 public class FrmNewUnit : IBBForm
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
23 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
24 private System.ComponentModel.IContainer components;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
25 private IBBoard.Windows.Forms.IBBButton bttnCancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
26 private IBBoard.Windows.Forms.IBBLabel lblUnitList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
27 private IBBoard.Windows.Forms.IBBButton bttnSelectUnit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
28 private System.Windows.Forms.ListBox lstUnits;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
29 private UnitType[] units;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
30 private Army army;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
31 private System.Windows.Forms.ImageList imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
32 private System.Windows.Forms.Label lblNewUnitWarning;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
33 private System.Windows.Forms.Label lblWarningIcon;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
34 private bool[] allowed;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
35
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
36 public FrmNewUnit(Race race, Category cat, Army army)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
37 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
38 InitializeComponent();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
39
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
40 ControlTranslator.TranslateControl(this, cat.Name);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
41 units = race.GetUnitTypes(cat);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
42 allowed = new bool[units.Length];
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
43 this.army = army;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
44
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
45 for (int i = 0; i<units.Length; i++)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
46 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
47 allowed[i] = army.CanAddUnitType(units[i]).Count == 0;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
48 lstUnits.Items.Add(units[i].Name);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
49 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
50 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
51
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
52 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
53 /// Clean up any resources being used.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
54 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
55 protected override void Dispose( bool disposing )
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
56 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
57 if( disposing )
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
58 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
59 if(components != null)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
60 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
61 components.Dispose();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
62 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
63 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
64 base.Dispose( disposing );
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
65 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
66
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
67 #region Windows Form Designer generated code
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
68 /// <summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
69 /// Required method for Designer support - do not modify
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
70 /// the contents of this method with the code editor.
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
71 /// </summary>
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
72 private void InitializeComponent()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
73 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
74 this.components = new System.ComponentModel.Container();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
75 System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(FrmNewUnit));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
76 this.lstUnits = new System.Windows.Forms.ListBox();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
77 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
78 this.lblUnitList = new IBBoard.Windows.Forms.IBBLabel();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
79 this.bttnSelectUnit = new IBBoard.Windows.Forms.IBBButton();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
80 this.lblNewUnitWarning = new System.Windows.Forms.Label();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
81 this.imageList = new System.Windows.Forms.ImageList(this.components);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
82 this.lblWarningIcon = new System.Windows.Forms.Label();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
83 this.SuspendLayout();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
84 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
85 // lstUnits
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
86 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
87 this.lstUnits.Location = new System.Drawing.Point(88, 8);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
88 this.lstUnits.Name = "lstUnits";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
89 this.lstUnits.Size = new System.Drawing.Size(272, 121);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
90 this.lstUnits.TabIndex = 7;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
91 this.lstUnits.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstUnits_MouseDown);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
92 this.lstUnits.DoubleClick += new System.EventHandler(this.lstUnits_DoubleClick);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
93 this.lstUnits.SelectedIndexChanged += new System.EventHandler(this.lstUnits_SelectedIndexChanged);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
94 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
95 // bttnCancel
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
96 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
97 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
98 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
99 this.bttnCancel.Location = new System.Drawing.Point(8, 168);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
100 this.bttnCancel.Name = "bttnCancel";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
101 this.bttnCancel.Size = new System.Drawing.Size(80, 24);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
102 this.bttnCancel.TabIndex = 6;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
103 this.bttnCancel.Text = "Cancel";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
104 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
105 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
106 // lblUnitList
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
107 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
108 this.lblUnitList.Location = new System.Drawing.Point(0, 8);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
109 this.lblUnitList.Name = "lblUnitList";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
110 this.lblUnitList.Size = new System.Drawing.Size(88, 80);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
111 this.lblUnitList.TabIndex = 5;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
112 this.lblUnitList.Text = "unit list";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
113 this.lblUnitList.TextAlign = System.Drawing.ContentAlignment.TopRight;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
114 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
115 // bttnSelectUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
116 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
117 this.bttnSelectUnit.Enabled = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
118 this.bttnSelectUnit.FlatStyle = System.Windows.Forms.FlatStyle.System;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
119 this.bttnSelectUnit.Location = new System.Drawing.Point(256, 168);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
120 this.bttnSelectUnit.Name = "bttnSelectUnit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
121 this.bttnSelectUnit.Size = new System.Drawing.Size(104, 24);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
122 this.bttnSelectUnit.TabIndex = 4;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
123 this.bttnSelectUnit.Text = "create unit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
124 this.bttnSelectUnit.Click += new System.EventHandler(this.bttnSelectUnit_Click);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
125 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
126 // lblNewUnitWarning
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
127 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
128 this.lblNewUnitWarning.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
129 this.lblNewUnitWarning.ImageList = this.imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
130 this.lblNewUnitWarning.Location = new System.Drawing.Point(48, 136);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
131 this.lblNewUnitWarning.Name = "lblNewUnitWarning";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
132 this.lblNewUnitWarning.Size = new System.Drawing.Size(312, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
133 this.lblNewUnitWarning.TabIndex = 9;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
134 this.lblNewUnitWarning.Text = "label1";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
135 this.lblNewUnitWarning.TextAlign = System.Drawing.ContentAlignment.TopRight;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
136 this.lblNewUnitWarning.Visible = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
137 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
138 // imageList
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
139 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
140 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
141 this.imageList.ImageSize = new System.Drawing.Size(32, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
142 this.imageList.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList.ImageStream")));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
143 this.imageList.TransparentColor = System.Drawing.Color.Transparent;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
144 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
145 // lblWarningIcon
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
146 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
147 this.lblWarningIcon.ImageIndex = 0;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
148 this.lblWarningIcon.ImageList = this.imageList;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
149 this.lblWarningIcon.Location = new System.Drawing.Point(8, 136);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
150 this.lblWarningIcon.Name = "lblWarningIcon";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
151 this.lblWarningIcon.Size = new System.Drawing.Size(40, 32);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
152 this.lblWarningIcon.TabIndex = 10;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
153 this.lblWarningIcon.Visible = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
154 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
155 // FrmNewUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
156 //
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
157 this.AcceptButton = this.bttnSelectUnit;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
158 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
159 this.CancelButton = this.bttnCancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
160 this.ClientSize = new System.Drawing.Size(370, 196);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
161 this.Controls.Add(this.lblWarningIcon);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
162 this.Controls.Add(this.lblNewUnitWarning);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
163 this.Controls.Add(this.bttnCancel);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
164 this.Controls.Add(this.lblUnitList);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
165 this.Controls.Add(this.bttnSelectUnit);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
166 this.Controls.Add(this.lstUnits);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
167 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
168 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
169 this.MaximizeBox = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
170 this.MinimizeBox = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
171 this.Name = "FrmNewUnit";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
172 this.ShowInTaskbar = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
173 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
174 this.Text = "FrmNewUni";
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
175 this.ResumeLayout(false);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
176
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
177 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
178 #endregion
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
179
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
180 public UnitType SelectedUnit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
181 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
182 get { return units[lstUnits.SelectedIndex]; }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
183 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
184
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
185 private void bttnCancel_Click(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
186 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
187 DialogResult = DialogResult.Cancel;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
188 this.Close();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
189 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
190
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
191 private void bttnSelectUnit_Click(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
192 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
193 selectUnit();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
194 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
195
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
196 private void selectUnit()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
197 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
198 DialogResult = DialogResult.OK;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
199 this.Close();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
200 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
201
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
202 private void setSelectUnitEnabledVal()
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
203 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
204 if (lstUnits.SelectedIndex>-1)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
205 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
206 bttnSelectUnit.Enabled = true;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
207 lblNewUnitWarning.Visible = !allowed[lstUnits.SelectedIndex];
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
208 lblWarningIcon.Visible = lblNewUnitWarning.Visible;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
209
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
210 if (lblNewUnitWarning.Visible)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
211 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
212 //lblNewUnitWarning.Text = army.GetFailedAddRequirement(units[lstUnits.SelectedIndex]).Description;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
213 //FIXME: Add failed requirement text
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
214 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
215 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
216 else
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
217 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
218 bttnSelectUnit.Enabled = false;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
219 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
220 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
221
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
222 private void lstUnits_SelectedIndexChanged(object sender, System.EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
223 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
224 setSelectUnitEnabledVal();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
225 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
226
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
227 private void lstUnits_DoubleClick(object sender, EventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
228 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
229 if (lstUnits.SelectedIndex>-1)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
230 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
231 selectUnit();
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
232 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
233 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
234
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
235 private void lstUnits_MouseDown(object sender, MouseEventArgs e)
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
236 {
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
237 //make sure no item is selected when a click is made outside a unit
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
238 int index = lstUnits.IndexFromPoint(e.X, e.Y);
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
239 lstUnits.SelectedIndex = index;
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
240 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
241 }
7c366fe55635 * Fix line terminators
IBBoard <dev@ibboard.co.uk>
parents: 3
diff changeset
242 }