aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-08-28 16:35:16 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-08-28 16:35:16 +0300
commitf3fc87dd10b3d55591a84ecbfb0612769f0c09b9 (patch)
tree640621ab876dd5368d91e44b07b4f2872752e5bb /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication
parent37fe17f09478a486dcd51f0edd8028724dc85c16 (diff)
downloadTango-f3fc87dd10b3d55591a84ecbfb0612769f0c09b9.tar.gz
Tango-f3fc87dd10b3d55591a84ecbfb0612769f0c09b9.zip
Working on BL Builders !
Working on making PPC work with builders..
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs70
1 files changed, 43 insertions, 27 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 2d0ac96fa..906794f6e 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -21,6 +21,8 @@ using Tango.PMR.Connection;
using Tango.PPC.Common.Connection;
using Tango.SQLExaminer;
using System.Data.SqlClient;
+using Tango.BL.Builders;
+using Tango.PPC.Common.Threading;
namespace Tango.PPC.UI.PPCApplication
{
@@ -33,6 +35,8 @@ namespace Tango.PPC.UI.PPCApplication
{
private List<PPCViewModel> _notifiedViewModels;
private IMachineProvider _machineProvider;
+ private Machine _machine;
+ private IDispatcherProvider _dispatcher;
/// <summary>
/// Occurs when the application has started.
@@ -45,9 +49,9 @@ namespace Tango.PPC.UI.PPCApplication
public event EventHandler ModulesInitialized;
/// <summary>
- /// Occurs when the all components are ready.
+ /// Occurs when the application is ready and all modules are views are loaded.
/// </summary>
- public event EventHandler Ready;
+ public event EventHandler ApplicationReady;
/// <summary>
/// Occurs when machine setup is required.
@@ -90,9 +94,10 @@ namespace Tango.PPC.UI.PPCApplication
/// <summary>
/// Initializes a new instance of the <see cref="DefaultPPCApplicationManager"/> class.
/// </summary>
- public DefaultPPCApplicationManager(IMachineProvider machineProvider)
+ public DefaultPPCApplicationManager(IMachineProvider machineProvider, IDispatcherProvider dispatcherProvider)
{
_machineProvider = machineProvider;
+ _dispatcher = dispatcherProvider;
if (!DesignMode)
{
@@ -146,8 +151,8 @@ namespace Tango.PPC.UI.PPCApplication
if (settings.ApplicationState == ApplicationStates.Ready)
{
- LogManager.Log("Initializing ObservablesEntitiesAdapter...");
- ObservablesEntitiesAdapter.Instance.Initialize();
+ LogManager.Log("Loading machine from database...");
+ _machine = new MachineBuilder(ObservablesContext.CreateDefault()).SetFirst().WithOrganization().WithConfiguration().Build();
}
});
@@ -190,22 +195,27 @@ namespace Tango.PPC.UI.PPCApplication
loader.ModulesLoaded += (x, y) =>
{
- LogManager.Log($"{loader.UserModules.Count} loaded. Waiting for last module initialization...");
-
- if (loader.UserModules.Count > 0)
+ LogManager.Log("Loading modules views");
+ _dispatcher.InvokeBlock(() =>
{
- if (loader.UserModules.ToList().Exists(m => !m.IsInitialized))
+ foreach (var module in TangoIOC.Default.GetInstance<IPPCModuleLoader>().UserModules)
{
- loader.UserModules.LastOrDefault().Initialized += (e, f) =>
+ if (!Views.LayoutView.Instance.NavigationControl.Elements.ToList().Exists(m => m.GetType() == module.MainViewType))
{
- FinalizeModuleInitialization();
- };
- }
- else
- {
- FinalizeModuleInitialization();
+ LogManager.Log("Loading module view " + module.Name + "...");
+ FrameworkElement view = Activator.CreateInstance(module.MainViewType) as FrameworkElement;
+ SharedUI.Controls.NavigationControl.SetNavigationName(view, module.Name);
+ Views.LayoutView.Instance.NavigationControl.Elements.Add(view);
+ }
}
- }
+ });
+
+ LogManager.Log($"{loader.UserModules.Count} modules loaded.");
+
+ LogManager.Log($"Invoking {nameof(ModulesInitialized)} event.");
+ ModulesInitialized?.Invoke(this, new EventArgs());
+
+ FinalizeModuleInitialization();
};
});
}
@@ -217,6 +227,11 @@ namespace Tango.PPC.UI.PPCApplication
{
LogManager.Log("Finalizing application initialization...");
+ LogManager.Log("Initializing Machine Provider...");
+ _machineProvider.Init(_machine);
+
+ LogManager.Log("Applications initialization completed!");
+
LogManager.Log("Checking for un-notified PPC view models...");
foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>())
{
@@ -228,17 +243,18 @@ namespace Tango.PPC.UI.PPCApplication
}
}
- LogManager.Log($"Invoking {nameof(ModulesInitialized)} event.");
-
- ModulesInitialized?.Invoke(this, new EventArgs());
-
- LogManager.Log("Initializing Machine Provider...");
- _machineProvider.Init();
-
- LogManager.Log("Applications initialization completed!");
+ _dispatcher.Invoke(() =>
+ {
+ LogManager.Log($"Invoking {nameof(ApplicationReady)} event.");
+ ApplicationReady?.Invoke(this, new EventArgs());
- LogManager.Log($"Invoking {nameof(Ready)} event.");
- Ready?.Invoke(this, new EventArgs());
+ LogManager.Log("Notifying view models about application ready...");
+ foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>())
+ {
+ LogManager.Log($"Invoking {vm.GetType().Name}.OnApplicationReady...");
+ vm.OnApplicationReady();
+ }
+ });
}
/// <summary>