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... --- .../Views/MainView.xaml | 299 ++++++++++++++++++++- .../Views/MainView.xaml.cs | 44 +++ 2 files changed, 338 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views') 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