From ae1cfd30f1efbd385eac04b3d02fa1ed161058a3 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 17 Dec 2018 16:43:40 +0200 Subject: Add AppButtons to PPC. Implemented Stop & Start job app buttons! --- .../HotSpot/DefaultHotSpotProvider.cs | 6 +- .../MachineSetup/MachineSetupManager.cs | 2 +- .../Tango.PPC.Common/Notifications/AppButton.cs | 112 +++++++++++++++++++++ .../Notifications/INotificationProvider.cs | 17 ++++ .../PPC/Tango.PPC.Common/Resources/Merged.xaml | 2 + .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 3 +- 6 files changed, 139 insertions(+), 3 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/AppButton.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs index 1126a84bc..5a6b2405c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/HotSpot/DefaultHotSpotProvider.cs @@ -77,8 +77,12 @@ namespace Tango.PPC.Common.HotSpot { try { - CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango_" + _machineProvider.Machine.SerialNumber}' key='{password}'"); + CmdCommand command = new CmdCommand("netsh", $"wlan set hostednetwork mode=allow ssid='{"Tango-" + _machineProvider.Machine.SerialNumber}' key='{password}'"); await command.Run(); + + command = new CmdCommand("netsh", "wlan start hosted network"); + await command.Run(); + IsEnabled = true; } catch (Exception ex) diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs index ead508488..31e3290d8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/MachineSetup/MachineSetupManager.cs @@ -136,7 +136,7 @@ namespace Tango.PPC.Common.MachineSetup LogManager.Log("Installing remote assistance..."); UpdateProgress("Installing remote assistance", "Installing..."); - await _remoteAssistance.InstallRemoteAssistance(); + //await _remoteAssistance.InstallRemoteAssistance(); //Create temporary folders for packages. var _newPackageTempFolder = TemporaryManager.CreateFolder(); 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 +{ + /// + /// Represents an app button that will be displayed in the layout view. + /// + /// + public abstract class AppButton : ExtendedObject + { + /// + /// Occurs when the button has been pressed. + /// + public event Action Pressed; + + private String _text; + /// + /// Gets or sets the text. + /// + public String Text + { + get { return _text; } + set { _text = value; RaisePropertyChangedAuto(); } + } + + private bool _isEnabled; + /// + /// Gets or sets a value indicating whether this instance is enabled. + /// + public bool IsEnabled + { + get { return _isEnabled; } + set { _isEnabled = value; RaisePropertyChangedAuto(); } + } + + private RelayCommand _command; + /// + /// Gets or sets the command. + /// + public RelayCommand Command + { + get { return _command; } + set { _command = value; RaisePropertyChangedAuto(); } + } + + /// + /// Initializes a new instance of the class. + /// + public AppButton() + { + + } + + /// + /// Initializes a new instance of the class. + /// + /// The text. + /// if set to true [is enabled]. + /// The on execute. + /// The can execute. + public AppButton(String text, bool isEnabled) : this() + { + Text = text; + IsEnabled = isEnabled; + Command = new RelayCommand(() => + { + Pressed?.Invoke(); + }); + } + + /// + /// Initializes a new instance of the class. + /// + /// The text. + /// The command. + public AppButton(String text, RelayCommand command) : this(text, true) + { + Command = command; + } + + /// + /// Invalidates the button state. + /// + public void RaiseCanExecute() + { + Command.RaiseCanExecuteChanged(); + } + + /// + /// Pops this instance. + /// + public void Pop() + { + TangoIOC.Default.GetInstance().PopAppButton(this); + } + + /// + /// Pushes this instance. + /// + public void Push() + { + TangoIOC.Default.GetInstance().PushAppButton(this); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs index c43e96b10..c4e82b7d2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/INotificationProvider.cs @@ -57,6 +57,11 @@ namespace Tango.PPC.Common.Notifications /// FrameworkElement CurrentDialog { get; } + /// + /// Gets the current app button. + /// + AppButton CurrentAppButton { get; } + /// /// Gets a value indicating whether this instance has a dialog. /// @@ -203,5 +208,17 @@ namespace Tango.PPC.Common.Notifications /// Gets or sets a value indicating whether to allow notifications visibility. /// bool NotificationsVisible { get; set; } + + /// + /// Pushes the app button. + /// + /// The app button. + void PushAppButton(AppButton appButton); + + /// + /// Pops the app button. + /// + /// The app button. + void PopAppButton(AppButton appButton); } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml index 01d69ecc9..266bef3eb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Merged.xaml @@ -44,6 +44,8 @@ + +