using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
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.Navigation;
using static C4IT.Logging.cLogManager;

namespace FasdDesktopUi.Basics.UserControls
{
    public partial class DontShowAgainDialog : UserControl
    {
        #region Properties

        #region Text

        public string Text
        {
            get { return (string)GetValue(TextProperty); }
            set { SetValue(TextProperty, value); }
        }

        public static readonly DependencyProperty TextProperty =
            DependencyProperty.Register("Text", typeof(string), typeof(DontShowAgainDialog), new PropertyMetadata(string.Empty));

        #endregion

        #region IsChecked

        public bool IsChecked
        {
            get { return (bool)GetValue(IsCheckedProperty); }
            set { SetValue(IsCheckedProperty, value); }
        }
        
        public static readonly DependencyProperty IsCheckedProperty =
            DependencyProperty.Register("IsChecked", typeof(bool), typeof(DontShowAgainDialog), new PropertyMetadata(false));

        #endregion

        #region IsCheckedChanged

        public EventHandler<bool> IsCheckedChanged
        {
            get { return (EventHandler<bool>)GetValue(IsCheckedChangedProperty); }
            set { SetValue(IsCheckedChangedProperty, value); }
        }

        public static readonly DependencyProperty IsCheckedChangedProperty =
            DependencyProperty.Register("IsCheckedChanged", typeof(EventHandler<bool>), typeof(DontShowAgainDialog), new PropertyMetadata(null));

        #endregion

        #endregion

        public DontShowAgainDialog()
        {
            InitializeComponent();
        }

        private void DontShowAgainCheck_Checked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsCheckedChanged is null)
                    return;

                IsCheckedChanged.Invoke(this, true);
            }
            catch (Exception E)
            {
                LogException(E);
            }
        }

        private void DontShowAgainCheck_Unchecked(object sender, RoutedEventArgs e)
        {
            try
            {
                if (IsCheckedChanged is null)
                    return;

                IsCheckedChanged.Invoke(this, false);
            }
            catch (Exception E)
            {
                LogException(E);
            }
        }
    }
}
