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 wrap: on
line diff
--- a/FrmXmlExport.Designer.cs	Sat Sep 01 16:12:48 2012 +0100
+++ b/FrmXmlExport.Designer.cs	Wed Nov 28 20:54:34 2012 +0000
@@ -28,122 +28,109 @@
         /// </summary>
         private void InitializeComponent()
         {
-            this.lbTitle = new IBBoard.Windows.Forms.IBBLabel();
-            this.tbOutputFile = new System.Windows.Forms.TextBox();
-            this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
-            this.bttnOutputSelect = new IBBoard.Windows.Forms.IBBButton();
-            this.cbApplyTransform = new System.Windows.Forms.CheckBox();
-            this.bttnExport = new IBBoard.Windows.Forms.IBBButton();
-            this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
-            this.tbXslPath = new System.Windows.Forms.TextBox();
-            this.bttnXslSelect = new IBBoard.Windows.Forms.IBBButton();
-            this.SuspendLayout();
-            // 
-            // lbTitle
-            // 
-            this.lbTitle.AutoSize = true;
-            this.lbTitle.Location = new System.Drawing.Point(12, 9);
-            this.lbTitle.Name = "lbTitle";
-            this.lbTitle.Size = new System.Drawing.Size(61, 13);
-            this.lbTitle.TabIndex = 0;
-            this.lbTitle.Text = "XML Ouput";
-            // 
-            // tbOutputFile
-            // 
-            this.tbOutputFile.Location = new System.Drawing.Point(15, 28);
-            this.tbOutputFile.Name = "tbOutputFile";
-            this.tbOutputFile.Size = new System.Drawing.Size(179, 20);
-            this.tbOutputFile.TabIndex = 1;
-            this.tbOutputFile.TextChanged += new System.EventHandler(this.tbOutputFile_Change);
-            // 
-            // bttnOutputSelect
-            // 
-            this.bttnOutputSelect.Location = new System.Drawing.Point(202, 28);
-            this.bttnOutputSelect.Name = "bttnOutputSelect";
-            this.bttnOutputSelect.Size = new System.Drawing.Size(32, 20);
-            this.bttnOutputSelect.TabIndex = 2;
-            this.bttnOutputSelect.Text = "...";
-            this.bttnOutputSelect.UseVisualStyleBackColor = true;
-            this.bttnOutputSelect.Click += new System.EventHandler(this.bttnOutputSelect_Click);
-            // 
-            // cbApplyTransform
-            // 
-            this.cbApplyTransform.AutoSize = true;
-            this.cbApplyTransform.Location = new System.Drawing.Point(15, 54);
-            this.cbApplyTransform.Name = "cbApplyTransform";
-            this.cbApplyTransform.Size = new System.Drawing.Size(125, 17);
-            this.cbApplyTransform.TabIndex = 3;
-            this.cbApplyTransform.Text = "Apply XSL Transform";
-            this.cbApplyTransform.UseVisualStyleBackColor = true;
-            this.cbApplyTransform.CheckedChanged += new System.EventHandler(this.cbApplyTransform_CheckedChanged);
-            // 
-            // bttnExport
-            // 
-            this.bttnExport.Enabled = false;
-            this.bttnExport.Location = new System.Drawing.Point(78, 116);
-            this.bttnExport.Name = "bttnExport";
-            this.bttnExport.Size = new System.Drawing.Size(75, 23);
-            this.bttnExport.TabIndex = 5;
-            this.bttnExport.Text = "&Export";
-            this.bttnExport.UseVisualStyleBackColor = true;
-            this.bttnExport.Click += new System.EventHandler(this.bttnExport_Click);
-            // 
-            // bttnCancel
-            // 
-            this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
-            this.bttnCancel.Location = new System.Drawing.Point(159, 116);
-            this.bttnCancel.Name = "bttnCancel";
-            this.bttnCancel.Size = new System.Drawing.Size(75, 23);
-            this.bttnCancel.TabIndex = 6;
-            this.bttnCancel.Text = "&Cancel";
-            this.bttnCancel.UseVisualStyleBackColor = true;
-            this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
-            // 
-            // tbXslPath
-            // 
-            this.tbXslPath.Enabled = false;
-            this.tbXslPath.Location = new System.Drawing.Point(15, 77);
-            this.tbXslPath.Name = "tbXslPath";
-            this.tbXslPath.Size = new System.Drawing.Size(179, 20);
-            this.tbXslPath.TabIndex = 7;
-            // 
-            // bttnXslSelect
-            // 
-            this.bttnXslSelect.Enabled = false;
-            this.bttnXslSelect.Location = new System.Drawing.Point(202, 77);
-            this.bttnXslSelect.Name = "bttnXslSelect";
-            this.bttnXslSelect.Size = new System.Drawing.Size(32, 20);
-            this.bttnXslSelect.TabIndex = 8;
-            this.bttnXslSelect.Text = "...";
-            this.bttnXslSelect.UseVisualStyleBackColor = true;
-            this.bttnXslSelect.Click += new System.EventHandler(this.bttnXslSelect_Click);
-            // 
-            // FrmXmlExport
-            // 
-            this.AcceptButton = this.bttnExport;
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
-            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.CancelButton = this.bttnCancel;
-            this.ClientSize = new System.Drawing.Size(241, 145);
-            this.ControlBox = false;
-            this.Controls.Add(this.bttnXslSelect);
-            this.Controls.Add(this.tbXslPath);
-            this.Controls.Add(this.bttnCancel);
-            this.Controls.Add(this.bttnExport);
-            this.Controls.Add(this.cbApplyTransform);
-            this.Controls.Add(this.bttnOutputSelect);
-            this.Controls.Add(this.tbOutputFile);
-            this.Controls.Add(this.lbTitle);
-            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
-            this.Name = "FrmXmlExport";
-            this.ShowIcon = false;
-            this.ShowInTaskbar = false;
-            this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
-            this.Text = "Export as XML";
-            this.TopMost = true;
-            this.Load += new System.EventHandler(this.FrmXmlExport_Load);
-            this.ResumeLayout(false);
-            this.PerformLayout();
+			this.lbTitle = new IBBoard.Windows.Forms.IBBLabel();
+			this.tbOutputFile = new System.Windows.Forms.TextBox();
+			this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
+			this.bttnOutputSelect = new IBBoard.Windows.Forms.IBBButton();
+			this.cbApplyTransform = new System.Windows.Forms.CheckBox();
+			this.bttnExport = new IBBoard.Windows.Forms.IBBButton();
+			this.bttnCancel = new IBBoard.Windows.Forms.IBBButton();
+			this.cbTransforms = new System.Windows.Forms.ComboBox();
+			this.SuspendLayout();
+			// 
+			// lbTitle
+			// 
+			this.lbTitle.AutoSize = true;
+			this.lbTitle.Location = new System.Drawing.Point(12, 9);
+			this.lbTitle.Name = "lbTitle";
+			this.lbTitle.Size = new System.Drawing.Size(61, 13);
+			this.lbTitle.TabIndex = 0;
+			this.lbTitle.Text = "XML Ouput";
+			// 
+			// tbOutputFile
+			// 
+			this.tbOutputFile.Location = new System.Drawing.Point(15, 28);
+			this.tbOutputFile.Name = "tbOutputFile";
+			this.tbOutputFile.Size = new System.Drawing.Size(179, 20);
+			this.tbOutputFile.TabIndex = 1;
+			this.tbOutputFile.TextChanged += new System.EventHandler(this.tbOutputFile_Change);
+			// 
+			// bttnOutputSelect
+			// 
+			this.bttnOutputSelect.Location = new System.Drawing.Point(202, 28);
+			this.bttnOutputSelect.Name = "bttnOutputSelect";
+			this.bttnOutputSelect.Size = new System.Drawing.Size(32, 20);
+			this.bttnOutputSelect.TabIndex = 2;
+			this.bttnOutputSelect.Text = "...";
+			this.bttnOutputSelect.UseVisualStyleBackColor = true;
+			this.bttnOutputSelect.Click += new System.EventHandler(this.bttnOutputSelect_Click);
+			// 
+			// cbApplyTransform
+			// 
+			this.cbApplyTransform.AutoSize = true;
+			this.cbApplyTransform.Location = new System.Drawing.Point(15, 54);
+			this.cbApplyTransform.Name = "cbApplyTransform";
+			this.cbApplyTransform.Size = new System.Drawing.Size(125, 17);
+			this.cbApplyTransform.TabIndex = 3;
+			this.cbApplyTransform.Text = "Apply XSL Transform";
+			this.cbApplyTransform.UseVisualStyleBackColor = true;
+			this.cbApplyTransform.CheckedChanged += new System.EventHandler(this.cbApplyTransform_CheckedChanged);
+			// 
+			// bttnExport
+			// 
+			this.bttnExport.Enabled = false;
+			this.bttnExport.Location = new System.Drawing.Point(78, 116);
+			this.bttnExport.Name = "bttnExport";
+			this.bttnExport.Size = new System.Drawing.Size(75, 23);
+			this.bttnExport.TabIndex = 5;
+			this.bttnExport.Text = "&Export";
+			this.bttnExport.UseVisualStyleBackColor = true;
+			this.bttnExport.Click += new System.EventHandler(this.bttnExport_Click);
+			// 
+			// bttnCancel
+			// 
+			this.bttnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+			this.bttnCancel.Location = new System.Drawing.Point(159, 116);
+			this.bttnCancel.Name = "bttnCancel";
+			this.bttnCancel.Size = new System.Drawing.Size(75, 23);
+			this.bttnCancel.TabIndex = 6;
+			this.bttnCancel.Text = "&Cancel";
+			this.bttnCancel.UseVisualStyleBackColor = true;
+			this.bttnCancel.Click += new System.EventHandler(this.bttnCancel_Click);
+			// 
+			// cbTransforms
+			// 
+			this.cbTransforms.Enabled = false;
+			this.cbTransforms.FormattingEnabled = true;
+			this.cbTransforms.Location = new System.Drawing.Point(15, 78);
+			this.cbTransforms.Name = "cbTransforms";
+			this.cbTransforms.Size = new System.Drawing.Size(179, 21);
+			this.cbTransforms.TabIndex = 7;
+			// 
+			// FrmXmlExport
+			// 
+			this.AcceptButton = this.bttnExport;
+			this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+			this.CancelButton = this.bttnCancel;
+			this.ClientSize = new System.Drawing.Size(241, 145);
+			this.ControlBox = false;
+			this.Controls.Add(this.cbTransforms);
+			this.Controls.Add(this.bttnCancel);
+			this.Controls.Add(this.bttnExport);
+			this.Controls.Add(this.cbApplyTransform);
+			this.Controls.Add(this.bttnOutputSelect);
+			this.Controls.Add(this.tbOutputFile);
+			this.Controls.Add(this.lbTitle);
+			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+			this.Name = "FrmXmlExport";
+			this.ShowIcon = false;
+			this.ShowInTaskbar = false;
+			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
+			this.Text = "Export as XML";
+			this.TopMost = true;
+			this.ResumeLayout(false);
+			this.PerformLayout();
 
         }
 
