aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-02-17 17:25:52 +0200
committerAvi Levkovich <avi@twine-s.com>2019-02-17 17:25:52 +0200
commit638ef66200cc71378f00e2705dc6b259c461ae78 (patch)
treef8143befd029c56599f4f892427713960e99c50b /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs
parente89e1d93b6c8198828a6bda95db0bbd6cbae3955 (diff)
parent21cdc1e12814f72e6aac795f9ddd2a32b9614389 (diff)
downloadTango-638ef66200cc71378f00e2705dc6b259c461ae78.tar.gz
Tango-638ef66200cc71378f00e2705dc6b259c461ae78.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs
index 09b63cfc9..e54c28e17 100644
--- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/FirmwareUpgradeViewVM.cs
@@ -5,11 +5,14 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Input;
using Tango.Core.Commands;
using Tango.Integration.Operation;
using Tango.Integration.Upgrade;
using Tango.MachineStudio.Common.Notifications;
using Tango.SharedUI;
+using Tango.SharedUI.Helpers;
namespace Tango.MachineStudio.UI.ViewModels
{
@@ -47,6 +50,35 @@ namespace Tango.MachineStudio.UI.ViewModels
set { upgradeError = value; RaisePropertyChangedAuto(); }
}
+ private bool _dfu;
+ public bool DFU
+ {
+ get { return _dfu; }
+ set
+ {
+ _dfu = value; RaisePropertyChangedAuto();
+
+ if (_dfu)
+ {
+ UploadTFP = false;
+ }
+ }
+ }
+
+ private bool _uploadTFP;
+ public bool UploadTFP
+ {
+ get { return _uploadTFP; }
+ set
+ {
+ _uploadTFP = value; RaisePropertyChangedAuto();
+
+ if (_uploadTFP)
+ {
+ DFU = false;
+ }
+ }
+ }
public RelayCommand SelectCommand { get; set; }
@@ -56,6 +88,7 @@ namespace Tango.MachineStudio.UI.ViewModels
public FirmwareUpgradeViewVM(IMachineOperator machineOperator, INotificationProvider notificationProvider) : base()
{
+ DFU = true;
_notification = notificationProvider;
_operator = machineOperator;
SelectCommand = new RelayCommand(BrowseForFile);
@@ -96,6 +129,17 @@ namespace Tango.MachineStudio.UI.ViewModels
try
{
+ IsFree = false;
+
+ if (UploadTFP)
+ {
+ _operator.FirmwareUpgradeMode = FirmwareUpgradeModes.DFU | FirmwareUpgradeModes.TFP_PACKAGE;
+ }
+ else
+ {
+ _operator.FirmwareUpgradeMode = FirmwareUpgradeModes.DFU;
+ }
+
_stream = new FileStream(SelectedFile, FileMode.Open);
Handler = await _operator.UpgradeFirmware(_stream);
Handler.Progress += (_, e) =>
@@ -104,18 +148,22 @@ namespace Tango.MachineStudio.UI.ViewModels
{
AbortCommand.RaiseCanExecuteChanged();
});
+
+ UIHelper.DoEvents();
};
Handler.Completed += (_, __) =>
{
CanClose = true;
_stream.Dispose();
CurrentPage = 2;
+ IsFree = true;
};
Handler.Canceled += (_, __) =>
{
CanClose = true;
_stream.Dispose();
CurrentPage = 0;
+ IsFree = true;
};
Handler.Failed += (_, ex) =>
{
@@ -123,10 +171,12 @@ namespace Tango.MachineStudio.UI.ViewModels
CanClose = true;
_stream.Dispose();
CurrentPage = 3;
+ IsFree = true;
};
}
catch (Exception ex)
{
+ IsFree = true;
CanClose = true;
UpgradeError = ex.FlattenMessage();
CurrentPage = 3;