From cc3bf81fabd005fa74c2b9663589892480f1a6bb Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 19 Dec 2017 15:25:33 +0200 Subject: Added Event Types and Action Types to DB Module ! --- .../EventTypeActionsToStringConverter.cs | 36 +++++++++++++ .../Tango.MachineStudio.DB.csproj | 31 +++++++++++- .../Tango.MachineStudio.DB/ViewModelLocator.cs | 11 ++++ .../ViewModels/ActionTypesViewVM.cs | 18 +++++++ .../ViewModels/ActionsTypesViewVM.cs | 18 ------- .../ViewModels/EventTypesViewVM.cs | 59 ++++++++++++++++++++++ .../Views/DBViews/ActionTypeView.xaml | 31 ++++++++++++ .../Views/DBViews/ActionTypeView.xaml.cs | 28 ++++++++++ .../Views/DBViews/ActionTypesView.xaml | 25 +++++++++ .../Views/DBViews/ActionTypesView.xaml.cs | 32 ++++++++++++ .../Views/DBViews/EventTypeView.xaml | 45 +++++++++++++++++ .../Views/DBViews/EventTypeView.xaml.cs | 34 +++++++++++++ .../Views/DBViews/EventTypesView.xaml | 31 ++++++++++++ .../Views/DBViews/EventTypesView.xaml.cs | 30 +++++++++++ 14 files changed, 410 insertions(+), 19 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/EventTypeActionsToStringConverter.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml.cs (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/EventTypeActionsToStringConverter.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/EventTypeActionsToStringConverter.cs new file mode 100644 index 000000000..4673d12b2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Converters/EventTypeActionsToStringConverter.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.DAL.Observables; +using Tango.MachineStudio.DB.ViewModels; + +namespace Tango.MachineStudio.DB.Converters +{ + public class EventTypeActionsToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) return ""; + + if (value is IEnumerable) + { + IEnumerable eventActions = value as IEnumerable; + return String.Join(", ", eventActions.Where(x => !x.Deleted).Select(x => x.ActionTypes.Name)); + } + else + { + IEnumerable> eventActions = value as IEnumerable>; + return String.Join(", ", eventActions.Where(x => x.IsSelected).Select(x => x.Entity.Name)); + } + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index 62503d47e..b77d0daf9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -87,12 +87,13 @@ + - + @@ -121,6 +122,12 @@ + + ActionTypesView.xaml + + + ActionTypeView.xaml + IdsPacksView.xaml @@ -241,9 +248,15 @@ OrganizationView.xaml + + EventTypesView.xaml + UsersView.xaml + + EventTypeView.xaml + UserView.xaml @@ -268,6 +281,14 @@ + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -428,10 +449,18 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index e8a84f1b2..8bc6ff1c0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -41,6 +41,9 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); SimpleIoc.Default.Register(); + + SimpleIoc.Default.Register(); + SimpleIoc.Default.Register(); } public static MainViewVM MainViewVM @@ -226,5 +229,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance(); } } + + public static ActionTypesViewVM ActionTypesViewVM + { + get + { + return ServiceLocator.Current.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs new file mode 100644 index 000000000..fe9ebda26 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionTypesViewVM.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class ActionTypesViewVM : DbTableViewModel + { + public ActionTypesViewVM(INotificationProvider notification) : base(notification) + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs deleted file mode 100644 index c627ffbc4..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/ActionsTypesViewVM.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.DAL.Observables; -using Tango.MachineStudio.Common.Notifications; - -namespace Tango.MachineStudio.DB.ViewModels -{ - public class ActionsTypesViewVM : DbTableViewModel - { - public ActionsTypesViewVM(INotificationProvider notification) : base(notification) - { - - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs index 442eac908..69e3c9ff6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/EventTypesViewVM.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -12,6 +13,64 @@ namespace Tango.MachineStudio.DB.ViewModels { public EventTypesViewVM(INotificationProvider notification) : base(notification) { + SelectedActions = new ObservableCollection>(); + } + + private ObservableCollection> _selectedActions; + public ObservableCollection> SelectedActions + { + get { return _selectedActions; } + set { _selectedActions = value; RaisePropertyChangedAuto(); } + } + + protected override void OnEdit() + { + SelectedActions = Adapter.ActionTypes.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedActions)))).ToObservableCollection(); + + foreach (var actionType in SelectedActions) + { + if (SelectedEntity.EventTypesActions.ToList().Exists(x => x.ActionTypes == actionType.Entity && !x.Deleted)) + { + actionType.IsSelected = true; + } + } + + base.OnEdit(); + } + + protected override void OnAdd() + { + SelectedActions = Adapter.ActionTypes.Select(x => new MultiComboVM(x, () => RaisePropertyChanged(nameof(SelectedActions)))).ToObservableCollection(); + + base.OnAdd(); + } + + protected override void OnBeforeEntitySave(DialogOpenMode mode, EventType eventType) + { + base.OnBeforeEntitySave(mode, eventType); + + foreach (var actionType in SelectedActions) + { + var userRole = eventType.EventTypesActions.SingleOrDefault(x => x.ActionTypes == actionType.Entity); + + if (userRole != null) + { + userRole.Deleted = !actionType.IsSelected; + } + else + { + if (actionType.IsSelected) + { + eventType.EventTypesActions.Add(new EventTypesAction() + { + ActionTypes = actionType.Entity, + EventTypes = eventType, + ActionTypeGuid = actionType.Entity.Guid, + EventTypeGuid = eventType.Guid + }); + } + } + } } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml new file mode 100644 index 000000000..11a472edb --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml.cs new file mode 100644 index 000000000..05a56fb89 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypeView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachineView.xaml + /// + public partial class ActionTypeView : UserControl + { + public ActionTypeView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml new file mode 100644 index 000000000..a9a14fb0c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml.cs new file mode 100644 index 000000000..aad79c87a --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/ActionTypesView.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for MachinesView.xaml + /// + [DBView] + public partial class ActionTypesView : UserControl + { + public ActionTypesView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml new file mode 100644 index 000000000..4bbc741f0 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml.cs new file mode 100644 index 000000000..6294b14e7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypeView.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for UserView.xaml + /// + public partial class EventTypeView : UserControl + { + public EventTypeView() + { + InitializeComponent(); + } + + private void comboRoles_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + comboActions.SelectedItem = null; + comboActions.Text = "Press to select"; + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml new file mode 100644 index 000000000..bb8f6e514 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml.cs new file mode 100644 index 000000000..3c197b7f2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/EventTypesView.xaml.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// + /// Interaction logic for UsersView.xaml + /// + [DBView] + public partial class EventTypesView : UserControl + { + public EventTypesView() + { + InitializeComponent(); + } + } +} -- cgit v1.3.1