diff --git a/Greenshot-OCR-Plugin/Greenshot-OCR-Plugin.csproj b/Greenshot-OCR-Plugin/Greenshot-OCR-Plugin.csproj
index 9a22173b5..1a134d0be 100644
--- a/Greenshot-OCR-Plugin/Greenshot-OCR-Plugin.csproj
+++ b/Greenshot-OCR-Plugin/Greenshot-OCR-Plugin.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
lib\MODI11.dll
@@ -76,12 +76,12 @@
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
-
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
+
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
diff --git a/Greenshot-OCR-Plugin/Language.cs b/Greenshot-OCR-Plugin/Language.cs
index 90788ff70..c917869ba 100644
--- a/Greenshot-OCR-Plugin/Language.cs
+++ b/Greenshot-OCR-Plugin/Language.cs
@@ -24,7 +24,7 @@ using System.Globalization;
using System.Resources;
using System.Threading;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotOCR {
///
diff --git a/Greenshot-OCR-Plugin/OCRPlugin.cs b/Greenshot-OCR-Plugin/OCRPlugin.cs
index 8917ed043..031651449 100644
--- a/Greenshot-OCR-Plugin/OCRPlugin.cs
+++ b/Greenshot-OCR-Plugin/OCRPlugin.cs
@@ -28,8 +28,9 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Windows.Forms;
+using Greenshot.Capturing;
+using Greenshot.Core;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
using Microsoft.Win32;
namespace GreenshotOCR {
diff --git a/Greenshot-OCR-Plugin/SettingsForm.cs b/Greenshot-OCR-Plugin/SettingsForm.cs
index 5b481c21e..b353c18b0 100644
--- a/Greenshot-OCR-Plugin/SettingsForm.cs
+++ b/Greenshot-OCR-Plugin/SettingsForm.cs
@@ -23,7 +23,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotOCR {
///
diff --git a/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj b/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
index 03bfc7759..9507582c3 100644
--- a/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
+++ b/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
@@ -65,9 +65,9 @@
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
\ No newline at end of file
diff --git a/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs b/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
index e0b1e9c07..160023fb0 100644
--- a/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
+++ b/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
@@ -28,6 +28,7 @@ using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
+using Greenshot.Capturing;
using Greenshot.Plugin;
namespace RunAtOutput {
diff --git a/Greenshot-TitleFix-Plugin/FixTitle.cs b/Greenshot-TitleFix-Plugin/FixTitle.cs
index 4a88196df..21a8651db 100644
--- a/Greenshot-TitleFix-Plugin/FixTitle.cs
+++ b/Greenshot-TitleFix-Plugin/FixTitle.cs
@@ -25,8 +25,9 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
+using Greenshot.Capturing;
+using Greenshot.Core;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
namespace FixTitle {
///
diff --git a/Greenshot-TitleFix-Plugin/Greenshot-TitleFix-Plugin.csproj b/Greenshot-TitleFix-Plugin/Greenshot-TitleFix-Plugin.csproj
index 938eac514..7625fe9e2 100644
--- a/Greenshot-TitleFix-Plugin/Greenshot-TitleFix-Plugin.csproj
+++ b/Greenshot-TitleFix-Plugin/Greenshot-TitleFix-Plugin.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
@@ -58,9 +58,9 @@ copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(SolutionDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
\ No newline at end of file
diff --git a/Greenshot/Configuration/AppConfig.cs b/Greenshot/Configuration/AppConfig.cs
index 3394a4758..abd1d74ea 100644
--- a/Greenshot/Configuration/AppConfig.cs
+++ b/Greenshot/Configuration/AppConfig.cs
@@ -31,9 +31,9 @@ using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using System.Windows.Forms;
+using Greenshot.Core;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
-using GreenshotPlugin.Core;
namespace Greenshot.Configuration {
public enum ScreenshotDestinations {Editor=1, FileDefault=2, FileWithDialog=4, Clipboard=8, Printer=16, EMail=32}
diff --git a/Greenshot/Configuration/Language.cs b/Greenshot/Configuration/Language.cs
index cbf3d8d40..9ce6cfbf7 100644
--- a/Greenshot/Configuration/Language.cs
+++ b/Greenshot/Configuration/Language.cs
@@ -27,7 +27,7 @@ using System.Threading;
using System.Windows.Forms;
using System.Xml;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot.Configuration {
///
diff --git a/Greenshot/Forms/AboutForm.cs b/Greenshot/Forms/AboutForm.cs
index 50ffb2f1a..c09da092e 100644
--- a/Greenshot/Forms/AboutForm.cs
+++ b/Greenshot/Forms/AboutForm.cs
@@ -24,7 +24,7 @@ using System.Reflection;
using System.Windows.Forms;
using Greenshot.Configuration;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot {
///
diff --git a/Greenshot/Forms/BugReportForm.cs b/Greenshot/Forms/BugReportForm.cs
index fd165b5fa..3bc07ed38 100644
--- a/Greenshot/Forms/BugReportForm.cs
+++ b/Greenshot/Forms/BugReportForm.cs
@@ -25,8 +25,8 @@ using System.Web;
using System.Windows.Forms;
using Greenshot.Configuration;
+using Greenshot.Core;
using Greenshot.Helpers;
-using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class BugReportForm : Form {
diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs
index eacc421b6..4e083e37d 100644
--- a/Greenshot/Forms/CaptureForm.cs
+++ b/Greenshot/Forms/CaptureForm.cs
@@ -31,11 +31,11 @@ using System.Windows.Forms;
using Greenshot.Capturing;
using Greenshot.Configuration;
+using Greenshot.Core;
using Greenshot.Drawing;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.UnmanagedHelpers;
-using GreenshotPlugin.Core;
namespace Greenshot.Forms {
///
diff --git a/Greenshot/Forms/ColorDialog.cs b/Greenshot/Forms/ColorDialog.cs
index 08f4ff8c7..4a6679ea7 100644
--- a/Greenshot/Forms/ColorDialog.cs
+++ b/Greenshot/Forms/ColorDialog.cs
@@ -26,7 +26,7 @@ using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot {
///
diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs
index d410749d3..f33ca942d 100644
--- a/Greenshot/Forms/ImageEditorForm.cs
+++ b/Greenshot/Forms/ImageEditorForm.cs
@@ -41,7 +41,7 @@ using Greenshot.Drawing.Fields.Binding;
using Greenshot.Help;
using Greenshot.Helpers;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot.Forms {
///
diff --git a/Greenshot/Forms/JpegQualityDialog.cs b/Greenshot/Forms/JpegQualityDialog.cs
index fc8e6aa96..fe0b68655 100644
--- a/Greenshot/Forms/JpegQualityDialog.cs
+++ b/Greenshot/Forms/JpegQualityDialog.cs
@@ -23,7 +23,7 @@ using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot {
///
diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs
index 43c30e6ad..00144b8f5 100644
--- a/Greenshot/Forms/MainForm.cs
+++ b/Greenshot/Forms/MainForm.cs
@@ -39,7 +39,7 @@ using Greenshot.Help;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.UnmanagedHelpers;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot {
///
diff --git a/Greenshot/Forms/PrintOptionsDialog.cs b/Greenshot/Forms/PrintOptionsDialog.cs
index 30db2ab1e..4b6440f46 100644
--- a/Greenshot/Forms/PrintOptionsDialog.cs
+++ b/Greenshot/Forms/PrintOptionsDialog.cs
@@ -23,7 +23,7 @@ using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot.Forms {
///
diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs
index 467d6d284..3d05e2865 100644
--- a/Greenshot/Forms/SettingsForm.cs
+++ b/Greenshot/Forms/SettingsForm.cs
@@ -29,7 +29,7 @@ using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Helpers;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot {
///
diff --git a/Greenshot/Help/HelpBrowserForm.cs b/Greenshot/Help/HelpBrowserForm.cs
index 34a345a36..410820ee7 100644
--- a/Greenshot/Help/HelpBrowserForm.cs
+++ b/Greenshot/Help/HelpBrowserForm.cs
@@ -21,7 +21,7 @@
using System;
using System.IO;
using Greenshot.Configuration;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Greenshot.Help {
///
diff --git a/Greenshot/Helpers/ClipboardHelper.cs b/Greenshot/Helpers/ClipboardHelper.cs
index 32b58dfb2..fe1eb15d2 100644
--- a/Greenshot/Helpers/ClipboardHelper.cs
+++ b/Greenshot/Helpers/ClipboardHelper.cs
@@ -29,9 +29,9 @@ using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
+using Greenshot.Core;
using Greenshot.Drawing;
using Greenshot.UnmanagedHelpers;
-using GreenshotPlugin.Core;
namespace Greenshot.Helpers {
///
diff --git a/Greenshot/Helpers/PrintHelper.cs b/Greenshot/Helpers/PrintHelper.cs
index be5654366..8caa61665 100644
--- a/Greenshot/Helpers/PrintHelper.cs
+++ b/Greenshot/Helpers/PrintHelper.cs
@@ -26,9 +26,9 @@ using System.Windows.Forms;
using Greenshot.Capturing;
using Greenshot.Configuration;
+using Greenshot.Core;
using Greenshot.Forms;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
namespace Greenshot.Helpers {
///
diff --git a/Greenshot/Helpers/WindowsHelper.cs b/Greenshot/Helpers/WindowsHelper.cs
index 5007d0dab..a7a3cc08a 100644
--- a/Greenshot/Helpers/WindowsHelper.cs
+++ b/Greenshot/Helpers/WindowsHelper.cs
@@ -29,8 +29,8 @@ using System.Text;
using System.Threading;
using System.Windows.Forms;
+using Greenshot.Core;
using Greenshot.UnmanagedHelpers;
-using GreenshotPlugin.Core;
///
/// Code for handling with "windows"
diff --git a/Greenshot/releases/innosetup/setup.iss b/Greenshot/releases/innosetup/setup.iss
index ea092d402..1145d735d 100644
--- a/Greenshot/releases/innosetup/setup.iss
+++ b/Greenshot/releases/innosetup/setup.iss
@@ -3,8 +3,8 @@ Source: ..\..\bin\Release\*; DestDir: {app}; Flags: overwritereadonly ignorevers
Source: ..\..\bin\Release\Languages\*; DestDir: {app}\Languages; Flags: overwritereadonly ignoreversion replacesameversion
Source: ..\additional_files\*; DestDir: {app}; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion
;Flickr Plugin
-;Source: ..\..\bin\Release\Plugins\GreenshotFlickrPlugin\*; DestDir: {app}\Plugins\GreenshotFlickrPlugin; Components: plugins\flickr; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion;
-;Source: ..\..\bin\Release\Languages\Plugins\GreenshotFlickrPlugin\*; DestDir: {app}\Languages\Plugins\GreenshotFlickrPlugin; Components: plugins\flickr; Flags: overwritereadonly ignoreversion replacesameversion;
+Source: ..\..\bin\Release\Plugins\GreenshotFlickrPlugin\*; DestDir: {app}\Plugins\GreenshotFlickrPlugin; Components: plugins\flickr; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion;
+Source: ..\..\bin\Release\Languages\Plugins\GreenshotFlickrPlugin\*; DestDir: {app}\Languages\Plugins\GreenshotFlickrPlugin; Components: plugins\flickr; Flags: overwritereadonly ignoreversion replacesameversion;
;OCR Plugin
;Source: ..\..\bin\Release\Plugins\Greenshot-OCR-Plugin\*; DestDir: {app}\Plugins\Greenshot-OCR-Plugin; Components: plugins\ocr; Flags: overwritereadonly recursesubdirs ignoreversion replacesameversion;
;Source: ..\..\bin\Release\Languages\Plugins\Greenshot-OCR-Plugin\*; DestDir: {app}\Languages\Plugins\Greenshot-OCR-Plugin; Components: plugins\ocr; Flags: overwritereadonly ignoreversion replacesameversion;
@@ -38,12 +38,12 @@ Name: de; MessagesFile: compiler:Languages\German.isl
Name: nl; MessagesFile: compiler:Languages\Dutch.isl
[Tasks]
Name: startup; Description: "{cm:startup}";
-;[Components]
-;Name: "plugins"; Description: "Plugins"; Types: Full
+[Components]
+Name: "plugins"; Description: "Plugins"; Types: Full
;Name: "plugins\ocr"; Description: "OCR Plugin"; Types: Full
;Name: "plugins\jira"; Description: "JIRA Plugin"; Types: Full
;Name: "plugins\titlefix"; Description: "Title-fix Plugin"; Types: Full
-;Name: "plugins\flickr"; Description: "Flickr Plugin"; Types: Full
+Name: "plugins\flickr"; Description: "Flickr Plugin"; Types: Full
[CustomMessages]
en.dotnetmissing=This setup requires the .NET Framework v2.0.%nDo you want to download the framework now?
de.dotnetmissing=Dieses Programm benötigt Microsoft .NET Framework v2.0.%nWollen Sie das Framework jetzt downloaden?
diff --git a/GreenshotConfluencePlugin/Confluence.cs b/GreenshotConfluencePlugin/Confluence.cs
index 9b5b4d798..498506fc6 100644
--- a/GreenshotConfluencePlugin/Confluence.cs
+++ b/GreenshotConfluencePlugin/Confluence.cs
@@ -26,7 +26,7 @@ using System.Text;
using System.Windows.Forms;
using GreenshotConfluencePlugin;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
///
/// For details see the Confluence API site
diff --git a/GreenshotConfluencePlugin/ConfluencePluginBase.cs b/GreenshotConfluencePlugin/ConfluencePluginBase.cs
index fb656ad6e..caadabbfb 100644
--- a/GreenshotConfluencePlugin/ConfluencePluginBase.cs
+++ b/GreenshotConfluencePlugin/ConfluencePluginBase.cs
@@ -27,8 +27,10 @@ using System.Text;
using System.Windows.Forms;
using Confluence;
+using Greenshot.Capturing;
+using Greenshot.Core;
+using Greenshot.Forms;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
namespace GreenshotConfluencePlugin {
///
diff --git a/GreenshotConfluencePlugin/Forms/LoginForm.cs b/GreenshotConfluencePlugin/Forms/LoginForm.cs
index fa38a7d98..9fb4dcce0 100644
--- a/GreenshotConfluencePlugin/Forms/LoginForm.cs
+++ b/GreenshotConfluencePlugin/Forms/LoginForm.cs
@@ -22,7 +22,7 @@ using System;
using System.Drawing;
using System.Windows.Forms;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotConfluencePlugin {
///
diff --git a/GreenshotConfluencePlugin/GreenshotConfluencePlugin.csproj b/GreenshotConfluencePlugin/GreenshotConfluencePlugin.csproj
index bf86e31a1..4f092f6db 100644
--- a/GreenshotConfluencePlugin/GreenshotConfluencePlugin.csproj
+++ b/GreenshotConfluencePlugin/GreenshotConfluencePlugin.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
@@ -87,10 +87,6 @@
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
-
Static
@@ -98,6 +94,10 @@
Web References\confluence
Confluence
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
+
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
diff --git a/GreenshotConfluencePlugin/Language.cs b/GreenshotConfluencePlugin/Language.cs
index 4463fac9f..aaee6647c 100644
--- a/GreenshotConfluencePlugin/Language.cs
+++ b/GreenshotConfluencePlugin/Language.cs
@@ -24,7 +24,7 @@ using System.Globalization;
using System.Resources;
using System.Threading;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotConfluencePlugin {
///
diff --git a/GreenshotCore/Core/LanguageHelper.cs b/GreenshotCore/Core/LanguageHelper.cs
new file mode 100644
index 000000000..13b977b69
--- /dev/null
+++ b/GreenshotCore/Core/LanguageHelper.cs
@@ -0,0 +1,451 @@
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
+ *
+ * For more information see: http://getgreenshot.org/
+ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using System.Xml;
+
+namespace Greenshot.Core {
+
+ public interface ILanguage {
+ void Load();
+ string GetString(Enum id);
+ string GetFormattedString(Enum id, object param);
+ string GetHelpFilePath();
+
+ ///
+ /// Set language
+ ///
+ /// wanted IETF
+ /// Actuall IETF
+ string SetLanguage(string cultureInfo);
+ void SynchronizeLanguageToCulture();
+ string CurrentLanguage {
+ get;
+ }
+
+ List SupportedLanguages {
+ get;
+ }
+
+ String LanguageFilePattern {
+ get;
+ set;
+ }
+
+ }
+ ///
+ /// Description of Language.
+ ///
+ public class LanguageContainer : ILanguage {
+ private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(LanguageContainer));
+ private static char [] TRIMCHARS = new char[] {' ', '\t', '\n', '\r'};
+ private const string DEFAULT_LANGUAGE= "en-US";
+ private static string APPLICATIONDATA_LANGUAGE_PATH = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),@"Greenshot\Languages\");
+ private static string STARTUP_LANGUAGE_PATH = Path.Combine(Application.StartupPath, @"Languages\");
+ private const string HELP_FILENAME_PATTERN = @"help-*.html";
+
+ private Dictionary strings = new Dictionary();
+ private List languages = new List();
+ private string currentIETF = null;
+ private string languageFilePattern;
+
+ public LanguageContainer() {
+ }
+
+ public String LanguageFilePattern {
+ get {
+ return languageFilePattern;
+ }
+ set {
+ languageFilePattern = value;
+ }
+ }
+
+ public void Load() {
+ languages = LoadFiles(languageFilePattern);
+ }
+
+ public string CurrentLanguage {
+ get {
+ return currentIETF;
+ }
+ }
+
+ public List SupportedLanguages {
+ get {
+ return languages;
+ }
+ }
+
+ public void SynchronizeLanguageToCulture() {
+ if (!CurrentLanguage.Equals(Thread.CurrentThread.CurrentUICulture.Name)) {
+ SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
+ }
+ }
+
+ ///
+ /// Set language
+ ///
+ /// wanted IETF
+ /// Actuall IETF
+ public string SetLanguage(string wantedIETF) {
+ LOG.Debug("SetLanguage called for : " + wantedIETF);
+ Dictionary identifiedLanguages = new Dictionary();
+
+ if (languages == null || languages.Count == 0) {
+ throw new FileNotFoundException("No language files found!");
+ }
+
+ // Find selected languages in available languages
+ foreach(LanguageConfiguration language in languages) {
+ LOG.Debug("Found language: " + language.Ietf);
+ identifiedLanguages.Add(language.Ietf, language);
+ }
+
+ LanguageConfiguration selectedLanguage = null;
+ try {
+ selectedLanguage = identifiedLanguages[wantedIETF];
+ } catch (KeyNotFoundException) {
+ LOG.Warn("Selecteded language " + wantedIETF + " not found.");
+ }
+
+ // Make best match for language (e.g. en -> "en-US")
+ if (selectedLanguage == null) {
+ foreach(string ietf in identifiedLanguages.Keys) {
+ if (ietf.StartsWith(wantedIETF)) {
+ try {
+ selectedLanguage = identifiedLanguages[ietf];
+ LOG.Info("Selecteded language " + ietf + " by near match for: " + wantedIETF);
+ wantedIETF = ietf;
+ break;
+ } catch (KeyNotFoundException) {
+ LOG.Warn("Selecteded language " + wantedIETF + " not found.");
+ }
+ }
+ }
+ }
+
+ if (selectedLanguage == null && !DEFAULT_LANGUAGE.Equals(wantedIETF)) {
+ try {
+ selectedLanguage = identifiedLanguages[DEFAULT_LANGUAGE];
+ } catch (KeyNotFoundException) {
+ LOG.Warn("No english language file found!!");
+ }
+ }
+ if (selectedLanguage == null) {
+ // Select first (maybe only) language!
+ selectedLanguage = languages[0];
+ LOG.Warn("Selected " + selectedLanguage.Ietf + " as fallback language!");
+ }
+
+ // build directionary for the strings
+ strings.Clear();
+ foreach(Resource resource in selectedLanguage.Resources) {
+ AddResource(resource);
+ }
+
+ currentIETF = selectedLanguage.Ietf;
+ return currentIETF;
+ }
+
+ private void AddResource(Resource resource) {
+ try {
+ if (resource.Text != null) {
+ strings.Add(resource.Name, resource.Text.Trim(TRIMCHARS));
+ } else {
+ LOG.Warn("Resource is null: " + resource.Name);
+ strings.Add(resource.Name, "");
+ }
+ } catch (ArgumentException ae) {
+ LOG.Error("Problem adding " + resource.Name, ae);
+ throw ae;
+ }
+ }
+
+ private List LoadFiles(string languageFilePattern) {
+ List loadedLanguages = new List();
+ List languageDirectories = new List();
+ languageDirectories.Add(STARTUP_LANGUAGE_PATH);
+ languageDirectories.Add(APPLICATIONDATA_LANGUAGE_PATH);
+ foreach(string path in languageDirectories) {
+ // Search in executable directory
+ if (Directory.Exists(path)) {
+ foreach(string languageFile in Directory.GetFiles(path, languageFilePattern, SearchOption.AllDirectories)) {
+ LanguageConfiguration languageConfig = LanguageConfiguration.Load(languageFile);
+ if (languageConfig != null) {
+ LOG.Info("Loaded language: " + languageConfig.Description);
+ loadedLanguages.Add(languageConfig);
+ }
+ }
+ }
+ }
+ return loadedLanguages;
+ }
+
+ public void Validate(Enum languageKeys) {
+ Dictionary> keysPerLanguage = new Dictionary>();
+ foreach(LanguageConfiguration languageToValidate in languages) {
+ List keys = new List();
+ foreach(Resource resource in languageToValidate.Resources) {
+ keys.Add(resource.Name);
+ }
+ keys.Sort();
+ keysPerLanguage.Add(languageToValidate.Ietf, keys);
+ }
+
+ // Make list of values in the enum
+ List fixedKeys = new List();
+ foreach(Enum langKey in Enum.GetValues(languageKeys.GetType())) {
+ fixedKeys.Add(langKey.ToString());
+ }
+
+ foreach(string ietf in keysPerLanguage.Keys) {
+ List keys = keysPerLanguage[ietf];
+ foreach(string key in fixedKeys) {
+ if (!keys.Contains(key)) {
+ LOG.Warn(ietf + " is missing resource with name [" + key + "]");
+ }
+ }
+ foreach(string key in keys) {
+ if (!fixedKeys.Contains(key)) {
+ LOG.Warn(ietf + " has additional resource with name [" + key + "]");
+ }
+ }
+ }
+ }
+
+ private void ToEnum() {
+ if (!LOG.IsDebugEnabled) {
+ return;
+ }
+ StringBuilder EnumClass = new StringBuilder();
+ EnumClass.AppendLine("/*");
+ EnumClass.AppendLine(" * Auto generated");
+ EnumClass.AppendLine(" */");
+ EnumClass.AppendLine("using System;");
+ EnumClass.AppendLine();
+ EnumClass.AppendLine("namespace Greenshot.Configuration {");
+ EnumClass.AppendLine(" public enum LangKey {");
+
+ List keys = new List();
+ foreach(LanguageConfiguration foundLanguage in languages) {
+ if (foundLanguage.Ietf.Equals(DEFAULT_LANGUAGE)) {
+ foreach(Resource resource in foundLanguage.Resources) {
+ keys.Add(resource.Name);
+ }
+ }
+ }
+ keys.Sort();
+ bool added = false;
+ foreach(string key in keys) {
+ if (added) {
+ EnumClass.AppendLine(",");
+ }
+ EnumClass.Append(" " + key);
+ added = true;
+ }
+ EnumClass.AppendLine();
+ EnumClass.AppendLine(" }");
+ EnumClass.AppendLine("}");
+ LOG.Debug("LangKeys should be: \r\n" + EnumClass.ToString());
+ }
+
+ public string GetString(Enum id) {
+ if(!strings.ContainsKey(id.ToString())) {
+ AdoptMissingResourcesFromDefaultLanguage();
+ }
+ try {
+ return strings[id.ToString()];
+ } catch (KeyNotFoundException) {
+ return "string ###"+id+"### not found";
+ }
+ }
+
+ public string GetFormattedString(Enum id, object param) {
+ if(!strings.ContainsKey(id.ToString())) {
+ AdoptMissingResourcesFromDefaultLanguage();
+ }
+ try {
+ return String.Format(strings[id.ToString()], param);
+ } catch (KeyNotFoundException) {
+ return "string ###"+id+"### not found";
+ }
+ }
+
+ private void AdoptMissingResourcesFromDefaultLanguage() {
+ LanguageConfiguration defaultLanguageConfiguration = GetDefaultLanguageConfiguration();
+ if (defaultLanguageConfiguration != null) {
+ foreach(Resource resource in GetDefaultLanguageConfiguration().Resources) {
+ if(!strings.ContainsKey(resource.Name)) {
+ AddResource(resource);
+ if(LOG.IsWarnEnabled) {
+ LOG.Warn("Adopted missing string resource from default language: "+resource.Name);
+ }
+ }
+ }
+ } else {
+ LOG.Warn("Default language file is missing! The default language file is: " + DEFAULT_LANGUAGE);
+ }
+ }
+
+ private LanguageConfiguration GetDefaultLanguageConfiguration() {
+ foreach(LanguageConfiguration language in languages) {
+ if(language.Ietf == DEFAULT_LANGUAGE) return language;
+ }
+ return null;
+ }
+
+ /// finds a returns the path of the best matching help file.
+ /// 1st tries to find file for currentLanguage, 2nd for defaultLanguage.
+ /// if neither is found, the first help file found is returned
+ public string GetHelpFilePath() {
+ List helpFiles = new List();
+ // Search in executable directory
+ if (Directory.Exists(STARTUP_LANGUAGE_PATH)) {
+ helpFiles.AddRange(Directory.GetFiles(STARTUP_LANGUAGE_PATH, HELP_FILENAME_PATTERN, SearchOption.AllDirectories));
+ }
+ // Search in ApplicationData directory
+ if (Directory.Exists(APPLICATIONDATA_LANGUAGE_PATH)) {
+ helpFiles.AddRange(Directory.GetFiles(APPLICATIONDATA_LANGUAGE_PATH, HELP_FILENAME_PATTERN, SearchOption.AllDirectories));
+ }
+
+ foreach(string helpFile in helpFiles) {
+ if(helpFile.EndsWith(currentIETF+".html")) {
+ return helpFile;
+ }
+ }
+ foreach(string helpFile in helpFiles) {
+ if(helpFile.EndsWith(DEFAULT_LANGUAGE+".html")) {
+ return helpFile;
+ }
+ }
+ LOG.Warn("Help file not found for default language, will load "+helpFiles[0]);
+ return helpFiles[0];
+ }
+
+ }
+
+ public class LanguageConfiguration {
+
+ private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(LanguageConfiguration));
+
+ public string description;
+ public string Description {get;set;}
+
+ public string ietf;
+ public string Ietf {get;set;}
+
+ public string version;
+ public string Version {get;set;}
+
+ public string file;
+ public string File {get;set;}
+
+ public List Resources;
+
+ public LanguageConfiguration() {
+ Resources = new List();
+ }
+
+ ///
+ /// loads a language configuration from a file path
+ ///
+ public static LanguageConfiguration Load(string path) {
+ LanguageConfiguration ret = null;
+ try {
+ XmlDocument doc = new XmlDocument();
+ doc.Load(path);
+ XmlNodeList nodes = doc.GetElementsByTagName("language");
+ if(nodes.Count > 0) {
+ ret = new LanguageConfiguration();
+ ret.File = path;
+ XmlNode node = nodes.Item(0);
+ ret.Description = node.Attributes["description"].Value;
+ ret.Ietf = node.Attributes["ietf"].Value;
+ ret.Version = node.Attributes["version"].Value;
+
+ XmlNodeList resourceNodes = doc.GetElementsByTagName("resource");
+ ret.Resources = new List(resourceNodes.Count);
+ foreach(XmlNode resourceNode in resourceNodes) {
+ Resource res = new Resource();
+ res.Name = resourceNode.Attributes["name"].Value;
+ res.Text = resourceNode.InnerText;
+ ret.Resources.Add(res);
+ }
+ } else {
+ throw new XmlException("Root element is missing");
+ }
+ } catch(Exception e) {
+ LOG.Error("Could not load language file "+path, e);
+ }
+ return ret;
+
+ }
+ }
+
+ public class Resource {
+
+ public string name;
+ public string Name {get; set;}
+
+ public string text;
+ public string Text {get; set;}
+
+ public override int GetHashCode() {
+ int hash = 7;
+ if (Text != null) {
+ hash = hash ^ Text.GetHashCode();
+ }
+ if (Name != null) {
+ hash = hash ^ Name.GetHashCode();
+ }
+ return hash;
+ }
+
+ public override bool Equals(object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (obj is Resource) {
+ Resource other = (Resource) obj;
+ if(Name == null) {
+ if (other.Name != null) {
+ return false;
+ }
+ return true;
+ }
+ if(Text == null) {
+ if (other.Text != null) {
+ return false;
+ }
+ return true;
+ }
+ return (Name.Equals(other.Name) && Text.Equals(other.Text));
+ }
+ return false;
+ }
+ }
+}
diff --git a/GreenshotCore/Core/PropertyHelper.cs b/GreenshotCore/Core/PropertyHelper.cs
new file mode 100644
index 000000000..94db0578d
--- /dev/null
+++ b/GreenshotCore/Core/PropertyHelper.cs
@@ -0,0 +1,118 @@
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
+ *
+ * For more information see: http://getgreenshot.org/
+ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+using System;
+using System.Collections.Generic;
+using System.IO;
+
+namespace Greenshot.Core {
+ ///
+ /// A Class to representate a simple "java" properties file
+ ///
+ public class Properties : Dictionary{
+ private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(Properties));
+
+ public string GetProperty(string key) {
+ try {
+ return this[key];
+ } catch (KeyNotFoundException) {
+ return null;
+ }
+ }
+ ///
+ /// Split property with ',' and return the splitted string as a string[]
+ ///
+ public string[] GetPropertyAsArray(string key) {
+ try {
+ string array = this[key];
+ return array.Split(new Char[] {','});
+ } catch (KeyNotFoundException) {
+ return null;
+ }
+ }
+ public bool GetBoolProperty(string key) {
+ return bool.Parse(this[key]);
+ }
+ public int GetIntProperty(string key) {
+ return int.Parse(this[key]);
+ }
+ public void AddProperty(string key, string value) {
+ Add(key, value);
+ }
+ public void AddBoolProperty(string key, bool value) {
+ AddProperty(key, value.ToString());
+ }
+ public void ChangeProperty(string key, string value) {
+ if (this.ContainsKey(key)) {
+ this[key] = value;
+ } else {
+ throw new KeyNotFoundException(key);
+ }
+ }
+ public void ChangeBoolProperty(string key, bool value) {
+ ChangeProperty(key, value.ToString());
+ }
+
+ public void write(string filename) {
+ using ( TextWriter textWriter = new StreamWriter(filename)) {
+ foreach(string key in Keys) {
+ textWriter.WriteLine(key +"=" + this[key]);
+ }
+ }
+ }
+
+ public void write(string filename, string header) {
+ using ( TextWriter textWriter = new StreamWriter(filename)) {
+ if (header != null) {
+ textWriter.WriteLine(header);
+ }
+ foreach(string key in Keys) {
+ textWriter.WriteLine(key +"=" + this[key]);
+ }
+ }
+ }
+
+ // Read properties file
+ public static Properties read(string filename) {
+ LOG.Debug("Reading properties from file: " + filename);
+ if (!File.Exists(filename)) {
+ return null;
+ }
+ Properties properties = new Properties();
+ foreach (string line in File.ReadAllLines(filename)) {
+ if (line == null) {
+ continue;
+ }
+ string currentLine = line.Trim();
+ if (!currentLine.StartsWith("#") && currentLine.IndexOf('=') > 0) {
+ string [] split = currentLine.Split(new Char[] {'='}, 2);
+ if (split != null && split.Length == 2) {
+ string name = split[0];
+ if (name == null || name.Length < 1) {
+ continue;
+ }
+ properties.Add(name.Trim(), split[1]);
+ }
+ }
+ }
+ return properties;
+ }
+ }
+}
diff --git a/GreenshotCore/GreenshotCore.csproj b/GreenshotCore/GreenshotCore.csproj
index b27c1c60b..146c50b9d 100644
--- a/GreenshotCore/GreenshotCore.csproj
+++ b/GreenshotCore/GreenshotCore.csproj
@@ -39,12 +39,16 @@
+
+ Lib\log4net.dll
+
+
@@ -53,6 +57,8 @@
+
+
diff --git a/GreenshotFlickrPlugin/FlickrPlugin.cs b/GreenshotFlickrPlugin/FlickrPlugin.cs
index 8d1aeb23c..5a3db76b5 100644
--- a/GreenshotFlickrPlugin/FlickrPlugin.cs
+++ b/GreenshotFlickrPlugin/FlickrPlugin.cs
@@ -30,9 +30,9 @@ using System.Windows.Forms;
using FlickrNet;
using Greenshot.Capturing;
+using Greenshot.Core;
using Greenshot.Forms;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
using Microsoft.Win32;
namespace GreenshotFlickrPlugin {
diff --git a/GreenshotFlickrPlugin/GreenshotFlickrPlugin.csproj b/GreenshotFlickrPlugin/GreenshotFlickrPlugin.csproj
index 1670186b7..0d12c0c81 100644
--- a/GreenshotFlickrPlugin/GreenshotFlickrPlugin.csproj
+++ b/GreenshotFlickrPlugin/GreenshotFlickrPlugin.csproj
@@ -83,10 +83,6 @@
{BDC408EE-DEA1-4474-B59D-7F05757B12EC}
GreenshotCore
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
-
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
diff --git a/GreenshotFlickrPlugin/Language.cs b/GreenshotFlickrPlugin/Language.cs
index a8810c987..c3de752e2 100644
--- a/GreenshotFlickrPlugin/Language.cs
+++ b/GreenshotFlickrPlugin/Language.cs
@@ -24,7 +24,7 @@ using System.Globalization;
using System.Resources;
using System.Threading;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotFlickrPlugin {
///
diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs
index 6586c23d4..3d1eb8a59 100644
--- a/GreenshotJiraPlugin/Forms/JiraForm.cs
+++ b/GreenshotJiraPlugin/Forms/JiraForm.cs
@@ -28,7 +28,7 @@ using System.Net;
using System.Text;
using System.Windows.Forms;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
using Jira;
namespace GreenshotJiraPlugin {
diff --git a/GreenshotJiraPlugin/Forms/LoginForm.cs b/GreenshotJiraPlugin/Forms/LoginForm.cs
index 418728467..57fb3d6d6 100644
--- a/GreenshotJiraPlugin/Forms/LoginForm.cs
+++ b/GreenshotJiraPlugin/Forms/LoginForm.cs
@@ -22,7 +22,7 @@ using System;
using System.Drawing;
using System.Windows.Forms;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotJiraPlugin {
///
diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
index 643d20d62..224f854dc 100644
--- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
+++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
@@ -94,9 +94,9 @@
Web References\JiraSoap
Jira
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
diff --git a/GreenshotJiraPlugin/Jira.cs b/GreenshotJiraPlugin/Jira.cs
index 4e1e58e19..6030ad71b 100644
--- a/GreenshotJiraPlugin/Jira.cs
+++ b/GreenshotJiraPlugin/Jira.cs
@@ -26,7 +26,7 @@ using System.Text;
using System.Windows.Forms;
using GreenshotJiraPlugin;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace Jira {
#region transport classes
diff --git a/GreenshotJiraPlugin/JiraPluginBase.cs b/GreenshotJiraPlugin/JiraPluginBase.cs
index 96e2bf342..898ced7ec 100644
--- a/GreenshotJiraPlugin/JiraPluginBase.cs
+++ b/GreenshotJiraPlugin/JiraPluginBase.cs
@@ -26,8 +26,10 @@ using System.IO;
using System.Text;
using System.Windows.Forms;
+using Greenshot.Capturing;
+using Greenshot.Core;
+using Greenshot.Forms;
using Greenshot.Plugin;
-using GreenshotPlugin.Core;
using Jira;
namespace GreenshotJiraPlugin {
diff --git a/GreenshotJiraPlugin/Language.cs b/GreenshotJiraPlugin/Language.cs
index 7687e3e8f..186acf25b 100644
--- a/GreenshotJiraPlugin/Language.cs
+++ b/GreenshotJiraPlugin/Language.cs
@@ -24,7 +24,7 @@ using System.Globalization;
using System.Resources;
using System.Threading;
-using GreenshotPlugin.Core;
+using Greenshot.Core;
namespace GreenshotJiraPlugin {
///
diff --git a/PluginExample/PluginExample.cs b/PluginExample/PluginExample.cs
index 1eef3cafe..b0d29fc39 100644
--- a/PluginExample/PluginExample.cs
+++ b/PluginExample/PluginExample.cs
@@ -26,6 +26,9 @@ using System.IO;
using System.Text;
using System.Windows.Forms;
+using Greenshot.Capturing;
+using Greenshot.Drawing;
+using Greenshot.Forms;
using Greenshot.Plugin;
namespace PluginExample {
diff --git a/PluginExample/PluginExample.csproj b/PluginExample/PluginExample.csproj
index 8707a130b..3656c36bc 100644
--- a/PluginExample/PluginExample.csproj
+++ b/PluginExample/PluginExample.csproj
@@ -41,7 +41,7 @@
- ..\Greenshot\Lib\log4net.dll
+ ..\GreenshotCore\Lib\log4net.dll
@@ -60,15 +60,15 @@
SettingsForm.cs
-
-
- {5B924697-4DCD-4F98-85F1-105CB84B7341}
- GreenshotPlugin
-
-
mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
+
+
+ {BDC408EE-DEA1-4474-B59D-7F05757B12EC}
+ GreenshotCore
+
+
\ No newline at end of file