using InABox.DynamicGrid;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace InABox.WPF
{
    public class ObjectToGridLengthConverter : AbstractConverter<FrameworkElement?, GridLength>
    {
        public GridLength NotNull { get; set; } = new GridLength(0, GridUnitType.Pixel);
        public GridLength IsNull { get; set; } = new GridLength(1, GridUnitType.Auto);
        
        public override GridLength Convert(FrameworkElement? value)
        {
            return value == null
                ? IsNull
                : NotNull;
        }
    }
    
    public class ObjectToVisibilityConverter : AbstractConverter<FrameworkElement?, Visibility>
    {
        public Visibility NotNull { get; set; } = Visibility.Visible;
        public Visibility IsNull { get; set; } = Visibility.Collapsed;
        
        public override Visibility Convert(FrameworkElement? value)
        {
            return value == null
                ? IsNull
                : NotNull;
        }
    }  
    
    public partial class Generic : ResourceDictionary
    {
        public Generic()
        {
            //InitializeComponent();
        }

        private void Panel_OnPreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            var parent = (sender as FrameworkElement)?.TemplatedParent as DynamicTabItem;
            if (parent == null)
                return;
            parent.ContextMenuCommand.Execute(null);
        }
    }
}
