24
|
1 // This file (FrmSelectSystem.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2009 IBBoard.
|
|
2 //
|
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license.
|
|
4
|
|
5 using System;
|
|
6 using System.IO;
|
|
7 using System.Drawing;
|
|
8 using System.Collections;
|
|
9 using System.ComponentModel;
|
|
10 using System.Windows.Forms;
|
|
11 using IBBoard;
|
|
12 using IBBoard.Lang;
|
|
13 using IBBoard.WarFoundry.API;
|
|
14 using IBBoard.Windows.Forms;
|
|
15 using IBBoard.WarFoundry.API.Objects;
|
|
16 using IBBoard.Windows.Forms.I18N;
|
|
17
|
|
18 namespace IBBoard.WarFoundry
|
|
19 {
|
|
20 /// <summary>
|
|
21 /// Summary description for FrmSelectSystem.
|
|
22 /// </summary>
|
|
23 public class FrmSelectSystem : IBBoard.Windows.Forms.IBBForm
|
|
24 {
|
|
25 private System.Windows.Forms.ListBox lstSystems;
|
|
26 private IBBoard.Windows.Forms.IBBLabel lblSystemList;
|
|
27 /// <summary>
|
|
28 /// Required designer variable.
|
|
29 /// </summary>
|
|
30 private System.ComponentModel.Container components = null;
|
|
31 private IBBoard.Windows.Forms.IBBButton bttnCancel;
|
|
32 private IBBoard.Windows.Forms.IBBButton bttnSelectSystem;
|
|
33 private GameSystem selectedSystem;
|
|
34
|
|
35
|
|
36 public FrmSelectSystem()
|
|
37 {
|
|
38 //
|
|
39 // Required for Windows Form Designer support
|
|
40 //
|
|
41 InitializeComponent();
|
|
42
|
|
43 ControlTranslator.TranslateControl(this);
|
|
44
|
|
45 lstSystems.Items.Clear();
|
|
46 GameSystem[] systems = WarFoundryLoader.GetDefault().GetGameSystems();
|
|
47 lstSystems.DataSource = systems;
|
|
48 lstSystems.DisplayMember = "Name";
|
|
49 }
|
|
50
|
|
51 /// <summary>
|
|
52 /// Clean up any resources being used.
|
|
53 /// </summary>
|
|
54 protected override void Dispose( bool disposing )
|
|
55 {
|
|
56 if( disposing )
|
|
57 {
|
|
58 if(components != null)
|
|
59 {
|
|
60 components.Dispose();
|
|
61 }
|
|
62 }
|
|
63 base.Dispose( disposing );
|
|
64 }
|
|
65
|
|
66 #region Windows Form Designer generated code
|
|
67 /// <summary>
|
|
68 /// Required method for Designer support - do not modify
|
|
69 /// the contents of this method with the code editor.
|
|
70 /// </summary>
|
|
71 private void InitializeComponent()
|
|
72 {
|
|
73 this.lstSystems = new System.Windows.Forms.ListBox();
|
|
74 this.bttnSelectSystem = new IBBoard.Windows.Forms.IBBButton();
|
|
75 this.lblSystemList = new IBBoard.Windows.Forms.IBBLabel();
|
|
76 this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
|
|
77 this.SuspendLayout();
|
|
78 //
|
|
79 // lstSystems
|
|
80 //
|
|
81 this.lstSystems.Location = new System.Drawing.Point(80, 8);
|
|
82 this.lstSystems.Name = "lstSystems";
|
|
83 this.lstSystems.Size = new System.Drawing.Size(216, 95);
|
|
84 this.lstSystems.TabIndex = 0;
|
|
85 this.lstSystems.SelectedIndexChanged += new System.EventHandler(this.lstSystems_SelectedIndexChanged);
|
|
86 //
|
|
87 // bttnSelectSystem
|
|
88 //
|
|
89 this.bttnSelectSystem.Enabled = false;
|
|
90 this.bttnSelectSystem.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
91 this.bttnSelectSystem.Location = new System.Drawing.Point(192, 112);
|
|
92 this.bttnSelectSystem.Name = "bttnSelectSystem";
|
|
93 this.bttnSelectSystem.Size = new System.Drawing.Size(104, 24);
|
|
94 this.bttnSelectSystem.TabIndex = 1;
|
|
95 this.bttnSelectSystem.Text = "Select system";
|
|
96 this.bttnSelectSystem.Click += new System.EventHandler(this.bttnSelectSystem_Click);
|
|
97 //
|
|
98 // lblSystemList
|
|
99 //
|
|
100 this.lblSystemList.Location = new System.Drawing.Point(0, 8);
|
|
101 this.lblSystemList.Name = "lblSystemList";
|
|
102 this.lblSystemList.Size = new System.Drawing.Size(80, 80);
|
|
103 this.lblSystemList.TabIndex = 2;
|
|
104 this.lblSystemList.Text = "system list";
|
|
105 this.lblSystemList.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
|
106 //
|
|
107 // bttnCancel
|
|
108 //
|
|
109 this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
|
110 this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System;
|
|
111 this.bttnCancel.Location = new System.Drawing.Point(8, 112);
|
|
112 this.bttnCancel.Name = "bttnCancel";
|
|
113 this.bttnCancel.Size = new System.Drawing.Size(80, 24);
|
|
114 this.bttnCancel.TabIndex = 3;
|
|
115 this.bttnCancel.Text = "Cancel";
|
|
116 this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
|
|
117 //
|
|
118 // FrmSelectSystem
|
|
119 //
|
|
120 this.AcceptButton = this.bttnSelectSystem;
|
|
121 this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
|
|
122 this.CancelButton = this.bttnCancel;
|
|
123 this.ClientSize = new System.Drawing.Size(306, 142);
|
|
124 this.ControlBox = false;
|
|
125 this.Controls.Add(this.bttnCancel);
|
|
126 this.Controls.Add(this.lblSystemList);
|
|
127 this.Controls.Add(this.bttnSelectSystem);
|
|
128 this.Controls.Add(this.lstSystems);
|
|
129 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
|
130 this.Name = "FrmSelectSystem";
|
|
131 this.ShowInTaskbar = false;
|
|
132 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
|
133 this.Text = "FrmSelectSystem";
|
|
134 this.ResumeLayout(false);
|
|
135
|
|
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; }
|
|
160 }
|
|
161 }
|
|
162 }
|