Ejemplo n.º 1
0
        //=============================================================================
        public void OnKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            if (Key.Escape == e.Key)
            {
                _Cancel();
            }
            else if (SelectedGeometry != null)
            {
                SelectedGeometry.OnKeyDown(e);
            }
            else if (m_NewGeometry != null)
            {
                m_NewGeometry.OnKeyDown(e);

                if (m_NewGeometry.IsPlaced)
                {
                    m_NewGeometry.Draw(this, null);
                    m_NewGeometry = null;

                    // start new geom
                    _CloneGeom();
                }
            }
        }
Ejemplo n.º 2
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);
                }
            }
        }