Ejemplo n.º 1
0
        private void ObjectMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            //var focusedControl = Keyboard.FocusedElement;
            //MessageBox.Show(focusedControl.ToString());
            if (sender is PathPointNode)
            {
                return;
            }

            //In this event, we get current mouse position on the control to use it in the MouseMove event.
            FirstXPos      = e.GetPosition(sender as FrameworkElement).X;
            FirstYPos      = e.GetPosition(sender as FrameworkElement).Y;
            FirstArrowXPos = e.GetPosition((sender as FrameworkElement).Parent as FrameworkElement).X - FirstXPos;
            FirstArrowYPos = e.GetPosition((sender as FrameworkElement).Parent as FrameworkElement).Y - FirstYPos;
            MovingObject   = sender;

            if (MovingObject is ModuleView)
            {
                CurrentSelect = sender as ModuleView;
                CurrentSelect.Focus();
                CurrentSelectPosition.Visibility = System.Windows.Visibility.Visible;

                CurrentSelectPosition.Width  = (CurrentSelect as FrameworkElement).ActualWidth + 5;
                CurrentSelectPosition.Height = (CurrentSelect as FrameworkElement).ActualHeight + 5;
                Point po1 = new Point();
                po1.X = e.GetPosition((MovingObject as FrameworkElement).Parent as FrameworkElement).X - FirstXPos;
                po1.Y = e.GetPosition((MovingObject as FrameworkElement).Parent as FrameworkElement).Y - FirstYPos;
                CurrentSelectPosition.SetValue(Canvas.LeftProperty, po1.X);
                CurrentSelectPosition.SetValue(Canvas.TopProperty, po1.Y);
            }
            else
            {
                CurrentSelect = null;
                CurrentSelectPosition.Visibility = System.Windows.Visibility.Hidden;
            }
        }