Fixed some language refactoring issues

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1788 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-18 07:18:12 +00:00
commit 88e99d78cb
6 changed files with 20 additions and 24 deletions

View file

@ -48,7 +48,6 @@ namespace Greenshot {
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AboutForm));
this.lblTitle = new System.Windows.Forms.Label();
this.lblLicense = new GreenshotPlugin.Controls.GreenshotLabel();
this.lblHost = new GreenshotPlugin.Controls.GreenshotLabel();
@ -82,7 +81,6 @@ namespace Greenshot {
this.lblLicense.Name = "lblLicense";
this.lblLicense.Size = new System.Drawing.Size(369, 68);
this.lblLicense.TabIndex = 3;
this.lblLicense.Text = resources.GetString("lblLicense.Text");
//
// lblHost
//
@ -184,7 +182,6 @@ namespace Greenshot {
//
// pictureBox1
//
this.pictureBox1.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox1.Image")));
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(90, 90);

View file

@ -39,7 +39,7 @@ namespace Greenshot {
//
InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.pictureBox1.Image = GreenshotPlugin.Core.GreenshotResources.getGreenshotImage();
Version v = Assembly.GetExecutingAssembly().GetName().Version;
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")]
lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable?" Portable":"") + (" (" + OSInfo.Bits +" bit)");

View file

@ -46,7 +46,6 @@ namespace Greenshot.Forms {
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BugReportForm));
this.labelBugReportInfo = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.btnClose = new GreenshotPlugin.Controls.GreenshotButton();
@ -60,7 +59,6 @@ namespace Greenshot.Forms {
this.labelBugReportInfo.Name = "labelBugReportInfo";
this.labelBugReportInfo.Size = new System.Drawing.Size(481, 141);
this.labelBugReportInfo.TabIndex = 0;
this.labelBugReportInfo.Text = resources.GetString("labelBugReportInfo.Text");
//
// textBoxDescription
//

View file

@ -459,15 +459,19 @@ namespace Greenshot {
private static bool RegisterHotkey(StringBuilder failedKeys, string functionName, string hotkeyString, HotKeyHandler handler) {
Keys modifierKeyCode = HotkeyControl.HotkeyModifiersFromString(hotkeyString);
Keys virtualKeyCode = HotkeyControl.HotkeyFromString(hotkeyString);
if (HotkeyControl.RegisterHotKey(modifierKeyCode, virtualKeyCode, handler) < 0) {
LOG.DebugFormat("Failed to register {0} to hotkey: {1}", functionName, hotkeyString);
if (failedKeys.Length > 0) {
failedKeys.Append(", ");
if (!Keys.None.Equals(virtualKeyCode)) {
if (HotkeyControl.RegisterHotKey(modifierKeyCode, virtualKeyCode, handler) < 0) {
LOG.DebugFormat("Failed to register {0} to hotkey: {1}", functionName, hotkeyString);
if (failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(hotkeyString);
return false;
} else {
LOG.DebugFormat("Registered {0} to hotkey: {1}", functionName, hotkeyString);
}
failedKeys.Append(hotkeyString);
return false;
} else {
LOG.DebugFormat("Registered {0} to hotkey: {1}", functionName, hotkeyString);
LOG.InfoFormat("Skipping hotkey registration for {0}, no hotkey set!", functionName);
}
return true;
}

View file

@ -147,7 +147,6 @@ namespace GreenshotPlugin.Controls {
if (ce.Component != null && ((IComponent)ce.Component).Site != null) {
Control control = ce.Component as Control;
if (control != null) {
LOG.DebugFormat("Control {0} added.", control.Name);
if (!designTimeControls.ContainsKey(control.Name)) {
designTimeControls.Add(control.Name, control);
} else {
@ -168,12 +167,10 @@ namespace GreenshotPlugin.Controls {
protected void ApplyLanguage(Control applyTo) {
IGreenshotLanguageBindable languageBindable = applyTo as IGreenshotLanguageBindable;
if (languageBindable == null) {
LOG.DebugFormat("Not bindable: {0}", applyTo.Name);
return;
}
string languageKey = languageBindable.LanguageKey;
LOG.DebugFormat("Found language key '{0}' configured on control '{1}'", languageKey, applyTo.Name);
// Apply language text to the control
ApplyLanguage(applyTo, languageKey);
// Repopulate the combox boxes
@ -197,14 +194,12 @@ namespace GreenshotPlugin.Controls {
/// Apply all the language settings to the "Greenshot" Controls on this form
/// </summary>
protected void ApplyLanguage() {
LOG.DebugFormat("Applying language, using key {0}", LanguageKey);
// Set title of the form
if (!string.IsNullOrEmpty(LanguageKey)) {
this.Text = Language.GetString(LanguageKey);
}
// Reset the text values for all GreenshotControls
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance)) {
LOG.DebugFormat("Checking field {0}", field.Name);
foreach (FieldInfo field in this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance)) {
if (!field.FieldType.IsSubclassOf(typeof(Control))) {
LOG.DebugFormat("No control: {0}", field.Name);
continue;

View file

@ -93,11 +93,13 @@ namespace GreenshotPlugin.Core {
coreConfig = IniConfig.GetIniSection<CoreConfiguration>();
ScanFiles();
if (!string.IsNullOrEmpty(coreConfig.Language)) {
currentLanguage = coreConfig.Language;
CurrentLanguage = coreConfig.Language;
} else {
currentLanguage = DEFAULT_LANGUAGE;
CurrentLanguage = DEFAULT_LANGUAGE;
}
if (string.IsNullOrEmpty(CurrentLanguage)) {
throw new ApplicationException("Couldn't set language, installation problem?");
}
Reload();
}
/// <summary>
@ -171,8 +173,8 @@ namespace GreenshotPlugin.Core {
return currentLanguage;
}
set {
LOG.DebugFormat("CurrentLangue = {0}, new value {1}", currentLanguage, value);
string ietf = ClearIETF(value);
LOG.DebugFormat("CurrentLangue = {0}, new value {1} ({2})", currentLanguage, value, ietf);
if (!string.IsNullOrEmpty(ietf)) {
if (!languageFiles.ContainsKey(ietf)) {
LOG.WarnFormat("Unknown language {0}, trying best match!", ietf);
@ -187,7 +189,7 @@ namespace GreenshotPlugin.Core {
if (!languageFiles.ContainsKey(ietf)) {
LOG.WarnFormat("No match for language {0} found!", ietf);
} else {
if (currentLanguage == null && !currentLanguage.Equals(ietf)) {
if (currentLanguage == null || !currentLanguage.Equals(ietf)) {
currentLanguage = ietf;
Reload();
return;