[longomatch] Make the exporter decide it's file
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Make the exporter decide it's file
- Date: Mon, 19 Dec 2011 23:47:58 +0000 (UTC)
commit 5feefed062128c43bb7ff9bfd9008454b4811e12
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Dec 20 00:44:24 2011 +0100
Make the exporter decide it's file
LongoMatch.Addins.COE/ExcelExporter.cs | 21 +++++++++++++++++--
LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp | 5 +--
LongoMatch.Addins/AddinsManager.cs | 2 +-
.../ExtensionPoints/IExportProject.cs | 2 +-
LongoMatch.Core/Interfaces/GUI/IMainWindow.cs | 2 +-
LongoMatch.GUI/Gui/MainWindow.cs | 16 +-------------
6 files changed, 25 insertions(+), 23 deletions(-)
---
diff --git a/LongoMatch.Addins.COE/ExcelExporter.cs b/LongoMatch.Addins.COE/ExcelExporter.cs
index bc29d67..14bdea0 100644
--- a/LongoMatch.Addins.COE/ExcelExporter.cs
+++ b/LongoMatch.Addins.COE/ExcelExporter.cs
@@ -28,6 +28,7 @@ using OfficeOpenXml.Style;
using LongoMatch;
using LongoMatch.Addins.ExtensionPoints;
using LongoMatch.Interfaces;
+using LongoMatch.Interfaces.GUI;
using LongoMatch.Store;
using LongoMatch.Common;
@@ -43,9 +44,23 @@ public class ExcelExporter:IExportProject
return "EPPLUSExport";
}
- public void ExportProject (Project project, string filename) {
- EPPLUSExporter exporter = new EPPLUSExporter(project, filename);
- exporter.Export();
+ public void ExportProject (Project project, IGUIToolkit guiToolkit) {
+ string filename = guiToolkit.SaveFile(Catalog.GetString("Output file"), null,
+ Config.HomeDir(), "Excel", ".xlsx");
+
+ if (filename == null)
+ return;
+
+ System.IO.Path.ChangeExtension(filename, ".xlsx");
+
+ try {
+ EPPLUSExporter exporter = new EPPLUSExporter(project, filename);
+ exporter.Export();
+ guiToolkit.InfoMessage(Catalog.GetString("Project exported successfully"));
+ }catch (Exception ex) {
+ guiToolkit.ErrorMessage(Catalog.GetString("Error exporting project"));
+ Log.Exception(ex);
+ }
}
}
diff --git a/LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp b/LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp
index f391a3a..3cca818 100644
--- a/LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp
+++ b/LongoMatch.Addins.COE/LongoMatch.Addins.COE.mdp
@@ -2,13 +2,13 @@
<Configurations active="Release">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="../bin" assembly="LongoMatch.Addins.COE" />
- <Build debugmode="True" target="Exe" />
+ <Build debugmode="True" target="Library" />
<Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
<CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
<Configuration name="Release" ctype="DotNetProjectConfiguration">
<Output directory="../bin" assembly="LongoMatch.Addins.COE" />
- <Build debugmode="False" target="Exe" />
+ <Build debugmode="False" target="Library" />
<Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
<CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
</Configuration>
@@ -17,7 +17,6 @@
<File subtype="Code" buildaction="Compile" name="GameUnitsEnabler.cs" />
<File subtype="Code" buildaction="Compile" name="ExcelExporter.cs" />
<File subtype="Code" buildaction="Compile" name="Assembly.cs" />
- <File subtype="Code" buildaction="Compile" name="Main.cs" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="Mono.Addins, Version=0.6.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
diff --git a/LongoMatch.Addins/AddinsManager.cs b/LongoMatch.Addins/AddinsManager.cs
index 5b29e40..72f4eec 100644
--- a/LongoMatch.Addins/AddinsManager.cs
+++ b/LongoMatch.Addins/AddinsManager.cs
@@ -46,7 +46,7 @@ namespace LongoMatch.Addins
public void LoadExportProjectAddins(IMainWindow mainWindow) {
foreach (IExportProject exportProject in AddinManager.GetExtensionObjects<IExportProject> ()) {
mainWindow.AddExportEntry(exportProject.GetMenuEntryName(), exportProject.GetMenuEntryShortName(),
- new Action<Project, string>(exportProject.ExportProject));
+ new Action<Project, IGUIToolkit>(exportProject.ExportProject));
}
}
diff --git a/LongoMatch.Addins/ExtensionPoints/IExportProject.cs b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
index cac3193..05816d5 100644
--- a/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
+++ b/LongoMatch.Addins/ExtensionPoints/IExportProject.cs
@@ -28,7 +28,7 @@ namespace LongoMatch.Addins.ExtensionPoints
{
string GetMenuEntryName();
string GetMenuEntryShortName();
- void ExportProject(Project project, string filename);
+ void ExportProject(Project project, IGUIToolkit guiToolkit);
}
}
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
index 761b469..48a351f 100644
--- a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -84,7 +84,7 @@ namespace LongoMatch.Interfaces.GUI
ICapturer Capturer{get;}
IPlaylistWidget Playlist{get;}
- void AddExportEntry (string name, string shortName, Action<Project, string> exportAction);
+ void AddExportEntry (string name, string shortName, Action<Project, IGUIToolkit> exportAction);
}
}
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index b52db74..556470a 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -198,25 +198,13 @@ namespace LongoMatch.Gui
gameunitstaggerwidget1.GameUnits = gameUnits;
}
- public void AddExportEntry (string name, string shortName, Action<Project, string> exportAction) {
+ public void AddExportEntry (string name, string shortName, Action<Project, IGUIToolkit> exportAction) {
string filename;
MenuItem parent = (MenuItem) this.UIManager.GetWidget("/menubar1/ToolsAction/ExportProjectAction1");
MenuItem item = new MenuItem(name);
- item.Activated += (sender, e) => {
- filename = guiToolKit.SaveFile(Catalog.GetString("Output file"), null,
- Config.HomeDir(), null, null);
-
- if (filename == null)
- return;
-
- try {
- exportAction(openedProject, filename);
- guiToolKit.InfoMessage(Catalog.GetString("Project exported successfully"));
- }catch (Exception ex) {
- guiToolKit.ErrorMessage(Catalog.GetString("Error exporting project"));
- Log.Exception(ex);}};
+ item.Activated += (sender, e) => (exportAction(openedProject, guiToolKit));
item.Show();
(parent.Submenu as Menu).Append(item);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]