aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-17 16:43:40 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-17 16:43:40 +0200
commitae1cfd30f1efbd385eac04b3d02fa1ed161058a3 (patch)
tree5b77d7484e80491b06f1b726a57a61c782b5569e /Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs
parent8270aa37dee33cda98603a995de823df393f7294 (diff)
downloadTango-ae1cfd30f1efbd385eac04b3d02fa1ed161058a3.tar.gz
Tango-ae1cfd30f1efbd385eac04b3d02fa1ed161058a3.zip
Add AppButtons to PPC.
Implemented Stop & Start job app buttons!
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs112
1 files changed, 112 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs
new file mode 100644
index 000000000..d5d6a0891
--- /dev/null
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs
@@ -0,0 +1,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);
+ }
+ }
+}