mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
BUG-1709: Suggestion for StringAlignment conversion issue.
This commit is contained in:
parent
2f6e9563d4
commit
018324d4c4
5 changed files with 16 additions and 105 deletions
|
@ -1,89 +0,0 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2014 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 Greenshot.Plugin;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing.Fields.Binding {
|
||||
/// <summary>
|
||||
/// Converting horizontal alignment to its StringAlignment representation and vice versa.
|
||||
/// Beware: there's currently no RTL support.
|
||||
/// </summary>
|
||||
public class HorizontalAlignmentConverter : AbstractBindingConverter<HorizontalAlignment, StringAlignment> {
|
||||
|
||||
private static HorizontalAlignmentConverter uniqueInstance;
|
||||
|
||||
protected override HorizontalAlignment convert(StringAlignment stringAlignment) {
|
||||
switch(stringAlignment) {
|
||||
case StringAlignment.Near: return HorizontalAlignment.Left;
|
||||
case StringAlignment.Center: return HorizontalAlignment.Center;
|
||||
case StringAlignment.Far: return HorizontalAlignment.Right;
|
||||
default: throw new NotImplementedException("Cannot handle: "+ stringAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
protected override StringAlignment convert(HorizontalAlignment horizontalAligment) {
|
||||
switch(horizontalAligment) {
|
||||
case HorizontalAlignment.Left: return StringAlignment.Near;
|
||||
case HorizontalAlignment.Center: return StringAlignment.Center;
|
||||
case HorizontalAlignment.Right: return StringAlignment.Far;
|
||||
default: throw new NotImplementedException("Cannot handle: "+ horizontalAligment);
|
||||
}
|
||||
}
|
||||
|
||||
public static HorizontalAlignmentConverter GetInstance() {
|
||||
if(uniqueInstance == null) uniqueInstance = new HorizontalAlignmentConverter();
|
||||
return uniqueInstance;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converting vertical alignment to its StringAlignment representation and vice versa.
|
||||
/// </summary>
|
||||
public class VerticalAlignmentConverter : AbstractBindingConverter<VerticalAlignment, StringAlignment> {
|
||||
|
||||
private static VerticalAlignmentConverter uniqueInstance;
|
||||
|
||||
protected override VerticalAlignment convert(StringAlignment stringAlignment) {
|
||||
switch(stringAlignment) {
|
||||
case StringAlignment.Near: return VerticalAlignment.TOP;
|
||||
case StringAlignment.Center: return VerticalAlignment.CENTER;
|
||||
case StringAlignment.Far: return VerticalAlignment.BOTTOM;
|
||||
default: throw new NotImplementedException("Cannot handle: "+ stringAlignment);
|
||||
}
|
||||
}
|
||||
|
||||
protected override StringAlignment convert(VerticalAlignment verticalAligment) {
|
||||
switch(verticalAligment) {
|
||||
case VerticalAlignment.TOP: return StringAlignment.Near;
|
||||
case VerticalAlignment.CENTER: return StringAlignment.Center;
|
||||
case VerticalAlignment.BOTTOM: return StringAlignment.Far;
|
||||
default: throw new NotImplementedException("Cannot handle: "+ verticalAligment);
|
||||
}
|
||||
}
|
||||
|
||||
public static VerticalAlignmentConverter GetInstance() {
|
||||
if(uniqueInstance == null) uniqueInstance = new VerticalAlignmentConverter();
|
||||
return uniqueInstance;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -81,8 +81,8 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.FILL_COLOR, Color.White);
|
||||
AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
|
||||
AddField(GetType(), FieldType.FONT_SIZE, 20f);
|
||||
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, HorizontalAlignment.Center);
|
||||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, VerticalAlignment.CENTER);
|
||||
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, StringAlignment.Center);
|
||||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, StringAlignment.Center);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -97,8 +97,8 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
|
||||
AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
|
||||
AddField(GetType(), FieldType.FONT_SIZE, 11f);
|
||||
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, HorizontalAlignment.Center);
|
||||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, VerticalAlignment.CENTER);
|
||||
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, StringAlignment.Center);
|
||||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, StringAlignment.Center);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
|
|
20
Greenshot/Forms/ImageEditorForm.Designer.cs
generated
20
Greenshot/Forms/ImageEditorForm.Designer.cs
generated
|
@ -1254,8 +1254,8 @@ namespace Greenshot {
|
|||
this.textVerticalAlignmentButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.textVerticalAlignmentButton.LanguageKey = "editor_align_vertical";
|
||||
this.textVerticalAlignmentButton.Name = "textVerticalAlignmentButton";
|
||||
this.textVerticalAlignmentButton.SelectedTag = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.textVerticalAlignmentButton.Tag = Greenshot.Plugin.VerticalAlignment.CENTER;
|
||||
this.textVerticalAlignmentButton.SelectedTag = System.Drawing.StringAlignment.Center;
|
||||
this.textVerticalAlignmentButton.Tag = System.Drawing.StringAlignment.Center;
|
||||
//
|
||||
// alignTopToolStripMenuItem
|
||||
//
|
||||
|
@ -1263,7 +1263,7 @@ namespace Greenshot {
|
|||
this.alignTopToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignTop.Image")));
|
||||
this.alignTopToolStripMenuItem.LanguageKey = "editor_align_top";
|
||||
this.alignTopToolStripMenuItem.Name = "alignTopToolStripMenuItem";
|
||||
this.alignTopToolStripMenuItem.Tag = Greenshot.Plugin.VerticalAlignment.TOP;
|
||||
this.alignTopToolStripMenuItem.Tag = System.Drawing.StringAlignment.Near;
|
||||
//
|
||||
// alignMiddleToolStripMenuItem
|
||||
//
|
||||
|
@ -1271,7 +1271,7 @@ namespace Greenshot {
|
|||
this.alignMiddleToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignMiddle.Image")));
|
||||
this.alignMiddleToolStripMenuItem.LanguageKey = "editor_align_middle";
|
||||
this.alignMiddleToolStripMenuItem.Name = "alignMiddleToolStripMenuItem";
|
||||
this.alignMiddleToolStripMenuItem.Tag = Greenshot.Plugin.VerticalAlignment.CENTER;
|
||||
this.alignMiddleToolStripMenuItem.Tag = System.Drawing.StringAlignment.Center;
|
||||
//
|
||||
// alignBottomToolStripMenuItem
|
||||
//
|
||||
|
@ -1279,7 +1279,7 @@ namespace Greenshot {
|
|||
this.alignBottomToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignBottom.Image")));
|
||||
this.alignBottomToolStripMenuItem.LanguageKey = "editor_align_bottom";
|
||||
this.alignBottomToolStripMenuItem.Name = "alignBottomToolStripMenuItem";
|
||||
this.alignBottomToolStripMenuItem.Tag = Greenshot.Plugin.VerticalAlignment.BOTTOM;
|
||||
this.alignBottomToolStripMenuItem.Tag = System.Drawing.StringAlignment.Far;
|
||||
//
|
||||
// blurRadiusLabel
|
||||
//
|
||||
|
@ -1575,8 +1575,8 @@ namespace Greenshot {
|
|||
this.textHorizontalAlignmentButton.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.textHorizontalAlignmentButton.LanguageKey = "editor_align_horizontal";
|
||||
this.textHorizontalAlignmentButton.Name = "textHorizontalAlignmentButton";
|
||||
this.textHorizontalAlignmentButton.SelectedTag = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.textHorizontalAlignmentButton.Tag = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.textHorizontalAlignmentButton.SelectedTag = System.Drawing.StringAlignment.Center;
|
||||
this.textHorizontalAlignmentButton.Tag = System.Drawing.StringAlignment.Center;
|
||||
//
|
||||
// alignLeftToolStripMenuItem
|
||||
//
|
||||
|
@ -1584,7 +1584,7 @@ namespace Greenshot {
|
|||
this.alignLeftToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignLeft.Image")));
|
||||
this.alignLeftToolStripMenuItem.LanguageKey = "editor_align_left";
|
||||
this.alignLeftToolStripMenuItem.Name = "alignLeftToolStripMenuItem";
|
||||
this.alignLeftToolStripMenuItem.Tag = System.Windows.Forms.HorizontalAlignment.Left;
|
||||
this.alignLeftToolStripMenuItem.Tag = System.Drawing.StringAlignment.Near;
|
||||
//
|
||||
// alignCenterToolStripMenuItem
|
||||
//
|
||||
|
@ -1592,7 +1592,7 @@ namespace Greenshot {
|
|||
this.alignCenterToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignCenter.Image")));
|
||||
this.alignCenterToolStripMenuItem.LanguageKey = "editor_align_center";
|
||||
this.alignCenterToolStripMenuItem.Name = "alignCenterToolStripMenuItem";
|
||||
this.alignCenterToolStripMenuItem.Tag = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.alignCenterToolStripMenuItem.Tag = System.Drawing.StringAlignment.Center;
|
||||
//
|
||||
// alignRightToolStripMenuItem
|
||||
//
|
||||
|
@ -1600,7 +1600,7 @@ namespace Greenshot {
|
|||
this.alignRightToolStripMenuItem.Image = ((System.Drawing.Image)(resources.GetObject("btnAlignRight.Image")));
|
||||
this.alignRightToolStripMenuItem.LanguageKey = "editor_align_right";
|
||||
this.alignRightToolStripMenuItem.Name = "alignRightToolStripMenuItem";
|
||||
this.alignRightToolStripMenuItem.Tag = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.alignRightToolStripMenuItem.Tag = System.Drawing.StringAlignment.Far;
|
||||
//
|
||||
// ImageEditorForm
|
||||
//
|
||||
|
|
|
@ -998,8 +998,8 @@ namespace Greenshot {
|
|||
new BidirectionalBinding(fontSizeUpDown, "Value", surface.FieldAggregator.GetField(FieldType.FONT_SIZE), "Value", DecimalFloatConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(fontBoldButton, "Checked", surface.FieldAggregator.GetField(FieldType.FONT_BOLD), "Value", NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(fontItalicButton, "Checked", surface.FieldAggregator.GetField(FieldType.FONT_ITALIC), "Value", NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(textHorizontalAlignmentButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.TEXT_HORIZONTAL_ALIGNMENT), "Value", HorizontalAlignmentConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(textVerticalAlignmentButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.TEXT_VERTICAL_ALIGNMENT), "Value", VerticalAlignmentConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(textHorizontalAlignmentButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.TEXT_HORIZONTAL_ALIGNMENT), "Value", NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(textVerticalAlignmentButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.TEXT_VERTICAL_ALIGNMENT), "Value", NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(shadowButton, "Checked", surface.FieldAggregator.GetField(FieldType.SHADOW), "Value", NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(previewQualityUpDown, "Value", surface.FieldAggregator.GetField(FieldType.PREVIEW_QUALITY), "Value", DecimalDoublePercentageConverter.GetInstance(), NotNullValidator.GetInstance());
|
||||
new BidirectionalBinding(obfuscateModeButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.PREPARED_FILTER_OBFUSCATE), "Value");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue