예제 #1
0
        /// <summary>
        /// 进行绘制
        /// </summary>
        public void SetAction(IAction action)
        {
            if (EAction != null)
            {
                EAction.Termimal();
            }
            this.Cursor = CursorGetter.Getter(CursorStyle.Cross);
            EAction     = action;
            this.Focus();
            //获取需要捕获的对象
            GetStatus();
            EAction.DrawStartEvent       += EAction_DrawStartEvent;
            EAction.DrawEraseEvent       += EAction_DrawEraseEvent;
            EAction.DrawCompleteEvent    += EAction_DrawCompleteEvent;
            EAction.DrawTermimationEvent += EAction_DrawTermimationEvent;
            ActionTip.SetAction(action);


            if (this.SelectIntersectGeometrys.Count > 0)
            {
                SelectIntersectGeometrys.ForEach(x =>
                {
                    x.GeometryShape.UnSelect();
                });
            }

            //发布一个命令
            if (this.ActionEstablish != null)
            {
                this.ActionEstablish(this, EAction);
            }
            this.RemoveTemporaryVisualsByType(1);
            this.SelectIntersectGeometrys = new List <IntersectGeometry>();
        }
예제 #2
0
 /// <summary>
 /// 中间按钮的按下事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void DrawingControl_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (e.ChangedButton == MouseButton.Middle)
     {
         IsDraging   = true;
         this.Cursor = CursorGetter.Getter(CursorStyle.Move);
         EndPoint    = e.GetPosition(this);
     }
 }
예제 #3
0
 /// <summary>
 /// 选取指定的线
 /// </summary>
 /// <returns></returns>
 public void Pick(PickType type, IPickFilter filter)
 {
     this.SetPickFilter(filter);
     this.isPick   = true;
     this.pickType = type;
     Cursor        = CursorGetter.Getter(CursorStyle.Pick);
     //首先删除界面上所有的选择对象
     this.RemoveTemporaryVisualsByType(1);
     this.SelectIntersectGeometrys = new List <IntersectGeometry>();
 }
예제 #4
0
 /// <summary>
 /// 拖动控件
 /// </summary>
 /// <param name="p"></param>
 private void DragMoveView(Point?p)
 {
     if (EndPoint != null)
     {
         this.Cursor = CursorGetter.Getter(CursorStyle.Move);
         KernelProperty.PanTo(p.Value, EndPoint.Value);
         this.Update();
     }
     EndPoint = p;
 }
예제 #5
0
        /// <summary>
        /// 设置定的移动命令
        /// </summary>
        /// <param name="command"></param>
        public void SetCommand(DrawingKernel.Commands.ICommand command)
        {
            this.SetAction(command);
            //当前命令的事件记录
            command.RecordCommand += Command_RecordCommand;

            if (this.SelectIntersectGeometrys != null && this.SelectIntersectGeometrys.Count == 1)
            {
                command.SetIntersectGeometry(this.SelectIntersectGeometrys[0]);
                Cursor = CursorGetter.Getter(CursorStyle.Cross);
            }
            else
            {
                this.Cursor = CursorGetter.Getter(CursorStyle.Command);
            }
        }
예제 #6
0
 /// <summary>
 /// 鼠标进入状态
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void DrawingControl_MouseEnter(object sender, MouseEventArgs e)
 {
     if (EAction != null)
     {
         if (EAction is DrawingKernel.Commands.ICommand && ((EAction as DrawingKernel.Commands.ICommand).GetTarget() == null || EAction is AlignCommand))
         {
             this.Cursor = CursorGetter.Getter(CursorStyle.Command);
         }
         else
         {
             Cursor = CursorGetter.Getter(CursorStyle.Cross);
         }
     }
     else if (isPick)
     {
         Cursor = CursorGetter.Getter(CursorStyle.Pick);;
     }
     else
     {
         Cursor = Cursors.Arrow;
     }
 }
예제 #7
0
        /// <summary>
        /// 把选中的对象设置为选中状态
        /// </summary>
        /// <param name="gss"></param>
        private void SetSelects(List <IntersectGeometry> gss)
        {
            if (gss.Count > 0)
            {
                this.RemoveTemporaryVisualsByType(1);
                SelectIntersectGeometrys.ForEach(x =>
                {
                    x.GeometryShape.UnSelect();
                });

                SelectIntersectGeometrys = gss;

                SelectIntersectGeometrys.ForEach(x =>
                {
                    if (x.IntersectPoint != null && x.IntersectPoint.Point != null)
                    {
                        x.GeometryShape.Select(x.IntersectPoint.Point);
                    }
                });
                if (isPick)
                {
                    if (Picked != null)
                    {
                        var resultSSG = gss.FindAll(x => !(x.GeometryShape is SelectingBox));
                        if (resultSSG != null && resultSSG.Count > 0)
                        {
                            PickedEventArgs ges = new PickedEventArgs(resultSSG[0]);
                            ges.PickType = pickType;
                            Picked(ges);

                            PickedGeometry sg = new PickedGeometry(gss[0]);
                            this.AddTemporaryVisual(sg);
                            sg.Update();
                        }
                    }
                }
                else
                {
                    //对选中的对象进行清除
                    gss.ForEach(x =>
                    {
                        if (!(x.GeometryShape is ImageGeometry))
                        {
                            SelectedGeometry sg = new SelectedGeometry(x);
                            this.AddTemporaryVisual(sg);
                            sg.Update();
                        }
                    });
                    //多选事件
                    if (SelectChanged != null)
                    {
                        MultiSelectedEventArgs ges = new MultiSelectedEventArgs(gss);
                        SelectChanged(ges);
                    }
                }
                //指定当前的命名模式
                if (this.EAction is DrawingKernel.Commands.ICommand)
                {
                    if (gss[0].GeometryShape != null && gss[0].GeometryShape.IsCommand)
                    {
                        (this.EAction as DrawingKernel.Commands.ICommand).SetIntersectGeometry(gss[0]);

                        if (EAction is DrawingKernel.Commands.AlignCommand && (this.EAction as DrawingKernel.Commands.ICommand).GetTarget() == null)
                        {
                            this.Cursor = CursorGetter.Getter(CursorStyle.Command);
                        }
                        else
                        {
                            this.Cursor = CursorGetter.Getter(CursorStyle.Cross);
                        }
                    }
                }
            }
            else
            {
                if (this.EAction is DrawingKernel.Commands.ICommand)
                {
                    this.Cursor = CursorGetter.Getter(CursorStyle.Command);
                }
            }
        }