From 93e915dd3fc06ae20b29aa927966676b9f8b7c5a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 1 Mar 2018 12:01:46 +0200 Subject: Lots of work ! --- .../Images/thread.png | Bin 0 -> 2540 bytes .../Tango.MachineStudio.HardwareDesigner.csproj | 3 + .../ViewModels/MainViewVM.cs | 45 +++++ .../Views/MainView.xaml | 202 +++++++++------------ .../Views/MainView.xaml.cs | 12 ++ 5 files changed, 144 insertions(+), 118 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/thread.png (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/thread.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/thread.png new file mode 100644 index 000000000..aa5a46140 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/thread.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj index 6ca84be11..b50dd9fa9 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Tango.MachineStudio.HardwareDesigner.csproj @@ -165,5 +165,8 @@ + + + \ No newline at end of file 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 6d605ed1c..8fede46fe 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 @@ -37,6 +37,19 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels set { _currentVersion = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } } + private IObservableEntity _selectedHardwareObject; + public IObservableEntity SelectedHardwareObject + { + get { return _selectedHardwareObject; } + set + { + _selectedHardwareObject = null; + RaisePropertyChangedAuto(); + _selectedHardwareObject = value; + RaisePropertyChangedAuto(); + } + } + public RelayCommand SaveCommand { get; set; } public RelayCommand DeleteCommand { get; set; } @@ -79,8 +92,15 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels CurrentVersion.HardwarePidControls.Remove(pidControl); } + public void OnRemoveWinder(HardwareWinder hardwareWinder) + { + CurrentVersion.HardwareWinders.Remove(hardwareWinder); + } + public void OnMotorDrop(HardwareMotorType motorType) { + if (CheckCurrentVersionNull()) return; + if (!CurrentVersion.HardwareMotors.ToList().Exists(x => x.HardwareMotorType == motorType)) { CurrentVersion.HardwareMotors.Add(new HardwareMotor() { HardwareMotorType = motorType }); @@ -89,6 +109,8 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels public void OnDropDancer(HardwareDancerType dancerType) { + if (CheckCurrentVersionNull()) return; + if (!CurrentVersion.HardwareDancers.ToList().Exists(x => x.HardwareDancerType == dancerType)) { CurrentVersion.HardwareDancers.Add(new HardwareDancer() { HardwareDancerType = dancerType }); @@ -97,12 +119,35 @@ namespace Tango.MachineStudio.HardwareDesigner.ViewModels public void OnDropPidControl(HardwarePidControlType pidControlType) { + if (CheckCurrentVersionNull()) return; + if (!CurrentVersion.HardwarePidControls.ToList().Exists(x => x.HardwarePidControlType == pidControlType)) { CurrentVersion.HardwarePidControls.Add(new HardwarePidControl() { HardwarePidControlType = pidControlType }); } } + public void OnDropWinder(HardwareWinderType hardwareWinderType) + { + if (CheckCurrentVersionNull()) return; + + if (!CurrentVersion.HardwareWinders.ToList().Exists(x => x.HardwareWinderType == hardwareWinderType)) + { + CurrentVersion.HardwareWinders.Add(new HardwareWinder() { HardwareWinderType = hardwareWinderType }); + } + } + + private bool CheckCurrentVersionNull() + { + if (CurrentVersion == null) + { + _notification.ShowInfo("Please select a hardware version before attempting to insert any components."); + return true; + } + + return false; + } + private void New() { String name = _notification.ShowTextInput("Enter hardware version name", "Name"); 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 f8de83966..d5f8b9e51 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 @@ -68,8 +68,8 @@ - DRAG & DROP DANCERS - + DRAG & DROP DANCERS + @@ -111,8 +111,8 @@ - DRAG & DROP MOTORS - + DRAG & DROP MOTORS + @@ -121,21 +121,6 @@ - - - - - - - - : - - - - - - - + + + + + + + + + + + @@ -250,6 +278,32 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -265,7 +319,7 @@ - + @@ -275,11 +329,7 @@ - - - - - + @@ -295,7 +345,7 @@ - + @@ -305,11 +355,7 @@ - - - - - + @@ -325,7 +371,7 @@ - + @@ -341,88 +387,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs index 0a3c06344..a95be867a 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs @@ -65,6 +65,14 @@ namespace Tango.MachineStudio.HardwareDesigner.Views } } + private void OnDropWinder(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is HardwareWinderType) + { + _vm.OnDropWinder(e.Draggable.DataContext as HardwareWinderType); + } + } + private void OnTrashDrop(object sender, DropEventArgs e) { if (e.Draggable.DataContext is HardwareMotor) @@ -79,6 +87,10 @@ namespace Tango.MachineStudio.HardwareDesigner.Views { _vm.OnRemovePidControl(e.Draggable.DataContext as HardwarePidControl); } + else if (e.Draggable.DataContext is HardwareWinder) + { + _vm.OnRemoveWinder(e.Draggable.DataContext as HardwareWinder); + } } } } -- cgit v1.3.1