using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace HouseHeatingTerminal.Classes
{
    public class HexValidator
    {
        public HexValidator()
        {

        }
        // the following function is needed to used to verify the input
        public static HexValidator Parse(string s)
        {
            // remove any spaces
            s = s.Replace(" ", "");
            if (s.Length > 2)
            {
                int nValue;
                s = s.Substring(2, s.Length - 2);
                bool result = int.TryParse(s, System.Globalization.NumberStyles.AllowHexSpecifier, null, out nValue);
                if (false == result || s.Length > 2)
                    throw new ArgumentException(string.Format("The provided address 0x{0} is not a valid device address.\nThe address must be a HEX(0x00-0xFF) value.", s.ToUpper()));
            }
            

                return new HexValidator();


        }
    }
}
