Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.WinForms
view FrmXmlExport.cs @ 218:83685ed69c69 xml-export-ui
Fixed menu to inherit properly for translation services to work
author | Dan.Kulinski@dank-laptop.Global.Local |
---|---|
date | Mon, 22 Aug 2011 17:20:05 -0600 |
parents | a0df71b24972 |
children | a3e62a2c267f |
line wrap: on
line source
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.IO; using System.Windows.Forms; using System.Xml.Xsl; using IBBoard.WarFoundry.API.Objects; using IBBoard.WarFoundry.API.Exporters; namespace IBBoard.WarFoundry.GUI.WinForms { public partial class FrmXmlExport : Form { Army myArmy = null; public FrmXmlExport(Army army) { InitializeComponent(); myArmy = army; } private void FrmXmlExport_Load(object sender, EventArgs e) { tbXslPath.Text = Directory.GetCurrentDirectory() + "\\xsl\\default_html.xsl"; } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { } private void bttnOutputSelect_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "XML File|*.xml|HTML File|*.html|XHTML File|*.xhtml"; sfd.Title = "Save XML output"; sfd.ShowDialog(); if (sfd.FileName != "") { tbOutputFile.Text = sfd.FileName; } } private void bttnCancel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; this.Hide(); } private void bttnExport_Click(object sender, EventArgs e) { if (cbApplyTransform.Checked) { try { WarFoundryXmlWithXslExporter.GetDefault().ExportArmyWithTransform(myArmy, tbOutputFile.Text, tbXslPath.Text); } catch (Exception ex) { MessageBox.Show(this, "Sorry, but an error occurred during export.", "Error on export", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } else { WarFoundryXmlWithXslExporter.GetDefault().ExportArmy(myArmy, tbOutputFile.Text); } this.DialogResult = DialogResult.OK; this.Hide(); } private void tbOutputFile_Change(object sender, EventArgs e) { if (tbOutputFile.Text != "") { bttnExport.Enabled = true; } else { bttnExport.Enabled = false; } } private void cbApplyTransform_CheckedChanged(object sender, EventArgs e) { if (cbApplyTransform.Checked) { tbXslPath.Enabled = true; bttnXslSelect.Enabled = true; } else { tbXslPath.Enabled = false; bttnXslSelect.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; } } } }