Mercurial > repos > IBDev-IBBoard.WarFoundry.GUI.GTK
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 wrap: on
line diff
--- a/FrmMainWindow.cs Fri Aug 28 18:52:34 2009 +0000 +++ b/FrmMainWindow.cs Tue Sep 01 19:10:13 2009 +0000 @@ -15,6 +15,7 @@ using IBBoard.Logging; using IBBoard.CustomMath; using IBBoard.WarFoundry.API; +using IBBoard.WarFoundry.API.Exporters; using IBBoard.WarFoundry.API.Factories; using IBBoard.WarFoundry.API.Factories.Xml; using IBBoard.WarFoundry.API.Objects; @@ -959,5 +960,31 @@ unitToWidgetMap.Remove(((UnitDisplayWidget)sender).Unit); } } + + protected virtual void OnMiExportAsBasicHtmlActivated (object sender, System.EventArgs e) + { + FileChooserDialog fileDialog = new FileChooserDialog("Export army", this, FileChooserAction.Save, "Cancel", ResponseType.Cancel, "Export", ResponseType.Accept); + FileFilter filter = new FileFilter(); + filter.AddPattern("*.html"); + filter.Name = "HTML pages (*.html)"; + fileDialog.AddFilter(filter); + int response = fileDialog.Run(); + string filePath = null; + + if (response == (int)ResponseType.Accept) + { + filePath = fileDialog.Filename; + } + + fileDialog.Hide(); + fileDialog.Dispose(); + + if (filePath != null) + { + Army army = WarFoundryCore.CurrentArmy; + logger.DebugFormat("Exporting {0} to {1} as basic HTML", army.Name, filePath); + WarFoundryHtmlExporter.GetDefault().ExportArmy(army, filePath); + } + } } }
--- a/gtk-gui/IBBoard.WarFoundry.GTK.FrmMainWindow.cs Fri Aug 28 18:52:34 2009 +0000 +++ b/gtk-gui/IBBoard.WarFoundry.GTK.FrmMainWindow.cs Tue Sep 01 19:10:13 2009 +0000 @@ -59,6 +59,10 @@ private Gtk.Action add; + private Gtk.Action miExportArmy; + + private Gtk.Action miExportAsBasicHtml; + private Gtk.VBox vbox1; private Gtk.MenuBar menubar1; @@ -148,6 +152,12 @@ w1.Add(this.goDown, null); this.add = new Gtk.Action("add", null, null, "gtk-add"); w1.Add(this.add, null); + this.miExportArmy = new Gtk.Action("miExportArmy", Mono.Unix.Catalog.GetString("Export army as..."), null, "gtk-convert"); + this.miExportArmy.ShortLabel = Mono.Unix.Catalog.GetString("Export army"); + w1.Add(this.miExportArmy, null); + this.miExportAsBasicHtml = new Gtk.Action("miExportAsBasicHtml", Mono.Unix.Catalog.GetString("Basic HTML"), null, null); + this.miExportAsBasicHtml.ShortLabel = Mono.Unix.Catalog.GetString("Basic HTML"); + w1.Add(this.miExportAsBasicHtml, null); this.UIManager.InsertActionGroup(w1, 0); this.AddAccelGroup(this.UIManager.AccelGroup); this.Name = "IBBoard.WarFoundry.GTK.FrmMainWindow"; @@ -157,7 +167,7 @@ this.vbox1 = new Gtk.VBox(); this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - 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>"); + 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>"); this.menubar1 = ((Gtk.MenuBar)(this.UIManager.GetWidget("/menubar1"))); this.menubar1.Name = "menubar1"; this.vbox1.Add(this.menubar1); @@ -227,6 +237,7 @@ this.saveArmyButton.Activated += new System.EventHandler(this.saveTBButtonActivated); this.undoActionButton.Activated += new System.EventHandler(this.undoTBButtonActivated); this.redoActionButton.Activated += new System.EventHandler(this.redoTBButtonActivated); + this.miExportAsBasicHtml.Activated += new System.EventHandler(this.OnMiExportAsBasicHtmlActivated); this.treeUnits.RowActivated += new Gtk.RowActivatedHandler(this.ArmyRowActivated); } }
--- a/gtk-gui/gui.stetic Fri Aug 28 18:52:34 2009 +0000 +++ b/gtk-gui/gui.stetic Tue Sep 01 19:10:13 2009 +0000 @@ -153,6 +153,18 @@ <property name="Label" translatable="yes" /> <property name="StockId">gtk-add</property> </action> + <action id="miExportArmy"> + <property name="Type">Action</property> + <property name="Label" translatable="yes">Export army as...</property> + <property name="ShortLabel" translatable="yes">Export army</property> + <property name="StockId">gtk-convert</property> + </action> + <action id="miExportAsBasicHtml"> + <property name="Type">Action</property> + <property name="Label" translatable="yes">Basic HTML</property> + <property name="ShortLabel" translatable="yes">Basic HTML</property> + <signal name="Activated" handler="OnMiExportAsBasicHtmlActivated" /> + </action> </action-group> <property name="MemberName" /> <property name="Title" translatable="yes">MainWindow</property> @@ -169,6 +181,9 @@ <node type="Menuitem" action="miOpenArmy" /> <node type="Menuitem" action="miSaveArmy" /> <node type="Menuitem" action="miSaveArmyAs" /> + <node type="Menu" action="miExportArmy"> + <node type="Menuitem" action="miExportAsBasicHtml" /> + </node> <node type="Menuitem" action="miCloseArmy" /> <node type="Separator" /> <node type="Menuitem" action="miChangeGameSystem" />