changeset 28:9440eef124b0

Closes #69: Add "export" UI * Add base menu for exports (will be populated automatically once exports are plugins) * Add menu item for "Basic HTML"
author IBBoard <dev@ibboard.co.uk>
date Tue, 01 Sep 2009 19:10:13 +0000
parents 83c8945edac2
children 2e5448a662b6
files FrmMainWindow.cs gtk-gui/IBBoard.WarFoundry.GTK.FrmMainWindow.cs gtk-gui/gui.stetic
diffstat 3 files changed, 54 insertions(+), 1 deletions(-) [+]
line diff
     1.1 --- a/FrmMainWindow.cs	Fri Aug 28 18:52:34 2009 +0000
     1.2 +++ b/FrmMainWindow.cs	Tue Sep 01 19:10:13 2009 +0000
     1.3 @@ -15,6 +15,7 @@
     1.4  using IBBoard.Logging;
     1.5  using IBBoard.CustomMath;
     1.6  using IBBoard.WarFoundry.API;
     1.7 +using IBBoard.WarFoundry.API.Exporters;
     1.8  using IBBoard.WarFoundry.API.Factories;
     1.9  using IBBoard.WarFoundry.API.Factories.Xml;
    1.10  using IBBoard.WarFoundry.API.Objects;
    1.11 @@ -959,5 +960,31 @@
    1.12  				unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit);
    1.13  			}
    1.14  		}
    1.15 +
    1.16 +		protected virtual void OnMiExportAsBasicHtmlActivated (object sender, System.EventArgs e)
    1.17 +		{
    1.18 +			FileChooserDialog fileDialog = new FileChooserDialog("Export army", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Export", ResponseType.Accept);
    1.19 +			FileFilter filter = new FileFilter();
    1.20 +			filter.AddPattern("*.html");
    1.21 +			filter.Name = "HTML pages (*.html)";
    1.22 +			fileDialog.AddFilter(filter);
    1.23 +			int response = fileDialog.Run();
    1.24 +			string filePath = null;
    1.25 +			
    1.26 +			if (response == (int)ResponseType.Accept)
    1.27 +			{
    1.28 +				filePath = fileDialog.Filename;
    1.29 +			}
    1.30 +			
    1.31 +			fileDialog.Hide();			
    1.32 +			fileDialog.Dispose();
    1.33 +
    1.34 +			if (filePath != null)
    1.35 +			{
    1.36 +				Army army = WarFoundryCore.CurrentArmy;
    1.37 +				logger.DebugFormat("Exporting {0} to {1} as basic HTML", army.Name, filePath);
    1.38 +				WarFoundryHtmlExporter.GetDefault().ExportArmy(army, filePath);
    1.39 +			}
    1.40 +		}
    1.41  	}
    1.42  }
     2.1 --- a/gtk-gui/IBBoard.WarFoundry.GTK.FrmMainWindow.cs	Fri Aug 28 18:52:34 2009 +0000
     2.2 +++ b/gtk-gui/IBBoard.WarFoundry.GTK.FrmMainWindow.cs	Tue Sep 01 19:10:13 2009 +0000
     2.3 @@ -59,6 +59,10 @@
     2.4          
     2.5          private Gtk.Action add;
     2.6          
     2.7 +        private Gtk.Action miExportArmy;
     2.8 +        
     2.9 +        private Gtk.Action miExportAsBasicHtml;
    2.10 +        
    2.11          private Gtk.VBox vbox1;
    2.12          
    2.13          private Gtk.MenuBar menubar1;
    2.14 @@ -148,6 +152,12 @@
    2.15              w1.Add(this.goDown, null);
    2.16              this.add = new Gtk.Action("add", null, null, "gtk-add");
    2.17              w1.Add(this.add, null);
    2.18 +            this.miExportArmy = new Gtk.Action("miExportArmy", Mono.Unix.Catalog.GetString("Export army as..."), null, "gtk-convert");
    2.19 +            this.miExportArmy.ShortLabel = Mono.Unix.Catalog.GetString("Export army");
    2.20 +            w1.Add(this.miExportArmy, null);
    2.21 +            this.miExportAsBasicHtml = new Gtk.Action("miExportAsBasicHtml", Mono.Unix.Catalog.GetString("Basic HTML"), null, null);
    2.22 +            this.miExportAsBasicHtml.ShortLabel = Mono.Unix.Catalog.GetString("Basic HTML");
    2.23 +            w1.Add(this.miExportAsBasicHtml, null);
    2.24              this.UIManager.InsertActionGroup(w1, 0);
    2.25              this.AddAccelGroup(this.UIManager.AccelGroup);
    2.26              this.Name = "IBBoard.WarFoundry.GTK.FrmMainWindow";
    2.27 @@ -157,7 +167,7 @@
    2.28              this.vbox1 = new Gtk.VBox();
    2.29              this.vbox1.Name = "vbox1";
    2.30              // Container child vbox1.Gtk.Box+BoxChild
    2.31 -            this.UIManager.AddUiFromString("<ui><menubar name='menubar1'><menu name='menuFile' action='menuFile'><menuitem name='miCreateArmy' action='miCreateArmy'/><menuitem name='miOpenArmy' action='miOpenArmy'/><menuitem name='miSaveArmy' action='miSaveArmy'/><menuitem name='miSaveArmyAs' action='miSaveArmyAs'/><menuitem name='miCloseArmy' action='miCloseArmy'/><separator/><menuitem name='miChangeGameSystem' action='miChangeGameSystem'/><separator/><menuitem name='miReloadFiles' action='miReloadFiles'/><separator/><menuitem name='miExit' action='miExit'/></menu><menu name='menuEdit' action='menuEdit'><menuitem name='miUndo' action='miUndo'/><menuitem name='miRedo' action='miRedo'/></menu><menu name='menuHelp' action='menuHelp'><menuitem name='miAbout' action='miAbout'/><menuitem name='miDebugInformation' action='miDebugInformation'/></menu></menubar></ui>");
    2.32 +            this.UIManager.AddUiFromString("<ui><menubar name='menubar1'><menu name='menuFile' action='menuFile'><menuitem name='miCreateArmy' action='miCreateArmy'/><menuitem name='miOpenArmy' action='miOpenArmy'/><menuitem name='miSaveArmy' action='miSaveArmy'/><menuitem name='miSaveArmyAs' action='miSaveArmyAs'/><menu name='miExportArmy' action='miExportArmy'><menuitem name='miExportAsBasicHtml' action='miExportAsBasicHtml'/></menu><menuitem name='miCloseArmy' action='miCloseArmy'/><separator/><menuitem name='miChangeGameSystem' action='miChangeGameSystem'/><separator/><menuitem name='miReloadFiles' action='miReloadFiles'/><separator/><menuitem name='miExit' action='miExit'/></menu><menu name='menuEdit' action='menuEdit'><menuitem name='miUndo' action='miUndo'/><menuitem name='miRedo' action='miRedo'/></menu><menu name='menuHelp' action='menuHelp'><menuitem name='miAbout' action='miAbout'/><menuitem name='miDebugInformation' action='miDebugInformation'/></menu></menubar></ui>");
    2.33              this.menubar1 = ((Gtk.MenuBar)(this.UIManager.GetWidget("/menubar1")));
    2.34              this.menubar1.Name = "menubar1";
    2.35              this.vbox1.Add(this.menubar1);
    2.36 @@ -227,6 +237,7 @@
    2.37              this.saveArmyButton.Activated += new System.EventHandler(this.saveTBButtonActivated);
    2.38              this.undoActionButton.Activated += new System.EventHandler(this.undoTBButtonActivated);
    2.39              this.redoActionButton.Activated += new System.EventHandler(this.redoTBButtonActivated);
    2.40 +            this.miExportAsBasicHtml.Activated += new System.EventHandler(this.OnMiExportAsBasicHtmlActivated);
    2.41              this.treeUnits.RowActivated += new Gtk.RowActivatedHandler(this.ArmyRowActivated);
    2.42          }
    2.43      }
     3.1 --- a/gtk-gui/gui.stetic	Fri Aug 28 18:52:34 2009 +0000
     3.2 +++ b/gtk-gui/gui.stetic	Tue Sep 01 19:10:13 2009 +0000
     3.3 @@ -153,6 +153,18 @@
     3.4          <property name="Label" translatable="yes" />
     3.5          <property name="StockId">gtk-add</property>
     3.6        </action>
     3.7 +      <action id="miExportArmy">
     3.8 +        <property name="Type">Action</property>
     3.9 +        <property name="Label" translatable="yes">Export army as...</property>
    3.10 +        <property name="ShortLabel" translatable="yes">Export army</property>
    3.11 +        <property name="StockId">gtk-convert</property>
    3.12 +      </action>
    3.13 +      <action id="miExportAsBasicHtml">
    3.14 +        <property name="Type">Action</property>
    3.15 +        <property name="Label" translatable="yes">Basic HTML</property>
    3.16 +        <property name="ShortLabel" translatable="yes">Basic HTML</property>
    3.17 +        <signal name="Activated" handler="OnMiExportAsBasicHtmlActivated" />
    3.18 +      </action>
    3.19      </action-group>
    3.20      <property name="MemberName" />
    3.21      <property name="Title" translatable="yes">MainWindow</property>
    3.22 @@ -169,6 +181,9 @@
    3.23                  <node type="Menuitem" action="miOpenArmy" />
    3.24                  <node type="Menuitem" action="miSaveArmy" />
    3.25                  <node type="Menuitem" action="miSaveArmyAs" />
    3.26 +                <node type="Menu" action="miExportArmy">
    3.27 +                  <node type="Menuitem" action="miExportAsBasicHtml" />
    3.28 +                </node>
    3.29                  <node type="Menuitem" action="miCloseArmy" />
    3.30                  <node type="Separator" />
    3.31                  <node type="Menuitem" action="miChangeGameSystem" />