78 lines
2.1 KiB
C#
78 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace GraphingCalculator
|
|
{
|
|
public class Bounds
|
|
{
|
|
private double left, right, top, bottom;
|
|
|
|
#region Public properties
|
|
public double Left
|
|
{
|
|
get { return left; }
|
|
set { left = value; if (BoundsChanged != null) BoundsChanged(this, new EventArgs()); }
|
|
}
|
|
public double Right
|
|
{
|
|
get { return right; }
|
|
set { right = value; if (BoundsChanged != null) BoundsChanged(this, new EventArgs()); }
|
|
}
|
|
public double Top
|
|
{
|
|
get { return top; }
|
|
set { top = value; if (BoundsChanged != null) BoundsChanged(this, new EventArgs()); }
|
|
}
|
|
public double Bottom
|
|
{
|
|
get { return bottom; }
|
|
set { bottom = value; if (BoundsChanged != null) BoundsChanged(this, new EventArgs()); }
|
|
}
|
|
|
|
public double Width
|
|
{
|
|
get { return Right - Left; }
|
|
set { Right = Left + value; }
|
|
}
|
|
public double Height
|
|
{
|
|
get { return Top - Bottom; }
|
|
set { Top = Bottom + Height; }
|
|
}
|
|
#endregion
|
|
|
|
public event EventHandler BoundsChanged;
|
|
|
|
#region Constructors
|
|
public Bounds()
|
|
{
|
|
Left = Right = Top = Bottom = 0;
|
|
}
|
|
public Bounds(double w, double h)
|
|
{
|
|
Left = Bottom = 0;
|
|
Width = w; Height = h;
|
|
}
|
|
public Bounds(double l, double t, double r, double b)
|
|
{
|
|
Left = l; Top = t; Right = r; Bottom = b;
|
|
}
|
|
#endregion
|
|
|
|
#region IsInBounds
|
|
public bool IsInBounds(double x, double y)
|
|
{
|
|
return (x >= Math.Min(Left, Right) && x <= Math.Max(Left, Right) &&
|
|
y >= Math.Min(Top, Bottom) && y <= Math.Max(Top, Bottom));
|
|
}
|
|
|
|
public bool IsInBounds(System.Windows.Point point)
|
|
{
|
|
return IsInBounds(point.X, point.Y);
|
|
}
|
|
#endregion
|
|
}
|
|
}
|