using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
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;
using SPC.Kiosk.Base;
using SPC.Kiosk.Common;
using SPC.Kiosk.Popup.Model;
namespace SPC.Kiosk.Popup
{
    /// <summary>
    /// DiscountAndValue.xaml에 대한 상호 작용 논리
    /// </summary>
    public partial class HappyAppCoupon : UserControl
    {
        #region [ Members ]
        /// <summary>
        /// ItemData
        /// </summary>
        public static readonly DependencyProperty ItemDataProperty =
                 DependencyProperty.Register(nameof(ItemData), typeof(M_HappyCoupon), typeof(HappyAppCoupon), new PropertyMetadata(new M_HappyCoupon(), new PropertyChangedCallback(OnItemDataPropertyChanged)));

        private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var target = d as HappyAppCoupon;
        }

        /// <summary>
        /// Display Language
        /// </summary>
        public static readonly DependencyProperty DisplayLanguagePropery =
                 DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(HappyAppCoupon), new PropertyMetadata(SupportLanguageType.ko));
        /// <summary>
        /// Button Switch
        /// </summary>
        public static readonly DependencyProperty SwitchPropery =
                 DependencyProperty.Register(nameof(Switch), typeof(bool), typeof(HappyAppCoupon), new PropertyMetadata(false, new PropertyChangedCallback(OnSwitchProperyChanged)));
        /// <summary>
        /// Button Switch
        /// </summary>
        public bool Switch
        {
            get { return (bool)GetValue(SwitchPropery); }
            set { SetValue(SwitchPropery, value);}

        }
        /// <summary>
        /// ItemData
        /// </summary>
        public M_HappyCoupon ItemData
        {
            get { return (M_HappyCoupon)GetValue(ItemDataProperty); }
            set { SetValue(ItemDataProperty, value); }
        }
        /// <summary>
        /// Display Language
        /// </summary>
        public SupportLanguageType DisplayLanguage
        {
            get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); }
            set { SetValue(DisplayLanguagePropery, value); }
        }
        /// <summary>
        /// Button NormalBrush
        /// </summary>
        public string ButtonNormalBrush { get; set; }
        public string ButtonDownBrush { get; set; }
        public string ButtonSwitchOnBrush { get; set; }
        public string ButtonDisableBrush { get; set; }

        #region [ RoutedEvent 'MouseClicked' ]

        /// <summary>
        /// MouseClicked Event
        /// </summary>
        public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HappyAppCoupon));
        /// <summary>
        /// MouseClicked Routed Event Handler
        /// </summary>
        public event RoutedEventHandler MouseClicked
        {
            add { AddHandler(MouseClickedEvent, value); }
            remove { RemoveHandler(MouseClickedEvent, value); }
        }
        #endregion RoutedEvent 'MouseClicked'

        #endregion Members

        #region [ Ctor & Etc ]
        /// <summary>
        /// Ctor
        /// </summary>
        public HappyAppCoupon()
        {
            ButtonNormalBrush = ResourceManager.GetNximagePathAdd("btn_coupon_n.png", CommonValue.PBdesignImagesPath);
            ButtonDownBrush = ResourceManager.GetNximagePathAdd("btn_coupon_p.png", CommonValue.PBdesignImagesPath);
            ButtonSwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_coupon_s.png", CommonValue.PBdesignImagesPath);
            ButtonDisableBrush = ResourceManager.GetNximagePathAdd("btn_coupon_d.png", CommonValue.PBdesignImagesPath);
            InitializeComponent();
        }

        #endregion Ctor & Etc

        #region [ Methods ]
        /// <summary>
        /// Raise MouseClicked Event
        /// </summary>
        private void RaiseMouseClickedEvent(object _sender)
        {
            RoutedEventArgs newEventArgs = new RoutedEventArgs(HappyAppCoupon.MouseClickedEvent, _sender);
            RaiseEvent(newEventArgs);
        }
        #endregion Methods

        #region [ Event Handlers ]
        private static void OnSwitchProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            var target = d as HappyAppCoupon;
            target.OptionButton.Switch = (bool)e.NewValue;
        }

        private void OptionButton_MouseClicked(object sender, RoutedEventArgs e)
        {
            RaiseMouseClickedEvent(this.ItemData);

        }
        #endregion Event Handlers

    }
}
