Exemplo n.º 1
0
        private void Viewport_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
        {
            Point mousePos = e.GetPosition(_Viewport);
            PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

            _PieceRightClicked = null;
            VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
            _PieceRightClicked = _PieceHit;
        }
Exemplo n.º 2
0
        private void Viewport_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (_PieceRightClicked != null)
            {
                Point mousePos = e.GetPosition(_Viewport);
                PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

                VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
                if (_PieceRightClicked.Equals(_PieceHit))
                    OnRightClick(_PieceRightClicked);
                _PieceRightClicked = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Determines which model was hit and stores the result in the _PieceHit field.
        /// </summary>
        /// <param name="raw"></param>
        /// <returns></returns>
        private HitTestResultBehavior HTResult(System.Windows.Media.HitTestResult raw)
        {
            RayMeshGeometry3DHitTestResult rayResult = raw as RayMeshGeometry3DHitTestResult;

            if (rayResult != null && rayResult.DistanceToRayOrigin < _RayDistance)
            {
                if (rayResult.ModelHit is GeometryModel3D)
                {
                    GeometryModel3D hitgeo = rayResult.ModelHit as GeometryModel3D;
                    foreach (BaseGraphPiece piece in _Pieces)
                    {
                        if (hitgeo.Equals(piece.Geometry))
                        {
                            _RayDistance = rayResult.DistanceToRayOrigin;
                            _PieceHit = piece;
                            break;
                        }
                    }
                }
            }

            return HitTestResultBehavior.Continue;
        }
Exemplo n.º 4
0
        private void Viewport_MouseMove(object obj, MouseEventArgs e)
        {
            Point mousePos = e.GetPosition(_Viewport);
            PointHitTestParameters pointparams = new PointHitTestParameters(mousePos);

            _RayDistance = double.MaxValue;
            _PieceHit = null;
            VisualTreeHelper.HitTest(_Viewport, null, HTResult, pointparams);
            if (_PieceHit != null)
                OnMouseOver(_PieceHit);
        }
Exemplo n.º 5
0
 /// <summary>
 /// When a user right-clicks on a piece, this method is called.  Typically it fires the 
 /// <see cref="RightClicked"/> event.  Override this to change this default behavior.
 /// </summary>
 /// <param name="piece"></param>
 protected virtual void OnRightClick(BaseGraphPiece piece)
 {
     if (RightClicked != null)
         RightClicked(this, piece.Key, piece.Value);
 }
Exemplo n.º 6
0
 /// <summary>
 /// When a user mouses over a piece, this method is called.  Typically it fires the
 /// <see cref="MouseOver"/> event.  Override this to change this default behavior.
 /// </summary>
 /// <param name="piece"></param>
 protected virtual void OnMouseOver(BaseGraphPiece piece)
 {
     if (MouseOver != null)
         MouseOver(this, piece.Key, piece.Value);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Handles the right click.
 /// </summary>
 /// <param name="piece"></param>
 protected override void OnRightClick(BaseGraphPiece piece)
 {
     base.OnRightClick(piece);
     HandleAction(_RightClickAction, piece as PiePiece);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Handles the mouse over.
 /// </summary>
 /// <param name="piece"></param>
 protected override void OnMouseOver(BaseGraphPiece piece)
 {
     base.OnMouseOver(piece);
     HandleAction(_MouseOverAction, piece as PiePiece);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Handles the left click.
 /// </summary>
 /// <param name="piece"></param>
 protected override void OnLeftClick(BaseGraphPiece piece)
 {
     base.OnLeftClick(piece);
     HandleAction(_LeftClickAction, piece as Bar);
 }