Fixes for Bug #3579467, context menu entries are updated when changing the language / hotkeys.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2200 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-25 12:43:44 +00:00
parent eeca9ec0de
commit 8b331ee3a4
8 changed files with 71 additions and 14 deletions

View file

@ -407,9 +407,6 @@ namespace Greenshot {
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
coreConfiguration.UpdateCheckInterval = (int)numericUpDown_daysbetweencheck.Value;
// Make sure the current language & settings are reflected in the Main-context menu
MainForm.Instance.UpdateUI();
try {
// Check if the Run for all is set
if(!StartupHelper.checkRunAll()) {
@ -438,6 +435,9 @@ namespace Greenshot {
SaveSettings();
StoreFields();
MainForm.RegisterHotkeys();
// Make sure the current language & settings are reflected in the Main-context menu
MainForm.Instance.UpdateUI();
DialogResult = DialogResult.OK;
} else {
this.tabcontrol.SelectTab(this.tab_output);

View file

@ -39,6 +39,7 @@ namespace GreenshotBoxPlugin {
public static PluginAttribute Attributes;
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem itemPlugInConfig;
public BoxPlugin() {
}
@ -65,16 +66,22 @@ namespace GreenshotBoxPlugin {
config = IniConfig.GetIniSection<BoxConfiguration>();
resources = new ComponentResourceManager(typeof(BoxPlugin));
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig.Image = (Image)resources.GetObject("Box");
itemPlugInConfig.Text = Language.GetString("box", LangKey.Configure);
itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
}
public void OnLanguageChanged() {
if (itemPlugInConfig != null) {
itemPlugInConfig.Text = Language.GetString("box", LangKey.Configure);
}
}
public virtual void Shutdown() {
LOG.Debug("Box Plugin shutdown.");
}

View file

@ -39,6 +39,7 @@ namespace GreenshotDropboxPlugin {
public static PluginAttribute Attributes;
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem itemPlugInConfig;
public DropboxPlugin() {
}
@ -65,17 +66,23 @@ namespace GreenshotDropboxPlugin {
config = IniConfig.GetIniSection<DropboxPluginConfiguration>();
resources = new ComponentResourceManager(typeof(DropboxPlugin));
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
itemPlugInConfig.Tag = host;
itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
itemPlugInConfig.Image = (Image)resources.GetObject("Dropbox");
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
}
public void OnLanguageChanged() {
if (itemPlugInConfig != null) {
itemPlugInConfig.Text = Language.GetString("dropbox", LangKey.Configure);
}
}
public virtual void Shutdown() {
LOG.Debug("Dropbox Plugin shutdown.");
}

View file

@ -35,6 +35,7 @@ namespace ExternalCommand {
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private IGreenshotHost host;
private PluginAttribute myAttributes;
private ToolStripMenuItem itemPlugInRoot;
public ExternalCommandPlugin() {
}
@ -68,7 +69,7 @@ namespace ExternalCommand {
this.myAttributes = myAttributes;
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem();
itemPlugInRoot = new ToolStripMenuItem();
itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
itemPlugInRoot.Tag = host;
string exePath = PluginUtils.GetExePath("cmd.exe");
@ -78,9 +79,16 @@ namespace ExternalCommand {
itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
}
public void OnLanguageChanged() {
if (itemPlugInRoot != null) {
itemPlugInRoot.Text = Language.GetString("externalcommand", "contextmenu_configure");
}
}
public virtual void Shutdown() {
LOG.Debug("Shutdown of " + myAttributes.Name);
}

View file

@ -40,6 +40,7 @@ namespace GreenshotFlickrPlugin
public static PluginAttribute Attributes;
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem itemPlugInConfig;
public FlickrPlugin() {
}
@ -67,17 +68,23 @@ namespace GreenshotFlickrPlugin
config = IniConfig.GetIniSection<FlickrConfiguration>();
resources = new ComponentResourceManager(typeof(FlickrPlugin));
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig = new ToolStripMenuItem();
itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure);
itemPlugInConfig.Tag = host;
itemPlugInConfig.Image = (Image)resources.GetObject("flickr");
itemPlugInConfig.Click += new System.EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInConfig);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
}
public void OnLanguageChanged() {
if (itemPlugInConfig != null) {
itemPlugInConfig.Text = Language.GetString("flickr", LangKey.Configure);
}
}
public virtual void Shutdown() {
LOG.Debug("Flickr Plugin shutdown.");
}

View file

@ -41,6 +41,7 @@ namespace GreenshotImgurPlugin {
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem historyMenuItem = null;
private ToolStripMenuItem itemPlugInConfig;
public ImgurPlugin() {
}
@ -78,7 +79,7 @@ namespace GreenshotImgurPlugin {
};
itemPlugInRoot.DropDownItems.Add(historyMenuItem);
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure));
itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.configure));
itemPlugInConfig.Tag = host;
itemPlugInConfig.Click += delegate {
config.ShowConfigDialog();
@ -86,6 +87,7 @@ namespace GreenshotImgurPlugin {
itemPlugInRoot.DropDownItems.Add(itemPlugInConfig);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
// retrieve history in the background
Thread backgroundTask = new Thread (new ThreadStart(CheckHistory));
@ -96,6 +98,15 @@ namespace GreenshotImgurPlugin {
return true;
}
public void OnLanguageChanged() {
if (itemPlugInConfig != null) {
itemPlugInConfig.Text = Language.GetString("imgur", LangKey.configure);
}
if (historyMenuItem != null) {
historyMenuItem.Text = Language.GetString("imgur", LangKey.history);
}
}
private void CheckHistory() {
try {
ImgurUtils.LoadHistory();

View file

@ -38,6 +38,7 @@ namespace GreenshotPicasaPlugin {
public static PluginAttribute Attributes;
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem itemPlugInRoot;
public PicasaPlugin() {
}
@ -65,18 +66,25 @@ namespace GreenshotPicasaPlugin {
config = IniConfig.GetIniSection<PicasaConfiguration>();
resources = new ComponentResourceManager(typeof(PicasaPlugin));
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem();
itemPlugInRoot = new ToolStripMenuItem();
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
itemPlugInRoot.Tag = host;
itemPlugInRoot.Image = (Image)resources.GetObject("Picasa");
itemPlugInRoot.Click += new System.EventHandler(ConfigMenuClick);
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
Language.LanguageChanged += new LanguageChangedHandler(OnLanguageChanged);
return true;
}
public void OnLanguageChanged() {
if (itemPlugInRoot != null) {
itemPlugInRoot.Text = Language.GetString("picasa", LangKey.Configure);
}
}
public virtual void Shutdown() {
LOG.Debug("Picasa Plugin shutdown.");
Language.LanguageChanged -= new LanguageChangedHandler(OnLanguageChanged);
//host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened);
}

View file

@ -28,6 +28,7 @@ using Greenshot.IniFile;
using Microsoft.Win32;
namespace GreenshotPlugin.Core {
public delegate void LanguageChangedHandler();
/// <summary>
/// This class supplies the GUI with translations, based upon keys.
/// The language resources are loaded from the language files found on fixed or supplied paths
@ -49,6 +50,8 @@ namespace GreenshotPlugin.Core {
private static string currentLanguage = null;
private static CoreConfiguration coreConfig = null;
public static event LanguageChangedHandler LanguageChanged;
/// <summary>
/// Static initializer for the language code
/// </summary>
@ -197,6 +200,12 @@ namespace GreenshotPlugin.Core {
if (currentLanguage == null || !currentLanguage.Equals(ietf)) {
currentLanguage = ietf;
Reload();
if (LanguageChanged != null) {
try {
LanguageChanged();
} catch {
}
}
return;
}
}