From d71c73171948d29db6dab71e1ca038445d6ab318 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 22 Jan 2018 17:12:18 +0200 Subject: Implemented Developer Module Configuration Section! --- .../ViewModels/MainViewVM.cs | 26 +- .../Tango.MachineStudio.DB/Views/MainDBView.xaml | 3 +- .../ViewModels/MainViewVM.cs | 65 ++- .../Views/MainView.xaml | 448 +++++++++++++++++---- .../Views/MachineView.xaml | 2 +- 5 files changed, 457 insertions(+), 87 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules') 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 a0ce93a5a..7e472ee75 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 @@ -1,18 +1,40 @@ -using System; +using Microsoft.Practices.ServiceLocation; +using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common; +using Tango.MachineStudio.Common.StudioApplication; using Tango.SharedUI; namespace Tango.MachineStudio.DB.ViewModels { - public class MainViewVM : ViewModel + public class MainViewVM : ViewModel, IModuleRequestListener { public MainViewVM() : base() { } + + public void OnRequestModule(IStudioModule module, object args) + { + if (module is DBModule && args != null && args is IObservableEntity) + { + String vmName = args.GetType().Name + "sViewVM"; + + Type vmType = Assembly.GetAssembly(typeof(MainViewVM)).GetTypes().SingleOrDefault(x => x.Name == vmName); + + if (vmType != null) + { + var vm = ServiceLocator.Current.GetInstance(vmType); + vmType.GetProperty("SelectedEntity").SetValue(vm, args); + vmType.GetMethod("OnEdit", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(vm, new object[] { }); + } + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml index 6c7cb2b95..a6edd80da 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/MainDBView.xaml @@ -9,10 +9,11 @@ xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:managers="clr-namespace:Tango.MachineStudio.DB.Managers" + xmlns:global="clr-namespace:Tango.MachineStudio.DB" xmlns:commonControls="clr-namespace:Tango.MachineStudio.Common.Controls;assembly=Tango.MachineStudio.Common" xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1270" DataContext="{Binding MainViewVM, Source={StaticResource Locator}}"> + d:DesignHeight="720" d:DesignWidth="1270" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs index e7e97097b..621ce550b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/ViewModels/MainViewVM.cs @@ -1,5 +1,7 @@ -using System; +using GalaSoft.MvvmLight.Ioc; +using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -21,29 +23,86 @@ namespace Tango.MachineStudio.Developer.ViewModels public Machine SelectedMachine { get { return _selectedMachine; } - set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } + set { _selectedMachine = value; RaisePropertyChangedAuto(); OnMachineChanged(); InvalidateRelayCommands(); } } + private List _liquidTypesRmls; + + public List LiquidTypesRmls + { + get { return _liquidTypesRmls; } + set { _liquidTypesRmls = value; RaisePropertyChangedAuto(); } + } + + private ObservableCollection _rmlProcessParametersTables; + + public ObservableCollection RmlProcessParametersTables + { + get { return _rmlProcessParametersTables; } + set { _rmlProcessParametersTables = value; RaisePropertyChangedAuto(); } + } + + private DBViewContextWrapper _selectedRML; public DBViewContextWrapper SelectedRML { get { return _selectedRML; } - set { _selectedRML = value; RaisePropertyChangedAuto(); } + set { _selectedRML = value; RaisePropertyChangedAuto(); InvalidateLiquidFactorsAndProcessTables(); InvalidateRelayCommands(); } } + private bool _isSideBarOpened; + + public bool IsSideBarOpened + { + get { return _isSideBarOpened; } + set { _isSideBarOpened = value; RaisePropertyChangedAuto(); } + } + + public RelayCommand EditMachineCommand { get; set; } + public RelayCommand EditRMLCommand { get; set; } + + public RelayCommand ToggleSideBarCommand { get; set; } + + public MainViewVM() + { + IsSideBarOpened = true; + } + + [PreferredConstructor] public MainViewVM(IStudioApplicationManager applicationManager) { Adapter = ObservablesEntitiesAdapter.Instance; EditMachineCommand = new RelayCommand(EditMachine, (x) => SelectedMachine != null); ApplicationManager = applicationManager; + EditRMLCommand = new RelayCommand(EditRML, (x) => SelectedRML != null); + ToggleSideBarCommand = new RelayCommand(() => IsSideBarOpened = !IsSideBarOpened); + } + + private void EditRML() + { + ApplicationManager.RequestModule("Data Base", SelectedRML.EditEntity); } private void EditMachine() { ApplicationManager.RequestModule("Machine Designer", SelectedMachine); } + + private void OnMachineChanged() + { + InvalidateLiquidFactorsAndProcessTables(); + } + + private void InvalidateLiquidFactorsAndProcessTables() + { + if (SelectedRML != null && SelectedMachine != null) + { + LiquidTypesRmls = SelectedMachine.Configuration.IdsPacks.OrderBy(x => x.PackIndex).Select(x => x.LiquidTypes).SelectMany(x => x.LiquidTypesRmls).Where(x => x.Rml.Guid == SelectedRML.EditEntity.Guid).ToList(); + RmlProcessParametersTables = SelectedRML.EditEntity.RmlsProcessParametersTables.ToObservableCollection(); + } + } } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml index 5b26b7891..0a65511c8 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Developer/Views/MainView.xaml @@ -12,9 +12,11 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.Developer.ViewModels" xmlns:localConverters="clr-namespace:Tango.MachineStudio.Developer.Converters" xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:observables="clr-namespace:Tango.DAL.Observables;assembly=Tango.DAL.Observables" + xmlns:shapes="clr-namespace:Tango.SharedUI.Shapes;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.Developer.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="1080" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=True}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - + + + + - - + + + Dyeing Speed: + + + - - + + + Min Ink Uptake: + + + - + + + Dryer Zone3 Temp: + + + + + + + + Dryer Air Flow: + + + + + + + Winder Tension: + + + + + + + Lubrication NL/CM: + + + + + + + Lubrication: + + + + + + + + + + + + + + + + + SELECT MACHINE & MEDIA + + + + + + + + - + + + + + + LIQUID FACTORS ( Max Nanolitter/CM ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT MACHINE & MEDIA + + + + + + + + - + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml index a54f9bbdc..a7e604352 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.MachineDesigner/Views/MachineView.xaml @@ -13,7 +13,7 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.MachineDesigner.ViewModels" xmlns:local="clr-namespace:Tango.MachineStudio.MachineDesigner.Views" mc:Ignorable="d" - d:DesignHeight="720" d:DesignWidth="1280" Background="White" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}"> + d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}"> -- cgit v1.3.1