Changed EditorForm to use language binding... long live search & replace...

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1834 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-05-04 13:01:04 +00:00
parent 00819deecd
commit 71f44023c2
11 changed files with 306 additions and 350 deletions

View file

@ -21,14 +21,21 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>
/// Description of BindableToolStripButton. /// Description of BindableToolStripButton.
/// </summary> /// </summary>
public class BindableToolStripButton : ToolStripButton, INotifyPropertyChanged { public class BindableToolStripButton : ToolStripButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public BindableToolStripButton() :base() { public BindableToolStripButton() :base() {
this.CheckedChanged += new EventHandler(BindableToolStripButton_CheckedChanged); this.CheckedChanged += new EventHandler(BindableToolStripButton_CheckedChanged);
} }

View file

@ -21,14 +21,21 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>
/// A simple ToolStripComboBox implementing INotifyPropertyChanged for data binding /// A simple ToolStripComboBox implementing INotifyPropertyChanged for data binding
/// </summary> /// </summary>
public class BindableToolStripComboBox : ToolStripComboBox, INotifyPropertyChanged { public class BindableToolStripComboBox : ToolStripComboBox, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public BindableToolStripComboBox() :base() { public BindableToolStripComboBox() :base() {
this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged); this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged);
} }

View file

@ -21,6 +21,7 @@
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>
@ -28,10 +29,16 @@ namespace Greenshot.Controls {
/// Also, when a DropDownItem is selected, the DropDownButton adops its Tag and Image. /// Also, when a DropDownItem is selected, the DropDownButton adops its Tag and Image.
/// The selected tag can be accessed via SelectedTag property. /// The selected tag can be accessed via SelectedTag property.
/// </summary> /// </summary>
public class BindableToolStripDropDownButton : ToolStripDropDownButton, INotifyPropertyChanged { public class BindableToolStripDropDownButton : ToolStripDropDownButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public BindableToolStripDropDownButton() { public BindableToolStripDropDownButton() {
} }

View file

@ -23,15 +23,22 @@ using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>
/// Description of ColorButton. /// Description of ColorButton.
/// </summary> /// </summary>
public class ColorButton : Button { public class ColorButton : Button, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
private Color selectedColor = Color.White; private Color selectedColor = Color.White;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public ColorButton() { public ColorButton() {
Click += new EventHandler(ColorButtonClick); Click += new EventHandler(ColorButtonClick);
} }

View file

@ -22,6 +22,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
using System.ComponentModel;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>
@ -45,7 +47,6 @@ namespace Greenshot.Controls {
/// <remarks> /// <remarks>
/// Default value is false, which is the same behavior provided by the base ToolStrip class. /// Default value is false, which is the same behavior provided by the base ToolStrip class.
/// </remarks> /// </remarks>
public bool ClickThrough { public bool ClickThrough {
get { get {
return this.clickThrough; return this.clickThrough;

View file

@ -23,11 +23,18 @@ using System.ComponentModel;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Windows.Forms; using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
public class ToolStripColorButton : ToolStripButton, INotifyPropertyChanged { public class ToolStripColorButton : ToolStripButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged; public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
private Color selectedColor = Color.Transparent; private Color selectedColor = Color.Transparent;
public ToolStripColorButton() { public ToolStripColorButton() {

View file

@ -22,6 +22,8 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using System.ComponentModel;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls { namespace Greenshot.Controls {
/// <summary> /// <summary>

View file

@ -108,7 +108,7 @@ namespace Greenshot.Drawing {
public bool KeysLocked = false; public bool KeysLocked = false;
private bool modified = false; private bool modified = true; // Initial state is modified, as it's not saved
public bool Modified { public bool Modified {
get { get {
return modified; return modified;

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,7 @@ namespace Greenshot {
/// <summary> /// <summary>
/// Description of ImageEditorForm. /// Description of ImageEditorForm.
/// </summary> /// </summary>
public partial class ImageEditorForm : Form, IImageEditor { public partial class ImageEditorForm : BaseForm, IImageEditor {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm)); private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>(); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
@ -54,7 +54,7 @@ namespace Greenshot {
private static List<IImageEditor> editorList = new List<IImageEditor>(); private static List<IImageEditor> editorList = new List<IImageEditor>();
private Surface surface; private Surface surface;
private System.Windows.Forms.ToolStripButton[] toolbarButtons; private GreenshotPlugin.Controls.GreenshotToolStripButton[] toolbarButtons;
private static string[] SUPPORTED_CLIPBOARD_FORMATS = {typeof(string).FullName, "Text", "DeviceIndependentBitmap", "Bitmap", typeof(DrawableContainerList).FullName}; private static string[] SUPPORTED_CLIPBOARD_FORMATS = {typeof(string).FullName, "Text", "DeviceIndependentBitmap", "Bitmap", typeof(DrawableContainerList).FullName};
@ -142,7 +142,7 @@ namespace Greenshot {
// Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it. // Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
hideToolstripItems(); hideToolstripItems();
toolbarButtons = new ToolStripButton[]{btnCursor,btnRect,btnEllipse,btnText,btnLine,btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop}; toolbarButtons = new GreenshotPlugin.Controls.GreenshotToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier}; //toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0; pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;
@ -251,7 +251,7 @@ namespace Greenshot {
} }
} }
// add the elements after the destinations // add the elements after the destinations
this.fileStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] {
this.toolStripSeparator9, this.toolStripSeparator9,
this.closeToolStripMenuItem}); this.closeToolStripMenuItem});
} }
@ -290,103 +290,10 @@ namespace Greenshot {
} }
private void updateUI() { private void updateUI() {
string editorTitle = Language.GetString(LangKey.editor_title); ApplyLanguage();
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) { if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
editorTitle = surface.CaptureDetails.Title + " - " + editorTitle; this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
} }
this.Text = editorTitle;
this.fileStripMenuItem.Text = Language.GetString(LangKey.editor_file);
this.btnSave.Text = Language.GetString(LangKey.editor_save);
this.btnClipboard.Text = Language.GetString(LangKey.editor_copyimagetoclipboard);
this.btnPrint.Text = Language.GetString(LangKey.editor_print);
this.closeToolStripMenuItem.Text = Language.GetString(LangKey.editor_close);
this.editToolStripMenuItem.Text = Language.GetString(LangKey.editor_edit);
this.btnCursor.Text = Language.GetString(LangKey.editor_cursortool);
this.btnRect.Text = Language.GetString(LangKey.editor_drawrectangle);
this.addRectangleToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawrectangle);
this.btnEllipse.Text = Language.GetString(LangKey.editor_drawellipse);
this.addEllipseToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawellipse);
this.btnText.Text = Language.GetString(LangKey.editor_drawtextbox);
this.addTextBoxToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawtextbox);
this.btnLine.Text = Language.GetString(LangKey.editor_drawline);
this.drawLineToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawline);
this.drawFreehandToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawfreehand);
this.btnArrow.Text = Language.GetString(LangKey.editor_drawarrow);
this.drawArrowToolStripMenuItem.Text = Language.GetString(LangKey.editor_drawarrow);
this.btnHighlight.Text = Language.GetString(LangKey.editor_drawhighlighter);
this.btnObfuscate.Text = Language.GetString(LangKey.editor_obfuscate);
this.btnFreehand.Text = Language.GetString(LangKey.editor_drawfreehand);
this.btnCrop.Text = Language.GetString(LangKey.editor_crop);
this.btnDelete.Text = Language.GetString(LangKey.editor_deleteelement);
this.btnSettings.Text = Language.GetString(LangKey.contextmenu_settings);
this.btnCut.Text = Language.GetString(LangKey.editor_cuttoclipboard);
this.btnCopy.Text = Language.GetString(LangKey.editor_copytoclipboard);
this.btnPaste.Text = Language.GetString(LangKey.editor_pastefromclipboard);
this.selectAllToolStripMenuItem.Text = Language.GetString(LangKey.editor_selectall);
this.preferencesToolStripMenuItem.Text = Language.GetString(LangKey.contextmenu_settings);
this.removeObjectToolStripMenuItem.Text = Language.GetString(LangKey.editor_deleteelement);
this.copyToolStripMenuItem.Text = Language.GetString(LangKey.editor_copytoclipboard);
this.pasteToolStripMenuItem.Text = Language.GetString(LangKey.editor_pastefromclipboard);
this.cutToolStripMenuItem.Text = Language.GetString(LangKey.editor_cuttoclipboard);
this.duplicateToolStripMenuItem.Text = Language.GetString(LangKey.editor_duplicate);
this.objectToolStripMenuItem.Text = Language.GetString(LangKey.editor_object);
this.arrangeToolStripMenuItem.Text = Language.GetString(LangKey.editor_arrange);
this.upToTopToolStripMenuItem.Text = Language.GetString(LangKey.editor_uptotop);
this.upOneLevelToolStripMenuItem.Text = Language.GetString(LangKey.editor_uponelevel);
this.downOneLevelToolStripMenuItem.Text = Language.GetString(LangKey.editor_downonelevel);
this.downToBottomToolStripMenuItem.Text = Language.GetString(LangKey.editor_downtobottom);
this.btnLineColor.Text = Language.GetString(LangKey.editor_forecolor);
this.btnFillColor.Text = Language.GetString(LangKey.editor_backcolor);
this.lineThicknessLabel.Text = Language.GetString(LangKey.editor_thickness);
this.arrowHeadsDropDownButton.Text = Language.GetString(LangKey.editor_arrowheads);
this.helpToolStripMenuItem.Text = Language.GetString(LangKey.contextmenu_help);
this.helpToolStripMenuItem1.Text = Language.GetString(LangKey.contextmenu_help);
this.btnHelp.Text = Language.GetString(LangKey.contextmenu_help);
this.aboutToolStripMenuItem.Text = Language.GetString(LangKey.contextmenu_about);
this.copyPathMenuItem.Text = Language.GetString(LangKey.editor_copypathtoclipboard);
this.openDirectoryMenuItem.Text = Language.GetString(LangKey.editor_opendirinexplorer);
this.obfuscateModeButton.Text = Language.GetString(LangKey.editor_obfuscate_mode);
this.highlightModeButton.Text = Language.GetString(LangKey.editor_highlight_mode);
this.pixelizeToolStripMenuItem.Text = Language.GetString(LangKey.editor_obfuscate_pixelize);
this.blurToolStripMenuItem.Text = Language.GetString(LangKey.editor_obfuscate_blur);
this.textHighlightMenuItem.Text = Language.GetString(LangKey.editor_highlight_text);
this.areaHighlightMenuItem.Text = Language.GetString(LangKey.editor_highlight_area);
this.grayscaleHighlightMenuItem.Text = Language.GetString(LangKey.editor_highlight_grayscale);
this.magnifyMenuItem.Text = Language.GetString(LangKey.editor_highlight_magnify);
this.blurRadiusLabel.Text = Language.GetString(LangKey.editor_blur_radius);
this.brightnessLabel.Text = Language.GetString(LangKey.editor_brightness);
this.previewQualityLabel.Text = Language.GetString(LangKey.editor_preview_quality);
this.magnificationFactorLabel.Text = Language.GetString(LangKey.editor_magnification_factor);
this.pixelSizeLabel.Text = Language.GetString(LangKey.editor_pixel_size);
this.arrowHeadsLabel.Text = Language.GetString(LangKey.editor_arrowheads);
this.arrowHeadStartMenuItem.Text = Language.GetString(LangKey.editor_arrowheads_start);
this.arrowHeadEndMenuItem.Text = Language.GetString(LangKey.editor_arrowheads_end);
this.arrowHeadBothMenuItem.Text = Language.GetString(LangKey.editor_arrowheads_both);
this.arrowHeadNoneMenuItem.Text = Language.GetString(LangKey.editor_arrowheads_none);
this.shadowButton.Text = Language.GetString(LangKey.editor_shadow);
this.fontSizeLabel.Text = Language.GetString(LangKey.editor_fontsize);
this.fontBoldButton.Text = Language.GetString(LangKey.editor_bold);
this.fontItalicButton.Text = Language.GetString(LangKey.editor_italic);
this.btnConfirm.Text = Language.GetString(LangKey.editor_confirm);
this.btnCancel.Text = Language.GetString(LangKey.editor_cancel);
this.saveElementsToolStripMenuItem.Text = Language.GetString(LangKey.editor_save_objects);
this.loadElementsToolStripMenuItem.Text = Language.GetString(LangKey.editor_load_objects);
this.autoCropToolStripMenuItem.Text = Language.GetString(LangKey.editor_autocrop);
this.insert_window_toolstripmenuitem.Text = Language.GetString(LangKey.editor_insertwindow);
} }
public ISurface Surface { public ISurface Surface {

View file

@ -476,7 +476,7 @@ time, e.g. 11_58_32 (plus extension defined in the settings)
Magnification factor Magnification factor
</resource> </resource>
<resource name="editor_shadow"> <resource name="editor_shadow">
Shadow Drop shadow
</resource> </resource>
<resource name="editor_torn_edge"> <resource name="editor_torn_edge">
Torn edge Torn edge
@ -490,6 +490,9 @@ time, e.g. 11_58_32 (plus extension defined in the settings)
<resource name="editor_grayscale"> <resource name="editor_grayscale">
Grayscale Grayscale
</resource> </resource>
<resource name="editor_invert">
Invert
</resource>
<resource name="editor_confirm"> <resource name="editor_confirm">
Confirm Confirm
</resource> </resource>