@@ -155,8 +142,7 @@
         private Windows.Forms.IBBButton bttnOutputSelect;
         private System.Windows.Forms.CheckBox cbApplyTransform;
         private Windows.Forms.IBBButton bttnExport;
-        private Windows.Forms.IBBButton bttnCancel;
-        private System.Windows.Forms.TextBox tbXslPath;
-        private Windows.Forms.IBBButton bttnXslSelect;
+		private Windows.Forms.IBBButton bttnCancel;
+		private System.Windows.Forms.ComboBox cbTransforms;
     }
 }
\ No newline at end of file
--- a/FrmXmlExport.cs	Sat Sep 01 16:12:48 2012 +0100
+++ b/FrmXmlExport.cs	Wed Nov 28 20:54:34 2012 +0000
@@ -20,11 +20,8 @@
         {
             InitializeComponent();
             myArmy = army;
-        }
-
-        private void FrmXmlExport_Load(object sender, EventArgs e)
-        {
-            tbXslPath.Text = Directory.GetCurrentDirectory() + "\\xsl\\default_html.xsl";
+			cbTransforms.DataSource = WarFoundryXmlWithXslExporter.GetDefault().GetXsltStreams();
+			cbTransforms.DisplayMember = "Name";
         }
 
         private void bttnOutputSelect_Click(object sender, EventArgs e)
