From 47c117490f9f9fed42329ebd1374709528693d6b Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 27 Feb 2018 15:40:19 +0200 Subject: Refactored Hardware Designer DAL. --- .../ViewModels/MainViewVM.cs | 54 ++++++------------- .../Views/MainView.xaml | 60 ++++++++++++++-------- .../Views/MainView.xaml.cs | 24 ++++----- 3 files changed, 67 insertions(+), 71 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs index 0da894aba..06a3c9ba4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/ViewModels/MainViewVM.cs @@ -33,27 +33,6 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _currentVersion = value; RaisePropertyChangedAuto(); } } - private ObservableCollection _currentVersionMotorTypes; - public ObservableCollection CurrentVersionMotorTypes - { - get { return _currentVersionMotorTypes; } - set { _currentVersionMotorTypes = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _currentVersionDancerTypes; - public ObservableCollection CurrentVersionDancerTypes - { - get { return _currentVersionDancerTypes; } - set { _currentVersionDancerTypes = value; RaisePropertyChangedAuto(); } - } - - private ObservableCollection _currentVersionPidControls; - public ObservableCollection CurrentVersionPidControls - { - get { return _currentVersionPidControls; } - set { _currentVersionPidControls = value; RaisePropertyChangedAuto(); } - } - public RelayCommand SaveCommand { get; set; } public MainViewVM() @@ -66,47 +45,44 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels private void OnSelectedVersionChanged() { CurrentVersion = SelectedVersion.Clone(); - CurrentVersionDancerTypes = CurrentVersion.HardwareVersionsDancerTypes.Select(x => x.DancerType).ToObservableCollection(); - CurrentVersionMotorTypes = CurrentVersion.HardwareVersionsMotorTypes.Select(x => x.MotorType).ToObservableCollection(); - CurrentVersionPidControls = CurrentVersion.HardwareVersionsPidControls.Select(x => x.PidControl).ToObservableCollection(); } - public void OnRemoveDancer(DancerType dancerType) + public void OnRemoveDancer(HardwareDancer dancer) { - CurrentVersionDancerTypes.Remove(dancerType); + CurrentVersion.HardwareDancers.Remove(dancer); } - public void OnRemoveMotor(MotorType motorType) + public void OnRemoveMotor(HardwareMotor motor) { - CurrentVersionMotorTypes.Remove(motorType); + CurrentVersion.HardwareMotors.Remove(motor); } - public void OnRemovePidControl(PidControl pidControl) + public void OnRemovePidControl(HardwarePidControl pidControl) { - CurrentVersionPidControls.Remove(pidControl); + CurrentVersion.HardwarePidControls.Remove(pidControl); } - public void OnMotorDrop(MotorType motorType) + public void OnMotorDrop(HardwareMotorType motorType) { - if (!CurrentVersionMotorTypes.Contains(motorType)) + if (!CurrentVersion.HardwareMotors.ToList().Exists(x => x.HardwareMotorType == motorType)) { - CurrentVersionMotorTypes.Add(motorType); + CurrentVersion.HardwareMotors.Add(new HardwareMotor() { HardwareMotorType = motorType }); } } - public void OnDropDancer(DancerType dancerType) + public void OnDropDancer(HardwareDancerType dancerType) { - if (!CurrentVersionDancerTypes.Contains(dancerType)) + if (!CurrentVersion.HardwareDancers.ToList().Exists(x => x.HardwareDancerType == dancerType)) { - CurrentVersionDancerTypes.Add(dancerType); + CurrentVersion.HardwareDancers.Add(new HardwareDancer() { HardwareDancerType = dancerType }); } } - public void OnDropPidControl(PidControl pidControl) + public void OnDropPidControl(HardwarePidControlType pidControlType) { - if (!CurrentVersionPidControls.Contains(pidControl)) + if (!CurrentVersion.HardwarePidControls.ToList().Exists(x => x.HardwarePidControlType == pidControlType)) { - CurrentVersionPidControls.Add(pidControl); + CurrentVersion.HardwarePidControls.Add(new HardwarePidControl() { HardwarePidControlType = pidControlType }); } } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml index e73ba2a1f..3e840467f 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml @@ -45,7 +45,13 @@ HARDWARE DESIGNER - + + + + v + + + @@ -63,14 +69,14 @@ DRAG & DROP DANCERS - + - + @@ -92,7 +98,7 @@ - + @@ -106,14 +112,14 @@ DRAG & DROP MOTORS - + - + @@ -150,7 +156,7 @@ - + @@ -164,14 +170,14 @@ DRAG & DROP PID CONTROLS - + - + @@ -193,7 +199,7 @@ - + @@ -227,7 +233,7 @@ - + @@ -245,7 +251,7 @@ - +