Fixed design-time displaying of the language mappings

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1778 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-04-17 13:17:44 +00:00
parent 27910e584a
commit b585a239b6
15 changed files with 83 additions and 117 deletions

View file

@ -1,20 +1,31 @@
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;
/*
* 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 <http://www.gnu.org/licenses/>.
*/
using System;
namespace GreenshotImgurPlugin.Forms {
public class ImgurForm : GreenshotForm {
protected override string LanguagePattern {
get {
return Language.LANGUAGE_FILENAME_PATTERN;
}
namespace GreenshotImgurPlugin {
/// <summary>
/// This class is needed for design-time resolving of the language files
/// </summary>
public class ImgurForm : GreenshotPlugin.Controls.GreenshotForm {
public ImgurForm() : base() {
}
}
}

View file

@ -18,7 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace GreenshotImgurPlugin.Forms
namespace GreenshotImgurPlugin
{
partial class ImgurHistory
{

View file

@ -27,7 +27,7 @@ using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
namespace GreenshotImgurPlugin.Forms {
namespace GreenshotImgurPlugin {
/// <summary>
/// Description of ImgurHistory.
/// </summary>
@ -35,7 +35,6 @@ namespace GreenshotImgurPlugin.Forms {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurHistory));
private ListViewColumnSorter columnSorter;
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private ILanguage lang = Language.GetInstance();
private static ImgurHistory instance;
public static void ShowHistory() {
@ -119,9 +118,9 @@ namespace GreenshotImgurPlugin.Forms {
pictureBox1.Image = pictureBox1.ErrorImage;
for (int i = 0; i < listview_imgur_uploads.SelectedItems.Count; i++) {
ImgurInfo imgurInfo = (ImgurInfo)listview_imgur_uploads.SelectedItems[i].Tag;
DialogResult result = MessageBox.Show(lang.GetFormattedString(LangKey.delete_question, imgurInfo.Title), lang.GetFormattedString(LangKey.delete_title, imgurInfo.Hash), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
DialogResult result = MessageBox.Show(Language.GetFormattedString("imgur", LangKey.delete_question, imgurInfo.Title), Language.GetFormattedString("imgur", LangKey.delete_title, imgurInfo.Hash), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes) {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(ImgurPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(ImgurPlugin.Attributes.Name, Language.GetString("imgur", LangKey.communication_wait));
try {
ImgurUtils.DeleteImgurImage(imgurInfo);
} catch (Exception ex) {
@ -161,7 +160,7 @@ namespace GreenshotImgurPlugin.Forms {
}
private void ClearHistoryButtonClick(object sender, EventArgs e) {
DialogResult result = MessageBox.Show(lang.GetString(LangKey.clear_question), "Imgur", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
DialogResult result = MessageBox.Show(Language.GetString("imgur", LangKey.clear_question), "Imgur", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes) {
config.runtimeImgurHistory.Clear();
config.ImgurUploadHistory.Clear();

View file

@ -59,7 +59,7 @@ namespace GreenshotImgurPlugin {
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.LanguageKey = "OK";
this.buttonOK.LanguageKey = "imgur.OK";
this.buttonOK.Location = new System.Drawing.Point(222, 129);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
@ -70,7 +70,7 @@ namespace GreenshotImgurPlugin {
// buttonCancel
//
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonCancel.LanguageKey = "CANCEL";
this.buttonCancel.LanguageKey = "imgur.CANCEL";
this.buttonCancel.Location = new System.Drawing.Point(303, 129);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
@ -80,7 +80,7 @@ namespace GreenshotImgurPlugin {
//
// label_url
//
this.label_url.LanguageKey = "label_url";
this.label_url.LanguageKey = "imgur.label_url";
this.label_url.Location = new System.Drawing.Point(12, 21);
this.label_url.Name = "label_url";
this.label_url.Size = new System.Drawing.Size(84, 20);
@ -109,34 +109,32 @@ namespace GreenshotImgurPlugin {
//
// label_upload_format
//
this.label_upload_format.LanguageKey = "label_upload_format";
this.label_upload_format.LanguageKey = "imgur.label_upload_format";
this.label_upload_format.Location = new System.Drawing.Point(12, 50);
this.label_upload_format.Name = "label_upload_format";
this.label_upload_format.Size = new System.Drawing.Size(84, 20);
this.label_upload_format.TabIndex = 9;
this.label_upload_format.Text = "Image format";
//
// historyButton
//
this.historyButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.historyButton.LanguageKey = "imgur_history";
this.historyButton.LanguageKey = "imgur.history";
this.historyButton.Location = new System.Drawing.Point(13, 129);
this.historyButton.Name = "historyButton";
this.historyButton.Size = new System.Drawing.Size(75, 23);
this.historyButton.TabIndex = 11;
this.historyButton.Text = "History";
this.historyButton.UseVisualStyleBackColor = true;
this.historyButton.Click += new System.EventHandler(this.ButtonHistoryClick);
//
// checkbox_usepagelink
//
this.checkbox_usepagelink.AutoSize = true;
this.checkbox_usepagelink.LanguageKey = "use_page_link";
this.checkbox_usepagelink.LanguageKey = "imgur.use_page_link";
this.checkbox_usepagelink.Location = new System.Drawing.Point(15, 97);
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.Size = new System.Drawing.Size(297, 17);
this.checkbox_usepagelink.TabIndex = 13;
this.checkbox_usepagelink.UseVisualStyleBackColor = true;
//
@ -154,10 +152,10 @@ namespace GreenshotImgurPlugin {
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.LanguageKey = "imgur.settings_title";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SettingsForm";
this.Text = "Imgur settings";
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -20,7 +20,6 @@
*/
using System;
using System.Windows.Forms;
using GreenshotImgurPlugin.Forms;
using GreenshotPlugin.Core;
using GreenshotPlugin.Controls;
@ -29,8 +28,7 @@ namespace GreenshotImgurPlugin {
/// Description of PasswordRequestForm.
/// </summary>
public partial class SettingsForm : ImgurForm {
public SettingsForm(ImgurConfiguration config) {
language = Language.GetInstance();
public SettingsForm(ImgurConfiguration config) : base() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@ -67,7 +67,6 @@
<Compile Include="ImgurPlugin.cs" />
<Compile Include="ImgurConfiguration.cs" />
<Compile Include="ImgurUtils.cs" />
<Compile Include="Language.cs" />
<Compile Include="LanguageKeys.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Languages\language_imgurplugin-de-DE.xml">

View file

@ -68,9 +68,8 @@ namespace GreenshotImgurPlugin {
/// <returns>bool true if OK was pressed, false if cancel</returns>
public bool ShowConfigDialog() {
SettingsForm settingsForm;
ILanguage lang = Language.GetInstance();
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(ImgurPlugin.Attributes.Name, lang.GetString(LangKey.communication_wait));
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(ImgurPlugin.Attributes.Name, Language.GetString("Imgur", LangKey.communication_wait));
try {
settingsForm = new SettingsForm(this);
} finally {

View file

@ -37,13 +37,10 @@ namespace GreenshotImgurPlugin {
public class ImgurDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurDestination));
private static ImgurConfiguration config = IniConfig.GetIniSection<ImgurConfiguration>();
private ILanguage lang = Language.GetInstance();
private ImgurPlugin plugin = null;
private ILanguage coreLanguage;
public ImgurDestination(ImgurPlugin plugin) {
this.plugin = plugin;
this.coreLanguage = plugin.CoreLanguage;
}
public override string Designation {
@ -54,7 +51,7 @@ namespace GreenshotImgurPlugin {
public override string Description {
get {
return lang.GetString(LangKey.upload_menu_item);
return Language.GetString("imgur", LangKey.upload_menu_item);
}
}
@ -69,7 +66,7 @@ namespace GreenshotImgurPlugin {
using (Image image = surface.GetImageForExport()) {
bool uploaded = plugin.Upload(captureDetails, image);
if (uploaded) {
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, coreLanguage.GetFormattedString("exported_to", Description));
surface.SendMessageEvent(this, SurfaceMessageTyp.Info, Language.GetFormattedString("imgur", "exported_to", Description));
surface.Modified = false;
}
return uploaded;

View file

@ -27,7 +27,6 @@ using System.Windows.Forms;
using System.Threading;
using Greenshot.Plugin;
using GreenshotImgurPlugin.Forms;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
using Greenshot.IniFile;
@ -40,7 +39,6 @@ namespace GreenshotImgurPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImgurPlugin));
private static ImgurConfiguration config;
public static PluginAttribute Attributes;
private ILanguage lang = Language.GetInstance();
private IGreenshotHost host;
private ComponentResourceManager resources;
private ToolStripMenuItem historyMenuItem = null;
@ -48,11 +46,6 @@ namespace GreenshotImgurPlugin {
public ImgurPlugin() {
}
public ILanguage CoreLanguage {
get {
return host.CoreLanguage;
}
}
public IEnumerable<IDestination> Destinations() {
yield return new ImgurDestination(this);
}
@ -79,14 +72,14 @@ namespace GreenshotImgurPlugin {
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem("Imgur");
itemPlugInRoot.Image = (Image)resources.GetObject("Imgur");
historyMenuItem = new ToolStripMenuItem(lang.GetString(LangKey.imgur_history));
historyMenuItem = new ToolStripMenuItem(Language.GetString("imgur", LangKey.imgur_history));
historyMenuItem.Tag = host;
historyMenuItem.Click += delegate {
ImgurHistory.ShowHistory();
};
itemPlugInRoot.DropDownItems.Add(historyMenuItem);
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(lang.GetString(LangKey.imgur_configure));
ToolStripMenuItem itemPlugInConfig = new ToolStripMenuItem(Language.GetString("imgur", LangKey.imgur_configure));
itemPlugInConfig.Tag = host;
itemPlugInConfig.Click += delegate {
config.ShowConfigDialog();
@ -138,7 +131,7 @@ namespace GreenshotImgurPlugin {
public bool Upload(ICaptureDetails captureDetails, Image image) {
using (MemoryStream stream = new MemoryStream()) {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, Language.GetString("imgur", LangKey.communication_wait));
host.SaveToStream(image, stream, config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
try {
@ -161,7 +154,7 @@ namespace GreenshotImgurPlugin {
}
return true;
} catch (Exception e) {
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
} finally {
backgroundForm.CloseDialog();
}
@ -176,7 +169,7 @@ namespace GreenshotImgurPlugin {
ToolStripMenuItem item = (ToolStripMenuItem)sender;
IImageEditor imageEditor = (IImageEditor)item.Tag;
using (MemoryStream stream = new MemoryStream()) {
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, lang.GetString(LangKey.communication_wait));
BackgroundForm backgroundForm = BackgroundForm.ShowAndWait(Attributes.Name, Language.GetString("imgur", LangKey.communication_wait));
imageEditor.SaveToStream(stream, config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
try {
@ -199,7 +192,7 @@ namespace GreenshotImgurPlugin {
Clipboard.SetText(imgurInfo.Original);
}
} catch(Exception e) {
MessageBox.Show(lang.GetString(LangKey.upload_failure) + " " + e.Message);
MessageBox.Show(Language.GetString("imgur", LangKey.upload_failure) + " " + e.Message);
} finally {
backgroundForm.CloseDialog();
}

View file

@ -107,7 +107,7 @@ namespace GreenshotImgurPlugin {
uploadRequest.Append(HttpUtility.UrlEncode(filename, Encoding.UTF8));
}
string url = config.ImgurApiUrl + "/upload";
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreatedWebRequest(url);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
@ -129,7 +129,7 @@ namespace GreenshotImgurPlugin {
public static void RetrieveImgurThumbnail(ImgurInfo imgurInfo) {
LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreatedWebRequest(imgurInfo.SmallSquare);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(imgurInfo.SmallSquare);
webRequest.Method = "GET";
webRequest.ServicePoint.Expect100Continue = false;
@ -143,7 +143,7 @@ namespace GreenshotImgurPlugin {
public static ImgurInfo RetrieveImgurInfo(string hash, string deleteHash) {
string url = config.ImgurApiUrl + "/image/" + hash;
LOG.InfoFormat("Retrieving Imgur info for {0} with url {1}", hash, url);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreatedWebRequest(url);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(url);
webRequest.Method = "GET";
webRequest.ServicePoint.Expect100Continue = false;
string responseString;
@ -172,7 +172,7 @@ namespace GreenshotImgurPlugin {
try {
string url = config.ImgurApiUrl + "/delete/" + imgurInfo.DeleteHash;
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreatedWebRequest(url);
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(url);
//webRequest.Method = "DELETE";
webRequest.Method = "GET";

View file

@ -1,40 +0,0 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/
using System;
using System.Threading;
using GreenshotPlugin.Core;
namespace GreenshotImgurPlugin {
/// <summary>
/// Wrapper for the language container for the Jira plugin.
/// </summary>
public class Language : LanguageContainer, ILanguage {
private static ILanguage uniqueInstance;
public const string LANGUAGE_FILENAME_PATTERN = @"language_imgurplugin-*.xml";
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer(LANGUAGE_FILENAME_PATTERN);
}
return uniqueInstance;
}
}
}

View file

@ -37,10 +37,13 @@
<resource name="delete_title">
Imgur {0} löschen
</resource>
<resource name="imgur_history">
<resource name="use_page_link">
Benutze der Seite-URL statt Bild-URL im Zwischenablage
</resource>
<resource name="history">
Verlauf
</resource>
<resource name="imgur_configure">
<resource name="configure">
Einstellungen
</resource>
</resources>

View file

@ -40,10 +40,10 @@
<resource name="use_page_link">
Use page link instead of image link on clipboard
</resource>
<resource name="imgur_history">
<resource name="history">
History
</resource>
<resource name="imgur_configure">
<resource name="configure">
Configure
</resource>
</resources>

View file

@ -31,5 +31,11 @@
<resource name="upload_wait">
Téléversement vers ImgUr, veuillez patienter...
</resource>
<resource name="history">
Histoire
</resource>
<resource name="configure">
Configurer
</resource>
</resources>
</language>

View file

@ -37,10 +37,13 @@
<resource name="delete_title">
Imgur {0} verwijderen
</resource>
<resource name="imgur_history">
Geschiedenis
<resource name="use_page_link">
Kopieer de pagina link in plaats van de beeld link in het klembord
</resource>
<resource name="imgur_configure">
<resource name="history">
Verloop
</resource>
<resource name="configure">
Instellingen
</resource>
</resources>