using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;


namespace CustomControls
{
    /// <summary>
    /// Interakční logika pro ColorChangingButton.xaml
    /// </summary>
    public partial class ColorChangingButton : UserControl
    {
        public ColorChangingButton()
        {
            InitializeComponent();
            LayoutRoot.DataContext = this;
        }

        [Description("Text written to on button"), Category("Data")]
        public string TextON
        {
            get { return (string)GetValue(TextONProperty); }
            set { SetValueDp(TextONProperty, value); }
        }

        [Description("Text written to on button"), Category("Data")]
        public string TextOFF
        {
            get { return (string)GetValue(TextOFFProperty); }
            set { SetValueDp(TextOFFProperty, value); }
        }

        [Description("State value"), Category("Data")]
        public bool Value
        {
            get { return (bool)GetValue(ValueProperty); }
            set
            {
                SetValueDp(ValueProperty, value);
            }
        }

        [Description("Button command"), Category("Data")]
        public ICommand Command
        {
            get { return (ICommand)GetValue(CommandProperty); }
            set { SetValueDp(CommandProperty, value); }
        }

        [Description("Command parameter"), Category("Data")]
        public string CommandPar
        {
            get { return (string)GetValue(CommandParProperty); }
            set { SetValueDp(CommandParProperty, value); }
        }




        public static readonly DependencyProperty TextONProperty = DependencyProperty.Register("TextON", typeof(string), typeof(ColorChangingButton));
        public static readonly DependencyProperty TextOFFProperty = DependencyProperty.Register("TextOFF", typeof(string), typeof(ColorChangingButton));
        public static readonly DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(bool), typeof(ColorChangingButton));
        public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(string), typeof(ColorChangingButton));
        public static readonly DependencyProperty CommandProperty = DependencyProperty.Register("Command", typeof(ICommand), typeof(ColorChangingButton));
        public static readonly DependencyProperty CommandParProperty = DependencyProperty.Register("CommadPar", typeof(object), typeof(ColorChangingButton));

        public event PropertyChangedEventHandler PropertyChanged;
        void SetValueDp(DependencyProperty property, object value, [System.Runtime.CompilerServices.CallerMemberName] string p = null)
        {
            SetCurrentValue(property, value);
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(p));
        }
    }
}
