Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
annotate FrmNewUnit.cs @ 239:c06d0865ff27
Fixes #388: Add "Add unit" options to army tree
* Add button, context menu and double-click hooks for adding units
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 21 Jan 2012 11:36:23 +0000 |
parents | 8021cc097ec8 |
children | 2c3474d652e1 |
rev | line source |
---|---|
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
1 // This file (FrmNewUnit.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard. |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
2 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
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. |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
4 |
199
f9ef9b2db496
Re #343: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
194
diff
changeset
|
5 using System; |
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
6 using System.Collections.Generic; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
7 using System.Drawing; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
8 using System.ComponentModel; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
9 using System.Windows.Forms; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
10 using IBBoard; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
11 using IBBoard.Lang; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
12 using IBBoard.Windows.Forms; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
13 using IBBoard.WarFoundry.API; |
194
137ec6d45280
Re #33: Centralised requirement handling
IBBoard <dev@ibboard.co.uk>
parents:
147
diff
changeset
|
14 using IBBoard.WarFoundry.API.Objects; |
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
15 using IBBoard.WarFoundry.API.Objects.Requirement; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
16 using IBBoard.Windows.Forms.I18N; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
17 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
18 namespace IBBoard.WarFoundry |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
19 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
20 /// <summary> |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
21 /// Summary description for FrmNewUnit. |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
22 /// </summary> |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
23 public class FrmNewUnit : IBBForm |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
24 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
25 private IBBoard.Windows.Forms.IBBButton bttnCancel; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
26 private IBBoard.Windows.Forms.IBBLabel lblUnitList; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
27 private IBBoard.Windows.Forms.IBBButton bttnSelectUnit; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
28 private System.Windows.Forms.ListBox lstUnits; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
29 private UnitType[] units; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
30 private Army army; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
31 private System.Windows.Forms.Label lblNewUnitWarning; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
32 private System.Windows.Forms.Label lblWarningIcon; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
33 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
34 public FrmNewUnit(Race race, Category cat, Army army) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
35 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
36 InitializeComponent(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
37 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
38 ControlTranslator.TranslateControl(this, cat.Name); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
39 units = race.GetUnitTypes(cat); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
40 this.army = army; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
41 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
42 for (int i = 0; i<units.Length; i++) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
43 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
44 lstUnits.Items.Add(units[i].Name); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
45 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
46 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
47 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
48 #region Windows Form Designer generated code |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
49 /// <summary> |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
50 /// Required method for Designer support - do not modify |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
51 /// the contents of this method with the code editor. |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
52 /// </summary> |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
53 private void InitializeComponent() |
147
1bcd7ea857c4
* Switch to using a single icon for the FrmNewUnit warning icon to work around Mono vs .Net2 SP2 serialisation bug (https://bugzilla.novell.com/show_bug.cgi?id=360429)
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
54 { |
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
55 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmNewUnit)); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
56 this.lstUnits = new System.Windows.Forms.ListBox(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
57 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
58 this.lblUnitList = new IBBoard.Windows.Forms.IBBLabel(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
59 this.bttnSelectUnit = new IBBoard.Windows.Forms.IBBButton(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
60 this.lblNewUnitWarning = new System.Windows.Forms.Label(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
61 this.lblWarningIcon = new System.Windows.Forms.Label(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
62 this.SuspendLayout(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
63 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
64 // lstUnits |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
65 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
66 this.lstUnits.Location = new System.Drawing.Point(88, 8); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
67 this.lstUnits.Name = "lstUnits"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
68 this.lstUnits.Size = new System.Drawing.Size(272, 121); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
69 this.lstUnits.TabIndex = 7; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
70 this.lstUnits.SelectedIndexChanged += new System.EventHandler(this.lstUnits_SelectedIndexChanged); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
71 this.lstUnits.DoubleClick += new System.EventHandler(this.lstUnits_DoubleClick); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
72 this.lstUnits.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lstUnits_MouseDown); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
73 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
74 // bttnCancel |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
75 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
76 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
77 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
78 this.bttnCancel.Location = new System.Drawing.Point(8, 168); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
79 this.bttnCancel.Name = "bttnCancel"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
80 this.bttnCancel.Size = new System.Drawing.Size(80, 24); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
81 this.bttnCancel.TabIndex = 6; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
82 this.bttnCancel.Text = "Cancel"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
83 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
84 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
85 // lblUnitList |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
86 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
87 this.lblUnitList.Location = new System.Drawing.Point(0, 8); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
88 this.lblUnitList.Name = "lblUnitList"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
89 this.lblUnitList.Size = new System.Drawing.Size(88, 80); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
90 this.lblUnitList.TabIndex = 5; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
91 this.lblUnitList.Text = "unit list"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
92 this.lblUnitList.TextAlign = System.Drawing.ContentAlignment.TopRight; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
93 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
94 // bttnSelectUnit |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
95 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
96 this.bttnSelectUnit.Enabled = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
97 this.bttnSelectUnit.FlatStyle = System.Windows.Forms.FlatStyle.System; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
98 this.bttnSelectUnit.Location = new System.Drawing.Point(256, 168); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
99 this.bttnSelectUnit.Name = "bttnSelectUnit"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
100 this.bttnSelectUnit.Size = new System.Drawing.Size(104, 24); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
101 this.bttnSelectUnit.TabIndex = 4; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
102 this.bttnSelectUnit.Text = "create unit"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
103 this.bttnSelectUnit.Click += new System.EventHandler(this.bttnSelectUnit_Click); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
104 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
105 // lblNewUnitWarning |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
106 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
107 this.lblNewUnitWarning.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
108 this.lblNewUnitWarning.Location = new System.Drawing.Point(48, 136); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
109 this.lblNewUnitWarning.Name = "lblNewUnitWarning"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
110 this.lblNewUnitWarning.Size = new System.Drawing.Size(312, 32); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
111 this.lblNewUnitWarning.TabIndex = 9; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
112 this.lblNewUnitWarning.Text = "One or more unit requirements are not satisfied."; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
113 this.lblNewUnitWarning.TextAlign = System.Drawing.ContentAlignment.TopRight; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
114 this.lblNewUnitWarning.Visible = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
115 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
116 // lblWarningIcon |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
117 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
118 this.lblWarningIcon.Image = global::IBBoard.WarFoundry.GUI.WinForms.Properties.Resources.dialog_warning; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
119 this.lblWarningIcon.Location = new System.Drawing.Point(8, 136); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
120 this.lblWarningIcon.Name = "lblWarningIcon"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
121 this.lblWarningIcon.Size = new System.Drawing.Size(40, 32); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
122 this.lblWarningIcon.TabIndex = 10; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
123 this.lblWarningIcon.Visible = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
124 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
125 // FrmNewUnit |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
126 // |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
127 this.AcceptButton = this.bttnSelectUnit; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
128 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
129 this.CancelButton = this.bttnCancel; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
130 this.ClientSize = new System.Drawing.Size(370, 196); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
131 this.Controls.Add(this.lblWarningIcon); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
132 this.Controls.Add(this.lblNewUnitWarning); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
133 this.Controls.Add(this.bttnCancel); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
134 this.Controls.Add(this.lblUnitList); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
135 this.Controls.Add(this.bttnSelectUnit); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
136 this.Controls.Add(this.lstUnits); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
137 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
138 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
139 this.MaximizeBox = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
140 this.MinimizeBox = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
141 this.Name = "FrmNewUnit"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
142 this.ShowInTaskbar = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
143 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
144 this.Text = "FrmNewUni"; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
145 this.ResumeLayout(false); |
147
1bcd7ea857c4
* Switch to using a single icon for the FrmNewUnit warning icon to work around Mono vs .Net2 SP2 serialisation bug (https://bugzilla.novell.com/show_bug.cgi?id=360429)
IBBoard <dev@ibboard.co.uk>
parents:
46
diff
changeset
|
146 |
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
147 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
148 #endregion |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
149 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
150 public UnitType SelectedUnit |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
151 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
152 get { return units[lstUnits.SelectedIndex]; } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
153 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
154 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
155 private void bttnCancel_Click(object sender, System.EventArgs e) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
156 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
157 DialogResult = DialogResult.Cancel; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
158 this.Close(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
159 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
160 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
161 private void bttnSelectUnit_Click(object sender, System.EventArgs e) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
162 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
163 selectUnit(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
164 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
165 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
166 private void selectUnit() |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
167 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
168 DialogResult = DialogResult.OK; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
169 this.Close(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
170 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
171 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
172 private void setSelectUnitEnabledVal() |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
173 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
174 if (lstUnits.SelectedIndex>-1) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
175 { |
199
f9ef9b2db496
Re #343: Show unit requirement failures
IBBoard <dev@ibboard.co.uk>
parents:
194
diff
changeset
|
176 bttnSelectUnit.Enabled = true; |
236
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
177 ICollection<string> failureMessages; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
178 lblNewUnitWarning.Visible = !Validates.AsOkay(RequirementHandler.AllowsAdding(SelectedUnit, army, out failureMessages)); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
179 lblWarningIcon.Visible = lblNewUnitWarning.Visible; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
180 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
181 if (lblNewUnitWarning.Visible) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
182 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
183 lblNewUnitWarning.Text = String.Join("\n", new List<string>(failureMessages).ToArray()); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
184 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
185 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
186 else |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
187 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
188 bttnSelectUnit.Enabled = false; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
189 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
190 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
191 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
192 private void lstUnits_SelectedIndexChanged(object sender, System.EventArgs e) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
193 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
194 setSelectUnitEnabledVal(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
195 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
196 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
197 private void lstUnits_DoubleClick(object sender, EventArgs e) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
198 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
199 if (lstUnits.SelectedIndex>-1) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
200 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
201 selectUnit(); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
202 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
203 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
204 |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
205 private void lstUnits_MouseDown(object sender, MouseEventArgs e) |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
206 { |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
207 //make sure no item is selected when a click is made outside a unit |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
208 int index = lstUnits.IndexFromPoint(e.X, e.Y); |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
209 lstUnits.SelectedIndex = index; |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
210 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
211 } |
8021cc097ec8
Re #382: WinForms builds from Linux/Mono fail on Windows/.Net
IBBoard <dev@ibboard.co.uk>
parents:
199
diff
changeset
|
212 } |