diff --git a/Greenshot-OCR-Plugin/Language.cs b/Greenshot-OCR-Plugin/Language.cs index 81c7ca265..d7b168cd1 100644 --- a/Greenshot-OCR-Plugin/Language.cs +++ b/Greenshot-OCR-Plugin/Language.cs @@ -31,13 +31,10 @@ namespace GreenshotOCR { private const string LANGUAGE_FILENAME_PATTERN = @"language_ocrplugin-*.xml"; public static ILanguage GetInstance() { - if(uniqueInstance == null) { - uniqueInstance = new LanguageContainer(); - uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN; - uniqueInstance.Load(); - uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name); + if (uniqueInstance == null) { + uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN); } return uniqueInstance; } - } + } } diff --git a/Greenshot-OCR-Plugin/SettingsForm.cs b/Greenshot-OCR-Plugin/SettingsForm.cs index bf407480c..0f79e0cba 100644 --- a/Greenshot-OCR-Plugin/SettingsForm.cs +++ b/Greenshot-OCR-Plugin/SettingsForm.cs @@ -37,7 +37,6 @@ namespace GreenshotOCR { this.config = config; InitializeComponent(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); - language.SynchronizeLanguageToCulture(); initializeComponentText(); comboBox_languages.Items.Clear(); diff --git a/Greenshot/Configuration/Language.cs b/Greenshot/Configuration/Language.cs index 529a6efc2..66b9ee44c 100644 --- a/Greenshot/Configuration/Language.cs +++ b/Greenshot/Configuration/Language.cs @@ -41,9 +41,9 @@ namespace Greenshot.Configuration { uniqueInstance.Load(); CoreConfiguration conf = IniConfig.GetIniSection(); if (string.IsNullOrEmpty(conf.Language)) { - uniqueInstance.SynchronizeLanguageToCulture(); + LanguageContainer.SynchronizeLanguageToCulture(); } else { - uniqueInstance.SetLanguage(conf.Language); + LanguageContainer.SetGlobalLanguage(conf.Language); } if (freeResources) { uniqueInstance.FreeResources(); diff --git a/Greenshot/Forms/LanguageDialog.cs b/Greenshot/Forms/LanguageDialog.cs index c5fa4d0cf..8b2887912 100644 --- a/Greenshot/Forms/LanguageDialog.cs +++ b/Greenshot/Forms/LanguageDialog.cs @@ -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(); } diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 8c03b647d..6ec4ac01a 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -431,7 +431,7 @@ namespace Greenshot { /// 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 diff --git a/Greenshot/Forms/SettingsForm.Designer.cs b/Greenshot/Forms/SettingsForm.Designer.cs index 5dd23bf6a..2309a7614 100644 --- a/Greenshot/Forms/SettingsForm.Designer.cs +++ b/Greenshot/Forms/SettingsForm.Designer.cs @@ -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(); @@ -374,7 +374,7 @@ namespace Greenshot { this.destinationsListView.AutoArrange = false; this.destinationsListView.CheckBoxes = true; this.destinationsListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.destination}); + this.destination}); this.destinationsListView.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.destinationsListView.LabelWrap = false; this.destinationsListView.Location = new System.Drawing.Point(6, 38); @@ -701,16 +701,16 @@ namespace Greenshot { // numericUpDownWaitTime // this.numericUpDownWaitTime.Increment = new decimal(new int[] { - 100, - 0, - 0, - 0}); + 100, + 0, + 0, + 0}); this.numericUpDownWaitTime.Location = new System.Drawing.Point(11, 69); this.numericUpDownWaitTime.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); + 10000, + 0, + 0, + 0}); this.numericUpDownWaitTime.Name = "numericUpDownWaitTime"; this.numericUpDownWaitTime.Size = new System.Drawing.Size(57, 20); this.numericUpDownWaitTime.TabIndex = 24; @@ -867,9 +867,9 @@ namespace Greenshot { // // groupbox_plugins // - this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.groupbox_plugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupbox_plugins.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; this.groupbox_plugins.Controls.Add(this.listview_plugins); this.groupbox_plugins.Controls.Add(this.button_pluginconfigure); diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index 8da3953b6..9d8d6e2df 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -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"; @@ -237,9 +240,10 @@ namespace Greenshot { // Set datasource last to prevent problems // See: http://www.codeproject.com/KB/database/scomlistcontrolbinding.aspx?fid=111644 this.combobox_language.DataSource = lang.SupportedLanguages; - + // 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,6 +258,50 @@ namespace Greenshot { return settingsOk; } + private void UpdateDestinations() { + foreach (ListViewItem item in destinationsListView.Items) { + IDestination destination = item.Tag as IDestination; + item.Text = destination.Description; + } + } + + private void DisplayDestinations() { + checkbox_picker.Checked = false; + + destinationsListView.Items.Clear(); + destinationsListView.ListViewItemSorter = new ListviewWithDestinationComparer(); + ImageList imageList = new ImageList(); + destinationsListView.SmallImageList = imageList; + int imageNr = -1; + foreach (IDestination destination in DestinationHelper.GetAllDestinations()) { + Image destinationImage = destination.DisplayIcon; + if (destinationImage != null) { + imageList.Images.Add(destination.DisplayIcon); + imageNr++; + } + if (PickerDestination.DESIGNATION.Equals(destination.Designation)) { + checkbox_picker.Checked = true; + checkbox_picker.Text = destination.Description; + } else { + ListViewItem item; + if (destinationImage != null) { + item = destinationsListView.Items.Add(destination.Description, imageNr); + } else { + item = destinationsListView.Items.Add(destination.Description); + } + item.Tag = destination; + item.Checked = coreConfiguration.OutputDestinations.Contains(destination.Designation); + } + } + if (checkbox_picker.Checked) { + destinationsListView.Enabled = false; + foreach (int index in destinationsListView.CheckedIndices) { + ListViewItem item = destinationsListView.Items[index]; + item.Checked = false; + } + } + } + private void DisplaySettings() { region_hotkeyControl.SetHotkey(coreConfiguration.RegionHotkey); fullscreen_hotkeyControl.SetHotkey(coreConfiguration.FullscreenHotkey); @@ -277,41 +325,9 @@ namespace Greenshot { textBoxJpegQuality.Text = coreConfiguration.OutputFileJpegQuality+"%"; checkbox_alwaysshowjpegqualitydialog.Checked = coreConfiguration.OutputFilePromptQuality; checkbox_playsound.Checked = coreConfiguration.PlayCameraSound; - - checkbox_picker.Checked = false; - destinationsListView.Items.Clear(); - destinationsListView.ListViewItemSorter = new ListviewWithDestinationComparer(); - ImageList imageList = new ImageList(); - destinationsListView.SmallImageList = imageList; - int imageNr = -1; - foreach(IDestination destination in DestinationHelper.GetAllDestinations()) { - Image destinationImage = destination.DisplayIcon; - if (destinationImage != null) { - imageList.Images.Add(destination.DisplayIcon); - imageNr++; - } - if (PickerDestination.DESIGNATION.Equals(destination.Designation)) { - checkbox_picker.Checked = true; - checkbox_picker.Text = destination.Description; - } else { - ListViewItem item; - if (destinationImage != null) { - item = destinationsListView.Items.Add(destination.Description, imageNr); - } else { - item = destinationsListView.Items.Add(destination.Description); - } - item.Tag = destination; - item.Checked = coreConfiguration.OutputDestinations.Contains(destination.Designation); - } - } - if (checkbox_picker.Checked) { - destinationsListView.Enabled = false; - foreach(int index in destinationsListView.CheckedIndices) { - ListViewItem item = destinationsListView.Items[index]; - item.Checked = false; - } - } + DisplayDestinations(); + // checkbox_clipboard.Checked = coreConfiguration.OutputDestinations.Contains("Clipboard"); // checkbox_file.Checked = coreConfiguration.OutputDestinations.Contains("File"); // checkbox_fileas.Checked = coreConfiguration.OutputDestinations.Contains("FileWithDialog"); @@ -480,14 +496,14 @@ namespace Greenshot { void Button_pluginconfigureClick(object sender, EventArgs e) { PluginHelper.instance.ConfigureSelectedItem(listview_plugins); } - + void Combobox_languageSelectedIndexChanged(object sender, EventArgs e) { // Get the combobox values BEFORE changing the language //EmailFormat selectedEmailFormat = GetSelected(combobox_emailformat); WindowCaptureMode selectedWindowCaptureMode = GetSelected(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(); diff --git a/Greenshot/Languages/language-de-DE.xml b/Greenshot/Languages/language-de-DE.xml index ade4dfb6c..c8ef4f4be 100644 --- a/Greenshot/Languages/language-de-DE.xml +++ b/Greenshot/Languages/language-de-DE.xml @@ -263,7 +263,7 @@ Sie können alle Greenshot-Funktionen aber auch über das Kontextmenü des Green In Zwischenablage kopieren - Ziel auswählen + Ziel dynamisch auswählen Linie zeichnen (L) diff --git a/Greenshot/Languages/language-en-US.xml b/Greenshot/Languages/language-en-US.xml index 0d8d393af..267faa228 100644 --- a/Greenshot/Languages/language-en-US.xml +++ b/Greenshot/Languages/language-en-US.xml @@ -268,7 +268,7 @@ All Greenshot features still work directly from the tray icon context menu witho Copy to clipboard - Select destination + Select destination dynamically Draw line (L) diff --git a/Greenshot/Languages/language-nl-NL.xml b/Greenshot/Languages/language-nl-NL.xml index 2e1f72874..4d53504ce 100644 --- a/Greenshot/Languages/language-nl-NL.xml +++ b/Greenshot/Languages/language-nl-NL.xml @@ -258,7 +258,7 @@ Alle Greenshot functies werken ook over het context menu. Kopieer naar klembord - Doel kiezen + Dynamisch het doel kiezen Lijn tekenen (L) diff --git a/Greenshot/releases/additional_files/readme.txt b/Greenshot/releases/additional_files/readme.txt index 54555fb7f..6fdabee5c 100644 --- a/Greenshot/releases/additional_files/readme.txt +++ b/Greenshot/releases/additional_files/readme.txt @@ -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: diff --git a/GreenshotConfluencePlugin/Language.cs b/GreenshotConfluencePlugin/Language.cs index 83a58ba18..1302144df 100644 --- a/GreenshotConfluencePlugin/Language.cs +++ b/GreenshotConfluencePlugin/Language.cs @@ -32,12 +32,9 @@ 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; } - } + } } diff --git a/GreenshotImgurPlugin/Language.cs b/GreenshotImgurPlugin/Language.cs index 71a2d3f55..2ad69ab6c 100644 --- a/GreenshotImgurPlugin/Language.cs +++ b/GreenshotImgurPlugin/Language.cs @@ -32,12 +32,9 @@ 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; } - } + } } diff --git a/GreenshotJiraPlugin/Forms/JiraForm.cs b/GreenshotJiraPlugin/Forms/JiraForm.cs index b5bb996b6..16a2b1f46 100644 --- a/GreenshotJiraPlugin/Forms/JiraForm.cs +++ b/GreenshotJiraPlugin/Forms/JiraForm.cs @@ -38,7 +38,6 @@ namespace GreenshotJiraPlugin { public JiraForm(JiraConnector jiraConnector) { InitializeComponent(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); - language.SynchronizeLanguageToCulture(); initializeComponentText(); this.columnSorter = new ListViewColumnSorter(); diff --git a/GreenshotJiraPlugin/Language.cs b/GreenshotJiraPlugin/Language.cs index 607a34bb4..b71947233 100644 --- a/GreenshotJiraPlugin/Language.cs +++ b/GreenshotJiraPlugin/Language.cs @@ -32,12 +32,9 @@ 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; } - } + } } diff --git a/GreenshotPlugin/Core/LanguageHelper.cs b/GreenshotPlugin/Core/LanguageHelper.cs index 752dc478b..6641a9fda 100644 --- a/GreenshotPlugin/Core/LanguageHelper.cs +++ b/GreenshotPlugin/Core/LanguageHelper.cs @@ -42,13 +42,6 @@ namespace GreenshotPlugin.Core { string GetFormattedString(string id, object param); string GetHelpFilePath(); - /// - /// Set language - /// - /// wanted IETF - /// Actuall IETF - 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 strings = new Dictionary(); private List languages = new List(); private string currentIETF = null; private string languageFilePattern; private static List supportedLanguageGroups = new List(); + private static List instances = new List(); 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 { /// /// wanted IETF /// Actuall IETF - public string SetLanguage(string wantedIETF) { + public string SetInstanceLanguage(string wantedIETF) { LOG.Debug("SetLanguage called for : " + wantedIETF); Dictionary identifiedLanguages = new Dictionary(); @@ -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!!"); } }