aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2018-08-26 10:55:44 +0300
committerShlomo Hecht <shlomo@twine-s.com>2018-08-26 10:55:44 +0300
commit6e2fbaffeec9d6e3518ea9706eea107a4f1b348c (patch)
treef50b3d8962dd37188061f8f52c1a7aeff1642232 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs
parentdb3dc558ec5fe5f3584081795865cd22f912da7d (diff)
parente6704dce7a2b7f6d5f9bbf1b8374cc7f00ea061e (diff)
downloadTango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.tar.gz
Tango-6e2fbaffeec9d6e3518ea9706eea107a4f1b348c.zip
merge
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs77
1 files changed, 57 insertions, 20 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs
index 727436306..9503e4c38 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/MainViewVM.cs
@@ -7,6 +7,7 @@ using System.Threading.Tasks;
using System.Windows;
using Tango.BL;
using Tango.BL.Entities;
+using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.StudioApplication;
@@ -14,36 +15,72 @@ using Tango.SharedUI;
namespace Tango.MachineStudio.DB.ViewModels
{
- public class MainViewVM : StudioViewModel<DBModule>
+ public class MainViewVM : StudioViewModel
{
- public MainViewVM() : base()
+ private bool _isLoading;
+ public bool IsLoading
{
+ get { return _isLoading; }
+ set { _isLoading = value; RaisePropertyChangedAuto(); }
+ }
+ private bool _notLoaded;
+ public bool NotLoaded
+ {
+ get { return _notLoaded; }
+ set { _notLoaded = value; RaisePropertyChangedAuto(); }
}
- public override void OnModuleRequest(params object[] args)
+ public RelayCommand LoadCommand { get; set; }
+
+ public MainViewVM() : base()
{
- if (args != null && args.Length > 0 && args[0] is IObservableEntity)
- {
- var arg = args[0];
+ NotLoaded = true;
+ LoadCommand = new RelayCommand(LoadAdapter,() => !IsLoading);
+ }
- String vmName = arg.GetType().Name + "sViewVM";
+ private async void LoadAdapter()
+ {
+ IsLoading = true;
+ InvalidateRelayCommands();
- Type vmType = Assembly.GetAssembly(typeof(MainViewVM)).GetTypes().SingleOrDefault(x => x.Name == vmName);
+ await Task.Factory.StartNew(() =>
+ {
+ ObservablesEntitiesAdapter.Instance.Initialize();
+ });
- if (vmType == null)
- {
- vmName = arg.GetType().BaseType.Name + "sViewVM";
- vmType = Assembly.GetAssembly(typeof(MainViewVM)).GetTypes().SingleOrDefault(x => x.Name == vmName);
- }
+ IsLoading = false;
+ NotLoaded = false;
+ }
- if (vmType != null)
- {
- var vm = TangoIOC.Default.GetInstance(vmType);
- vmType.GetProperty("SelectedEntity").SetValue(vm, arg);
- vmType.GetMethod("OnEdit", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(vm, new object[] { });
- }
- }
+ public override void OnApplicationReady()
+ {
+
}
+
+ //public override void OnModuleRequest(params object[] args)
+ //{
+ // if (args != null && args.Length > 0 && args[0] is IObservableEntity)
+ // {
+ // var arg = args[0];
+
+ // String vmName = arg.GetType().Name + "sViewVM";
+
+ // Type vmType = Assembly.GetAssembly(typeof(MainViewVM)).GetTypes().SingleOrDefault(x => x.Name == vmName);
+
+ // if (vmType == null)
+ // {
+ // vmName = arg.GetType().BaseType.Name + "sViewVM";
+ // vmType = Assembly.GetAssembly(typeof(MainViewVM)).GetTypes().SingleOrDefault(x => x.Name == vmName);
+ // }
+
+ // if (vmType != null)
+ // {
+ // var vm = TangoIOC.Default.GetInstance(vmType);
+ // vmType.GetProperty("SelectedEntity").SetValue(vm, arg);
+ // vmType.GetMethod("OnEdit", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(vm, new object[] { });
+ // }
+ // }
+ //}
}
}