Beispiel #1
0
        public override IDrawObject Clone()
        {
            StarCommon starCommon = new StarCommon();

            starCommon.Copy(this);
            return(starCommon);
        }
        /// <summary>
        /// 发送绘图信息
        /// </summary>
        /// <param name="drawObjectId"></param>
        /// <param name="obj"></param>
        public void SendDrawMsg(string drawObjectId, string obj, List <Patameter> SubPatameter = null)
        {
            if (CommandEntityDraw.IsCancel || CommandEntityDraw.IsComplete)
            {
                return;
            }
            ReDraw();
            if (CommandEntityDraw == null || CommandEntityDraw.Parameters == null || CommandEntityDraw.Parameters.Count <= 0)
            {
                return;
            }
            {//draw
                if (CanvasCommands.SingleDot.ToString().Equals(drawObjectId))
                {
                    DrawComplere(obj);;
                }

                if (CanvasCommands.Lines.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);
                    if (CommandEntityDraw.Parameters.Count == 1)
                    {
                        AddParameters("请指定下一点:", DrawDataFormat.PointFormat);
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                    else
                    {
                        DrawComplere(obj);
                    }
                }
                if (CanvasCommands.MultiLine.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);

                    if (CommandEntityDraw.Parameters.Count < 3)
                    {
                        AddParameters("请指定下一点:", DrawDataFormat.PointFormat);
                    }
                    else
                    {
                        AddParameters("请指定下一点: 闭合(C)", DrawDataFormat.PointOrCharFormat, new List <string>()
                        {
                            "c"
                        });
                    }
                    Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                }
                if (CanvasCommands.SingleRectangle.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);
                    if (CommandEntityDraw.Parameters.Count == 1)
                    {
                        AddParameters("请指定对角点:", DrawDataFormat.PointFormat);
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                    else
                    {
                        DrawComplere(obj);
                    }
                }
                if (CanvasCommands.CircleCR.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);
                    if (CommandEntityDraw.Parameters.Count == 1)
                    {
                        AddParameters("请指定半径:", DrawDataFormat.FloatFormat);
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                    else
                    {
                        UnitPoint p1 = new UnitPoint();
                        p1.X = double.Parse(CommandEntityDraw.Parameters[0].ParameterValue.Split(',')[0]);
                        p1.Y = double.Parse(CommandEntityDraw.Parameters[0].ParameterValue.Split(',')[1]);

                        UnitPoint p2 = new UnitPoint();
                        p2.X = double.Parse(obj.Split(',')[0]);
                        p2.Y = double.Parse(obj.Split(',')[1]);

                        double distance = HitUtil.Distance(p1, p2);
                        DrawComplere(distance.ToString());
                    }
                }
                if (CanvasCommands.Arc3P.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);
                    if (CommandEntityDraw.Parameters.Count == 3)
                    {
                        DrawComplere(obj);
                    }
                    else
                    {
                        AddParameters("请指定下一点:", DrawDataFormat.PointFormat);
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                }///
                if (CanvasCommands.ArcCR.ToString().Equals(drawObjectId))//圆弧
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);

                    if ((CommandEntityDraw.Parameters.Count == 3 && float.TryParse(CommandEntityDraw.Parameters[1].ParameterValue, out float f) == false) ||
                        CommandEntityDraw.Parameters.Count == 4)

                    {
                        DrawComplere(obj);
                    }
                    else
                    {
                        if (CommandEntityDraw.Parameters.Count == 1)
                        {
                            AddParameters("请指定半径:", DrawDataFormat.FloatFormat);
                        }
                        else if (CommandEntityDraw.Parameters.Count == 2)
                        {
                            if (float.TryParse(CommandEntityDraw.Parameters[1].ParameterValue, out float q))
                            {
                                AddParameters("请指定起点:", DrawDataFormat.PointFormat);
                            }
                            else
                            {
                                AddParameters("请指定终点:", DrawDataFormat.PointFormat);
                            }
                        }
                        else
                        {
                            AddParameters("请指定终点:", DrawDataFormat.PointFormat);
                        }
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                }
                if (CanvasCommands.RoundRect.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);
                    if (CommandEntityDraw.Parameters.Count == 3)
                    {
                        DrawComplere(obj);
                    }
                    else
                    {
                        if (CommandEntityDraw.Parameters.Count == 1)
                        {
                            AddParameters("请指定对角点:", DrawDataFormat.PointFormat);
                        }
                        else if (CommandEntityDraw.Parameters.Count == 2)
                        {
                            AddParameters("请指定圆角半径或[倒角]:", DrawDataFormat.PointOrFloatFormat);
                        }
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                }

                if (CanvasCommands.Hexagon.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);

                    if (CommandEntityDraw.Parameters.Count == 3)
                    {
                        DrawComplere(obj);
                    }
                    else
                    {
                        if (CommandEntityDraw.Parameters.Count == 1)
                        {
                            string sendmmsg  = "请指定圆心:";
                            string sidecount = "";
                            if (int.TryParse(obj, out int result) == false)//单击生成

                            {
                                if (LastCommandEntityDraw != null &&
                                    string.IsNullOrEmpty(LastCommandEntityDraw.CanvasCommand) == false &&
                                    LastCommandEntityDraw.CanvasCommand.Equals(drawObjectId))
                                {
                                    if (LastCommandEntityDraw.Parameters != null && LastCommandEntityDraw.Parameters.Count > 0 &&
                                        string.IsNullOrEmpty(LastCommandEntityDraw.Parameters[0].ParameterValue) == false)
                                    {
                                        sidecount = sendmmsg = LastCommandEntityDraw.Parameters[0].ParameterValue;
                                    }
                                }
                                else
                                {
                                    var drawcom = new WSX.DrawService.DrawTool.MultiSegmentLine.MultiLine.PolygonCommon();
                                    sidecount = drawcom.SideCount.ToString();
                                }
                                sendmmsg = $"使用上次边数: {sidecount} 请指定圆心:";

                                SetParameterValue(sidecount, DrawDataFormat.IntFormat, true);
                                AddParameters(sendmmsg, DrawDataFormat.PointFormat);
                                Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                                SetParameterValue(obj, DrawDataFormat.PointFormat);
                                AddParameters("请指定顶点:", DrawDataFormat.PointFormat);
                            }
                            else
                            {
                                AddParameters(sendmmsg, DrawDataFormat.PointFormat);
                            }
                        }
                        else if (CommandEntityDraw.Parameters.Count == 2)
                        {
                            AddParameters("请指定顶点:", DrawDataFormat.PointFormat);
                        }
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                }
                if (CanvasCommands.StarCommon.ToString().Equals(drawObjectId))
                {
                    SetParameterValue(obj, DrawDataFormat.PointFormat);

                    if (CommandEntityDraw.Parameters.Count == 4)
                    {
                        DrawComplere(obj);
                    }
                    else
                    {
                        if (CommandEntityDraw.Parameters.Count == 1)
                        {
                            string sendmmsg  = "请指定圆心:";
                            string sidecount = "";

                            if (int.TryParse(obj, out int result) == false)//单击生成
                            {
                                if (LastCommandEntityDraw != null &&
                                    string.IsNullOrEmpty(LastCommandEntityDraw.CanvasCommand) == false &&
                                    LastCommandEntityDraw.CanvasCommand.Equals(drawObjectId))
                                {
                                    if (LastCommandEntityDraw.Parameters != null && LastCommandEntityDraw.Parameters.Count > 0 &&
                                        string.IsNullOrEmpty(LastCommandEntityDraw.Parameters[0].ParameterValue) == false)
                                    {
                                        sidecount = sendmmsg = LastCommandEntityDraw.Parameters[0].ParameterValue;
                                    }
                                }
                                else
                                {
                                    var drawcom = new WSX.DrawService.DrawTool.MultiSegmentLine.MultiLine.StarCommon();
                                    sidecount = drawcom.SideCount.ToString();
                                }
                                sendmmsg = $"使用上次边数: {sidecount} 请指定圆心:";

                                SetParameterValue(sidecount, DrawDataFormat.IntFormat, true);
                                AddParameters(sendmmsg, DrawDataFormat.PointFormat);
                                Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                                SetParameterValue(obj, DrawDataFormat.PointFormat);
                                AddParameters("请指定顶点:", DrawDataFormat.PointFormat);
                            }
                            else
                            {
                                AddParameters(sendmmsg, DrawDataFormat.PointFormat);
                            }
                        }
                        else if (CommandEntityDraw.Parameters.Count == 2)
                        {
                            AddParameters("请指定顶点:", DrawDataFormat.PointFormat);
                        }
                        else if (CommandEntityDraw.Parameters.Count == 3)
                        {
                            AddParameters("请指定内顶点:", DrawDataFormat.PointFormat);
                        }
                        Messenger.Instance.Send(MainEvent.OnAddLogDrawInfos, CommandEntityDraw);
                    }
                }
            }