aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-10 11:08:14 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-10 11:08:14 +0200
commitee0f4151c329542c30041ff1da91d25e8d8e2575 (patch)
treec9528600e903e5bd7bc6084946a43c88c26c1f1c /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent0f60e99c075458a746a5e574ee6f87f33c0acd75 (diff)
downloadTango-ee0f4151c329542c30041ff1da91d25e8d8e2575.tar.gz
Tango-ee0f4151c329542c30041ff1da91d25e8d8e2575.zip
Removed Firmware Upgrade Views and VM from PPC.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/FirmwareUpgradeViewVM.cs170
1 files changed, 0 insertions, 170 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/FirmwareUpgradeViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/FirmwareUpgradeViewVM.cs
deleted file mode 100644
index 1cde1fe1a..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/FirmwareUpgradeViewVM.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Tango.Core.Commands;
-using Tango.PPC.Common;
-using Tango.PPC.Common.Application;
-using Tango.PPC.Common.FirmwareUpgrade;
-using Tango.PPC.Common.Navigation;
-using Tango.PPC.UI.ViewsContracts;
-
-namespace Tango.PPC.UI.ViewModels
-{
- public class FirmwareUpgradeViewVM : PPCViewModel<IFirmwareUpgradeView>
- {
- public enum FirmUpgradeView
- {
- FirmwareProgressView,
- FirmwareCompletedView,
- FirmwareFailedView,
- }
-
-
- private IFirmwareUpgrader _firmwareUpgrader;
-
- private String _status;
- /// <summary>
- /// Gets or sets the firmware upgrade status.
- /// </summary>
- public String Status
- {
- get { return _status; }
- set { _status = value; RaisePropertyChangedAuto(); }
- }
-
- private long _maxProgress;
- /// <summary>
- /// Gets or sets the firmware upgrade maximum progress.
- /// </summary>
- public long MaxProgress
- {
- get { return _maxProgress; }
- set { _maxProgress = value; RaisePropertyChangedAuto(); }
- }
-
- private long _progress;
- /// <summary>
- /// Gets or sets the firmware upgrade progress.
- /// </summary>
- public long Progress
- {
- get { return _progress; }
- set { _progress = value; RaisePropertyChangedAuto(); }
- }
-
- private bool _isIntermediate;
- /// <summary>
- /// Gets or sets a value indicating whether firmware upgrade progress is intermediate.
- /// </summary>
- public bool IsIntermediate
- {
- get { return _isIntermediate; }
- set { _isIntermediate = value; RaisePropertyChangedAuto(); }
- }
-
- /// <summary>
- /// Gets or sets the complete command.
- /// </summary>
- public RelayCommand CompleteCommand { get; set; }
-
- public RelayCommand TryAgainCommand { get; set; }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="FirmwareUpgradeViewVM"/> class.
- /// </summary>
- /// <param name="applicationManager">The application manager.</param>
- /// <param name="firmwareUpgrader">The firmware upgrader.</param>
- public FirmwareUpgradeViewVM(IPPCApplicationManager applicationManager, IFirmwareUpgrader firmwareUpgrader)
- {
- _firmwareUpgrader = firmwareUpgrader;
- CompleteCommand = new RelayCommand(Complete);
- TryAgainCommand = new RelayCommand(TryAgain);
- }
-
- private async void Upgrade()
- {
- IsIntermediate = true;
- Progress = 0;
- Status = "Connecting to the embedded firmware device...";
- await Task.Delay(2000);
- await NavigateTo(FirmUpgradeView.FirmwareProgressView);
- try
- {
- var handler = await _firmwareUpgrader.PerformUpgrade();
- IsIntermediate = false;
-
- handler.Progress += (_, e) =>
- {
- MaxProgress = e.Total;
- Progress = e.Current;
- Status = e.Message;
-
- if (e.Status != Integration.Upgrade.FirmwareUpgradeStatus.Uploading)
- {
- IsIntermediate = true;
- }
- };
- handler.Canceled += (_, __) =>
- {
- NavigateTo(FirmUpgradeView.FirmwareFailedView);
- };
- handler.Failed += (_, ex) =>
- {
- Status = ex.FlattenMessage();
- NavigateTo(FirmUpgradeView.FirmwareFailedView);
- };
- handler.Completed += (_, __) =>
- {
- NavigateTo(FirmUpgradeView.FirmwareCompletedView);
- };
- }
- catch (Exception ex)
- {
- Status = ex.FlattenMessage();
- LogManager.Log(ex);
- await NavigateTo(FirmUpgradeView.FirmwareFailedView);
- }
- }
-
- private void Complete()
- {
- Restart();
- }
-
- private async void TryAgain()
- {
- await NavigateTo(FirmUpgradeView.FirmwareProgressView);
- Upgrade();
- }
-
- private async void ApplicationManager_FirmwareUpgradeRequired(object sender, EventArgs e)
- {
- LogManager.Log("SetupRequired event received. Navigating to FirmwareUpgradeView...");
- await NavigationManager.NavigateTo(NavigationView.FirmwareUpgradeView);
- Upgrade();
- }
-
- private void Restart()
- {
- Settings.ApplicationState = ApplicationStates.Ready;
- Settings.Save();
- ApplicationManager.Restart();
- }
-
- /// <summary>
- /// Navigates to the specified view.
- /// </summary>
- /// <param name="view">The view.</param>
- private Task NavigateTo(FirmUpgradeView view)
- {
- return View.NavigateTo(view);
- }
-
- public override void OnApplicationStarted()
- {
-
- }
- }
-}