using System;
using System.Globalization;
using System.Windows.Controls;
using System.Windows.Data;

namespace Valg.EVA.Skanning.Sample.Startup.Converters
{
    public class BooleanToScrollBarVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null) { 
                var b = (bool)value;
                return b ? ScrollBarVisibility.Auto : ScrollBarVisibility.Disabled;
            }
            return ScrollBarVisibility.Disabled;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null) { 
                var e = (ScrollBarVisibility)value;
                if (e == ScrollBarVisibility.Disabled)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }

            return false;
        }
    }
}

