mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -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) {
|
protected void ApplyLanguage(ToolStripItem applyTo, string languageKey) {
|
||||||
|
string langString = null;
|
||||||
if (!string.IsNullOrEmpty(languageKey)) {
|
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);
|
LOG.WarnFormat("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name);
|
||||||
if (DesignMode) {
|
if (DesignMode) {
|
||||||
MessageBox.Show(string.Format("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;
|
return;
|
||||||
}
|
}
|
||||||
applyTo.Text = Language.GetString(languageKey);
|
applyTo.Text = langString;
|
||||||
} else {
|
} else {
|
||||||
// Fallback to control name!
|
// Fallback to control name!
|
||||||
if (Language.hasKey(applyTo.Name)) {
|
if (Language.TryGetString(applyTo.Name, out langString)) {
|
||||||
applyTo.Text = Language.GetString(applyTo.Name);
|
applyTo.Text = langString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.DesignMode) {
|
if (this.DesignMode) {
|
||||||
|
@ -267,13 +268,15 @@ namespace GreenshotPlugin.Controls {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply all the language settings to the "Greenshot" Controls on this form
|
/// Apply all the language settings to the "Greenshot" Controls on this form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void ApplyLanguage() {
|
protected void ApplyLanguage() {
|
||||||
|
string langString = null;
|
||||||
// Set title of the form
|
// Set title of the form
|
||||||
if (!string.IsNullOrEmpty(LanguageKey) && Language.hasKey(LanguageKey)) {
|
if (!string.IsNullOrEmpty(LanguageKey) && Language.TryGetString(LanguageKey, out langString)) {
|
||||||
this.Text = Language.GetString(LanguageKey);
|
this.Text = langString;
|
||||||
}
|
}
|
||||||
// Reset the text values for all GreenshotControls
|
// Reset the text values for all GreenshotControls
|
||||||
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
|
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
|
/// Apply the language text to supplied control
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void ApplyLanguage(Control applyTo, string languageKey) {
|
protected void ApplyLanguage(Control applyTo, string languageKey) {
|
||||||
|
string langString = null;
|
||||||
if (!string.IsNullOrEmpty(languageKey)) {
|
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);
|
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));
|
MessageBox.Show(string.Format("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
applyTo.Text = Language.GetString(languageKey);
|
applyTo.Text = langString;
|
||||||
} else {
|
} else {
|
||||||
// Fallback to control name!
|
// Fallback to control name!
|
||||||
if (Language.hasKey(applyTo.Name)) {
|
if (Language.TryGetString(applyTo.Name, out langString)) {
|
||||||
applyTo.Text = Language.GetString(applyTo.Name);
|
applyTo.Text = langString;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.DesignMode) {
|
if (this.DesignMode) {
|
||||||
|
|
|
@ -489,6 +489,27 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
return resources.ContainsKey(key);
|
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) {
|
public static string Translate(object key) {
|
||||||
string typename = key.GetType().Name;
|
string typename = key.GetType().Name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue