diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-12 19:04:09 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-12 19:04:09 +0300 |
| commit | ca50e0c8fc88acd06d6e1932e9412464bff95edb (patch) | |
| tree | aaafb06deca983c1e80c8c34508d23a452e4a235 /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | |
| parent | 8a59643571080bfff715f0b0e4bb03e2dee4961a (diff) | |
| download | Tango-ca50e0c8fc88acd06d6e1932e9412464bff95edb.tar.gz Tango-ca50e0c8fc88acd06d6e1932e9412464bff95edb.zip | |
Working on PPC modules and loading.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs index 6c2afb403..8b772b8bc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -14,11 +14,14 @@ using System.Windows; using Tango.Core; using System.IO; using Tango.Core.Helpers; +using Tango.PPC.Common.Modules; namespace Tango.PPC.UI.PPCApplication { public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager { + private List<PPCViewModel> _notifiedViewModels; + public bool IsShuttingDown { get; private set; } public IMachineOperator ConnectedMachine @@ -61,6 +64,8 @@ namespace Tango.PPC.UI.PPCApplication { if (!DesignMode) { + _notifiedViewModels = new List<PPCViewModel>(); + MainWindow.Instance.ContentRendered += async (_, __) => { await Task.Factory.StartNew(() => @@ -87,13 +92,41 @@ namespace Tango.PPC.UI.PPCApplication { Machine = db.Machines.SingleOrDefault(x => x.SerialNumber == settings.MachineSerialNumber); } - }); + ApplicationStarted?.Invoke(this, new EventArgs()); + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) { - vm.OnApplicationStarted(); + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } } + + TangoIOC.Default.GetInstanceWhenAvailable<IPPCModuleLoader>((loader) => + { + loader.ModulesLoaded += (x, y) => + { + if (loader.UserModules.Count > 0) + { + loader.UserModules.LastOrDefault().Initialized += (e, f) => + { + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + { + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } + } + + ModulesInitialized?.Invoke(this, new EventArgs()); + }; + } + }; + }); }; } } @@ -107,5 +140,11 @@ namespace Tango.PPC.UI.PPCApplication vm.OnApplicationShuttingDown(); } } + + /// <summary> + /// Occurs when the application has started. + /// </summary> + public event EventHandler ApplicationStarted; + public event EventHandler ModulesInitialized; } } |
