using System.ComponentModel;
using Autodesk.Navisworks.Api;

namespace NavisworksTransport.UI.WPF.Models
{
    /// <summary>
    /// 分层预览项数据模型
    /// 用于在UI中显示分层预览结果的简化数据结构
    /// </summary>
    public class SplitPreviewItem : INotifyPropertyChanged
    {
        private string _layerName;
        private string _layerAttribute;
        private string _estimatedSize;
        private string _status;

        /// <summary>
        /// 分层名称
        /// </summary>
        public string LayerName
        {
            get => _layerName;
            set
            {
                if (_layerName != value)
                {
                    _layerName = value;
                    OnPropertyChanged(nameof(LayerName));
                }
            }
        }

        /// <summary>
        /// 对象数量
        /// </summary>
        /// <summary>
        /// 分层属性
        /// </summary>
        public string LayerAttribute
        {
            get => _layerAttribute;
            set
            {
                if (_layerAttribute != value)
                {
                    _layerAttribute = value;
                    OnPropertyChanged(nameof(LayerAttribute));
                }
            }
        }

        /// <summary>
        /// 预估文件大小
        /// </summary>
        public string EstimatedSize
        {
            get => _estimatedSize;
            set
            {
                if (_estimatedSize != value)
                {
                    _estimatedSize = value;
                    OnPropertyChanged(nameof(EstimatedSize));
                }
            }
        }

        /// <summary>
        /// 状态
        /// </summary>
        public string Status
        {
            get => _status;
            set
            {
                if (_status != value)
                {
                    _status = value;
                    OnPropertyChanged(nameof(Status));
                }
            }
        }

        /// <summary>
        /// 预估文件大小（字节）
        /// 内部使用，不绑定UI
        /// </summary>
        public long EstimatedFileSize { get; set; }

        /// <summary>
        /// 是否选中用于保存，默认为true
        /// </summary>
        private bool _isSelectedForSave = true;
        public bool IsSelectedForSave
        {
            get => _isSelectedForSave;
            set
            {
                if (_isSelectedForSave != value)
                {
                    _isSelectedForSave = value;
                    OnPropertyChanged(nameof(IsSelectedForSave));
                }
            }
        }

        /// <summary>
        /// 关联的模型项集合
        /// 用于隔离显示功能
        /// </summary>
        public ModelItemCollection Items { get; set; } = new ModelItemCollection();

        /// <summary>
        /// 元数据字典
        /// 存储额外信息，如RootNodes等优化数据
        /// </summary>
        public System.Collections.Generic.Dictionary<string, object> Metadata { get; set; } = new System.Collections.Generic.Dictionary<string, object>();

        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }
}