diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-07 19:26:57 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-08-07 19:26:57 +0300 |
| commit | 6511527e4b576d29fc97aa80479b61d7d1abc079 (patch) | |
| tree | 9734dc9bc5b6c347c7fc651702419afa37d0d3d9 /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication | |
| parent | 3bcad30c7eacb41c134631f79bb50957751f11c7 (diff) | |
| download | Tango-6511527e4b576d29fc97aa80479b61d7d1abc079.tar.gz Tango-6511527e4b576d29fc97aa80479b61d7d1abc079.zip | |
Working on PPC Machine Setup !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication')
| -rw-r--r-- | Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs | 82 |
1 files changed, 56 insertions, 26 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 01dfed9d0..01f963df3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs @@ -19,6 +19,8 @@ using System.Windows.Threading; using Tango.Transport.Adapters; using Tango.PMR.Connection; using Tango.PPC.Common.Connection; +using Tango.SQLExaminer; +using System.Data.SqlClient; namespace Tango.PPC.UI.PPCApplication { @@ -70,6 +72,8 @@ namespace Tango.PPC.UI.PPCApplication { _notifiedViewModels = new List<PPCViewModel>(); + PPCSettings settings = null; + MainWindow.Instance.ContentRendered += async (_, __) => { await Task.Factory.StartNew(() => @@ -88,7 +92,7 @@ namespace Tango.PPC.UI.PPCApplication File.Copy(Path.Combine(PathHelper.GetStartupPath(), "DB", "Tango.mdf"), CoreSettings.DefaultDataBaseSource); } - var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); + settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); var coreSettings = SettingsManager.Default.GetOrCreate<CoreSettings>(); if (!SettingsManager.Default.IsFileExists()) @@ -96,42 +100,67 @@ namespace Tango.PPC.UI.PPCApplication settings.Save(); } - ObservablesEntitiesAdapter.Instance.Initialize(); + if (settings.HasSetup) + { + ObservablesEntitiesAdapter.Instance.Initialize(); + } }); - ApplicationStarted?.Invoke(this, new EventArgs()); - foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + if (settings.HasSetup) + { + PostSetup(); + } + else { - if (!_notifiedViewModels.Contains(vm)) + SetupRequiredEventArgs args = new SetupRequiredEventArgs(async () => { - vm.OnApplicationStarted(); - _notifiedViewModels.Add(vm); - } + ObservablesEntitiesAdapter.Instance.Initialize(); + + InvokeUI(() => + { + PostSetup(); + }); + }); + SetupRequired?.Invoke(this, args); } + }; + } + } + + private void PostSetup() + { + ApplicationStarted?.Invoke(this, new EventArgs()); + + foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>()) + { + if (!_notifiedViewModels.Contains(vm)) + { + vm.OnApplicationStarted(); + _notifiedViewModels.Add(vm); + } + } - TangoIOC.Default.GetInstanceWhenAvailable<IPPCModuleLoader>((loader) => + TangoIOC.Default.GetInstanceWhenAvailable<IPPCModuleLoader>((loader) => + { + loader.ModulesLoaded += (x, y) => + { + if (loader.UserModules.Count > 0) { - loader.ModulesLoaded += (x, y) => + if (loader.UserModules.ToList().Exists(m => !m.IsInitialized)) { - if (loader.UserModules.Count > 0) + loader.UserModules.LastOrDefault().Initialized += (e, f) => { - if (loader.UserModules.ToList().Exists(m => !m.IsInitialized)) - { - loader.UserModules.LastOrDefault().Initialized += (e, f) => - { - FinalizeModuleInitialization(); - }; - } - else - { - FinalizeModuleInitialization(); - } - } - }; - }); + FinalizeModuleInitialization(); + }; + } + else + { + FinalizeModuleInitialization(); + } + } }; - } + }); } private void FinalizeModuleInitialization() @@ -164,5 +193,6 @@ namespace Tango.PPC.UI.PPCApplication } public event EventHandler Ready; + public event EventHandler<SetupRequiredEventArgs> SetupRequired; } } |
