blob: c8d606efcce7d9582ee9f8ad5014b1d1c59be4bb (
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
69
70
71
72
73
74
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.SharedUI;
namespace Tango.MachineStudio.Common.Notifications
{
/// <summary>
/// Represents a dialog view model base class.
/// </summary>
/// <seealso cref="Tango.SharedUI.ViewModel" />
public abstract class DialogViewVM : ViewModel
{
public event Action Accepted;
public event Action Canceled;
/// <summary>
/// Initializes a new instance of the <see cref="DialogViewVM"/> class.
/// </summary>
public DialogViewVM()
{
CanClose = true;
CloseCommand = new RelayCommand(Cancel, (x) => CanClose);
OKCommand = new RelayCommand(Accept, (x) => CanClose);
}
private bool _canClose;
/// <summary>
/// Gets or sets a value indicating whether this dialog can be closed.
/// </summary>
public bool CanClose
{
get { return _canClose; }
set { _canClose = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
/// <summary>
/// Gets or sets the close command.
/// </summary>
public RelayCommand CloseCommand { get; set; }
/// <summary>
/// Gets or sets the ok command.
/// </summary>
public RelayCommand OKCommand { get; set; }
/// <summary>
/// Called when the dialog has been shown.
/// </summary>
public virtual void OnShow()
{
}
/// <summary>
/// Invokes the <see cref="Accepted"/> event.
/// </summary>
protected virtual void Accept()
{
Accepted?.Invoke();
}
/// <summary>
/// Invokes the <see cref="Canceled"/> event.
/// </summary>
protected virtual void Cancel()
{
Canceled?.Invoke();
}
}
}
|