using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace parkMonitor.view.util {
	/// <summary></summary>
	public class ImageMenuItem : Label {
		static ImageMenuItem() {
			DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageMenuItem), new FrameworkPropertyMetadata(typeof(ImageMenuItem)));
		}

		//Source
		public static readonly DependencyProperty SourcePro = DependencyProperty.Register("Source", typeof(ImageSource), typeof(ImageMenuItem), new PropertyMetadata(null));
		public ImageSource Source {
			get { return (ImageSource)GetValue(SourcePro); }
			set { SetCurrentValue(SourcePro, value); }
		}

		//附加图片资源
		public static readonly DependencyProperty MiniSourcePro = DependencyProperty.Register("MiniSource", typeof(ImageSource), typeof(ImageMenuItem), new PropertyMetadata(null));
		public ImageSource MiniSource {
			get { return (ImageSource)GetValue(MiniSourcePro); }
			set { SetCurrentValue(MiniSourcePro, value); }
		}

		//IsSmall
		public static readonly DependencyProperty IsSmallPro = DependencyProperty.Register("IsSmall", typeof(bool), typeof(ImageMenuItem), new PropertyMetadata(false));
		public bool IsSmall {
			get { return (bool)GetValue(IsSmallPro); }
			set { SetCurrentValue(IsSmallPro, value); }
		}

		//Image Margin
		public static readonly DependencyProperty ImgMarginPro = DependencyProperty.Register("ImgMargin", typeof(Thickness), typeof(ImageMenuItem), new PropertyMetadata(new Thickness(0)));
		public Thickness ImgMargin {
			get { return (Thickness)GetValue(ImgMarginPro); }
			set { SetCurrentValue(ImgMarginPro, value); }
		}

		//Mouse Over Color
		public static readonly DependencyProperty MouseOverColorProperty = DependencyProperty.Register("MouseOverColor", typeof(Brush), typeof(ImageMenuItem), new PropertyMetadata(new SolidColorBrush((Color)ColorConverter.ConvertFromString("#636363"))));
		public Brush MouseOverColor {
			get { return (Brush)GetValue(MouseOverColorProperty); }
			set { SetCurrentValue(MouseOverColorProperty, value); }
		}
	}

	[ValueConversion(typeof(int), typeof(bool))]
	class XImageItemScaleCvt : IValueConverter {
		public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
			double? iValue = value as double?;
			if(iValue == null) {
				return iValue;
			}

			return iValue * 0.25;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
			return -1;
		}

	}

}
