59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using System.Collections.ObjectModel;
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
namespace BoreholeExtract
|
|
{
|
|
public partial class CategoryWrapper : ObservableObject
|
|
{
|
|
public Identify Id { get; set; }
|
|
|
|
public string Title { get; set; }
|
|
|
|
public ObservableCollection<string> Items { get; set; }
|
|
|
|
[ObservableProperty]
|
|
public partial string InputText { get; set; }
|
|
|
|
public CategoryWrapper(Identify id, string title, ObservableCollection<string> items)
|
|
{
|
|
Id = id;
|
|
Title = title;
|
|
Items = items;
|
|
}
|
|
[RelayCommand]
|
|
private void Remove(string param)
|
|
{
|
|
if (param is string item) Items.Remove(item);
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Add()
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(InputText))
|
|
{
|
|
var val = InputText.Trim();
|
|
if (!Items.Contains(val)) Items.Add(val);
|
|
InputText = ""; // 清空输入框
|
|
}
|
|
}
|
|
}
|
|
|
|
public enum Identify
|
|
{
|
|
Company = 0,
|
|
Project = 1,
|
|
Mileage = 2,
|
|
DesignElevation = 3,
|
|
DrillCode = 4,
|
|
DrillCategory = 5,
|
|
HoleDiameter = 6,
|
|
HoleElevation = 7,
|
|
StartDate = 8,
|
|
EndDate = 9,
|
|
InitialWater = 10,
|
|
StableWater = 11,
|
|
}
|
|
}
|