From 2a07d840333062ed0d364eec608e352939e668c4 Mon Sep 17 00:00:00 2001 From: RKrom Date: Tue, 17 Apr 2012 16:13:07 +0000 Subject: [PATCH] Fixed path locating in DesignMode git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1786 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- GreenshotPlugin/Controls/GreenshotForm.cs | 12 ++++++------ GreenshotPlugin/Core/Language.cs | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 51f9a7919..a5ad426f9 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -31,11 +31,12 @@ namespace GreenshotPlugin.Controls { ITypeResolutionService typeResService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService; Assembly currentAssembly = this.GetType().Assembly; string assemblyPath = typeResService.GetPathOfAssembly(currentAssembly.GetName()); - string designTimeLanguagePath = Path.Combine(Path.GetDirectoryName(assemblyPath), "../../../Greenshot/Languages/"); - string designTimePluginLanguagePath = Path.Combine(Path.GetDirectoryName(assemblyPath), "../../Languages/"); - //MessageBox.Show(designTimeLanguagePath); - Language.AddLanguageFilePath(designTimeLanguagePath); - Language.AddLanguageFilePath(designTimePluginLanguagePath); + if (!Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\Greenshot\Languages\"))) { + Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\..\Greenshot\Languages\")); + } + if (!Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\Languages\"))) { + Language.AddLanguageFilePath(Path.Combine(Path.GetDirectoryName(assemblyPath), @"..\..\..\Languages\")); + } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } @@ -48,7 +49,6 @@ namespace GreenshotPlugin.Controls { /// protected override void OnPaint(PaintEventArgs e) { if (this.DesignMode) { - LOG.InfoFormat("OnPaint called from designer. Key={0}", LanguageKey); if (!isLanguageSet) { isLanguageSet = true; try { diff --git a/GreenshotPlugin/Core/Language.cs b/GreenshotPlugin/Core/Language.cs index 8afc67f0b..4f84f77f9 100644 --- a/GreenshotPlugin/Core/Language.cs +++ b/GreenshotPlugin/Core/Language.cs @@ -148,24 +148,30 @@ namespace GreenshotPlugin.Core { Reload(); } - private static void AddPath(string path) { + private static bool AddPath(string path) { if (!languagePaths.Contains(path)) { if (Directory.Exists(path)) { LOG.DebugFormat("Adding language path {0}", path); languagePaths.Add(path); } else { LOG.InfoFormat("Not adding non existing language path {0}", path); + return false; } } + return true; } - public static void AddLanguageFilePath(string path) { + public static bool AddLanguageFilePath(string path) { if (!languagePaths.Contains(path)) { LOG.DebugFormat("New language path {0}", path); - AddPath(path); - ScanFiles(); - Reload(); + if (AddPath(path)) { + ScanFiles(); + Reload(); + } else { + return false; + } } + return true; } private static void LoadFiles(string ietf) { @@ -278,7 +284,7 @@ namespace GreenshotPlugin.Core { languageFile.Version = new Version(node.Attributes["version"].Value); } if (node.Attributes["prefix"] != null) { - languageFile.Prefix = node.Attributes["prefix"].Value; + languageFile.Prefix = node.Attributes["prefix"].Value.ToLower(); } if (node.Attributes["languagegroup"] != null) { string languageGroup = node.Attributes["languagegroup"].Value; @@ -317,7 +323,7 @@ namespace GreenshotPlugin.Core { if (PREFIX_REGEXP.IsMatch(languageFilename)) { languageFile.Prefix = PREFIX_REGEXP.Replace(languageFilename, "$1"); if (!string.IsNullOrEmpty(languageFile.Prefix)) { - languageFile.Prefix = languageFile.Prefix.Replace("plugin", ""); + languageFile.Prefix = languageFile.Prefix.Replace("plugin", "").ToLower(); } } }