using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Runtime.CompilerServices; using AI.Models.Form; namespace AI.Models.SpecialMessages { /// /// 井点导入卡片的阶段 /// public enum WellPointLoadPhase { SelectFile = 0, FileLoaded = 1, Completed = 2, } /// /// 井点数据导入综合卡片:选择文件 → 数据预览 → 列头匹配(井号/X/Y/Z)。 /// public class WellPointLoadCardMessage : ISpecialMessage, INotifyPropertyChanged { private WellPointLoadPhase _phase = WellPointLoadPhase.SelectFile; private string _filePath = string.Empty; private bool _isLoading; private string _statusMessage = string.Empty; private TableDataMessage? _tablePreview; private string _matchButtonLabel = "确认匹配"; public string Id { get; set; } = Guid.NewGuid().ToString(); public string TypeName => "WellPointLoadCard"; public bool IsLive => false; public WellPointLoadPhase Phase { get => _phase; set { if (SetProperty(ref _phase, value)) { OnPropertyChanged(nameof(IsFileInputEnabled)); OnPropertyChanged(nameof(ShowLoadButtons)); OnPropertyChanged(nameof(HasSubmittedFile)); OnPropertyChanged(nameof(ShowPreviewSection)); OnPropertyChanged(nameof(ShowMatchSection)); OnPropertyChanged(nameof(ShowMatchButton)); } } } public bool IsLoading { get => _isLoading; set { if (SetProperty(ref _isLoading, value)) { OnPropertyChanged(nameof(ShowLoadButtons)); OnPropertyChanged(nameof(IsFileInputEnabled)); } } } public string StatusMessage { get => _statusMessage; set { SetProperty(ref _statusMessage, value ?? string.Empty); OnPropertyChanged(nameof(HasStatusMessage)); } } public bool HasStatusMessage => !string.IsNullOrEmpty(_statusMessage); public string FilePath { get => _filePath; set => SetProperty(ref _filePath, value ?? string.Empty); } public bool IsFileInputEnabled => Phase == WellPointLoadPhase.SelectFile && !IsLoading; public bool ShowLoadButtons => Phase == WellPointLoadPhase.SelectFile && !IsLoading; public bool ShowLoadingHint => IsLoading; public bool HasSubmittedFile => Phase != WellPointLoadPhase.SelectFile; public TableDataMessage? TablePreview { get => _tablePreview; set { if (SetProperty(ref _tablePreview, value)) { OnPropertyChanged(nameof(ShowPreviewSection)); } } } public bool ShowPreviewSection => _tablePreview != null && Phase != WellPointLoadPhase.SelectFile; public ObservableCollection ColumnMatchFields { get; } = new(); public string MatchButtonLabel { get => _matchButtonLabel; set => SetProperty(ref _matchButtonLabel, value); } public bool ShowMatchSection => Phase == WellPointLoadPhase.FileLoaded; public bool ShowMatchButton => Phase == WellPointLoadPhase.FileLoaded; public event PropertyChangedEventHandler? PropertyChanged; protected void OnPropertyChanged([CallerMemberName] string? propertyName = null) { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); } protected bool SetProperty(ref T field, T value, [CallerMemberName] string? propertyName = null) { if (EqualityComparer.Default.Equals(field, value)) { return false; } field = value; OnPropertyChanged(propertyName); return true; } } }