using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using Tango.DragAndDrop; using Tango.BL.Entities; using Tango.MachineStudio.HardwareDesigner.ViewModels; namespace Tango.MachineStudio.HardwareDesigner.Views { /// /// Interaction logic for MainView.xaml /// 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 HardwareMotorType) { _vm.OnMotorDrop(e.Draggable.DataContext as HardwareMotorType); } } private void OnDancerDrop(object sender, DropEventArgs e) { if (e.Draggable.DataContext is HardwareDancerType) { _vm.OnDropDancer(e.Draggable.DataContext as HardwareDancerType); } } private void OnPidControlDrop(object sender, DropEventArgs e) { if (e.Draggable.DataContext is HardwarePidControlType) { _vm.OnDropPidControl(e.Draggable.DataContext as HardwarePidControlType); } } 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) { _vm.OnRemoveMotor(e.Draggable.DataContext as HardwareMotor); } else if (e.Draggable.DataContext is HardwareDancer) { _vm.OnRemoveDancer(e.Draggable.DataContext as HardwareDancer); } else if (e.Draggable.DataContext is HardwarePidControl) { _vm.OnRemovePidControl(e.Draggable.DataContext as HardwarePidControl); } else if (e.Draggable.DataContext is HardwareWinder) { _vm.OnRemoveWinder(e.Draggable.DataContext as HardwareWinder); } } } }