Exemplo n.º 1
0
        private static void OnDragMove(object sender, MouseEventArgs e)
        {
            FrameworkElement el     = (FrameworkElement)sender;
            Point            origin = GetTargetStart(el);

            if (origin != default(Point))
            {
                SocketBaseViewModel socket = GetTarget(el);
                if (socket != null)
                {
                    Vector distance = e.GetPosition(GetAnchor(el)) - GetDragStart(el);

                    socket.Left = OneDecimal(origin.X + distance.X * 25.4 / 96.0);
                    socket.Top  = OneDecimal(origin.Y + distance.Y * 25.4 / 96.0);

                    e.Handled = true;
                }
            }
        }
Exemplo n.º 2
0
        private static void OnDragStart(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement el = (FrameworkElement)sender;

            if (el.Focusable)
            {
                el.Focus();
            }

            if (el.CaptureMouse())
            {
                SetDragStart(el, e.GetPosition(GetAnchor(el)));

                SocketBaseViewModel socket = GetTarget(el);
                if (socket != null)
                {
                    SetTargetStart(el, new Point(socket.Left, socket.Top));
                }

                e.Handled = true;
            }
        }
Exemplo n.º 3
0
        private static void OnNotchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            SocketBaseViewModel socket = (SocketBaseViewModel)d;

            switch ((Dock)e.NewValue)
            {
            case Dock.Right:
                socket.Orientation = 0;
                break;

            case Dock.Top:
                socket.Orientation = 90;
                break;

            case Dock.Left:
                socket.Orientation = 180;
                break;

            case Dock.Bottom:
                socket.Orientation = 270;
                break;
            }
        }
Exemplo n.º 4
0
        private static void OnDragKey(object sender, KeyEventArgs e)
        {
            SocketBaseViewModel socket = GetTarget(sender as FrameworkElement);

            double delta = e.KeyboardDevice.Modifiers.HasFlag(ModifierKeys.Control) ? 5.0 : 0.1;

            switch (e.Key)
            {
            case Key.Left:
                socket.Left = OneDecimal(socket.Left - delta);
                e.Handled   = true;
                break;

            case Key.Right:
                socket.Left = OneDecimal(socket.Left + delta);
                e.Handled   = true;
                break;

            case Key.Up:
                socket.Top = OneDecimal(socket.Top - delta);
                e.Handled  = true;
                break;

            case Key.Down:
                socket.Top = OneDecimal(socket.Top + delta);
                e.Handled  = true;
                break;

            case Key.Space:
                socket.Notch = (Dock)(((int)socket.Notch + 1) % 4);
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
 public static void SetTarget(DependencyObject obj, SocketBaseViewModel value)
 {
     obj.SetValue(TargetProperty, value);
 }