From 718a583833613a378ac2f4e4a5927ba5b48677ce Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 26 Feb 2018 20:32:55 +0200 Subject: Working on hardware designer... --- .../Images/compass.png | Bin 0 -> 1765 bytes .../Images/engine.png | Bin 0 -> 800 bytes .../Images/machine-sketch-trans.png | Bin 0 -> 96593 bytes .../Images/seamless-grid.jpg | Bin 0 -> 12022 bytes .../Tango.MachineStudio.HardwareDesigner.csproj | 12 + .../ViewModels/MainViewVM.cs | 69 +++++ .../Views/MainView.xaml | 299 ++++++++++++++++++++- .../Views/MainView.xaml.cs | 44 +++ 8 files changed, 419 insertions(+), 5 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/compass.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/engine.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/machine-sketch-trans.png create mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/seamless-grid.jpg (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/compass.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/compass.png new file mode 100644 index 000000000..564428dd7 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/compass.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/engine.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/engine.png new file mode 100644 index 000000000..731ddc4f6 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/engine.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/machine-sketch-trans.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/machine-sketch-trans.png new file mode 100644 index 000000000..82a211a4e Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/machine-sketch-trans.png differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/seamless-grid.jpg b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/seamless-grid.jpg new file mode 100644 index 000000000..59bb9c370 Binary files /dev/null and b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Images/seamless-grid.jpg 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 20cc9d059..15186d65b 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 @@ -143,5 +143,17 @@ + + + + + + + + + + + + \ 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 9fd24d165..4becc0b04 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 @@ -1,13 +1,82 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.Integration.Observables; using Tango.SharedUI; namespace Tango.MachineStudio.HardwareDesigner.ViewModels { public class MainViewVM : ViewModel { + private ObservablesEntitiesAdapter _adapter; + public ObservablesEntitiesAdapter Adapter + { + get { return _adapter; } + set { _adapter = value; RaisePropertyChangedAuto(); } + } + + private HardwareVersion _selectedVersion; + public HardwareVersion SelectedVersion + { + get { return _selectedVersion; } + set { _selectedVersion = value; RaisePropertyChangedAuto(); OnSelectedVersionChanged(); } + } + + private HardwareVersion _currentVersion; + public HardwareVersion CurrentVersion + { + get { return _currentVersion; } + 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(); } + } + + + public MainViewVM() + { + Adapter = ObservablesEntitiesAdapter.Instance; + } + + private void OnSelectedVersionChanged() + { + CurrentVersion = SelectedVersion.Clone(); + CurrentVersionDancerTypes = CurrentVersion.HardwareVersionsDancerTypes.Select(x => x.DancerType).ToObservableCollection(); + CurrentVersionMotorTypes = CurrentVersion.HardwareVersionsMotorTypes.Select(x => x.MotorType).ToObservableCollection(); + } + + public void OnRemoveDancer(DancerType dancerType) + { + CurrentVersionDancerTypes.Remove(dancerType); + } + + public void OnRemoveMotor(MotorType motorType) + { + CurrentVersionMotorTypes.Remove(motorType); + } + + public void OnMotorDrop(MotorType motorType) + { + CurrentVersionMotorTypes.Add(motorType); + } + + public void OnDropDancer(DancerType dancerType) + { + CurrentVersionDancerTypes.Add(dancerType); + } } } 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 187ea728a..77ace3e63 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 @@ -5,12 +5,21 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" - xmlns:sharedConverters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:mahApps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:editors="clr-namespace:Tango.SharedUI.Editors;assembly=Tango.SharedUI" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:local="clr-namespace:Tango.MachineStudio.HardwareDesigner.Views" xmlns:vm="clr-namespace:Tango.MachineStudio.HardwareDesigner.ViewModels" + xmlns:observables="clr-namespace:Tango.Integration.Observables;assembly=Tango.Integration" xmlns:global="clr-namespace:Tango.MachineStudio.HardwareDesigner" mc:Ignorable="d" - d:DesignHeight="720" Background="White" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + d:DesignHeight="720" Background="Transparent" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> + + + + + + @@ -31,14 +40,294 @@ - + HARDWARE DESIGNER - - + + + + + + + + + + + + + + + + + DRAG & DROP DANCERS + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + DRAG & DROP MOTORS + + + + + + + + + + + + + + + + + : + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DROP HERE TO DELETE + + + + + + + + + + + + + + + + + + + + + + Name + + + Version + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 ebd3c6c6a..b06d3bd27 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 @@ -12,6 +12,9 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.DragAndDrop; +using Tango.Integration.Observables; +using Tango.MachineStudio.HardwareDesigner.ViewModels; namespace Tango.MachineStudio.HardwareDesigner.Views { @@ -20,9 +23,50 @@ namespace Tango.MachineStudio.HardwareDesigner.Views /// public partial class MainView : UserControl { + private MainViewVM _vm; + + public DraggingSurface DraggingSurface + { + get { return (DraggingSurface)GetValue(DraggingSurfaceProperty); } + set { SetValue(DraggingSurfaceProperty, value); } + } + public static readonly DependencyProperty DraggingSurfaceProperty = + DependencyProperty.Register("DraggingSurface", typeof(DraggingSurface), typeof(MainView), new PropertyMetadata(null)); + public MainView() { InitializeComponent(); + DraggingSurface = dragSufrace; + + Loaded += (x, y) => _vm = DataContext as MainViewVM; + } + + private void OnMotorsDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is MotorType) + { + _vm.OnMotorDrop(e.Draggable.DataContext as MotorType); + } + } + + private void OnDancerDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is DancerType) + { + _vm.OnDropDancer(e.Draggable.DataContext as DancerType); + } + } + + private void OnTrashDrop(object sender, DropEventArgs e) + { + if (e.Draggable.DataContext is MotorType) + { + _vm.OnRemoveMotor(e.Draggable.DataContext as MotorType); + } + else if (e.Draggable.DataContext is DancerType) + { + _vm.OnRemoveDancer(e.Draggable.DataContext as DancerType); + } } } } -- cgit v1.3.1