aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-06-12 19:04:09 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-06-12 19:04:09 +0300
commitca50e0c8fc88acd06d6e1932e9412464bff95edb (patch)
treeaaafb06deca983c1e80c8c34508d23a452e4a235 /Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels
parent8a59643571080bfff715f0b0e4bb03e2dee4961a (diff)
downloadTango-ca50e0c8fc88acd06d6e1932e9412464bff95edb.tar.gz
Tango-ca50e0c8fc88acd06d6e1932e9412464bff95edb.zip
Working on PPC modules and loading.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs130
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs23
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs15
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs2
4 files changed, 36 insertions, 134 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs
deleted file mode 100644
index 75ef7a2ac..000000000
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs
+++ /dev/null
@@ -1,130 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Linq;
-using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows.Data;
-using Tango.BL;
-using Tango.BL.Entities;
-using Tango.Core.Commands;
-using Tango.DragAndDrop;
-using Tango.PPC.Common;
-using Tango.PPC.Common.Application;
-using Tango.PPC.Common.Authentication;
-using Tango.PPC.Common.Navigation;
-using Tango.PPC.Common.Notifications;
-using Tango.Settings;
-using Tango.SharedUI;
-
-namespace Tango.PPC.UI.ViewModels
-{
- public class JobsViewVM : PPCViewModel
- {
- private ObservablesContext _jobsContext;
-
- private ObservableCollection<Job> _jobs;
- public ObservableCollection<Job> Jobs
- {
- get { return _jobs; }
- set { _jobs = value; RaisePropertyChangedAuto(); }
- }
-
- private ICollectionView _jobsCollectionView;
- /// <summary>
- /// Gets or sets the jobs collection view.
- /// </summary>
- public ICollectionView JobsCollectionView
- {
- get { return _jobsCollectionView; }
- set
- {
- _jobsCollectionView = value;
- RaisePropertyChangedAuto();
- }
- }
-
- public RelayCommand JobSelectedCommand { get; set; }
-
- public RelayCommand<DropEventArgs> OnDragAndDropCommand { get; set; }
-
- public RelayCommand<Job> RemoveJobCommand { get; set; }
-
- private void OnDragAndDropJobs(Job draggedJob, Job droppedJob)
- {
- Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name);
-
- if (draggedJob.JobIndex > droppedJob.JobIndex)
- {
- draggedJob.JobIndex = droppedJob.JobIndex - 1;
- }
- else
- {
- draggedJob.JobIndex = droppedJob.JobIndex + 1;
- }
-
- int index = 1;
-
- foreach (var job in Jobs.OrderBy(x => x.JobIndex))
- {
- job.JobIndex = index++;
- }
-
- JobsCollectionView.Refresh();
- }
-
- private async void JobSelected(Job job)
- {
- Debug.WriteLine(job.Name);
- await NotificationProvider.ShowInfo("Job details not yet implemented...");
- }
-
- public JobsViewVM()
- {
- Jobs = new ObservableCollection<Job>();
-
- JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job));
- OnDragAndDropCommand = new RelayCommand<DropEventArgs>((e) =>
- {
- Job draggedJob = e.Draggable.DataContext as Job;
- Job droppedJob = e.Droppable.DataContext as Job;
-
- OnDragAndDropJobs(draggedJob, droppedJob);
- });
-
- RemoveJobCommand = new RelayCommand<Job>(RemoveJob);
- }
-
- private void RemoveJob(Job job)
- {
- NotificationProvider.ShowQuestion("Are you sure you want to remove " + job.Name);
- }
-
- public override void OnApplicationStarted()
- {
- LoadJobs();
- }
-
- private void LoadJobs()
- {
- Task.Factory.StartNew(() =>
- {
- Thread.Sleep(500);
-
- if (_jobsContext != null)
- {
- _jobsContext.Dispose();
- }
-
- _jobsContext = ObservablesContext.CreateDefault();
-
- Jobs = _jobsContext.Jobs.Where(x => x.Machine.SerialNumber == Settings.MachineSerialNumber).ToObservableCollection();
- JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs);
- JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending));
- });
- }
- }
-}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
index cc64f82f5..168df019a 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LayoutViewVM.cs
@@ -3,12 +3,33 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.DI;
+using Tango.PPC.Common;
+using Tango.PPC.Common.Modules;
+using Tango.PPC.UI.ViewsContracts;
using Tango.SharedUI;
namespace Tango.PPC.UI.ViewModels
{
- public class LayoutViewVM : ViewModel
+ public class LayoutViewVM : PPCViewModel<ILayoutView>
{
+ [TangoInject]
+ public IPPCModuleLoader ModuleLoader { get; set; }
+ public override void OnApplicationStarted()
+ {
+ base.OnApplicationStarted();
+ ModuleLoader.ModulesLoaded += ModuleLoader_ModulesLoaded;
+ }
+
+ private void ModuleLoader_ModulesLoaded(object sender, EventArgs e)
+ {
+ View.ApplyModules(ModuleLoader.UserModules);
+ }
+
+ public override void OnViewAttached()
+ {
+
+ }
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
index a33dc25d7..20752ac71 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core;
using Tango.Core.Helpers;
using Tango.PPC.Common;
@@ -19,9 +20,17 @@ namespace Tango.PPC.UI.ViewModels
{
public async override void OnApplicationStarted()
{
- await Task.Delay(500);
- NavigationManager.NavigateTo(NavigationView.LayoutView);
- NavigationManager.NavigateTo(NavigationView.JobsView);
+ await Task.Factory.StartNew(() =>
+ {
+ ObservablesEntitiesAdapter.Instance.Initialize();
+ });
+
+ ApplicationManager.ModulesInitialized += (_, __) =>
+ {
+ NavigationManager.NavigateTo(NavigationView.LayoutView);
+ };
+
+ await AuthenticationProvider.Login("roy@twine-s.com", "1234");
}
}
}
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
index d1fc4c015..deea33a0d 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
@@ -3,9 +3,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.Core.DI;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
+using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
using Tango.SharedUI;