diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 2ae335e26..a5dfc1d89 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -13,7 +13,8 @@ namespace GreenshotPlugin.Controls { public abstract class GreenshotForm : Form, IGreenshotLanguageBindable { private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm)); private IComponentChangeService m_changeService; - private bool isLanguageSet = false; + private bool isDesignModeLanguageSet = false; + private bool applyLanguageManually = false; private IDictionary designTimeControls; private IDictionary designTimeToolStripItems; [Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")] @@ -22,6 +23,15 @@ namespace GreenshotPlugin.Controls { set; } + protected bool ManualLanguageApply { + get { + return applyLanguageManually; + } + set { + applyLanguageManually = value; + } + } + /// /// Code to initialize the language etc during design time /// @@ -57,8 +67,8 @@ namespace GreenshotPlugin.Controls { /// protected override void OnPaint(PaintEventArgs e) { if (this.DesignMode) { - if (!isLanguageSet) { - isLanguageSet = true; + if (!isDesignModeLanguageSet) { + isDesignModeLanguageSet = true; try { ApplyLanguage(); } catch (Exception ex) { @@ -71,7 +81,9 @@ namespace GreenshotPlugin.Controls { protected override void OnLoad(EventArgs e) { if (!this.DesignMode) { - ApplyLanguage(); + if (!applyLanguageManually) { + ApplyLanguage(); + } FillFields(); base.OnLoad(e); } else { @@ -265,8 +277,8 @@ namespace GreenshotPlugin.Controls { } // Reset the text values for all GreenshotControls 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); + if (!field.FieldType.IsSubclassOf(typeof(Control)) && !field.FieldType.IsSubclassOf(typeof(ToolStripItem))) { + LOG.DebugFormat("No Control or ToolStripItem: {0}", field.Name); continue; } Object controlObject = field.GetValue(this); @@ -274,13 +286,17 @@ namespace GreenshotPlugin.Controls { LOG.DebugFormat("No value: {0}", field.Name); continue; } - Control applyTo = controlObject as Control; - if (applyTo == null) { - // not a control - LOG.DebugFormat("No control: {0}", field.Name); - continue; + Control applyToControl = controlObject as Control; + if (applyToControl == null) { + ToolStripItem applyToItem = controlObject as ToolStripItem; + if (applyToItem == null) { + LOG.DebugFormat("No Control or ToolStripItem: {0}", field.Name); + continue; + } + ApplyLanguage(applyToItem); + } else { + ApplyLanguage(applyToControl); } - ApplyLanguage(applyTo); } if (DesignMode) { diff --git a/GreenshotPlugin/Controls/GreenshotToolDropDownButton.cs b/GreenshotPlugin/Controls/GreenshotToolDropDownButton.cs new file mode 100644 index 000000000..21fc5e3fe --- /dev/null +++ b/GreenshotPlugin/Controls/GreenshotToolDropDownButton.cs @@ -0,0 +1,33 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace GreenshotPlugin.Controls { + public class GreenshotToolStripDropDownButton : ToolStripDropDownButton, IGreenshotLanguageBindable { + [Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")] + public string LanguageKey { + get; + set; + } + } +} diff --git a/GreenshotPlugin/Controls/GreenshotToolStripButton.cs b/GreenshotPlugin/Controls/GreenshotToolStripButton.cs new file mode 100644 index 000000000..49a1fb15a --- /dev/null +++ b/GreenshotPlugin/Controls/GreenshotToolStripButton.cs @@ -0,0 +1,33 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.ComponentModel; +using System.Windows.Forms; + +namespace GreenshotPlugin.Controls { + public class GreenshotToolStripButton : ToolStripButton, IGreenshotLanguageBindable { + [Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")] + public string LanguageKey { + get; + set; + } + } +} diff --git a/GreenshotPlugin/Controls/GreenshotToolStripLabel.cs b/GreenshotPlugin/Controls/GreenshotToolStripLabel.cs new file mode 100644 index 000000000..64293ad19 --- /dev/null +++ b/GreenshotPlugin/Controls/GreenshotToolStripLabel.cs @@ -0,0 +1,33 @@ +/* + * Greenshot - a free and open source screenshot tool + * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom + * + * For more information see: http://getgreenshot.org/ + * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/ + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +using System; +using System.Windows.Forms; +using System.ComponentModel; + +namespace GreenshotPlugin.Controls { + public class GreenshotToolStripLabel : ToolStripLabel, IGreenshotLanguageBindable { + [Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")] + public string LanguageKey { + get; + set; + } + } +} diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj index cbd927f7d..e6758989a 100644 --- a/GreenshotPlugin/GreenshotPlugin.csproj +++ b/GreenshotPlugin/GreenshotPlugin.csproj @@ -214,6 +214,15 @@ + + Component + + + Component + + + Component +