You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kev/Drawer/AI/Models/SpecialMessages/WellPointLoadCardMessage.cs

141 lines
4.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
{
/// <summary>
/// 井点导入卡片的阶段
/// </summary>
public enum WellPointLoadPhase
{
SelectFile = 0,
FileLoaded = 1,
Completed = 2,
}
/// <summary>
/// 井点数据导入综合卡片:选择文件 → 数据预览 → 列头匹配(井号/X/Y/Z
/// </summary>
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<FormFieldEntry> 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<T>(ref T field, T value, [CallerMemberName] string? propertyName = null)
{
if (EqualityComparer<T>.Default.Equals(field, value))
{
return false;
}
field = value;
OnPropertyChanged(propertyName);
return true;
}
}
}