blob: d5d6a089152a20038a2123ac3ee72cfe5769a2a7 (
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core;
using Tango.Core.Commands;
using Tango.Core.DI;
namespace Tango.PPC.Common.Notifications
{
/// <summary>
/// Represents an app button that will be displayed in the layout view.
/// </summary>
/// <seealso cref="ExtendedObject" />
public abstract class AppButton : ExtendedObject
{
/// <summary>
/// Occurs when the button has been pressed.
/// </summary>
public event Action Pressed;
private String _text;
/// <summary>
/// Gets or sets the text.
/// </summary>
public String Text
{
get { return _text; }
set { _text = value; RaisePropertyChangedAuto(); }
}
private bool _isEnabled;
/// <summary>
/// Gets or sets a value indicating whether this instance is enabled.
/// </summary>
public bool IsEnabled
{
get { return _isEnabled; }
set { _isEnabled = value; RaisePropertyChangedAuto(); }
}
private RelayCommand _command;
/// <summary>
/// Gets or sets the command.
/// </summary>
public RelayCommand Command
{
get { return _command; }
set { _command = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Initializes a new instance of the <see cref="AppButton"/> class.
/// </summary>
public AppButton()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AppButton"/> class.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="isEnabled">if set to <c>true</c> [is enabled].</param>
/// <param name="onExecute">The on execute.</param>
/// <param name="canExecute">The can execute.</param>
public AppButton(String text, bool isEnabled) : this()
{
Text = text;
IsEnabled = isEnabled;
Command = new RelayCommand(() =>
{
Pressed?.Invoke();
});
}
/// <summary>
/// Initializes a new instance of the <see cref="AppButton"/> class.
/// </summary>
/// <param name="text">The text.</param>
/// <param name="command">The command.</param>
public AppButton(String text, RelayCommand command) : this(text, true)
{
Command = command;
}
/// <summary>
/// Invalidates the button state.
/// </summary>
public void RaiseCanExecute()
{
Command.RaiseCanExecuteChanged();
}
/// <summary>
/// Pops this instance.
/// </summary>
public void Pop()
{
TangoIOC.Default.GetInstance<INotificationProvider>().PopAppButton(this);
}
/// <summary>
/// Pushes this instance.
/// </summary>
public void Push()
{
TangoIOC.Default.GetInstance<INotificationProvider>().PushAppButton(this);
}
}
}
|