using C4IT.Logging;
using FasdDesktopUi.Basics.Models;
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.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static C4IT.Logging.cLogManager;

namespace FasdDesktopUi.Basics.UserControls
{
    public partial class BlurInvokerContainer : UserControl, IBlurInvoker
    {
        #region Properties

        public UIElement Child
        {
            get { return (UIElement)GetValue(ChildProperty); }
            set { SetValue(ChildProperty, value); }
        }

        public static readonly DependencyProperty ChildProperty =
            DependencyProperty.Register("Child", typeof(UIElement), typeof(BlurInvokerContainer), new PropertyMetadata(null, new PropertyChangedCallback(ChildChanged)));

        private static void ChildChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            try
            {
                if (!(d is BlurInvokerContainer _me))
                    return;

                _me.MainDecorator.Child = _me.Child;
            }
            catch (Exception E)
            {
                LogException(E);
            }
        }

        #endregion

        public BlurInvokerContainer()
        {
            InitializeComponent();
        }

        public void BlurInvoker_IsActiveChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            BlurInvoker.InvokeVisibilityChanged(this, new EventArgs());
        }

        public bool BlurInvoker_IsActive => IsVisible;

    }
}
