コード例 #1
0
        /// <summary>
        /// 信息提示show
        /// </summary>
        /// <param name="pt"></param>
        private void InitSetShow(Point pt, string name)
        {
            if (locset != null)
            {
                locset.Close();
                locset = null;
            }

            locset      = new LocationSet(name);
            locset.Left = pt.X;
            locset.Top  = pt.Y;
            locset.Show();
        }
コード例 #2
0
        /// <summary>
        /// 点击命中测试事件
        /// </summary>
        /// <param name="rawresult"></param>
        /// <returns></returns>
        public HitTestResultBehavior HTResult(System.Windows.Media.HitTestResult rawresult)
        {
            RayHitTestResult rayResult = rawresult as RayHitTestResult;

            if (rayResult != null)
            {
                //rayResult.ModelHit
                RayMeshGeometry3DHitTestResult raymeshresult = rayResult as RayMeshGeometry3DHitTestResult;
                var     visual3D = rayResult.ModelHit; //使用visual3D作为命中的模型
                Point3D hitPoint = rayResult.PointHit;
                if (visual3D != null)                  //如果不为空,即确实命中了某一个模型
                {
                    //if (hitPoint != null &&
                    //    (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                    //{
                    //    MoveControl(hitPoint);

                    //}
                    //else
                    //{
                    //if (viewport.FindName("Box009") == visual3D) //用FindName方法进行检索。如果相等,执行一些事件
                    //{
                    //    AxisRatationEvent(axisRotation, raymeshresult, new Vector3D(-1, 0, -1));//此处执行了一个小动画,可以根据需要进行修改。
                    //}
                    //else if (viewport.FindName("Box013") == visual3D)
                    //{
                    //    //MainWindow
                    //    ScaleEvent(scaleControl);
                    //}
                    //else if (viewport.FindName("Box014") == visual3D)
                    //{
                    //    AxisRatationEvent(axisRotation1, raymeshresult, new Vector3D(-1, 0, 0));
                    //}
                    //else if (viewport.FindName("Box015") == visual3D)
                    //{
                    //    AxisRatationEvent(axisRotation2, raymeshresult, new Vector3D(-1, 0, 1));
                    //}


                    //}
                    if (mode == ControlMode.Set && !string.IsNullOrEmpty(visual3D.GetName()))
                    {
                        InitSetShow(mouseP, visual3D.GetName());
                        GeometryModel3D v  = visual3D as GeometryModel3D;
                        string          xx = v.GetName();
                        if (v != null)
                        {
                            setModelColor(v, new SolidColorBrush(Colors.Red));
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(visual3D.GetName()) &&
                            (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)))
                        {
                            InitInfoShow(mouseP, visual3D.GetName());
                        }
                    }
                    return(HitTestResultBehavior.Stop);
                }
                else
                {
                    if (show != null)
                    {
                        show.Close();
                        show = null;
                    }
                    if (locset != null)
                    {
                        locset.Close();
                        locset = null;
                    }
                }
            }
            return(HitTestResultBehavior.Continue);
        }