Ejemplo n.º 1
0
        /// <summary>
        /// Invoked when an unhandled MouseLeftButtonDown routed event is raised on this element.
        /// </summary>
        /// <param name="e">The MouseButtonEventArgs that contains the event data.</param>
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            Keyboard.Focus(this);
            // if (!System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
            {
                if (!((Keyboard.Modifiers & ModifierKeys.Control) > 0) && (!this.IsDragging))
                {
                    // Memorizations must occur before CaptureAndHideMouse() call
                    // GetCursorPos(out _dragOriginScreenPoint);

                    // Mouse.GetPosition(
                    // _dragOriginScreenPoint = _viewport.PointToScreen(point);

                    _viewport = Helper3D.GetViewport3D(this);

                    _dragOriginPoint = e.GetPosition(this);

                    // CaptureAndHideMouse Moves the mouse
                    CaptureAndHideMouse();

                    base.SetValue(IsDraggingPropertyKey, true);
                    base.SetValue(IsSelectedPropertyKey, true);
                }
            }
            base.OnMouseLeftButtonDown(e);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Captures and hides the mouse.
        /// </summary>
        protected void CaptureAndHideMouse()
        {
            base.CaptureMouse();
            Mouse.OverrideCursor = Cursors.None;

            // code specific to 3D
            Viewport3D viewport = Helper3D.GetViewport3D(this);

            // GeneralTransform3DTo2D transform = this.TransformToAncestor(ancestor);
            // Point pScreen = transform.Transform(<3d point from the mesh in myVisual3D space>);

            Point p = new Point(
                _dragOriginPoint.X,
                _dragOriginPoint.Y - (DragHeight * Rate));
            Point pScreen = viewport.PointToScreen(p);

            SetCursorPos(
                Convert.ToInt32(pScreen.X),
                Convert.ToInt32(pScreen.Y));
        }