using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
namespace Flyad7_WPF.Converters
{
    public class IO2BitBoolConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                string str = (string)parameter;
                int bitno = int.Parse(str);

                if (value is UInt16)
                {
                    UInt16 io = (UInt16)value;
                    if (Misc.MyBase.CHECKBIT(io, bitno))
                        return false;
                    else
                        return true;
                }
                else if (value is UInt32)
                {
                    UInt32 io = (UInt32)value;
                    if (Misc.MyBase.CHECKBIT(io, bitno))
                        return false;
                    else
                        return true;
                }
                else
                {
                    return false;
                }
            }
            catch
            {
                return false;
            }

        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
