aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.BootScreen/MainWindow.xaml.cs
blob: 497a592465c829d16738f7f9687b2db9a93fad55 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Tango.PPC.BootScreen
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}
mponentBase : ExtendedObject { protected IAzure Azure { get; private set; } public event EventHandler<AzureUtilsProgressEventArgs> Progress; public event EventHandler<AzureUtilsConfirmationEventArgs> ConfirmationRequired; public AzureUtilsComponentBase(IAzure azure) { Azure = azure; } protected virtual void OnProgress(AzureUtilsStage stage, String message = null, double progress = 0, double maximum = 100, bool indeterminate = true) { LogManager.Log($"{stage}: {message}"); Progress?.Invoke(this, new AzureUtilsProgressEventArgs() { Stage = stage, Message = message, Progress = progress, Maximum = maximum, IsIndeterminate = indeterminate, }); } protected virtual void OnCompleted(String message) { OnProgress(AzureUtilsStage.Ready, message, 0, 100, false); } protected virtual void OnProgress(AzureUtilsProgressEventArgs e) { Progress?.Invoke(this, e); } protected async Task<bool> RequestConfirmation(String message) { LogManager.Log($"Confirmation Required: {message}"); AzureUtilsConfirmationEventArgs e = new AzureUtilsConfirmationEventArgs(message); if (ConfirmationRequired != null) { OnProgress(AzureUtilsStage.ConfirmationRequired, "Waiting for user confirmation..."); OnRequestConfirmation(e); var result = await e.GetAwaiter(); if (!result) { throw new OperationCanceledException("Operation canceled."); } return result; } else { throw new OperationCanceledException($"Confirmation required no event handler found. ({message})"); } } protected void OnRequestConfirmation(AzureUtilsConfirmationEventArgs e) { ConfirmationRequired?.Invoke(this, e); } protected T CreateManager<T>() where T : AzureUtilsComponentBase { T manager = Activator.CreateInstance(typeof(T), new object[] { Azure }) as T; manager.ConfirmationRequired += (x, e) => OnRequestConfirmation(e); manager.Progress += (x, e) => OnProgress(e); return manager; } } }