mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -07:00
Performance fixes
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1918 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
959bcd3135
commit
e4a87aa4e4
2 changed files with 35 additions and 10 deletions
|
@ -204,19 +204,20 @@ namespace GreenshotPlugin.Controls {
|
|||
}
|
||||
|
||||
protected void ApplyLanguage(ToolStripItem applyTo, string languageKey) {
|
||||
string langString = null;
|
||||
if (!string.IsNullOrEmpty(languageKey)) {
|
||||
if (!Language.hasKey(languageKey)) {
|
||||
if (!Language.TryGetString(languageKey, out langString)) {
|
||||
LOG.WarnFormat("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name);
|
||||
if (DesignMode) {
|
||||
MessageBox.Show(string.Format("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name));
|
||||
}
|
||||
return;
|
||||
}
|
||||
applyTo.Text = Language.GetString(languageKey);
|
||||
applyTo.Text = langString;
|
||||
} else {
|
||||
// Fallback to control name!
|
||||
if (Language.hasKey(applyTo.Name)) {
|
||||
applyTo.Text = Language.GetString(applyTo.Name);
|
||||
if (Language.TryGetString(applyTo.Name, out langString)) {
|
||||
applyTo.Text = langString;
|
||||
return;
|
||||
}
|
||||
if (this.DesignMode) {
|
||||
|
@ -267,13 +268,15 @@ namespace GreenshotPlugin.Controls {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply all the language settings to the "Greenshot" Controls on this form
|
||||
/// </summary>
|
||||
protected void ApplyLanguage() {
|
||||
string langString = null;
|
||||
// Set title of the form
|
||||
if (!string.IsNullOrEmpty(LanguageKey) && Language.hasKey(LanguageKey)) {
|
||||
this.Text = Language.GetString(LanguageKey);
|
||||
if (!string.IsNullOrEmpty(LanguageKey) && Language.TryGetString(LanguageKey, out langString)) {
|
||||
this.Text = langString;
|
||||
}
|
||||
// Reset the text values for all GreenshotControls
|
||||
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
|
||||
|
@ -313,17 +316,18 @@ namespace GreenshotPlugin.Controls {
|
|||
/// Apply the language text to supplied control
|
||||
/// </summary>
|
||||
protected void ApplyLanguage(Control applyTo, string languageKey) {
|
||||
string langString = null;
|
||||
if (!string.IsNullOrEmpty(languageKey)) {
|
||||
if (!Language.hasKey(languageKey)) {
|
||||
if (!Language.TryGetString(languageKey, out langString)) {
|
||||
LOG.WarnFormat("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name);
|
||||
MessageBox.Show(string.Format("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name));
|
||||
return;
|
||||
}
|
||||
applyTo.Text = Language.GetString(languageKey);
|
||||
applyTo.Text = langString;
|
||||
} else {
|
||||
// Fallback to control name!
|
||||
if (Language.hasKey(applyTo.Name)) {
|
||||
applyTo.Text = Language.GetString(applyTo.Name);
|
||||
if (Language.TryGetString(applyTo.Name, out langString)) {
|
||||
applyTo.Text = langString;
|
||||
return;
|
||||
}
|
||||
if (this.DesignMode) {
|
||||
|
|
|
@ -489,6 +489,27 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
return resources.ContainsKey(key);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TryGet method which combines hasKey & GetString
|
||||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="languageString">out string</param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetString(string key, out string languageString) {
|
||||
return resources.TryGetValue(key, out languageString);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TryGet method which combines hasKey & GetString
|
||||
/// </summary>
|
||||
/// <param name="prefix">string with prefix</param>
|
||||
/// <param name="key">string with key</param>
|
||||
/// <param name="languageString">out string</param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGetString(string prefix, string key, out string languageString) {
|
||||
return resources.TryGetValue(prefix + "." + key, out languageString);
|
||||
}
|
||||
|
||||
public static string Translate(object key) {
|
||||
string typename = key.GetType().Name;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue