aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-05 18:54:19 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-05 18:54:19 +0300
commit9c78856e51418bebe66095fecf4c39d9b225e961 (patch)
treea0e2b7354a4805448acf229168dae56b6f3b1cd6 /Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication
parentb1b9ec165cc318caed1fc9b5919a03029b6cb29e (diff)
downloadTango-9c78856e51418bebe66095fecf4c39d9b225e961.tar.gz
Tango-9c78856e51418bebe66095fecf4c39d9b225e961.zip
Working on PPC !
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs49
1 files changed, 36 insertions, 13 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 29b9f7823..6c2afb403 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/PPCApplication/DefaultPPCApplicationManager.cs
@@ -12,18 +12,14 @@ using Tango.Core.DI;
using Tango.PPC.Common;
using System.Windows;
using Tango.Core;
+using System.IO;
+using Tango.Core.Helpers;
namespace Tango.PPC.UI.PPCApplication
{
public class DefaultPPCApplicationManager : ExtendedObject, IPPCApplicationManager
{
- public bool IsShuttingDown
- {
- get
- {
- throw new NotImplementedException();
- }
- }
+ public bool IsShuttingDown { get; private set; }
public IMachineOperator ConnectedMachine
{
@@ -65,8 +61,35 @@ namespace Tango.PPC.UI.PPCApplication
{
if (!DesignMode)
{
- MainWindow.Instance.ContentRendered += (_, __) =>
+ MainWindow.Instance.ContentRendered += async (_, __) =>
{
+ await Task.Factory.StartNew(() =>
+ {
+ //TODO: Use this in the future.
+
+ //#if DEBUG
+ // DataSource = "localhost\\SQLEXPRESS";
+ //#else
+ // DataBaseSettings.DefaultDataSource = Path.Combine(PathHelper.GetUserTangoFolder(), "DB", "Tango.db");
+ //#endif
+
+ CoreSettings.DefaultDataBaseSource = Path.Combine(PathHelper.GetUserTangoFolder(), "DB", "Tango.db");
+
+ if (!File.Exists(CoreSettings.DefaultDataBaseSource))
+ {
+ Directory.CreateDirectory(Path.GetDirectoryName(CoreSettings.DefaultDataBaseSource));
+ File.Copy(Path.Combine(PathHelper.GetStartupPath(), "DB", "Tango.db"), CoreSettings.DefaultDataBaseSource);
+ }
+
+ var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); ;
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ Machine = db.Machines.SingleOrDefault(x => x.SerialNumber == settings.MachineSerialNumber);
+ }
+
+ });
+
foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>())
{
vm.OnApplicationStarted();
@@ -77,12 +100,12 @@ namespace Tango.PPC.UI.PPCApplication
public void ShutDown()
{
- throw new NotImplementedException();
- }
+ IsShuttingDown = true;
- public void SetMachine(Machine machine)
- {
- Machine = machine;
+ foreach (var vm in TangoIOC.Default.GetAllInstancesByBase<PPCViewModel>())
+ {
+ vm.OnApplicationShuttingDown();
+ }
}
}
}