mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 02:37:03 -07:00
Made the re/undo code from the branch work in this, this is a manual copy as something went horribly wrong with the repository. Before building I first want to check if everything is there.[skip ci]
This commit is contained in:
parent
9702ac730f
commit
45615275cf
35 changed files with 1890 additions and 922 deletions
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2007-2015 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/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/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
|
||||
|
@ -18,36 +18,53 @@
|
|||
* 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 GreenshotPlugin.Interfaces.Drawing;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Greenshot.Drawing.Fields {
|
||||
namespace Greenshot.Drawing.Fields
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single field of a drawable element, i.e.
|
||||
/// line thickness of a rectangle.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class Field : INotifyPropertyChanged {
|
||||
[field:NonSerialized]
|
||||
public class Field : IField
|
||||
{
|
||||
[field: NonSerialized]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public object myValue;
|
||||
public object Value {
|
||||
get {
|
||||
return myValue;
|
||||
|
||||
private object _myValue;
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _myValue;
|
||||
}
|
||||
set {
|
||||
if (!Equals(myValue,value)) {
|
||||
myValue = value;
|
||||
if (PropertyChanged!=null) {
|
||||
set
|
||||
{
|
||||
if (!Equals(_myValue, value))
|
||||
{
|
||||
_myValue = value;
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public FieldType FieldType;
|
||||
public string Scope;
|
||||
|
||||
public IFieldType FieldType
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public string Scope
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new Field instance, usually you should be using FieldFactory
|
||||
/// to create Fields.
|
||||
|
@ -59,70 +76,64 @@ namespace Greenshot.Drawing.Fields {
|
|||
/// When scope is set to a Type (e.g. typeof(RectangleContainer)), its value
|
||||
/// should not be reused for FieldHolders of another Type (e.g. typeof(EllipseContainer))
|
||||
/// </param>
|
||||
public Field(FieldType fieldType, Type scope) {
|
||||
public Field(IFieldType fieldType, Type scope)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
Scope = scope.Name;
|
||||
}
|
||||
public Field(FieldType fieldType, string scope) {
|
||||
public Field(IFieldType fieldType, string scope)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
Scope = scope;
|
||||
}
|
||||
public Field(FieldType fieldType) {
|
||||
public Field(IFieldType fieldType)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if this field holds a value other than null.
|
||||
/// </summary>
|
||||
public bool HasValue {
|
||||
get{ return Value != null; }
|
||||
public bool HasValue
|
||||
{
|
||||
get { return Value != null; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates a flat clone of this Field. The fields value itself is not cloned.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Field Clone() {
|
||||
public Field Clone()
|
||||
{
|
||||
Field ret = new Field(FieldType, Scope);
|
||||
ret.Value = Value;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 0;
|
||||
unchecked {
|
||||
unchecked
|
||||
{
|
||||
hashCode += 1000000009 * FieldType.GetHashCode();
|
||||
if (Scope != null)
|
||||
hashCode += 1000000021 * Scope.GetHashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
Field other = obj as Field;
|
||||
if (other == null) {
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return FieldType == other.FieldType && Equals(Scope, other.Scope);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return string.Format("[Field FieldType={1} Value={0} Scope={2}]", myValue, FieldType, Scope);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler to be used when a field value changes
|
||||
/// </summary>
|
||||
public delegate void FieldChangedEventHandler(object sender, FieldChangedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// EventArgs to be used with FieldChangedEventHandler
|
||||
/// </summary>
|
||||
public class FieldChangedEventArgs : EventArgs {
|
||||
public readonly Field Field;
|
||||
public FieldChangedEventArgs(Field field) {
|
||||
Field = field;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("[Field FieldType={1} Value={0} Scope={2}]", _myValue, FieldType, Scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue