Test with the ImgurPlugin and designer language support, the form needs to extend a simple class which extends GreenshotForm and implements the language pattern getter. Some day we can change this to be simpler when there is only one global Language object...

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1774 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-12 14:44:21 +00:00
commit d1b5232898
9 changed files with 190 additions and 87 deletions

View file

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
using System.ComponentModel.Design;
using System.Reflection;
using System.IO;
using System.Windows.Forms;
namespace GreenshotImgurPlugin.Forms {
public class ImgurForm : GreenshotForm {
protected override string LanguagePattern {
get {
return Language.LANGUAGE_FILENAME_PATTERN;
}
}
}
}

View file

@ -46,19 +46,20 @@ namespace GreenshotImgurPlugin {
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new GreenshotPlugin.Controls.GreenshotButton();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton();
this.label_url = new System.Windows.Forms.Label(); this.label_url = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxUrl = new System.Windows.Forms.TextBox(); this.textBoxUrl = new GreenshotPlugin.Controls.GreenshotTextBox();
this.combobox_uploadimageformat = new System.Windows.Forms.ComboBox(); this.combobox_uploadimageformat = new GreenshotPlugin.Controls.GreenshotComboBox();
this.label_upload_format = new System.Windows.Forms.Label(); this.label_upload_format = new GreenshotPlugin.Controls.GreenshotLabel();
this.historyButton = new System.Windows.Forms.Button(); this.historyButton = new GreenshotPlugin.Controls.GreenshotButton();
this.checkbox_usepagelink = new System.Windows.Forms.CheckBox(); this.checkbox_usepagelink = new GreenshotPlugin.Controls.GreenshotCheckBox();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonOK // buttonOK
// //
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.LanguageKey = "OK";
this.buttonOK.Location = new System.Drawing.Point(222, 129); this.buttonOK.Location = new System.Drawing.Point(222, 129);
this.buttonOK.Name = "buttonOK"; this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23); this.buttonOK.Size = new System.Drawing.Size(75, 23);
@ -69,6 +70,7 @@ namespace GreenshotImgurPlugin {
// buttonCancel // buttonCancel
// //
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.LanguageKey = "CANCEL";
this.buttonCancel.Location = new System.Drawing.Point(303, 129); this.buttonCancel.Location = new System.Drawing.Point(303, 129);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23); this.buttonCancel.Size = new System.Drawing.Size(75, 23);
@ -78,6 +80,7 @@ namespace GreenshotImgurPlugin {
// //
// label_url // label_url
// //
this.label_url.LanguageKey = "label_url";
this.label_url.Location = new System.Drawing.Point(12, 21); this.label_url.Location = new System.Drawing.Point(12, 21);
this.label_url.Name = "label_url"; this.label_url.Name = "label_url";
this.label_url.Size = new System.Drawing.Size(84, 20); this.label_url.Size = new System.Drawing.Size(84, 20);
@ -88,6 +91,8 @@ namespace GreenshotImgurPlugin {
this.textBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.textBoxUrl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.textBoxUrl.Location = new System.Drawing.Point(102, 21); this.textBoxUrl.Location = new System.Drawing.Point(102, 21);
this.textBoxUrl.Name = "textBoxUrl"; this.textBoxUrl.Name = "textBoxUrl";
this.textBoxUrl.PropertyName = "ImgurApiUrl";
this.textBoxUrl.SectionName = "Imgur";
this.textBoxUrl.Size = new System.Drawing.Size(276, 20); this.textBoxUrl.Size = new System.Drawing.Size(276, 20);
this.textBoxUrl.TabIndex = 6; this.textBoxUrl.TabIndex = 6;
// //
@ -97,20 +102,24 @@ namespace GreenshotImgurPlugin {
this.combobox_uploadimageformat.FormattingEnabled = true; this.combobox_uploadimageformat.FormattingEnabled = true;
this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 47); this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 47);
this.combobox_uploadimageformat.Name = "combobox_uploadimageformat"; this.combobox_uploadimageformat.Name = "combobox_uploadimageformat";
this.combobox_uploadimageformat.PropertyName = "UploadFormat";
this.combobox_uploadimageformat.SectionName = "Imgur";
this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21); this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21);
this.combobox_uploadimageformat.TabIndex = 8; this.combobox_uploadimageformat.TabIndex = 8;
// //
// label_upload_format // label_upload_format
// //
this.label_upload_format.LanguageKey = "label_upload_format";
this.label_upload_format.Location = new System.Drawing.Point(12, 50); this.label_upload_format.Location = new System.Drawing.Point(12, 50);
this.label_upload_format.Name = "label_upload_format"; this.label_upload_format.Name = "label_upload_format";
this.label_upload_format.Size = new System.Drawing.Size(84, 20); this.label_upload_format.Size = new System.Drawing.Size(84, 20);
this.label_upload_format.TabIndex = 9; this.label_upload_format.TabIndex = 9;
this.label_upload_format.Text = "Upload format"; this.label_upload_format.Text = "Image format";
// //
// historyButton // historyButton
// //
this.historyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.historyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.historyButton.LanguageKey = "imgur_history";
this.historyButton.Location = new System.Drawing.Point(13, 129); this.historyButton.Location = new System.Drawing.Point(13, 129);
this.historyButton.Name = "historyButton"; this.historyButton.Name = "historyButton";
this.historyButton.Size = new System.Drawing.Size(75, 23); this.historyButton.Size = new System.Drawing.Size(75, 23);
@ -122,9 +131,12 @@ namespace GreenshotImgurPlugin {
// checkbox_usepagelink // checkbox_usepagelink
// //
this.checkbox_usepagelink.AutoSize = true; this.checkbox_usepagelink.AutoSize = true;
this.checkbox_usepagelink.Location = new System.Drawing.Point(102, 97); this.checkbox_usepagelink.LanguageKey = "use_page_link";
this.checkbox_usepagelink.Name = "copyOriginalLinkCheck"; this.checkbox_usepagelink.Location = new System.Drawing.Point(15, 97);
this.checkbox_usepagelink.Size = new System.Drawing.Size(188, 17); this.checkbox_usepagelink.Name = "checkbox_usepagelink";
this.checkbox_usepagelink.PropertyName = "UsePageLink";
this.checkbox_usepagelink.SectionName = "Imgur";
this.checkbox_usepagelink.Size = new System.Drawing.Size(251, 17);
this.checkbox_usepagelink.TabIndex = 13; this.checkbox_usepagelink.TabIndex = 13;
this.checkbox_usepagelink.UseVisualStyleBackColor = true; this.checkbox_usepagelink.UseVisualStyleBackColor = true;
// //
@ -150,13 +162,13 @@ namespace GreenshotImgurPlugin {
this.PerformLayout(); this.PerformLayout();
} }
private System.Windows.Forms.Button historyButton; private GreenshotPlugin.Controls.GreenshotButton historyButton;
private System.Windows.Forms.ComboBox combobox_uploadimageformat; private GreenshotPlugin.Controls.GreenshotComboBox combobox_uploadimageformat;
private System.Windows.Forms.Label label_upload_format; private GreenshotPlugin.Controls.GreenshotLabel label_upload_format;
private System.Windows.Forms.TextBox textBoxUrl; private GreenshotPlugin.Controls.GreenshotTextBox textBoxUrl;
private System.Windows.Forms.Label label_url; private GreenshotPlugin.Controls.GreenshotLabel label_url;
private System.Windows.Forms.Button buttonCancel; private GreenshotPlugin.Controls.GreenshotButton buttonCancel;
private System.Windows.Forms.Button buttonOK; private GreenshotPlugin.Controls.GreenshotButton buttonOK;
private System.Windows.Forms.CheckBox checkbox_usepagelink; private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_usepagelink;
} }
} }

View file

@ -22,26 +22,21 @@ using System;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotImgurPlugin.Forms; using GreenshotImgurPlugin.Forms;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using GreenshotPlugin.Controls;
namespace GreenshotImgurPlugin { namespace GreenshotImgurPlugin {
/// <summary> /// <summary>
/// Description of PasswordRequestForm. /// Description of PasswordRequestForm.
/// </summary> /// </summary>
public partial class SettingsForm : Form { public partial class SettingsForm : ImgurForm {
private ILanguage lang = Language.GetInstance();
public SettingsForm(ImgurConfiguration config) { public SettingsForm(ImgurConfiguration config) {
language = Language.GetInstance();
// //
// The InitializeComponent() call is required for Windows Forms designer support. // The InitializeComponent() call is required for Windows Forms designer support.
// //
InitializeComponent(); InitializeComponent();
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon(); this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
InitializeTexts();
combobox_uploadimageformat.Items.Clear();
foreach(OutputFormat format in Enum.GetValues(typeof(OutputFormat))) {
combobox_uploadimageformat.Items.Add(format.ToString());
}
ImgurUtils.LoadHistory(); ImgurUtils.LoadHistory();
if (config.runtimeImgurHistory.Count > 0) { if (config.runtimeImgurHistory.Count > 0) {
@ -51,31 +46,6 @@ namespace GreenshotImgurPlugin {
} }
} }
private void InitializeTexts() {
this.label_url.Text = lang.GetString(LangKey.label_url);
this.buttonOK.Text = lang.GetString(LangKey.OK);
this.buttonCancel.Text = lang.GetString(LangKey.CANCEL);
this.Text = lang.GetString(LangKey.settings_title);
this.label_upload_format.Text = lang.GetString(LangKey.label_upload_format);
this.checkbox_usepagelink.Text = lang.GetString(LangKey.use_page_link);
this.historyButton.Text = lang.GetString(LangKey.imgur_history);
}
public string Url {
get {return textBoxUrl.Text;}
set {textBoxUrl.Text = value;}
}
public string UploadFormat {
get {return combobox_uploadimageformat.Text;}
set {combobox_uploadimageformat.Text = value;}
}
public bool UsePageLink {
get { return checkbox_usepagelink.Checked; }
set { checkbox_usepagelink.Checked = value; }
}
void ButtonOKClick(object sender, EventArgs e) { void ButtonOKClick(object sender, EventArgs e) {
this.DialogResult = DialogResult.OK; this.DialogResult = DialogResult.OK;
} }

View file

@ -53,7 +53,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Forms\ImgurHistory.cs" /> <Compile Include="Forms\ImgurForm.cs" />
<Compile Include="Forms\ImgurHistory.Designer.cs"> <Compile Include="Forms\ImgurHistory.Designer.cs">
<DependentUpon>ImgurHistory.cs</DependentUpon> <DependentUpon>ImgurHistory.cs</DependentUpon>
</Compile> </Compile>

View file

@ -76,18 +76,8 @@ namespace GreenshotImgurPlugin {
} finally { } finally {
backgroundForm.CloseDialog(); backgroundForm.CloseDialog();
} }
settingsForm.Url = ImgurApiUrl;
settingsForm.UsePageLink = UsePageLink;
settingsForm.UploadFormat = UploadFormat.ToString();
DialogResult result = settingsForm.ShowDialog(); DialogResult result = settingsForm.ShowDialog();
if (result == DialogResult.OK) { if (result == DialogResult.OK) {
if (!settingsForm.Url.Equals(ImgurApiUrl) || !settingsForm.UploadFormat.Equals(UploadFormat.ToString())
|| !!settingsForm.UsePageLink.Equals(UsePageLink)) {
ImgurApiUrl = settingsForm.Url;
UploadFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), settingsForm.UploadFormat.ToLower());
UsePageLink = settingsForm.UsePageLink;
}
IniConfig.Save();
return true; return true;
} }
return false; return false;

View file

@ -28,7 +28,7 @@ namespace GreenshotImgurPlugin {
/// </summary> /// </summary>
public class Language : LanguageContainer, ILanguage { public class Language : LanguageContainer, ILanguage {
private static ILanguage uniqueInstance; private static ILanguage uniqueInstance;
private const string LANGUAGE_FILENAME_PATTERN = @"language_imgurplugin-*.xml"; public const string LANGUAGE_FILENAME_PATTERN = @"language_imgurplugin-*.xml";
public static ILanguage GetInstance() { public static ILanguage GetInstance() {
if(uniqueInstance == null) { if(uniqueInstance == null) {

View file

@ -6,11 +6,14 @@ using System.Reflection;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using Greenshot.IniFile; using Greenshot.IniFile;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO;
namespace GreenshotPlugin.Controls { namespace GreenshotPlugin.Controls {
public class GreenshotForm : Form , IGreenshotLanguageBindable { public abstract class GreenshotForm : Form, IGreenshotLanguageBindable {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm)); private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreenshotForm));
protected ILanguage language; protected ILanguage language;
private IComponentChangeService m_changeService;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")] [Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey { public string LanguageKey {
@ -18,13 +21,32 @@ namespace GreenshotPlugin.Controls {
set; set;
} }
public GreenshotForm() : base() { protected abstract string LanguagePattern { get; }
protected void InitializeForDesigner() {
if (language == null && this.DesignMode) {
try {
if (!IniConfig.IsInited) {
IniConfig.Init("greenshot", "greenshot");
}
ITypeResolutionService typeResService = GetService(typeof(ITypeResolutionService)) as ITypeResolutionService;
Assembly currentAssembly = this.GetType().Assembly;
string assemblyPath = typeResService.GetPathOfAssembly(currentAssembly.GetName());
string designTimeLanguagePath = Path.Combine(Path.GetDirectoryName(assemblyPath), "../../Languages/");
language = new LanguageContainer(LanguagePattern, designTimeLanguagePath);
} catch (Exception ex) {
MessageBox.Show(ex.ToString());
}
}
} }
protected override void OnLoad(EventArgs e) { protected override void OnLoad(EventArgs e) {
if (!this.DesignMode) { if (!this.DesignMode) {
ApplyLanguage(); ApplyLanguage();
FillFields(); FillFields();
} else {
InitializeForDesigner();
} }
base.OnLoad(e); base.OnLoad(e);
} }
@ -34,19 +56,78 @@ namespace GreenshotPlugin.Controls {
/// </summary> /// </summary>
/// <param name="e"></param> /// <param name="e"></param>
protected override void OnClosed(EventArgs e) { protected override void OnClosed(EventArgs e) {
if (!this.DesignMode) {
if (DialogResult == DialogResult.OK) { if (DialogResult == DialogResult.OK) {
LOG.Info("Form was closed with OK: storing field values."); LOG.Info("Form was closed with OK: storing field values.");
StoreFields(); StoreFields();
} }
}
base.OnClosed(e); base.OnClosed(e);
} }
// This override allows the control to register event handlers for IComponentChangeService events
// at the time the control is sited, which happens only in design mode.
public override ISite Site {
get {
return base.Site;
}
set {
// Clear any component change event handlers.
ClearChangeNotifications();
// Set the new Site value.
base.Site = value;
m_changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
// Register event handlers for component change events.
RegisterChangeNotifications();
}
}
private void ClearChangeNotifications() {
// The m_changeService value is null when not in design mode,
// as the IComponentChangeService is only available at design time.
m_changeService = (IComponentChangeService)GetService(typeof(IComponentChangeService));
// Clear our the component change events to prepare for re-siting.
if (m_changeService != null) {
m_changeService.ComponentChanged -= new ComponentChangedEventHandler(OnComponentChanged);
}
}
private void RegisterChangeNotifications() {
// Register the event handlers for the IComponentChangeService events
if (m_changeService != null) {
m_changeService.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
}
}
/* This method handles the OnComponentChanged event to display a notification. */
private void OnComponentChanged(object sender, ComponentChangedEventArgs ce) {
if (ce.Component != null && ((IComponent)ce.Component).Site != null && ce.Member != null) {
//OnUserChange("The " + ce.Member.Name + " member of the " + ((IComponent)ce.Component).Site.Name + " component has been changed.");
if ("LanguageKey".Equals(ce.Member.Name)) {
ApplyLanguage(ce.Component as Control, (string)ce.NewValue);
}
}
}
// Clean up any resources being used.
protected override void Dispose(bool disposing) {
if (disposing) {
ClearChangeNotifications();
}
base.Dispose(disposing);
}
/// <summary> /// <summary>
/// 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() {
if (language == null) { if (language == null) {
throw new ArgumentNullException("Language not set!! Please use 'language = Language.GetInstance()' in your form constructor!"); MessageBox.Show("Language not set!! Please use 'language = Language.GetInstance()' in your form constructor!");
return;
} }
// Set title of the form // Set title of the form
if (!string.IsNullOrEmpty(LanguageKey)) { if (!string.IsNullOrEmpty(LanguageKey)) {
@ -58,19 +139,21 @@ namespace GreenshotPlugin.Controls {
continue; continue;
} }
Object controlObject = field.GetValue(this); Object controlObject = field.GetValue(this);
if (typeof(IGreenshotLanguageBindable).IsAssignableFrom(field.FieldType)) { if (controlObject == null) {
IGreenshotLanguageBindable languageBindable = controlObject as IGreenshotLanguageBindable;
if (!string.IsNullOrEmpty(languageBindable.LanguageKey)) {
if (!language.hasKey(languageBindable.LanguageKey)) {
LOG.WarnFormat("Wrong language key '{0}' configured for field '{1}'", languageBindable.LanguageKey, field.Name);
continue; continue;
} }
Control control = controlObject as Control; Control applyTo = controlObject as Control;
control.Text = language.GetString(languageBindable.LanguageKey); if (applyTo == null) {
} else { // not a control
LOG.WarnFormat("Greenshot control without language key: {0}", field.Name); continue;
} }
IGreenshotLanguageBindable languageBindable = applyTo as IGreenshotLanguageBindable;
if (languageBindable == null) {
continue;
} }
string languageKey = languageBindable.LanguageKey;
// Apply language text to the control
ApplyLanguage(applyTo, languageKey);
// Repopulate the combox boxes // Repopulate the combox boxes
if (typeof(IGreenshotConfigBindable).IsAssignableFrom(field.FieldType)) { if (typeof(IGreenshotConfigBindable).IsAssignableFrom(field.FieldType)) {
if (typeof(GreenshotComboBox).IsAssignableFrom(field.FieldType)) { if (typeof(GreenshotComboBox).IsAssignableFrom(field.FieldType)) {
@ -87,7 +170,21 @@ namespace GreenshotPlugin.Controls {
} }
} }
} }
}
/// <summary>
/// Apply the language text to supplied control
/// </summary>
protected void ApplyLanguage(Control applyTo, string languageKey) {
if (!string.IsNullOrEmpty(languageKey)) {
if (!language.hasKey(languageKey)) {
MessageBox.Show(string.Format("Wrong language key '{0}' configured for control '{1}'", languageKey, applyTo.Name));
return;
}
applyTo.Text = language.GetString(languageKey);
} else {
MessageBox.Show(string.Format("Greenshot control without language key: {0}", applyTo.Name));
}
} }
/// <summary> /// <summary>

View file

@ -74,7 +74,8 @@ namespace GreenshotPlugin.Core {
private static string PAF_LANGUAGE_PATH = Path.Combine(APPLICATION_PATH, @"App\Greenshot\Languages"); private static string PAF_LANGUAGE_PATH = Path.Combine(APPLICATION_PATH, @"App\Greenshot\Languages");
private const string HELP_FILENAME_PATTERN = @"help-*.html"; private const string HELP_FILENAME_PATTERN = @"help-*.html";
private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups"; private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups";
private static string globalLanguage = null; private static string globalLanguage = DEFAULT_LANGUAGE;
private string additionalPath = null; // Set if the designer is used
private Dictionary<string, string> strings = new Dictionary<string, string>(); private Dictionary<string, string> strings = new Dictionary<string, string>();
private List<LanguageConfiguration> languages = new List<LanguageConfiguration>(); private List<LanguageConfiguration> languages = new List<LanguageConfiguration>();
@ -106,7 +107,11 @@ namespace GreenshotPlugin.Core {
instances.Add(this); instances.Add(this);
} }
public LanguageContainer(string filePattern) : this() { public LanguageContainer(string filePattern) : this(filePattern, null) {
}
public LanguageContainer(string filePattern, string additionalPath) {
this.additionalPath = additionalPath;
LanguageFilePattern = filePattern; LanguageFilePattern = filePattern;
Load(); Load();
SetInstanceLanguage(globalLanguage); SetInstanceLanguage(globalLanguage);
@ -171,7 +176,7 @@ namespace GreenshotPlugin.Core {
Dictionary<string, LanguageConfiguration> identifiedLanguages = new Dictionary<string, LanguageConfiguration>(); Dictionary<string, LanguageConfiguration> identifiedLanguages = new Dictionary<string, LanguageConfiguration>();
if (languages == null || languages.Count == 0) { if (languages == null || languages.Count == 0) {
throw new FileNotFoundException("No language files found!"); throw new FileNotFoundException(string.Format("No language files for {0} found!", wantedIETF));
} }
// Find selected languages in available languages // Find selected languages in available languages
@ -265,6 +270,9 @@ namespace GreenshotPlugin.Core {
} else { } else {
languageDirectories.Add(APPLICATIONDATA_LANGUAGE_PATH); languageDirectories.Add(APPLICATIONDATA_LANGUAGE_PATH);
} }
if (additionalPath != null) {
languageDirectories.Add(additionalPath);
}
languageDirectories.Add(STARTUP_LANGUAGE_PATH); languageDirectories.Add(STARTUP_LANGUAGE_PATH);
foreach(string path in languageDirectories) { foreach(string path in languageDirectories) {
if (!Directory.Exists(path)) { if (!Directory.Exists(path)) {

View file

@ -61,6 +61,12 @@ namespace Greenshot.IniFile {
WatchConfigFile(true); WatchConfigFile(true);
} }
public static bool IsInited {
get {
return applicationName != null && configName != null;
}
}
public static void ForceIniInStartupPath() { public static void ForceIniInStartupPath() {
if (portableCheckMade) { if (portableCheckMade) {
throw new Exception("ForceLocal should be called before any file is read"); throw new Exception("ForceLocal should be called before any file is read");