changeset 247:53d79e1be712

Re #354: Single-button Add Unit * Start creating new form
author IBBoard <dev@ibboard.co.uk>
date Tue, 16 Aug 2011 21:01:45 +0100
parents 314d90a059d8
children 19a88383dfa7
files FrmMain.cs FrmNewUnitFromTree.Designer.cs FrmNewUnitFromTree.cs FrmNewUnitFromTree.resx IBBoard.WarFoundry.GUI.WinForms.csproj
diffstat 5 files changed, 264 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- a/FrmMain.cs	Tue Aug 16 20:34:46 2011 +0100
     1.2 +++ b/FrmMain.cs	Tue Aug 16 21:01:45 2011 +0100
     1.3 @@ -59,6 +59,7 @@
     1.4  		//public FailedUnitRequirementDelegate FailedUnitRequirementMethod;
     1.5  
     1.6  		private FrmArmyTree armyTree;
     1.7 +        private FrmNewUnitFromTree newUnitTree;
     1.8  		private string loadedFilePath;
     1.9  		private Dictionary<string, FrmUnit> unitWindows;
    1.10  
    1.11 @@ -184,6 +185,24 @@
    1.12  			armyTree.Location = new Point(this.DisplayRectangle.Width - armyTree.Width - 10, 10);
    1.13  		}
    1.14  
    1.15 +        private FrmNewUnitFromTree GetNewUnitTree()
    1.16 +        {
    1.17 +            if (newUnitTree == null || newUnitTree.IsDisposed)
    1.18 +            {
    1.19 +                CreateNewUnitTree();
    1.20 +            }
    1.21 +
    1.22 +            return newUnitTree;
    1.23 +        }
    1.24 +
    1.25 +        private void CreateNewUnitTree()
    1.26 +        {
    1.27 +            newUnitTree = new FrmNewUnitFromTree();
    1.28 +            newUnitTree.MdiParent = this;
    1.29 +            newUnitTree.StartPosition = FormStartPosition.Manual;
    1.30 +            newUnitTree.Location = new Point(10, 10);
    1.31 +        }
    1.32 +
    1.33  		private void TranslateControls()
    1.34  		{
    1.35  			ControlTranslator.TranslateControls(Controls);
    1.36 @@ -957,6 +976,7 @@
    1.37  			miExportArmyAs.Enabled = false;
    1.38  			DisableCategoryButtons();
    1.39  			GetArmyTree().Hide();
    1.40 +            GetNewUnitTree().Hide();
    1.41  		}
    1.42  
    1.43  		private void SetNonNullArmyState(Army newArmy)
    1.44 @@ -967,6 +987,7 @@
    1.45  			miCloseArmy.Enabled = true;
    1.46  			miExportArmyAs.Enabled = true;
    1.47  			GetArmyTree().Show();
    1.48 +            GetNewUnitTree().Show();
    1.49  		}
    1.50  
    1.51  		private void SetCategoryButtons(Category[] cats)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/FrmNewUnitFromTree.Designer.cs	Tue Aug 16 21:01:45 2011 +0100
     2.3 @@ -0,0 +1,60 @@
     2.4 +´╗┐namespace IBBoard.WarFoundry.GUI.WinForms
     2.5 +{
     2.6 +    partial class FrmNewUnitFromTree
     2.7 +    {
     2.8 +        /// <summary>
     2.9 +        /// Required designer variable.
    2.10 +        /// </summary>
    2.11 +        private System.ComponentModel.IContainer components = null;
    2.12 +
    2.13 +        /// <summary>
    2.14 +        /// Clean up any resources being used.
    2.15 +        /// </summary>
    2.16 +        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    2.17 +        protected override void Dispose(bool disposing)
    2.18 +        {
    2.19 +            if (disposing && (components != null))
    2.20 +            {
    2.21 +                components.Dispose();
    2.22 +            }
    2.23 +            base.Dispose(disposing);
    2.24 +        }
    2.25 +
    2.26 +        #region Windows Form Designer generated code
    2.27 +
    2.28 +        /// <summary>
    2.29 +        /// Required method for Designer support - do not modify
    2.30 +        /// the contents of this method with the code editor.
    2.31 +        /// </summary>
    2.32 +        private void InitializeComponent()
    2.33 +        {
    2.34 +            this.unitTypeTree = new System.Windows.Forms.TreeView();
    2.35 +            this.SuspendLayout();
    2.36 +            // 
    2.37 +            // unitTypeTree
    2.38 +            // 
    2.39 +            this.unitTypeTree.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    2.40 +                        | System.Windows.Forms.AnchorStyles.Left)
    2.41 +                        | System.Windows.Forms.AnchorStyles.Right)));
    2.42 +            this.unitTypeTree.Location = new System.Drawing.Point(0, 0);
    2.43 +            this.unitTypeTree.Name = "unitTypeTree";
    2.44 +            this.unitTypeTree.Size = new System.Drawing.Size(292, 267);
    2.45 +            this.unitTypeTree.TabIndex = 0;
    2.46 +            // 
    2.47 +            // FrmNewUnitFromTree
    2.48 +            // 
    2.49 +            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    2.50 +            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    2.51 +            this.ClientSize = new System.Drawing.Size(292, 266);
    2.52 +            this.Controls.Add(this.unitTypeTree);
    2.53 +            this.Name = "FrmNewUnitFromTree";
    2.54 +            this.Text = "FrmNewUnitFromTree";
    2.55 +            this.ResumeLayout(false);
    2.56 +
    2.57 +        }
    2.58 +
    2.59 +        #endregion
    2.60 +
    2.61 +        private System.Windows.Forms.TreeView unitTypeTree;
    2.62 +    }
    2.63 +}
    2.64 \ No newline at end of file
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/FrmNewUnitFromTree.cs	Tue Aug 16 21:01:45 2011 +0100
     3.3 @@ -0,0 +1,54 @@
     3.4 +´╗┐using System;
     3.5 +using System.Collections.Generic;
     3.6 +using System.ComponentModel;
     3.7 +using System.Data;
     3.8 +using System.Drawing;
     3.9 +using System.Linq;
    3.10 +using System.Text;
    3.11 +using System.Windows.Forms;
    3.12 +using IBBoard.WarFoundry.API.Objects;
    3.13 +using IBBoard.WarFoundry.API;
    3.14 +
    3.15 +namespace IBBoard.WarFoundry.GUI.WinForms
    3.16 +{
    3.17 +    public partial class FrmNewUnitFromTree : Form
    3.18 +    {
    3.19 +        public FrmNewUnitFromTree()
    3.20 +        {
    3.21 +            InitializeComponent();
    3.22 +            WarFoundryCore.ArmyChanged += new ArmyChangedDelegate(ArmyChanged);
    3.23 +        }
    3.24 +
    3.25 +        private void ArmyChanged(Army newArmy, Army oldArmy)
    3.26 +        {
    3.27 +            unitTypeTree.Nodes.Clear();
    3.28 +
    3.29 +            if (newArmy != null)
    3.30 +            {
    3.31 +                BuildTree(newArmy.Race);
    3.32 +            }
    3.33 +        }
    3.34 +
    3.35 +        private void BuildTree(Race race)
    3.36 +        {
    3.37 +            foreach (Category cat in race.Categories)
    3.38 +            {
    3.39 +                UnitType[] unitTypes = race.GetUnitTypes(cat);
    3.40 +                TreeNode[] unitNodes = new TreeNode[unitTypes.Length];
    3.41 +
    3.42 +                for (int i = 0; i < unitTypes.Length; i++)
    3.43 +                {
    3.44 +                    UnitType unitType = unitTypes[i];
    3.45 +                    TreeNode temp = new TreeNode(unitType.Name);
    3.46 +                    temp.Tag = unitType;
    3.47 +                    unitNodes[i] = temp;
    3.48 +                }
    3.49 +
    3.50 +                TreeNode catTemp = new TreeNode(cat.Name, unitNodes);
    3.51 +                catTemp.Tag = cat;
    3.52 +                unitTypeTree.Nodes.Add(catTemp);
    3.53 +                catTemp.ExpandAll();
    3.54 +            }
    3.55 +        }
    3.56 +    }
    3.57 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/FrmNewUnitFromTree.resx	Tue Aug 16 21:01:45 2011 +0100
     4.3 @@ -0,0 +1,120 @@
     4.4 +´╗┐<?xml version="1.0" encoding="utf-8"?>
     4.5 +<root>
     4.6 +  <!-- 
     4.7 +    Microsoft ResX Schema 
     4.8 +    
     4.9 +    Version 2.0
    4.10 +    
    4.11 +    The primary goals of this format is to allow a simple XML format 
    4.12 +    that is mostly human readable. The generation and parsing of the 
    4.13 +    various data types are done through the TypeConverter classes 
    4.14 +    associated with the data types.
    4.15 +    
    4.16 +    Example:
    4.17 +    
    4.18 +    ... ado.net/XML headers & schema ...
    4.19 +    <resheader name="resmimetype">text/microsoft-resx</resheader>
    4.20 +    <resheader name="version">2.0</resheader>
    4.21 +    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
    4.22 +    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
    4.23 +    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
    4.24 +    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
    4.25 +    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
    4.26 +        <value>[base64 mime encoded serialized .NET Framework object]</value>
    4.27 +    </data>
    4.28 +    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
    4.29 +        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
    4.30 +        <comment>This is a comment</comment>
    4.31 +    </data>
    4.32 +                
    4.33 +    There are any number of "resheader" rows that contain simple 
    4.34 +    name/value pairs.
    4.35 +    
    4.36 +    Each data row contains a name, and value. The row also contains a 
    4.37 +    type or mimetype. Type corresponds to a .NET class that support 
    4.38 +    text/value conversion through the TypeConverter architecture. 
    4.39 +    Classes that don't support this are serialized and stored with the 
    4.40 +    mimetype set.
    4.41 +    
    4.42 +    The mimetype is used for serialized objects, and tells the 
    4.43 +    ResXResourceReader how to depersist the object. This is currently not 
    4.44 +    extensible. For a given mimetype the value must be set accordingly:
    4.45 +    
    4.46 +    Note - application/x-microsoft.net.object.binary.base64 is the format 
    4.47 +    that the ResXResourceWriter will generate, however the reader can 
    4.48 +    read any of the formats listed below.
    4.49 +    
    4.50 +    mimetype: application/x-microsoft.net.object.binary.base64
    4.51 +    value   : The object must be serialized with 
    4.52 +            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
    4.53 +            : and then encoded with base64 encoding.
    4.54 +    
    4.55 +    mimetype: application/x-microsoft.net.object.soap.base64
    4.56 +    value   : The object must be serialized with 
    4.57 +            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
    4.58 +            : and then encoded with base64 encoding.
    4.59 +
    4.60 +    mimetype: application/x-microsoft.net.object.bytearray.base64
    4.61 +    value   : The object must be serialized into a byte array 
    4.62 +            : using a System.ComponentModel.TypeConverter
    4.63 +            : and then encoded with base64 encoding.
    4.64 +    -->
    4.65 +  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
    4.66 +    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    4.67 +    <xsd:element name="root" msdata:IsDataSet="true">
    4.68 +      <xsd:complexType>
    4.69 +        <xsd:choice maxOccurs="unbounded">
    4.70 +          <xsd:element name="metadata">
    4.71 +            <xsd:complexType>
    4.72 +              <xsd:sequence>
    4.73 +                <xsd:element name="value" type="xsd:string" minOccurs="0" />
    4.74 +              </xsd:sequence>
    4.75 +              <xsd:attribute name="name" use="required" type="xsd:string" />
    4.76 +              <xsd:attribute name="type" type="xsd:string" />
    4.77 +              <xsd:attribute name="mimetype" type="xsd:string" />
    4.78 +              <xsd:attribute ref="xml:space" />
    4.79 +            </xsd:complexType>
    4.80 +          </xsd:element>
    4.81 +          <xsd:element name="assembly">
    4.82 +            <xsd:complexType>
    4.83 +              <xsd:attribute name="alias" type="xsd:string" />
    4.84 +              <xsd:attribute name="name" type="xsd:string" />
    4.85 +            </xsd:complexType>
    4.86 +          </xsd:element>
    4.87 +          <xsd:element name="data">
    4.88 +            <xsd:complexType>
    4.89 +              <xsd:sequence>
    4.90 +                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
    4.91 +                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
    4.92 +              </xsd:sequence>
    4.93 +              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
    4.94 +              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
    4.95 +              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
    4.96 +              <xsd:attribute ref="xml:space" />
    4.97 +            </xsd:complexType>
    4.98 +          </xsd:element>
    4.99 +          <xsd:element name="resheader">
   4.100 +            <xsd:complexType>
   4.101 +              <xsd:sequence>
   4.102 +                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
   4.103 +              </xsd:sequence>
   4.104 +              <xsd:attribute name="name" type="xsd:string" use="required" />
   4.105 +            </xsd:complexType>
   4.106 +          </xsd:element>
   4.107 +        </xsd:choice>
   4.108 +      </xsd:complexType>
   4.109 +    </xsd:element>
   4.110 +  </xsd:schema>
   4.111 +  <resheader name="resmimetype">
   4.112 +    <value>text/microsoft-resx</value>
   4.113 +  </resheader>
   4.114 +  <resheader name="version">
   4.115 +    <value>2.0</value>
   4.116 +  </resheader>
   4.117 +  <resheader name="reader">
   4.118 +    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   4.119 +  </resheader>
   4.120 +  <resheader name="writer">
   4.121 +    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   4.122 +  </resheader>
   4.123 +</root>
   4.124 \ No newline at end of file
     5.1 --- a/IBBoard.WarFoundry.GUI.WinForms.csproj	Tue Aug 16 20:34:46 2011 +0100
     5.2 +++ b/IBBoard.WarFoundry.GUI.WinForms.csproj	Tue Aug 16 21:01:45 2011 +0100
     5.3 @@ -150,6 +150,12 @@
     5.4      <Compile Include="FrmNewUnitEquipment.cs">
     5.5        <SubType>Form</SubType>
     5.6      </Compile>
     5.7 +    <Compile Include="FrmNewUnitFromTree.cs">
     5.8 +      <SubType>Form</SubType>
     5.9 +    </Compile>
    5.10 +    <Compile Include="FrmNewUnitFromTree.Designer.cs">
    5.11 +      <DependentUpon>FrmNewUnitFromTree.cs</DependentUpon>
    5.12 +    </Compile>
    5.13      <Compile Include="FrmPreferences.cs">
    5.14        <SubType>Form</SubType>
    5.15      </Compile>
    5.16 @@ -206,6 +212,9 @@
    5.17        <DependentUpon>FrmNewUnitEquipment.cs</DependentUpon>
    5.18        <SubType>Designer</SubType>
    5.19      </EmbeddedResource>
    5.20 +    <EmbeddedResource Include="FrmNewUnitFromTree.resx">
    5.21 +      <DependentUpon>FrmNewUnitFromTree.cs</DependentUpon>
    5.22 +    </EmbeddedResource>
    5.23      <EmbeddedResource Include="FrmPreferences.resx">
    5.24        <SubType>Designer</SubType>
    5.25        <DependentUpon>FrmPreferences.cs</DependentUpon>