# HG changeset patch # User IBBoard # Date 1354136074 0 # Node ID 4d25c42bbe7b2d9b05b01a815a2eb0cb9939177a # Parent b57a7cf844f894cfc71260e9eb8f591b2be45cda Re #419: Remove assumptions of a file-based install * Swap to drop-down in WinForms * Update to use streams diff -r b57a7cf844f8 -r 4d25c42bbe7b FrmXmlExport.Designer.cs --- 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 @@ /// 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 diff -r b57a7cf844f8 -r 4d25c42bbe7b FrmXmlExport.cs --- 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; - } - - } } } diff -r b57a7cf844f8 -r 4d25c42bbe7b FrmXmlExport.resx --- 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 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + 17, 17 \ No newline at end of file