예제 #1
0
 public void RemoveVisual(VisualElementFactory vi)
 {
     removeList.Add(vi);
 }
예제 #2
0
        /// <summary>
        /// 鼠标左键点击时的逻辑
        /// </summary>
        public void onPress(Boolean isCancled = false)
        {
            #region 可锁部分

            if (!isOnPressLocked)
            {
                lastSelectedElement = currSelectedElement;
                currSelectedElement = currOveredElement;
                // 两次选取的点不一样
                if (currSelectedElement != lastSelectedElement)
                {
                    if (isVisualEnable)
                    {
                        lastSelectedElementVi = currSelectedElementVi;
                        currSelectedElementVi = null;
                    }
                    if (currSelectedElement != null)
                    {
                        if (isVisualEnable)
                        {
                            // 当前拾取到的是点
                            if (currOveredElement.GetType().ToString() == "Clover.Vertex")
                            {
                                Point3D p = ((Clover.Vertex)currSelectedElement).RenderPoint;
                                p *= Utility.GetInstance().To2DMat;
                                currSelectedElementVi = new VertexHeightLightVisual((SolidColorBrush)App.Current.FindResource("VisualElementRedBrush"),
                                    p.X, p.Y);
                                currSelectedElementVi.Start();
                                visualController.AddVisual(currSelectedElementVi);
                            }
                        }
                        onSelectElement(currSelectedElement);
                    }
                    if (lastSelectedElement != null)
                    {
                        if (isVisualEnable)
                        {
                            // 使上一个视觉元素消失
                            if (lastSelectedElementVi != null)
                            {
                                lastSelectedElementVi.End();
                                lastSelectedElementVi = null;
                            }
                        }
                        onUnselectElement(lastSelectedElement);
                    }
                }
            }

            #endregion

            onClick(isCancled);
        }
예제 #3
0
 public void AddVisual(VisualElementFactory vi)
 {
     grid.Children.Add(vi.box);
     visualList.Add(vi);
 }
예제 #4
0
        /// <summary>
        /// 鼠标移动时的逻辑
        /// </summary>
        public void onMove()
        {
            currMousePos = Mouse.GetPosition(mainWindow);

            if (!isOnMoveLocked)
            {
                #region 鼠标未按下
                // 当鼠标未按下时,触发拾取事件
                if (Mouse.LeftButton != MouseButtonState.Pressed && Mouse.RightButton != MouseButtonState.Pressed)
                {
                    Object shadowElement;
                    currOveredElement = ExcuteHitTest(out shadowElement);

                    // 上一帧拾取到的元素和这一帧拾取到的不同
                    if (currOveredElement != lastOveredElement)
                    {
                        if (isVisualEnable)
                        {
                            lastOveredElementVi = currOveredElementVi;
                            currOveredElementVi = null;
                        }
                        if (currOveredElement != null)
                        {
                            if (isVisualEnable)
                            {
                                // 当前拾取到的是点
                                if (currOveredElement.GetType().ToString() == "Clover.Vertex")
                                {
                                    Point pos = (Point)shadowElement;
                                    currOveredElementVi = new VertexHeightLightVisual((SolidColorBrush)App.Current.FindResource("VisualElementBlueBrush"),
                                        pos.X, pos.Y);
                                    currOveredElementVi.Start();
                                    visualController.AddVisual(currOveredElementVi);
                                }
                                // 当前拾取到的是边
                                //else if (currOveredElement.GetType().ToString() == "Clover.Edge")
                                //{
                                //    Clover.Edge2D edge2d = (Clover.Edge2D)shadowElement;
                                //    currOveredElementVi = new EdgeHeightLightVisual((SolidColorBrush)App.Current.FindResource("VisualElementBlueBrush"),
                                //        edge2d.p1, edge2d.p2);
                                //    currOveredElementVi.Start();
                                //    visualController.AddVisual(currOveredElementVi);
                                //}
                            }
                            onEnterElement(currOveredElement);
                        }
                        if (lastOveredElement != null)
                        {
                            if (isVisualEnable)
                            {
                                // 使上一个视觉元素消失
                                if (lastOveredElementVi != null)
                                {
                                    lastOveredElementVi.End();
                                    lastOveredElementVi = null;
                                }
                            }
                            onLeaveElement(lastOveredElement);
                        }
                    }
                }
                #endregion

                lastOveredElement = currOveredElement;
            }
            else
            {
                #region 鼠标未按下
                if (currOveredElement != null)
                    onOverElement(currOveredElement);
                #endregion
                #region 鼠标已按下
                if (Mouse.LeftButton == MouseButtonState.Pressed || Mouse.RightButton == MouseButtonState.Pressed)
                {
                    if (currSelectedElement != null)
                        onDrag(currSelectedElement);
                }
                #endregion
            }

            lastMousePos = currMousePos;

            //Debug.WriteLine("=====================");
            //Debug.WriteLine(Mouse.GetPosition(mainWindow.foldingPaperViewport));
        }