@@ -54,7 +51,10 @@
             {
                 if (cbApplyTransform.Checked)
                 {
-                    WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, tbXslPath.Text);
+					using (Stream xsltStream = (Stream)cbTransforms.SelectedItem)
+					{
+						WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, xsltStream);
+					}
                 }
                 else
                 {
@@ -111,29 +111,12 @@
         {
             if (cbApplyTransform.Checked)
             {
-                tbXslPath.Enabled = true;
-                bttnXslSelect.Enabled = true;
+                cbTransforms.Enabled = true;
             }
             else
             {
-                tbXslPath.Enabled = false;
-                bttnXslSelect.Enabled = false;
+				cbTransforms.Enabled = false;
             }
         }
-
-        private void bttnXslSelect_Click(object sender, EventArgs e)
-        {
-            OpenFileDialog ofd = new OpenFileDialog();
-            
-            ofd.InitialDirectory = Directory.GetCurrentDirectory() + "\\xsl";
-            ofd.Filter = "XSL Files|*.xsl";
-            DialogResult result = ofd.ShowDialog();
-
-            if (result == DialogResult.OK)
-            {
-                tbXslPath.Text = ofd.FileName;
-            }
-          
-        }
     }
 }
--- a/FrmXmlExport.resx	Sat Sep 01 16:12:48 2012 +0100
+++ b/FrmXmlExport.resx	Wed Nov 28 20:54:34 2012 +0000
@@ -112,12 +112,12 @@
     <value>2.0</value>
   </resheader>
   <resheader name="reader">
-    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
   </resheader>
-  <metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+  <metadata name="saveFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>17, 17</value>
   </metadata>
 </root>
\ No newline at end of file