Hi, I've had a look through my files and I never completed it as it was no longer required. You are welcome to use what I did and finish it off if you'd like. The main things that need doing are marked // ToDo: - unfortunately that includes the painting and mouse handling - but the Range struct is pretty much complete and the main code for the control is in place.
// Range.cs
using System;
namespace DaveyM69
{
[Serializable]
public struct Range : IEquatable<Range>
{
// ToDo: Make struct designer friendly!
public static readonly Range Empty = new Range();
public static readonly Range MaxRange = new Range(int.MinValue, int.MaxValue);
public static readonly Range Percentage = new Range(0, 100);
private int lower;
private int upper;
public Range(int lower, int upper)
{
if (lower > upper)
{
int newUpper = lower;
lower = upper;
upper = newUpper;
}
this.lower = lower;
this.upper = upper;
}
public static bool operator ==(Range rangeA, Range rangeB)
{
return (rangeA.lower == rangeB.lower) && (rangeA.upper == rangeB.upper);
}
public static bool operator !=(Range rangeA, Range rangeB)
{
return !(rangeA == rangeB);
}
public int Lower
{
get { return lower; }
}
public int Upper
{
get { return upper; }
}
public Range Adjust(int offset)
{
return new Range(lower + offset, upper + offset);
}
public int Contain(int value)
{
return Contain(value, false);
}
public int Contain(int value, bool excludeExtremities)
{
Range testRange = excludeExtremities ? this.Expand(-1) : this;
if (value < testRange.lower)
return testRange.lower;
if (value > testRange.upper)
return testRange.upper;
return value;
}
public Range Contain(Range range)
{
return Contain(range, false);
}
public Range Contain(Range range, bool excludeExtremities)
{
if (Contains(range, excludeExtremities))
return range;
int newLower = range.lower;