Mercurial > repos > IBBoard.WarFoundry.GUI.WinForms
changeset 40:740350673006
Re #117: Add percentage and number boxes to equipment item dialogs
* Add a new EquipmentAmountControl to bundle the controls with some initial implementation
* Add new control to "new equipment" dialog and remove old controls
Also:
* Update some namespaces
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 06 Sep 2009 18:01:54 +0000 |
parents | 25dfeb1db285 |
children | 4fc87d6e6119 |
files | AssemblyInfo.cs FrmArmyTree.cs FrmMain.cs FrmNewUnitEquipment.cs FrmNewUnitEquipment.resx FrmUnit.cs IBBoard.WarFoundry.GUI.WinForms.csproj UI/EquipmentAmountControl.Designer.cs UI/EquipmentAmountControl.cs UI/EquipmentAmountControl.resx UI/StatColumnStyle.cs |
diffstat | 11 files changed, 482 insertions(+), 244 deletions(-) [+] |
line wrap: on
line diff
--- a/AssemblyInfo.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/AssemblyInfo.cs Sun Sep 06 18:01:54 2009 +0000 @@ -1,62 +1,62 @@ // This file (AssemblyInfo.cs) is a part of the IBBoard.WarFoundry.GUI.WinForms project and is copyright 2007, 2008, 2009 IBBoard. // // 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. - -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("WarFoundry Army Builder")] -[assembly: AssemblyDescription("WarFoundry is an army creator/designer/builder designed to cover a wide range of war game systems")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("WarFoundry")] -[assembly: AssemblyCopyright("IBBoard, 2007-2009")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\<configuration>. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] + +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("WarFoundry Army Builder")] +[assembly: AssemblyDescription("WarFoundry is an army creator/designer/builder designed to cover a wide range of war game systems")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WarFoundry")] +[assembly: AssemblyCopyright("IBBoard, 2007-2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\<configuration>. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")]
--- a/FrmArmyTree.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/FrmArmyTree.cs Sun Sep 06 18:01:54 2009 +0000 @@ -13,7 +13,7 @@ using IBBoard.Windows.Forms; using IBBoard.WarFoundry.API.Objects; -namespace IBBoard.WarFoundry.WinForms +namespace IBBoard.WarFoundry.GUI.WinForms { /// <summary> /// Summary description for FrmArmyTree.
--- a/FrmMain.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/FrmMain.cs Sun Sep 06 18:01:54 2009 +0000 @@ -28,7 +28,7 @@ using IBBoard.WarFoundry.API.Factories; using IBBoard.WarFoundry.API.Factories.Xml; -namespace IBBoard.WarFoundry.WinForms +namespace IBBoard.WarFoundry.GUI.WinForms { /// <summary> /// Summary description for Form1.
--- a/FrmNewUnitEquipment.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/FrmNewUnitEquipment.cs Sun Sep 06 18:01:54 2009 +0000 @@ -13,8 +13,9 @@ using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Commands; using IBBoard.WarFoundry.API.Objects; +using IBBoard.WarFoundry.GUI.WinForms.Util; -namespace IBBoard.WarFoundry +namespace IBBoard.WarFoundry.GUI.WinForms { /// <summary> /// Summary description for FrmNewUnitEquipment. @@ -22,17 +23,13 @@ public class FrmNewUnitEquipment : System.Windows.Forms.Form { private Unit unit; - private bool required; private CommandStack commandStack; - - private System.Windows.Forms.NumericUpDown numEquipAmount; - private System.Windows.Forms.Label lblPercent; private System.Windows.Forms.Label lblAmount; private System.Windows.Forms.Button bttnCancel; private System.Windows.Forms.Button bttnOkay; - private System.Windows.Forms.CheckBox cbEquipAll; private System.Windows.Forms.Label lblItem; private System.Windows.Forms.ListBox listItems; + private IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl equipmentAmount; /// <summary> /// Required designer variable. /// </summary> @@ -70,35 +67,14 @@ /// </summary> private void InitializeComponent() { - this.numEquipAmount = new System.Windows.Forms.NumericUpDown(); - this.lblPercent = new System.Windows.Forms.Label(); this.lblAmount = new System.Windows.Forms.Label(); this.bttnCancel = new System.Windows.Forms.Button(); this.bttnOkay = new System.Windows.Forms.Button(); - this.cbEquipAll = new System.Windows.Forms.CheckBox(); this.lblItem = new System.Windows.Forms.Label(); this.listItems = new System.Windows.Forms.ListBox(); - ((System.ComponentModel.ISupportInitialize)(this.numEquipAmount)).BeginInit(); + this.equipmentAmount = new IBBoard.WarFoundry.GUI.WinForms.UI.EquipmentAmountControl(); this.SuspendLayout(); // - // numEquipAmount - // - this.numEquipAmount.Enabled = false; - this.numEquipAmount.Location = new System.Drawing.Point(88, 80); - this.numEquipAmount.Name = "numEquipAmount"; - this.numEquipAmount.Size = new System.Drawing.Size(144, 20); - this.numEquipAmount.TabIndex = 0; - this.numEquipAmount.ValueChanged += new System.EventHandler(this.numEquipAmount_ValueChanged); - // - // lblPercent - // - this.lblPercent.Location = new System.Drawing.Point(208, 80); - this.lblPercent.Name = "lblPercent"; - this.lblPercent.Size = new System.Drawing.Size(16, 16); - this.lblPercent.TabIndex = 1; - this.lblPercent.Text = "%"; - this.lblPercent.Visible = false; - // // lblAmount // this.lblAmount.Location = new System.Drawing.Point(8, 80); @@ -112,8 +88,9 @@ // this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.bttnCancel.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.bttnCancel.Location = new System.Drawing.Point(160, 136); + this.bttnCancel.Location = new System.Drawing.Point(158, 162); this.bttnCancel.Name = "bttnCancel"; + this.bttnCancel.Size = new System.Drawing.Size(75, 23); this.bttnCancel.TabIndex = 3; this.bttnCancel.Text = "cancel"; this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click); @@ -122,22 +99,13 @@ // this.bttnOkay.Enabled = false; this.bttnOkay.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.bttnOkay.Location = new System.Drawing.Point(8, 136); + this.bttnOkay.Location = new System.Drawing.Point(12, 162); this.bttnOkay.Name = "bttnOkay"; + this.bttnOkay.Size = new System.Drawing.Size(75, 23); this.bttnOkay.TabIndex = 4; this.bttnOkay.Text = "okay"; this.bttnOkay.Click += new System.EventHandler(this.bttnOkay_Click); // - // cbEquipAll - // - this.cbEquipAll.Enabled = false; - this.cbEquipAll.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.cbEquipAll.Location = new System.Drawing.Point(88, 104); - this.cbEquipAll.Name = "cbEquipAll"; - this.cbEquipAll.TabIndex = 5; - this.cbEquipAll.Text = "equip all"; - this.cbEquipAll.CheckedChanged += new System.EventHandler(this.cbEquipAll_CheckedChanged); - // // lblItem // this.lblItem.Location = new System.Drawing.Point(0, 8); @@ -151,31 +119,35 @@ // this.listItems.Location = new System.Drawing.Point(88, 8); this.listItems.Name = "listItems"; - this.listItems.Size = new System.Drawing.Size(144, 69); + this.listItems.Size = new System.Drawing.Size(145, 69); this.listItems.TabIndex = 7; this.listItems.SelectedIndexChanged += new System.EventHandler(this.listItems_SelectedIndexChanged); // + // equipmentAmount + // + this.equipmentAmount.Location = new System.Drawing.Point(88, 80); + this.equipmentAmount.Name = "equipmentAmount"; + this.equipmentAmount.Size = new System.Drawing.Size(155, 77); + this.equipmentAmount.TabIndex = 8; + // // FrmNewUnitEquipment // this.AcceptButton = this.bttnOkay; this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.CancelButton = this.bttnCancel; - this.ClientSize = new System.Drawing.Size(240, 164); + this.ClientSize = new System.Drawing.Size(245, 190); this.ControlBox = false; + this.Controls.Add(this.equipmentAmount); this.Controls.Add(this.listItems); this.Controls.Add(this.lblItem); - this.Controls.Add(this.cbEquipAll); this.Controls.Add(this.bttnOkay); this.Controls.Add(this.bttnCancel); this.Controls.Add(this.lblAmount); - this.Controls.Add(this.numEquipAmount); - this.Controls.Add(this.lblPercent); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.Name = "FrmNewUnitEquipment"; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "FrmEditUnitEquipment"; - ((System.ComponentModel.ISupportInitialize)(this.numEquipAmount)).EndInit(); this.ResumeLayout(false); } @@ -183,28 +155,22 @@ private void bttnOkay_Click(object sender, System.EventArgs e) { - setValue(); + SetValue(); this.Close(); } - private void setValue() + private void SetValue() { UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; - if (cbEquipAll.Checked) + if (equipmentAmount.IsRatioEquipmentAmount) { - commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, WarFoundryCore.INFINITY)); + commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, equipmentAmount.EquipmentAmount)); } else { - if (equipItem.IsRatioLimit) - { - commandStack.Execute(new SetUnitEquipmentRatioAmountCommand(unit, equipItem, (double)numEquipAmount.Value / 100.0)); - } - else - { - commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int)numEquipAmount.Value)); - } + //Just cast here - we should be returned a whole number anyway + commandStack.Execute(new SetUnitEquipmentNumericAmountCommand(unit, equipItem, (int) equipmentAmount.EquipmentAmount)); } } @@ -215,7 +181,7 @@ private void cbEquipAll_CheckedChanged(object sender, System.EventArgs e) { - numEquipAmount.Enabled = ((UnitEquipmentItem)listItems.SelectedItem).MinNumber != WarFoundryCore.INFINITY && !cbEquipAll.Checked; + //numEquipAmount.Enabled = ((UnitEquipmentItem) listItems.SelectedItem).MinNumber != WarFoundryCore.INFINITY && !rbEquipAll.Checked; setOkayButton(); } @@ -227,6 +193,7 @@ private void refreshNumber() { + /* if (listItems.SelectedIndex > -1) { UnitEquipmentItem equipItem = (UnitEquipmentItem)listItems.SelectedItem; @@ -238,7 +205,7 @@ numEquipAmount.Maximum = (decimal) equipItem.MaxPercentage; numEquipAmount.Enabled = true; numEquipAmount.Value = numEquipAmount.Minimum; - cbEquipAll.Enabled = false; + rbEquipAll.Enabled = false; lblPercent.Visible = true; numEquipAmount.Width = 120; } @@ -248,8 +215,8 @@ numEquipAmount.Maximum = (decimal)(equipItem.MaxNumber != WarFoundryCore.INFINITY ? Math.Min(equipItem.MaxNumber, unit.Size) : unit.Size); numEquipAmount.Value = numEquipAmount.Minimum; numEquipAmount.Enabled = equipItem.MinNumber != WarFoundryCore.INFINITY; - cbEquipAll.Enabled = equipItem.MinNumber != WarFoundryCore.INFINITY && equipItem.MaxNumber == WarFoundryCore.INFINITY; - cbEquipAll.Checked = equipItem.MinNumber == WarFoundryCore.INFINITY; + rbEquipAll.Enabled = equipItem.MinNumber != WarFoundryCore.INFINITY && equipItem.MaxNumber == WarFoundryCore.INFINITY; + rbEquipAll.Checked = equipItem.MinNumber == WarFoundryCore.INFINITY; lblPercent.Visible = false; numEquipAmount.Width = 144; } @@ -259,13 +226,13 @@ numEquipAmount.Minimum = 0; numEquipAmount.Value = 0; numEquipAmount.Enabled = false; - cbEquipAll.Enabled = false; - } + rbEquipAll.Enabled = false; + }*/ } private void setOkayButton() { - bttnOkay.Enabled = listItems.SelectedIndex > -1 && (cbEquipAll.Checked || (numEquipAmount.Enabled && numEquipAmount.Value > 0)); + bttnOkay.Enabled = listItems.SelectedIndex > -1;// && (rbEquipAll.Checked || (numEquipAmount.Enabled && numEquipAmount.Value > 0)); } private void numEquipAmount_ValueChanged(object sender, System.EventArgs e)
--- a/FrmNewUnitEquipment.resx Tue Sep 01 19:47:33 2009 +0000 +++ b/FrmNewUnitEquipment.resx Sun Sep 06 18:01:54 2009 +0000 @@ -3,7 +3,7 @@ <!-- Microsoft ResX Schema - Version 1.3 + Version 2.0 The primary goals of this format is to allow a simple XML format that is mostly human readable. The generation and parsing of the @@ -14,16 +14,17 @@ ... ado.net/XML headers & schema ... <resheader name="resmimetype">text/microsoft-resx</resheader> - <resheader name="version">1.3</resheader> + <resheader name="version">2.0</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> - <data name="Name1">this is my long string</data> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> - [base64 mime encoded serialized .NET Framework object] + <value>[base64 mime encoded serialized .NET Framework object]</value> </data> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> - [base64 mime encoded string representing a byte array form of the .NET Framework object] + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> </data> There are any number of "resheader" rows that contain simple @@ -35,7 +36,7 @@ Classes that don't support this are serialized and stored with the mimetype set. - The mimetype is used forserialized objects, and tells the + The mimetype is used for serialized objects, and tells the ResXResourceReader how to depersist the object. This is currently not extensible. For a given mimetype the value must be set accordingly: @@ -45,7 +46,7 @@ mimetype: application/x-microsoft.net.object.binary.base64 value : The object must be serialized with - : System.Serialization.Formatters.Binary.BinaryFormatter + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : and then encoded with base64 encoding. mimetype: application/x-microsoft.net.object.soap.base64 @@ -59,18 +60,37 @@ : and then encoded with base64 encoding. --> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:element name="root" msdata:IsDataSet="true"> <xsd:complexType> <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> <xsd:element name="data"> <xsd:complexType> <xsd:sequence> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> </xsd:sequence> - <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> </xsd:complexType> </xsd:element> <xsd:element name="resheader"> @@ -89,114 +109,12 @@ <value>text/microsoft-resx</value> </resheader> <resheader name="version"> - <value>1.3</value> + <value>2.0</value> </resheader> <resheader name="reader"> - <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> <resheader name="writer"> - <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> </resheader> - <data name="numEquipAmount.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="numEquipAmount.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="numEquipAmount.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblPercent.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="lblPercent.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblPercent.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblAmount.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblAmount.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="lblAmount.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="bttnCancel.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="bttnCancel.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="bttnCancel.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="bttnOkay.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="bttnOkay.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="bttnOkay.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="cbEquipAll.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="cbEquipAll.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="cbEquipAll.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblItem.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="lblItem.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="lblItem.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="listItems.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="listItems.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="listItems.Modifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> - <data name="$this.Locked" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="$this.Localizable" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>False</value> - </data> - <data name="$this.GridSize" type="System.Drawing.Size, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <value>8, 8</value> - </data> - <data name="$this.Language" type="System.Globalization.CultureInfo, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>(Default)</value> - </data> - <data name="$this.DrawGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </data> - <data name="$this.TrayHeight" type="System.Int32, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>80</value> - </data> - <data name="$this.Name"> - <value>FrmNewUnitEquipment</value> - </data> - <data name="$this.SnapToGrid" type="System.Boolean, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>True</value> - </data> - <data name="$this.DefaultModifiers" type="System.CodeDom.MemberAttributes, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> - <value>Private</value> - </data> </root> \ No newline at end of file
--- a/FrmUnit.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/FrmUnit.cs Sun Sep 06 18:01:54 2009 +0000 @@ -14,10 +14,10 @@ using IBBoard.WarFoundry.API; using IBBoard.WarFoundry.API.Commands; using IBBoard.WarFoundry.API.Objects; -using IBBoard.WarFoundry.WinForms.UI; +using IBBoard.WarFoundry.GUI.WinForms.UI; using IBBoard.WarFoundry.GUI.WinForms.Util; -namespace IBBoard.WarFoundry.WinForms +namespace IBBoard.WarFoundry.GUI.WinForms { /// <summary> /// Summary description for FrmUnit.
--- a/IBBoard.WarFoundry.GUI.WinForms.csproj Tue Sep 01 19:47:33 2009 +0000 +++ b/IBBoard.WarFoundry.GUI.WinForms.csproj Sun Sep 06 18:01:54 2009 +0000 @@ -17,9 +17,9 @@ <DefaultTargetSchema>IE50</DefaultTargetSchema> <DelaySign>false</DelaySign> <OutputType>WinExe</OutputType> - <RootNamespace>IBBoard.WarFoundry</RootNamespace> + <RootNamespace>IBBoard.WarFoundry.GUI.WinForms</RootNamespace> <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> - <StartupObject>IBBoard.WarFoundry.WinForms.FrmMain</StartupObject> + <StartupObject>IBBoard.WarFoundry.GUI.WinForms.FrmMain</StartupObject> <FileUpgradeFlags> </FileUpgradeFlags> <UpgradeBackupLocation> @@ -145,6 +145,12 @@ <Compile Include="FrmUnit.cs"> <SubType>Form</SubType> </Compile> + <Compile Include="UI\EquipmentAmountControl.cs"> + <SubType>UserControl</SubType> + </Compile> + <Compile Include="UI\EquipmentAmountControl.Designer.cs"> + <DependentUpon>EquipmentAmountControl.cs</DependentUpon> + </Compile> <Compile Include="UI\StatColumnStyle.cs"> <SubType>Component</SubType> </Compile> @@ -181,6 +187,10 @@ <EmbeddedResource Include="FrmUnit.resx"> <DependentUpon>FrmUnit.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="UI\EquipmentAmountControl.resx"> + <SubType>Designer</SubType> + <DependentUpon>EquipmentAmountControl.cs</DependentUpon> + </EmbeddedResource> <None Include="app.config" /> <None Include="COPYING" /> <None Include="translations\en.translation">
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/EquipmentAmountControl.Designer.cs Sun Sep 06 18:01:54 2009 +0000 @@ -0,0 +1,132 @@ +namespace IBBoard.WarFoundry.GUI.WinForms.UI +{ + partial class EquipmentAmountControl + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.rbNumeric = new System.Windows.Forms.RadioButton(); + this.rbPercentage = new System.Windows.Forms.RadioButton(); + this.rbEquipAll = new System.Windows.Forms.RadioButton(); + this.numeric = new System.Windows.Forms.NumericUpDown(); + this.percentage = new System.Windows.Forms.NumericUpDown(); + this.lblPercentSign = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize) (this.numeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize) (this.percentage)).BeginInit(); + this.SuspendLayout(); + // + // rbNumeric + // + this.rbNumeric.AutoSize = true; + this.rbNumeric.Enabled = false; + this.rbNumeric.Location = new System.Drawing.Point(6, 5); + this.rbNumeric.Name = "rbNumeric"; + this.rbNumeric.Size = new System.Drawing.Size(14, 13); + this.rbNumeric.TabIndex = 0; + this.rbNumeric.TabStop = true; + this.rbNumeric.UseVisualStyleBackColor = true; + // + // rbPercentage + // + this.rbPercentage.AutoSize = true; + this.rbPercentage.Enabled = false; + this.rbPercentage.Location = new System.Drawing.Point(6, 31); + this.rbPercentage.Name = "rbPercentage"; + this.rbPercentage.Size = new System.Drawing.Size(14, 13); + this.rbPercentage.TabIndex = 1; + this.rbPercentage.TabStop = true; + this.rbPercentage.UseVisualStyleBackColor = true; + // + // rbEquipAll + // + this.rbEquipAll.AutoSize = true; + this.rbEquipAll.Enabled = false; + this.rbEquipAll.Location = new System.Drawing.Point(6, 55); + this.rbEquipAll.Name = "rbEquipAll"; + this.rbEquipAll.Size = new System.Drawing.Size(66, 17); + this.rbEquipAll.TabIndex = 2; + this.rbEquipAll.TabStop = true; + this.rbEquipAll.Text = "Equip All"; + this.rbEquipAll.UseVisualStyleBackColor = true; + this.rbEquipAll.CheckedChanged += new System.EventHandler(this.rbEquipAll_CheckedChanged); + // + // numeric + // + this.numeric.Enabled = false; + this.numeric.Location = new System.Drawing.Point(26, 3); + this.numeric.Name = "numeric"; + this.numeric.Size = new System.Drawing.Size(120, 20); + this.numeric.TabIndex = 3; + this.numeric.ValueChanged += new System.EventHandler(this.numeric_ValueChanged); + // + // percentage + // + this.percentage.DecimalPlaces = 1; + this.percentage.Enabled = false; + this.percentage.Location = new System.Drawing.Point(26, 29); + this.percentage.Name = "percentage"; + this.percentage.Size = new System.Drawing.Size(105, 20); + this.percentage.TabIndex = 4; + this.percentage.ValueChanged += new System.EventHandler(this.percentage_ValueChanged); + // + // lblPercentSign + // + this.lblPercentSign.AutoSize = true; + this.lblPercentSign.Location = new System.Drawing.Point(131, 31); + this.lblPercentSign.Name = "lblPercentSign"; + this.lblPercentSign.Size = new System.Drawing.Size(15, 13); + this.lblPercentSign.TabIndex = 5; + this.lblPercentSign.Text = "%"; + // + // EquipmentAmountControl + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.lblPercentSign); + this.Controls.Add(this.percentage); + this.Controls.Add(this.numeric); + this.Controls.Add(this.rbEquipAll); + this.Controls.Add(this.rbPercentage); + this.Controls.Add(this.rbNumeric); + this.Name = "EquipmentAmountControl"; + this.Size = new System.Drawing.Size(155, 77); + ((System.ComponentModel.ISupportInitialize) (this.numeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize) (this.percentage)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.RadioButton rbNumeric; + private System.Windows.Forms.RadioButton rbPercentage; + private System.Windows.Forms.RadioButton rbEquipAll; + private System.Windows.Forms.NumericUpDown numeric; + private System.Windows.Forms.NumericUpDown percentage; + private System.Windows.Forms.Label lblPercentSign; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/EquipmentAmountControl.cs Sun Sep 06 18:01:54 2009 +0000 @@ -0,0 +1,91 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using IBBoard.Lang; +using IBBoard.WarFoundry.API; +using IBBoard.WarFoundry.API.Objects; + +namespace IBBoard.WarFoundry.GUI.WinForms.UI +{ + public partial class EquipmentAmountControl : UserControl + { + private Unit unit; + private UnitEquipmentItem equip; + + public EquipmentAmountControl() + { + InitializeComponent(); + } + + public void SetUnit(Unit equipUnit) + { + unit = equipUnit; + } + + public void SetUnitEquipmentItem(UnitEquipmentItem unitEquipment) + { + equip = unitEquipment; + //SetWidgetValues(); + } + + private void rbEquipAll_CheckedChanged(object sender, EventArgs e) + { + bool equipAll = rbEquipAll.Checked; + numeric.Enabled = !equipAll; + percentage.Enabled = !equipAll; + + if (equipAll) + { + numeric.Value = unit.Size; + percentage.Value = 100; + } + } + + private void percentage_ValueChanged(object sender, EventArgs e) + { + double percent = (double) percentage.Value; + numeric.Value = (decimal) IBBMath.Round(unit.Size * (percent / 100.0), equip.RoundNumberUp); + rbEquipAll.Checked = (percentage.Value == 100); + } + + private void numeric_ValueChanged(object sender, EventArgs e) + { + percentage.Value = (unit.Size / numeric.Value) * 100; + } + + public double EquipmentAmount + { + get + { + double val = 0; + + if (rbNumeric.Checked) + { + val = (double) numeric.Value; + } + else if (rbPercentage.Enabled) + { + val = (double) percentage.Value / 100.0; + } + else + { + val = WarFoundryCore.INFINITY; + } + + return val; + } + } + + public bool IsRatioEquipmentAmount + { + get + { + return rbPercentage.Checked; + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/EquipmentAmountControl.resx Sun Sep 06 18:01:54 2009 +0000 @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file
--- a/UI/StatColumnStyle.cs Tue Sep 01 19:47:33 2009 +0000 +++ b/UI/StatColumnStyle.cs Sun Sep 06 18:01:54 2009 +0000 @@ -8,7 +8,7 @@ using System.Windows.Forms; using IBBoard.WarFoundry.API.Objects; -namespace IBBoard.WarFoundry.WinForms.UI +namespace IBBoard.WarFoundry.GUI.WinForms.UI { class StatColumnStyle : DataGridTextBoxColumn {