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

View file

@ -39,7 +39,7 @@ namespace Greenshot {
// //
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.pictureBox1.Image = GreenshotPlugin.Core.GreenshotResources.getGreenshotImage();
Version v = Assembly.GetExecutingAssembly().GetName().Version; Version v = Assembly.GetExecutingAssembly().GetName().Version;
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")] // 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)"); 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> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BugReportForm));
this.labelBugReportInfo = new GreenshotPlugin.Controls.GreenshotLabel(); this.labelBugReportInfo = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxDescription = new System.Windows.Forms.TextBox(); this.textBoxDescription = new System.Windows.Forms.TextBox();
this.btnClose = new GreenshotPlugin.Controls.GreenshotButton(); this.btnClose = new GreenshotPlugin.Controls.GreenshotButton();
@ -60,7 +59,6 @@ namespace Greenshot.Forms {
this.labelBugReportInfo.Name = "labelBugReportInfo"; this.labelBugReportInfo.Name = "labelBugReportInfo";
this.labelBugReportInfo.Size = new System.Drawing.Size(481, 141); this.labelBugReportInfo.Size = new System.Drawing.Size(481, 141);
this.labelBugReportInfo.TabIndex = 0; this.labelBugReportInfo.TabIndex = 0;
this.labelBugReportInfo.Text = resources.GetString("labelBugReportInfo.Text");
// //
// textBoxDescription // textBoxDescription
// //

View file

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

View file

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

View file

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