You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

113 lines
2.6 KiB

using System.ComponentModel;
using System.Runtime.CompilerServices;
using HandyControl.Collections;
using BrilliantSightClient.ViewModel.Configuration;
namespace BrilliantSightClient.Model.Entity;
public class AgileJsonConfigEntity
{
// public readonly List<string> Keys;
private AlgorithmConfigVM ACVM;
private ManualObservableCollection<string> _runKey;
public ManualObservableCollection<string> RunKey {
get => _runKey;
set
{
_runKey = value;
OnPropertyChanged(nameof(RunKey));
}
}
public AgileJsonConfigEntity(AlgorithmConfigVM acVM)
{
Shape = "圆形";
ModeValue = "999";
SpecValue = "999";
ACVM = acVM;
RunKey = new ManualObservableCollection<string>(acVM.JsonKeysBak);
}
private string _modeValue;
public string ModeValue
{
get => _modeValue;
set
{
SetField(ref _modeValue, value);
OnPropertyChanged(nameof(ModeValue));
}
}
private string _specValue;
public string SpecValue
{
get => _specValue;
set
{
SetField(ref _specValue, value);
OnPropertyChanged(nameof(SpecValue));
}
}
private string _shape;
public string Shape
{
get => _shape;
set => SetField(ref _shape, value);
}
private string _jsonKey;
public string JsonKey
{
get => _jsonKey;
set
{
SetField(ref _jsonKey, value);
OnPropertyChanged(nameof(JsonKey));
FilterItems(value);
}
}
private string _value;
public string Value
{
get => _value;
set => SetField(ref _value, value);
}
private void FilterItems(string key)
{
RunKey.CanNotify = false;
RunKey.Clear();
foreach (var data in ACVM.JsonKeysBak)
{
if (data.ToLower().Contains(key.ToLower()))
{
RunKey.Add(data);
}
}
if(RunKey.Count <= 0)
RunKey.Add(key);
RunKey.CanNotify = true;
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
protected bool SetField<T>(ref T field, T value, [CallerMemberName] string name = null)
{
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
field = value;
OnPropertyChanged(name);
return true;
}
}