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.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.HardwareDesigner/Views/MainView.xaml.cs') 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