changeset 252:4d25c42bbe7b

Re #419: Remove assumptions of a file-based install * Swap to drop-down in WinForms * Update to use streams
author IBBoard <dev@ibboard.co.uk>
date Wed, 28 Nov 2012 20:54:34 +0000
parents b57a7cf844f8
children 7243e6646926
files FrmXmlExport.Designer.cs FrmXmlExport.cs FrmXmlExport.resx
diffstat 3 files changed, 116 insertions(+), 147 deletions(-) [+]
line diff
     1.1 --- a/FrmXmlExport.Designer.cs	Sat Sep 01 16:12:48 2012 +0100
     1.2 +++ b/FrmXmlExport.Designer.cs	Wed Nov 28 20:54:34 2012 +0000
     1.3 @@ -28,122 +28,109 @@
     1.4          /// </summary>
     1.5          private void InitializeComponent()
     1.6          {
     1.7 -            this.lbTitle = new IBBoard.Windows.Forms.IBBLabel();
     1.8 -            this.tbOutputFile = new System.Windows.Forms.TextBox();
     1.9 -            this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
    1.10 -            this.bttnOutputSelect = new IBBoard.Windows.Forms.IBBButton();
    1.11 -            this.cbApplyTransform = new System.Windows.Forms.CheckBox();
    1.12 -            this.bttnExport = new IBBoard.Windows.Forms.IBBButton();
    1.13 -            this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
    1.14 -            this.tbXslPath = new System.Windows.Forms.TextBox();
    1.15 -            this.bttnXslSelect = new IBBoard.Windows.Forms.IBBButton();
    1.16 -            this.SuspendLayout();
    1.17 -            // 
    1.18 -            // lbTitle
    1.19 -            // 
    1.20 -            this.lbTitle.AutoSize = true;
    1.21 -            this.lbTitle.Location = new System.Drawing.Point(12, 9);
    1.22 -            this.lbTitle.Name = "lbTitle";
    1.23 -            this.lbTitle.Size = new System.Drawing.Size(61, 13);
    1.24 -            this.lbTitle.TabIndex = 0;
    1.25 -            this.lbTitle.Text = "XML Ouput";
    1.26 -            // 
    1.27 -            // tbOutputFile
    1.28 -            // 
    1.29 -            this.tbOutputFile.Location = new System.Drawing.Point(15, 28);
    1.30 -            this.tbOutputFile.Name = "tbOutputFile";
    1.31 -            this.tbOutputFile.Size = new System.Drawing.Size(179, 20);
    1.32 -            this.tbOutputFile.TabIndex = 1;
    1.33 -            this.tbOutputFile.TextChanged += new System.EventHandler(this.tbOutputFile_Change);
    1.34 -            // 
    1.35 -            // bttnOutputSelect
    1.36 -            // 
    1.37 -            this.bttnOutputSelect.Location = new System.Drawing.Point(202, 28);
    1.38 -            this.bttnOutputSelect.Name = "bttnOutputSelect";
    1.39 -            this.bttnOutputSelect.Size = new System.Drawing.Size(32, 20);
    1.40 -            this.bttnOutputSelect.TabIndex = 2;
    1.41 -            this.bttnOutputSelect.Text = "...";
    1.42 -            this.bttnOutputSelect.UseVisualStyleBackColor = true;
    1.43 -            this.bttnOutputSelect.Click += new System.EventHandler(this.bttnOutputSelect_Click);
    1.44 -            // 
    1.45 -            // cbApplyTransform
    1.46 -            // 
    1.47 -            this.cbApplyTransform.AutoSize = true;
    1.48 -            this.cbApplyTransform.Location = new System.Drawing.Point(15, 54);
    1.49 -            this.cbApplyTransform.Name = "cbApplyTransform";
    1.50 -            this.cbApplyTransform.Size = new System.Drawing.Size(125, 17);
    1.51 -            this.cbApplyTransform.TabIndex = 3;
    1.52 -            this.cbApplyTransform.Text = "Apply XSL Transform";
    1.53 -            this.cbApplyTransform.UseVisualStyleBackColor = true;
    1.54 -            this.cbApplyTransform.CheckedChanged += new System.EventHandler(this.cbApplyTransform_CheckedChanged);
    1.55 -            // 
    1.56 -            // bttnExport
    1.57 -            // 
    1.58 -            this.bttnExport.Enabled = false;
    1.59 -            this.bttnExport.Location = new System.Drawing.Point(78, 116);
    1.60 -            this.bttnExport.Name = "bttnExport";
    1.61 -            this.bttnExport.Size = new System.Drawing.Size(75, 23);
    1.62 -            this.bttnExport.TabIndex = 5;
    1.63 -            this.bttnExport.Text = "&Export";
    1.64 -            this.bttnExport.UseVisualStyleBackColor = true;
    1.65 -            this.bttnExport.Click += new System.EventHandler(this.bttnExport_Click);
    1.66 -            // 
    1.67 -            // bttnCancel
    1.68 -            // 
    1.69 -            this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    1.70 -            this.bttnCancel.Location = new System.Drawing.Point(159, 116);
    1.71 -            this.bttnCancel.Name = "bttnCancel";
    1.72 -            this.bttnCancel.Size = new System.Drawing.Size(75, 23);
    1.73 -            this.bttnCancel.TabIndex = 6;
    1.74 -            this.bttnCancel.Text = "&Cancel";
    1.75 -            this.bttnCancel.UseVisualStyleBackColor = true;
    1.76 -            this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
    1.77 -            // 
    1.78 -            // tbXslPath
    1.79 -            // 
    1.80 -            this.tbXslPath.Enabled = false;
    1.81 -            this.tbXslPath.Location = new System.Drawing.Point(15, 77);
    1.82 -            this.tbXslPath.Name = "tbXslPath";
    1.83 -            this.tbXslPath.Size = new System.Drawing.Size(179, 20);
    1.84 -            this.tbXslPath.TabIndex = 7;
    1.85 -            // 
    1.86 -            // bttnXslSelect
    1.87 -            // 
    1.88 -            this.bttnXslSelect.Enabled = false;
    1.89 -            this.bttnXslSelect.Location = new System.Drawing.Point(202, 77);
    1.90 -            this.bttnXslSelect.Name = "bttnXslSelect";
    1.91 -            this.bttnXslSelect.Size = new System.Drawing.Size(32, 20);
    1.92 -            this.bttnXslSelect.TabIndex = 8;
    1.93 -            this.bttnXslSelect.Text = "...";
    1.94 -            this.bttnXslSelect.UseVisualStyleBackColor = true;
    1.95 -            this.bttnXslSelect.Click += new System.EventHandler(this.bttnXslSelect_Click);
    1.96 -            // 
    1.97 -            // FrmXmlExport
    1.98 -            // 
    1.99 -            this.AcceptButton = this.bttnExport;
   1.100 -            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   1.101 -            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
   1.102 -            this.CancelButton = this.bttnCancel;
   1.103 -            this.ClientSize = new System.Drawing.Size(241, 145);
   1.104 -            this.ControlBox = false;
   1.105 -            this.Controls.Add(this.bttnXslSelect);
   1.106 -            this.Controls.Add(this.tbXslPath);
   1.107 -            this.Controls.Add(this.bttnCancel);
   1.108 -            this.Controls.Add(this.bttnExport);
   1.109 -            this.Controls.Add(this.cbApplyTransform);
   1.110 -            this.Controls.Add(this.bttnOutputSelect);
   1.111 -            this.Controls.Add(this.tbOutputFile);
   1.112 -            this.Controls.Add(this.lbTitle);
   1.113 -            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
   1.114 -            this.Name = "FrmXmlExport";
   1.115 -            this.ShowIcon = false;
   1.116 -            this.ShowInTaskbar = false;
   1.117 -            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
   1.118 -            this.Text = "Export as XML";
   1.119 -            this.TopMost = true;
   1.120 -            this.Load += new System.EventHandler(this.FrmXmlExport_Load);
   1.121 -            this.ResumeLayout(false);
   1.122 -            this.PerformLayout();
   1.123 +			this.lbTitle = new IBBoard.Windows.Forms.IBBLabel();
   1.124 +			this.tbOutputFile = new System.Windows.Forms.TextBox();
   1.125 +			this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
   1.126 +			this.bttnOutputSelect = new IBBoard.Windows.Forms.IBBButton();
   1.127 +			this.cbApplyTransform = new System.Windows.Forms.CheckBox();
   1.128 +			this.bttnExport = new IBBoard.Windows.Forms.IBBButton();
   1.129 +			this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
   1.130 +			this.cbTransforms = new System.Windows.Forms.ComboBox();
   1.131 +			this.SuspendLayout();
   1.132 +			// 
   1.133 +			// lbTitle
   1.134 +			// 
   1.135 +			this.lbTitle.AutoSize = true;
   1.136 +			this.lbTitle.Location = new System.Drawing.Point(12, 9);
   1.137 +			this.lbTitle.Name = "lbTitle";
   1.138 +			this.lbTitle.Size = new System.Drawing.Size(61, 13);
   1.139 +			this.lbTitle.TabIndex = 0;
   1.140 +			this.lbTitle.Text = "XML Ouput";
   1.141 +			// 
   1.142 +			// tbOutputFile
   1.143 +			// 
   1.144 +			this.tbOutputFile.Location = new System.Drawing.Point(15, 28);
   1.145 +			this.tbOutputFile.Name = "tbOutputFile";
   1.146 +			this.tbOutputFile.Size = new System.Drawing.Size(179, 20);
   1.147 +			this.tbOutputFile.TabIndex = 1;
   1.148 +			this.tbOutputFile.TextChanged += new System.EventHandler(this.tbOutputFile_Change);
   1.149 +			// 
   1.150 +			// bttnOutputSelect
   1.151 +			// 
   1.152 +			this.bttnOutputSelect.Location = new System.Drawing.Point(202, 28);
   1.153 +			this.bttnOutputSelect.Name = "bttnOutputSelect";
   1.154 +			this.bttnOutputSelect.Size = new System.Drawing.Size(32, 20);
   1.155 +			this.bttnOutputSelect.TabIndex = 2;
   1.156 +			this.bttnOutputSelect.Text = "...";
   1.157 +			this.bttnOutputSelect.UseVisualStyleBackColor = true;
   1.158 +			this.bttnOutputSelect.Click += new System.EventHandler(this.bttnOutputSelect_Click);
   1.159 +			// 
   1.160 +			// cbApplyTransform
   1.161 +			// 
   1.162 +			this.cbApplyTransform.AutoSize = true;
   1.163 +			this.cbApplyTransform.Location = new System.Drawing.Point(15, 54);
   1.164 +			this.cbApplyTransform.Name = "cbApplyTransform";
   1.165 +			this.cbApplyTransform.Size = new System.Drawing.Size(125, 17);
   1.166 +			this.cbApplyTransform.TabIndex = 3;
   1.167 +			this.cbApplyTransform.Text = "Apply XSL Transform";
   1.168 +			this.cbApplyTransform.UseVisualStyleBackColor = true;
   1.169 +			this.cbApplyTransform.CheckedChanged += new System.EventHandler(this.cbApplyTransform_CheckedChanged);
   1.170 +			// 
   1.171 +			// bttnExport
   1.172 +			// 
   1.173 +			this.bttnExport.Enabled = false;
   1.174 +			this.bttnExport.Location = new System.Drawing.Point(78, 116);
   1.175 +			this.bttnExport.Name = "bttnExport";
   1.176 +			this.bttnExport.Size = new System.Drawing.Size(75, 23);
   1.177 +			this.bttnExport.TabIndex = 5;
   1.178 +			this.bttnExport.Text = "&Export";
   1.179 +			this.bttnExport.UseVisualStyleBackColor = true;
   1.180 +			this.bttnExport.Click += new System.EventHandler(this.bttnExport_Click);
   1.181 +			// 
   1.182 +			// bttnCancel
   1.183 +			// 
   1.184 +			this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
   1.185 +			this.bttnCancel.Location = new System.Drawing.Point(159, 116);
   1.186 +			this.bttnCancel.Name = "bttnCancel";
   1.187 +			this.bttnCancel.Size = new System.Drawing.Size(75, 23);
   1.188 +			this.bttnCancel.TabIndex = 6;
   1.189 +			this.bttnCancel.Text = "&Cancel";
   1.190 +			this.bttnCancel.UseVisualStyleBackColor = true;
   1.191 +			this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
   1.192 +			// 
   1.193 +			// cbTransforms
   1.194 +			// 
   1.195 +			this.cbTransforms.Enabled = false;
   1.196 +			this.cbTransforms.FormattingEnabled = true;
   1.197 +			this.cbTransforms.Location = new System.Drawing.Point(15, 78);
   1.198 +			this.cbTransforms.Name = "cbTransforms";
   1.199 +			this.cbTransforms.Size = new System.Drawing.Size(179, 21);
   1.200 +			this.cbTransforms.TabIndex = 7;
   1.201 +			// 
   1.202 +			// FrmXmlExport
   1.203 +			// 
   1.204 +			this.AcceptButton = this.bttnExport;
   1.205 +			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
   1.206 +			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
   1.207 +			this.CancelButton = this.bttnCancel;
   1.208 +			this.ClientSize = new System.Drawing.Size(241, 145);
   1.209 +			this.ControlBox = false;
   1.210 +			this.Controls.Add(this.cbTransforms);
   1.211 +			this.Controls.Add(this.bttnCancel);
   1.212 +			this.Controls.Add(this.bttnExport);
   1.213 +			this.Controls.Add(this.cbApplyTransform);
   1.214 +			this.Controls.Add(this.bttnOutputSelect);
   1.215 +			this.Controls.Add(this.tbOutputFile);
   1.216 +			this.Controls.Add(this.lbTitle);
   1.217 +			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
   1.218 +			this.Name = "FrmXmlExport";
   1.219 +			this.ShowIcon = false;
   1.220 +			this.ShowInTaskbar = false;
   1.221 +			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
   1.222 +			this.Text = "Export as XML";
   1.223 +			this.TopMost = true;
   1.224 +			this.ResumeLayout(false);
   1.225 +			this.PerformLayout();
   1.226  
   1.227          }
   1.228  
   1.229 @@ -155,8 +142,7 @@
   1.230          private Windows.Forms.IBBButton bttnOutputSelect;
   1.231          private System.Windows.Forms.CheckBox cbApplyTransform;
   1.232          private Windows.Forms.IBBButton bttnExport;
   1.233 -        private Windows.Forms.IBBButton bttnCancel;
   1.234 -        private System.Windows.Forms.TextBox tbXslPath;
   1.235 -        private Windows.Forms.IBBButton bttnXslSelect;
   1.236 +		private Windows.Forms.IBBButton bttnCancel;
   1.237 +		private System.Windows.Forms.ComboBox cbTransforms;
   1.238      }
   1.239  }
   1.240 \ No newline at end of file
     2.1 --- a/FrmXmlExport.cs	Sat Sep 01 16:12:48 2012 +0100
     2.2 +++ b/FrmXmlExport.cs	Wed Nov 28 20:54:34 2012 +0000
     2.3 @@ -20,11 +20,8 @@
     2.4          {
     2.5              InitializeComponent();
     2.6              myArmy = army;
     2.7 -        }
     2.8 -
     2.9 -        private void FrmXmlExport_Load(object sender, EventArgs e)
    2.10 -        {
    2.11 -            tbXslPath.Text = Directory.GetCurrentDirectory() + "\\xsl\\default_html.xsl";
    2.12 +			cbTransforms.DataSource = WarFoundryXmlWithXslExporter.GetDefault().GetXsltStreams();
    2.13 +			cbTransforms.DisplayMember = "Name";
    2.14          }
    2.15  
    2.16          private void bttnOutputSelect_Click(object sender, EventArgs e)
    2.17 @@ -54,7 +51,10 @@
    2.18              {
    2.19                  if (cbApplyTransform.Checked)
    2.20                  {
    2.21 -                    WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, tbXslPath.Text);
    2.22 +					using (Stream xsltStream = (Stream)cbTransforms.SelectedItem)
    2.23 +					{
    2.24 +						WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, xsltStream);
    2.25 +					}
    2.26                  }
    2.27                  else
    2.28                  {
    2.29 @@ -111,29 +111,12 @@
    2.30          {
    2.31              if (cbApplyTransform.Checked)
    2.32              {
    2.33 -                tbXslPath.Enabled = true;
    2.34 -                bttnXslSelect.Enabled = true;
    2.35 +                cbTransforms.Enabled = true;
    2.36              }
    2.37              else
    2.38              {
    2.39 -                tbXslPath.Enabled = false;
    2.40 -                bttnXslSelect.Enabled = false;
    2.41 +				cbTransforms.Enabled = false;
    2.42              }
    2.43          }
    2.44 -
    2.45 -        private void bttnXslSelect_Click(object sender, EventArgs e)
    2.46 -        {
    2.47 -            OpenFileDialog ofd = new OpenFileDialog();
    2.48 -            
    2.49 -            ofd.InitialDirectory = Directory.GetCurrentDirectory() + "\\xsl";
    2.50 -            ofd.Filter = "XSL Files|*.xsl";
    2.51 -            DialogResult result = ofd.ShowDialog();
    2.52 -
    2.53 -            if (result == DialogResult.OK)
    2.54 -            {
    2.55 -                tbXslPath.Text = ofd.FileName;
    2.56 -            }
    2.57 -          
    2.58 -        }
    2.59      }
    2.60  }
     3.1 --- a/FrmXmlExport.resx	Sat Sep 01 16:12:48 2012 +0100
     3.2 +++ b/FrmXmlExport.resx	Wed Nov 28 20:54:34 2012 +0000
     3.3 @@ -112,12 +112,12 @@
     3.4      <value>2.0</value>
     3.5    </resheader>
     3.6    <resheader name="reader">
     3.7 -    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     3.8 +    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
     3.9    </resheader>
    3.10    <resheader name="writer">
    3.11 -    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    3.12 +    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    3.13    </resheader>
    3.14 -  <metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    3.15 +  <metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
    3.16      <value>17, 17</value>
    3.17    </metadata>
    3.18  </root>
    3.19 \ No newline at end of file