Fixed language synchronizing over Greenshot and the plugins

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1741 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-02 16:56:03 +00:00
parent ee950872e9
commit 59f9922670
16 changed files with 116 additions and 102 deletions

View file

@ -32,10 +32,7 @@ namespace GreenshotOCR {
public static ILanguage GetInstance() {
if (uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
}
return uniqueInstance;
}

View file

@ -37,7 +37,6 @@ namespace GreenshotOCR {
this.config = config;
InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
language.SynchronizeLanguageToCulture();
initializeComponentText();
comboBox_languages.Items.Clear();

View file

@ -41,9 +41,9 @@ namespace Greenshot.Configuration {
uniqueInstance.Load();
CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
if (string.IsNullOrEmpty(conf.Language)) {
uniqueInstance.SynchronizeLanguageToCulture();
LanguageContainer.SynchronizeLanguageToCulture();
} else {
uniqueInstance.SetLanguage(conf.Language);
LanguageContainer.SetGlobalLanguage(conf.Language);
}
if (freeResources) {
uniqueInstance.FreeResources();

View file

@ -77,7 +77,7 @@ namespace Greenshot.Forms {
// But the use-case is not so interesting, only happens once, to invest a lot of time here.
if (language.SupportedLanguages.Count == 1) {
this.comboBoxLanguage.SelectedValue = language.SupportedLanguages[0].Ietf;
language.SetLanguage(SelectedLanguage);
LanguageContainer.SetGlobalLanguage(SelectedLanguage);
properOkPressed = true;
this.Close();
}
@ -86,7 +86,7 @@ namespace Greenshot.Forms {
void BtnOKClick(object sender, EventArgs e) {
properOkPressed = true;
// Fix for Bug #3431100
language.SetLanguage(SelectedLanguage);
LanguageContainer.SetGlobalLanguage(SelectedLanguage);
this.Close();
}

View file

@ -431,7 +431,7 @@ namespace Greenshot {
/// <param name="e"></param>
private void ReloadConfiguration(object source, FileSystemEventArgs e) {
lang.Load();
lang.SetLanguage(conf.Language);
LanguageContainer.SetGlobalLanguage(conf.Language);
lang.FreeResources();
this.Invoke((MethodInvoker) delegate {
// Even update language when needed

View file

@ -72,7 +72,7 @@ namespace Greenshot {
this.groupbox_destination = new System.Windows.Forms.GroupBox();
this.checkbox_picker = new System.Windows.Forms.CheckBox();
this.destinationsListView = new System.Windows.Forms.ListView();
this.destination = new System.Windows.Forms.ColumnHeader();
this.destination = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tabcontrol = new System.Windows.Forms.TabControl();
this.tab_general = new System.Windows.Forms.TabPage();
this.groupbox_network = new System.Windows.Forms.GroupBox();

View file

@ -228,6 +228,9 @@ namespace Greenshot {
this.label_region_hotkey.Text = lang.GetString(LangKey.contextmenu_capturearea);
this.label_window_hotkey.Text = lang.GetString(LangKey.contextmenu_capturewindow);
// Removing, otherwise we keep getting the event multiple times!
this.combobox_language.SelectedIndexChanged -= new System.EventHandler(this.Combobox_languageSelectedIndexChanged);
// Initialize the Language ComboBox
this.combobox_language.DisplayMember = "Description";
this.combobox_language.ValueMember = "Ietf";
@ -240,6 +243,7 @@ namespace Greenshot {
// Delaying the SelectedIndexChanged events untill all is initiated
this.combobox_language.SelectedIndexChanged += new System.EventHandler(this.Combobox_languageSelectedIndexChanged);
UpdateDestinations();
}
// Check the settings and somehow visibly mark when something is incorrect
@ -254,30 +258,14 @@ namespace Greenshot {
return settingsOk;
}
private void DisplaySettings() {
region_hotkeyControl.SetHotkey(coreConfiguration.RegionHotkey);
fullscreen_hotkeyControl.SetHotkey(coreConfiguration.FullscreenHotkey);
window_hotkeyControl.SetHotkey(coreConfiguration.WindowHotkey);
lastregion_hotkeyControl.SetHotkey(coreConfiguration.LastregionHotkey);
ie_hotkeyControl.SetHotkey(coreConfiguration.IEHotkey);
colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;
checkbox_ie_capture.Checked = coreConfiguration.IECapture;
if (lang.CurrentLanguage != null) {
combobox_language.SelectedValue = lang.CurrentLanguage;
private void UpdateDestinations() {
foreach (ListViewItem item in destinationsListView.Items) {
IDestination destination = item.Tag as IDestination;
item.Text = destination.Description;
}
}
textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);
textbox_screenshotname.Text = coreConfiguration.OutputFileFilenamePattern;
combobox_primaryimageformat.SelectedItem = coreConfiguration.OutputFileFormat;
SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);
checkbox_copypathtoclipboard.Checked = coreConfiguration.OutputFileCopyPathToClipboard;
trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality;
textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%";
checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality;
checkbox_playsound.Checked = coreConfiguration.PlayCameraSound;
private void DisplayDestinations() {
checkbox_picker.Checked = false;
destinationsListView.Items.Clear();
@ -312,6 +300,34 @@ namespace Greenshot {
item.Checked = false;
}
}
}
private void DisplaySettings() {
region_hotkeyControl.SetHotkey(coreConfiguration.RegionHotkey);
fullscreen_hotkeyControl.SetHotkey(coreConfiguration.FullscreenHotkey);
window_hotkeyControl.SetHotkey(coreConfiguration.WindowHotkey);
lastregion_hotkeyControl.SetHotkey(coreConfiguration.LastregionHotkey);
ie_hotkeyControl.SetHotkey(coreConfiguration.IEHotkey);
colorButton_window_background.SelectedColor = coreConfiguration.DWMBackgroundColor;
checkbox_ie_capture.Checked = coreConfiguration.IECapture;
if (lang.CurrentLanguage != null) {
combobox_language.SelectedValue = lang.CurrentLanguage;
}
textbox_storagelocation.Text = FilenameHelper.FillVariables(coreConfiguration.OutputFilePath, false);
textbox_screenshotname.Text = coreConfiguration.OutputFileFilenamePattern;
combobox_primaryimageformat.SelectedItem = coreConfiguration.OutputFileFormat;
SetWindowCaptureMode(coreConfiguration.WindowCaptureMode);
checkbox_copypathtoclipboard.Checked = coreConfiguration.OutputFileCopyPathToClipboard;
trackBarJpegQuality.Value = coreConfiguration.OutputFileJpegQuality;
textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%";
checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality;
checkbox_playsound.Checked = coreConfiguration.PlayCameraSound;
DisplayDestinations();
// checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard");
// checkbox_file.Checked = coreConfiguration.OutputDestinations.Contains("File");
// checkbox_fileas.Checked = coreConfiguration.OutputDestinations.Contains("FileWithDialog");
@ -487,7 +503,7 @@ namespace Greenshot {
WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
if (combobox_language.SelectedItem != null) {
LOG.Debug("Setting language to: " + (string)combobox_language.SelectedValue);
lang.SetLanguage((string)combobox_language.SelectedValue);
LanguageContainer.SetGlobalLanguage((string)combobox_language.SelectedValue);
}
// Reflect language changes to the settings form
UpdateUI();

View file

@ -263,7 +263,7 @@ Sie können alle Greenshot-Funktionen aber auch über das Kontextmenü des Green
In Zwischenablage kopieren
</resource>
<resource name="settings_destination_picker">
Ziel auswählen
Ziel dynamisch auswählen
</resource>
<resource name="editor_drawline">
Linie zeichnen (L)

View file

@ -268,7 +268,7 @@ All Greenshot features still work directly from the tray icon context menu witho
Copy to clipboard
</resource>
<resource name="settings_destination_picker">
Select destination
Select destination dynamically
</resource>
<resource name="editor_drawline">
Draw line (L)

View file

@ -258,7 +258,7 @@ Alle Greenshot functies werken ook over het context menu.
Kopieer naar klembord
</resource>
<resource name="settings_destination_picker">
Doel kiezen
Dynamisch het doel kiezen
</resource>
<resource name="editor_drawline">
Lijn tekenen (L)

View file

@ -3,9 +3,9 @@ Greenshot: A screenshot tool optimized for productivity. Save a screenshot or a
CHANGE LOG:
0.9.0 Build 1714
1.0.0 build 1740
We changed the version to 0.9.0 as the amount of features in 0.8.1 was more than planned.
We changed the version to 1.0.0, after 5 year the version should no longer have a "beta" feeling!
Bugs resolved:
* Fixed a problem with the window preview, if the window had a small height, when using the context menu (Windows Vista and later)
@ -16,17 +16,20 @@ Bugs resolved:
* Fixed bug #3482709 print with timestamp cropped the image
* Removed the always active CaptureForm, which resulted in greenshot not "recovering" when a capture caused an exception.
* Improved the auto-capture mode to honor some settings better
* Synchronized the selected language to the plugins
Features added:
* Greenshot will now run in 64 bit mode, if the OS supports it.
* Added a "destinations" concept, making it possible to select all destinations from the main settings or using them inside the editor.
* Added a "processor" concept, making it possible to modify the capture before it's send to a destination. Currently there is only an internal implementation which replaces the TitleFix plugin.
* Added Office destinations (Word, Excel, Powerpoint & Outlook) with dynamic resolving of open "instances".
* Added Office destinations (Word, Excel, Powerpoint, OneNote & Outlook) with dynamic resolving of open "instances".
* Added Ctrl/shift logic to the editor, hard to explain (see help) but hold one of the keys down and draw..
* Added a color picker in the color dialog.
* Added shadow & torn edges
* Added effects: shadow, torn edges, invert, border and grayscale
* Added rotate clockwise & counter clockwise
* Added color reduction as an option and auto detection for image with less than 256 color. When using reduction this results in smaller files.
0.8.1 Build 1483
Bugs resolved:

View file

@ -32,10 +32,7 @@ namespace GreenshotConfluencePlugin {
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
}
return uniqueInstance;
}

View file

@ -32,10 +32,7 @@ namespace GreenshotImgurPlugin {
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
}
return uniqueInstance;
}

View file

@ -38,7 +38,6 @@ namespace GreenshotJiraPlugin {
public JiraForm(JiraConnector jiraConnector) {
InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
language.SynchronizeLanguageToCulture();
initializeComponentText();
this.columnSorter = new ListViewColumnSorter();

View file

@ -32,10 +32,7 @@ namespace GreenshotJiraPlugin {
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
}
return uniqueInstance;
}

View file

@ -42,13 +42,6 @@ namespace GreenshotPlugin.Core {
string GetFormattedString(string id, object param);
string GetHelpFilePath();
/// <summary>
/// Set language
/// </summary>
/// <param name="wantedIETF">wanted IETF</param>
/// <returns>Actuall IETF </returns>
string SetLanguage(string cultureInfo);
void SynchronizeLanguageToCulture();
void FreeResources();
string CurrentLanguage {
@ -81,12 +74,14 @@ namespace GreenshotPlugin.Core {
private static string PAF_LANGUAGE_PATH = Path.Combine(APPLICATION_PATH, @"App\Greenshot\Languages");
private const string HELP_FILENAME_PATTERN = @"help-*.html";
private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups";
private static string globalLanguage = null;
private Dictionary<string, string> strings = new Dictionary<string, string>();
private List<LanguageConfiguration> languages = new List<LanguageConfiguration>();
private string currentIETF = null;
private string languageFilePattern;
private static List<string> supportedLanguageGroups = new List<string>();
private static List<LanguageContainer> instances = new List<LanguageContainer>();
static LanguageContainer() {
try {
@ -108,6 +103,13 @@ namespace GreenshotPlugin.Core {
}
public LanguageContainer() {
instances.Add(this);
}
public LanguageContainer(string filePattern) : this() {
LanguageFilePattern = filePattern;
Load();
SetInstanceLanguage(globalLanguage);
}
public String LanguageFilePattern {
@ -146,9 +148,16 @@ namespace GreenshotPlugin.Core {
}
}
public void SynchronizeLanguageToCulture() {
if (CurrentLanguage == null || !CurrentLanguage.Equals(Thread.CurrentThread.CurrentUICulture.Name)) {
SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
public static void SynchronizeLanguageToCulture() {
if (globalLanguage == null || !globalLanguage.Equals(Thread.CurrentThread.CurrentUICulture.Name)) {
SetGlobalLanguage(Thread.CurrentThread.CurrentUICulture.Name);
}
}
public static void SetGlobalLanguage(string wantedIETF) {
globalLanguage = wantedIETF;
foreach (LanguageContainer langInstance in instances) {
langInstance.SetInstanceLanguage(wantedIETF);
}
}
@ -157,7 +166,7 @@ namespace GreenshotPlugin.Core {
/// </summary>
/// <param name="wantedIETF">wanted IETF</param>
/// <returns>Actuall IETF </returns>
public string SetLanguage(string wantedIETF) {
public string SetInstanceLanguage(string wantedIETF) {
LOG.Debug("SetLanguage called for : " + wantedIETF);
Dictionary<string, LanguageConfiguration> identifiedLanguages = new Dictionary<string, LanguageConfiguration>();
@ -176,9 +185,9 @@ namespace GreenshotPlugin.Core {
}
LanguageConfiguration selectedLanguage = null;
try {
if (identifiedLanguages.ContainsKey(wantedIETF)) {
selectedLanguage = identifiedLanguages[wantedIETF];
} catch (KeyNotFoundException) {
} else {
LOG.Warn("Selecteded language " + wantedIETF + " not found.");
}
@ -186,12 +195,12 @@ namespace GreenshotPlugin.Core {
if (selectedLanguage == null) {
foreach(string ietf in identifiedLanguages.Keys) {
if (ietf.StartsWith(wantedIETF)) {
try {
if (identifiedLanguages.ContainsKey(ietf)) {
selectedLanguage = identifiedLanguages[ietf];
LOG.Info("Selecteded language " + ietf + " by near match for: " + wantedIETF);
wantedIETF = ietf;
break;
} catch (KeyNotFoundException) {
} else {
LOG.Warn("Selecteded language " + wantedIETF + " not found.");
}
}
@ -199,9 +208,9 @@ namespace GreenshotPlugin.Core {
}
if (selectedLanguage == null && !DEFAULT_LANGUAGE.Equals(wantedIETF)) {
try {
if (identifiedLanguages.ContainsKey(DEFAULT_LANGUAGE)) {
selectedLanguage = identifiedLanguages[DEFAULT_LANGUAGE];
} catch (KeyNotFoundException) {
} else {
LOG.Warn("No english language file found!!");
}
}