aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/FirmwareUpgrade/DefaultFirmwareUpgrader.cs
blob: 4cceec50ce25ffb18136d97d18cabdf57fdc2dff (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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Integration.Operation;
using Tango.Integration.Upgrade;
using Tango.MachineStudio.Common.FirmwareUpgrade;
using Tango.MachineStudio.Common.Notifications;
using Tango.MachineStudio.Common.StudioApplication;
using Tango.MachineStudio.UI.ViewModels;
using Tango.MachineStudio.UI.Views;

namespace Tango.MachineStudio.UI.FirmwareUpgrade
{
    /// <summary>
    /// Default firmware upgrade manager.
    /// </summary>
    /// <seealso cref="Tango.MachineStudio.Common.FirmwareUpgrade.IFirmwareUpgrader" />
    public class DefaultFirmwareUpgrader : IFirmwareUpgrader
    {
        private IStudioApplicationManager _applicationManager;
        private INotificationProvider _notification;

        /// <summary>
        /// Initializes a new instance of the <see cref="DefaultFirmwareUpgrader"/> class.
        /// </summary>
        public DefaultFirmwareUpgrader(IStudioApplicationManager applicationManager, INotificationProvider notificationProvider)
        {
            _applicationManager = applicationManager;
            _notification = notificationProvider;
        }

        /// <summary>
        /// Performs a firmware upgrade.
        /// </summary>
        /// <param name="tfpStream">The TFP stream.</param>
        public Task<FirmwareUpgradeHandler> PerformUpgrade(Stream tfpStream)
        {
            return _applicationManager.ConnectedMachine.UpgradeFirmware(tfpStream);
        }

        /// <summary>
        /// Invokes the upgrade dialog.
        /// </summary>
        public void InvokeUpgradeUI()
        {
            FirmwareUpgradeViewVM vm = new FirmwareUpgradeViewVM(_applicationManager.ConnectedMachine, _notification);

            _notification.ShowModalDialog<FirmwareUpgradeViewVM, FirmwareUpgradeView>(vm, (x) =>
            {

            }, () => { });
        }
    }
}
>/// <param name="view">The view.</param> Task<bool> NavigateWithObject<TPass>(NavigationView view, TPass obj, bool pushToHistory = true); /// <summary> /// Navigates to the specified module. /// </summary> /// <typeparam name="T"></typeparam> Task<bool> NavigateTo<T>(bool pushToHistory = true) where T : IStudioModule; /// <summary> /// Navigates to the specified module using the view path (e.g MainView.JobsView). /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> Task<bool> NavigateTo<T>(String viewPath, bool pushToHistory = true) where T : IStudioModule; /// <summary> /// Navigates to the specified module using the view path (e.g MainView,JobsView). /// This method makes it easy to do stuff like NavigateTo(nameof(MainView),nameof(JobsView)); /// </summary> /// <typeparam name="T"></typeparam> /// <param name="viewPath">The view path.</param> Task<bool> NavigateTo<T>(bool pushToHistory = true, params String[] viewPath) where T : IStudioModule; /// <summary> /// Navigates to the specified module and view by full path (e.g Jobs.JobsView). /// </summary> /// <param name="fullPath">The full path.</param> Task<bool> NavigateTo(String fullPath, bool pushToHistory = true); /// <summary> /// Navigates to the specified module and view with the specified object and expecting a return parameter. /// The view must be of type INavigationResultProvider<TResult>. /// </summary> /// <param name="fullPath">The full path.</param> Task<TResult> NavigateForResult<TModule, TView, TResult, TPass>(TPass obj, bool pushToHistory = true) where TModule : IStudioModule; /// <summary> /// Navigates to the specified module and view with the specified object. /// </summary> /// <typeparam name="TModule">The type of the module.</typeparam> /// <typeparam name="TView">The type of the view.</typeparam> /// <typeparam name="TPass">The type of the pass.</typeparam> /// <param name="obj">The object.</param> /// <param name="pushToHistory">if set to <c>true</c> [push to history].</param> /// <returns></returns> Task<bool> NavigateWithObject<TModule, TView, TPass>(TPass obj, bool pushToHistory = true) where TModule : IStudioModule; void NavigateToModule<T>() where T : IStudioModule; /// <summary> /// Clears the navigation back history. /// </summary> void ClearHistory(); /// <summary> /// Clears the navigation back history except the specified view type. /// </summary> void ClearHistoryExcept<T>(); } }