// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
namespace System.Windows.Controls.DataVisualization.Charting
{
///
/// A margin specified for a given value.
///
public struct ValueMargin
{
///
/// Gets the value that the margin is associated with.
///
public object Value { get; private set; }
///
/// Gets the low margin for a value.
///
public double LowMargin { get; private set; }
///
/// Gets the high margin for a value.
///
public double HighMargin { get; private set; }
///
/// Initializes a new instance of the ValueMargin class.
///
/// The value the margin is associated with.
/// The lower margin.
/// The higher margin.
public ValueMargin(object value, double lowMargin, double highMargin) : this()
{
Value = value;
LowMargin = lowMargin;
HighMargin = highMargin;
}
///
/// Determines whether two value margins are equal.
///
/// The value margin to compare with this one.
/// A value indicating whether the two value margins are equal.
///
public override bool Equals(object obj)
{
if (obj is ValueMargin)
{
ValueMargin valueMargin = (ValueMargin)obj;
return this.Value.Equals(valueMargin.Value) && this.LowMargin.Equals(valueMargin.LowMargin) && this.HighMargin.Equals(valueMargin.HighMargin);
}
return false;
}
///
/// Determines whether two unit value objects are equal.
///
/// The left value margin.
/// The right value margin.
/// A value indicating whether two value margins objects are
/// equal.
public static bool operator ==(ValueMargin left, ValueMargin right)
{
return left.Equals(right);
}
///
/// Determines whether two value margin objects are not equal.
///
/// The left value margin.
/// The right value margin.
/// A value indicating whether two value margin objects are not
/// equal.
public static bool operator !=(ValueMargin left, ValueMargin right)
{
return !left.Equals(right);
}
///
/// Returns the hash code of the value margin object.
///
/// The hash code.
public override int GetHashCode()
{
return this.Value.GetHashCode() ^ this.LowMargin.GetHashCode() ^ this.HighMargin.GetHashCode();
}
}
}