using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using CtrEditor.ObjetosSim;
using CtrEditor.FuncionesBase;

namespace CtrEditor.ObjetosSim.HydraulicComponents
{
    /// <summary>
    /// Interaction logic for ucHydDischargeTank.xaml
    /// </summary>
    public partial class ucHydDischargeTank : UserControl, IDataContainer
    {
        public osBase? Datos { get; set; }
        public int zIndex_fromFrames { get; set; } = 0;
        
        private bool _isHighlighted = false;
        
        public ucHydDischargeTank()
        {
            InitializeComponent();
            this.Loaded += OnLoaded;
            this.Unloaded += OnUnloaded;
            DataContextChanged += OnDataContextChanged;
        }
        
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            Datos?.ucLoaded();
        }
        
        private void OnUnloaded(object sender, RoutedEventArgs e)
        {
            Datos?.ucUnLoaded();
        }
        
        private void OnDataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (DataContext is osHydDischargeTank tank)
            {
                Datos = tank;
            }
        }
        
        #region IDataContainer Implementation
        
        public void Highlight(bool state)
        {
            _isHighlighted = state;
            
            if (state)
            {
                rectTank.Stroke = new SolidColorBrush(Colors.Yellow);
                rectTank.StrokeThickness = 3;
            }
            else
            {
                rectTank.Stroke = new SolidColorBrush(Colors.DarkSlateGray);
                rectTank.StrokeThickness = 2;
            }
        }
        
        #endregion
        
        public ZIndexEnum ZIndex_Base()
        {
            return ZIndexEnum.Estaticos;
        }
    }
}
