using GalaSoft.MvvmLight.Ioc;
|
using GalaSoft.MvvmLight.Messaging;
|
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls.Dialogs;
|
using System;
|
using System.Threading;
|
using System.Threading.Tasks;
|
using System.Windows;
|
using Bro.UI.Ctrls;
|
using Bro.UI.ViewModel;
|
|
namespace Bro.UI
|
{
|
/// <summary>
|
/// Interaction logic for MainWindow.xaml
|
/// </summary>
|
public partial class MainWindow : MetroWindow
|
{
|
ManualResetEvent loadHandle = new ManualResetEvent(false);
|
|
/// <summary>
|
/// Initializes a new instance of the MainWindow class.
|
/// </summary>
|
public MainWindow()
|
{
|
Messenger.Default.Register<string>(this, "ProcessDone", OnProcessChanged);
|
|
InitializeComponent();
|
|
SimpleIoc.Default.Register<IDialogCoordinator>(() => DialogCoordinator.Instance, "Main");
|
|
Closing += (s, e) =>
|
{
|
ViewModelLocator.Cleanup();
|
|
(this.DataContext as MainViewModel)?.Cleanup();
|
|
Messenger.Default.Unregister(this);
|
};
|
|
Closed += (s, e) => Application.Current.Shutdown();
|
|
Loaded += (s, e) =>
|
{
|
loadHandle.Set();
|
};
|
}
|
|
private void OnProcessChanged(string obj)
|
{
|
Task.Run(() =>
|
{
|
loadHandle.WaitOne();
|
runningViewBorder.Dispatcher.Invoke(() =>
|
{
|
RunningView view = new RunningView();
|
view.Margin = new Thickness(3, 3, 3, 0);
|
runningViewBorder.Child = view;
|
});
|
|
gridInfo.Dispatcher.Invoke(() =>
|
{
|
gridInfo.Children.Clear();
|
InformationCtrl infoCtrl = new InformationCtrl();
|
gridInfo.Children.Add(infoCtrl);
|
});
|
});
|
}
|
}
|
}
|