mirror of
https://github.com/chylex/Discord-History-Tracker.git
synced 2025-08-18 13:31:42 +02:00
.github
.idea
app
.idea
Desktop
Common
Dialogs
CheckBox
File
Message
Progress
TextBox
TextBoxDialog.axaml
TextBoxDialog.axaml.cs
TextBoxDialogModel.cs
TextBoxItem.cs
Discord
Main
Resources
Server
App.axaml
App.axaml.cs
Arguments.cs
Desktop.csproj
Program.cs
Resources
Server
Utils
.gitignore
Directory.Build.props
DiscordHistoryTracker.sln
NuGet.Config
Version.cs
build.bat
build.sh
empty.dht
global.json
tools
web
.gitattributes
.gitignore
LICENSE.md
README.md
43 lines
1.0 KiB
C#
43 lines
1.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.ComponentModel;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
namespace DHT.Desktop.Dialogs.TextBox;
|
|
|
|
class TextBoxItem : ObservableObject, INotifyDataErrorInfo {
|
|
public string Title { get; init; } = "";
|
|
public object? Item { get; init; } = null;
|
|
|
|
public Func<string, bool> ValidityCheck { get; init; } = static _ => true;
|
|
public bool IsValid => ValidityCheck(Value);
|
|
|
|
private string value = string.Empty;
|
|
|
|
public string Value {
|
|
get => this.value;
|
|
set {
|
|
SetProperty(ref this.value, value);
|
|
ErrorsChanged?.Invoke(this, new DataErrorsChangedEventArgs(nameof(Value)));
|
|
}
|
|
}
|
|
|
|
public IEnumerable GetErrors(string? propertyName) {
|
|
if (propertyName == nameof(Value) && !IsValid) {
|
|
yield return string.Empty;
|
|
}
|
|
}
|
|
|
|
public bool HasErrors => !IsValid;
|
|
public event EventHandler<DataErrorsChangedEventArgs>? ErrorsChanged;
|
|
}
|
|
|
|
sealed class TextBoxItem<T> : TextBoxItem {
|
|
public new T Item { get; }
|
|
|
|
public TextBoxItem(T item) {
|
|
this.Item = item;
|
|
base.Item = item;
|
|
}
|
|
}
|