using System;
using System.Collections.Generic;
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 PDF_Office.CustomControl.CompositeControl
{
    //类的说明：
    //复合控件：调色版
    //组合而成的控件：调色板选择的颜色圆形按钮UI，弹出调色版的按钮
    /// <summary>
    /// ColorSubContent.xaml 的交互逻辑
    /// </summary>
    public partial class ColorSubContent : UserControl
    {
        /// <summary>
        /// 改变颜色后，触发事件
        /// </summary>
        public event EventHandler<Color> SelectedColorHandler;
        public ColorSubContent()
        {
            InitializeComponent();
        }

        private void ElcustomColor_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            CurrentColor = (ElcustomColor.Fill as SolidColorBrush).Color;
            SelectedColorHandler?.Invoke(this, (ElcustomColor.Fill as SolidColorBrush).Color);
        }

        private void ColorDropPicker_SelectedColorChanged(object sender, Color? e)
        {
           
            SelectedColorHandler?.Invoke(this, e.Value);
            ElcustomColor.Fill = new SolidColorBrush(e.Value);
            CurrentColor = e.Value;
        }

        /// <summary>
        /// 当前选择的颜色，默认为透明色
        /// </summary>
        public Color CurrentColor
        {
            get { return (Color)GetValue(CurrentColorProperty); }
            set { SetValue(CurrentColorProperty, value); }
        }
        public static readonly DependencyProperty CurrentColorProperty =
           DependencyProperty.Register("CurrentColor", typeof(Color), typeof(ColorSubContent), new PropertyMetadata(Colors.Transparent));

    }
}
