using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace PDF_Office.DataConvert
{
    public class WidthConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return 0;
            }
            else
            {
                if (value is double)
                {
                    double width = (double)value;
                    width = width - SystemParameters.VerticalScrollBarWidth-8;
                    return Math.Max(0, width);
                }
                else
                {
                    return 0;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    public class SearchWidthConvert : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return 0;
            }
            else
            {
                if (value is double)
                {
                    double width = (double)value;
                    width = width - SystemParameters.VerticalScrollBarWidth-20;
                    return Math.Max(0, width);
                }
                else
                {
                    return 0;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
    public class WidthMultiConvert : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length==0)
            {
                return 0;
            }
            else
            {
                if (values[0] is double)
                {
                    double width = (double)values[0];
                    width = width - SystemParameters.VerticalScrollBarWidth - 8;
                    return Math.Max(0, width);
                }
                else
                {
                    return 0;
                }
            }
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
