blob: 415c6cfc5bd70e506691dfd5354d13f0c8e056ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
using MaterialDesignThemes.Wpf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tango.FSE.Common.Notifications
{
public class InputBoxVM : MessageBoxVM
{
public PackIconKind Icon { get; set; }
public String InputHint { get; set; }
public int MaxCharacters { get; set; }
internal Func<String,String> ValidationFunction { get; set; }
private String _input;
public String Input
{
get { return _input; }
set
{
_input = value;
RaisePropertyChangedAuto();
if (_input.IsNotNullOrEmpty())
{
if (ValidationFunction != null)
{
Error = ValidationFunction.Invoke(_input);
}
}
else
{
Error = null;
}
RaisePropertyChanged(nameof(HasValidationError));
InvalidateRelayCommands();
}
}
public bool HasValidationError
{
get { return !String.IsNullOrWhiteSpace(Error); }
}
private String _error;
public String Error
{
get { return _error; }
set { _error = value; RaisePropertyChangedAuto(); }
}
public InputBoxVM() : base()
{
HasCancel = true;
}
protected override bool CanOK()
{
return base.CanOK() && Input.IsNotNullOrEmpty() && !HasValidationError;
}
}
}
|