/// <summary> /// Author: liyi /// Date: 2019/08/20 /// Description:去除非点胶指令 /// </summary> private void RemainGlueCmd() { List <CmdLine> temp = new List <CmdLine>(); foreach (CmdLine cmdLine in this.updateCmdLines) { if (cmdLine is CircleCmdLine || cmdLine is ArcCmdLine || cmdLine is DotCmdLine || cmdLine is SnakeLineCmdLine || cmdLine is LineCmdLine || cmdLine is MultiTracesCmdLine || cmdLine is SymbolLinesCmdLine) { temp.Add(cmdLine); if (cmdLine is SymbolLinesCmdLine) { SymbolLinesCmdLine symbolLine = cmdLine as SymbolLinesCmdLine; this.hasSymbolLine = true; this.transPosR = symbolLine.Symbols[0].transitionR; } } } this.updateCmdLines = temp; }
public EditSymbolLinesForm(Pattern pattern, SymbolLinesCmdLine symbolLinesCmdLine) : base(pattern.GetOriginPos()) { InitializeComponent(); for (int i = 0; i < FluidProgram.Current.ProgramSettings.LineParamList.Count; i++) { cbxLineType.Items.Add("Type " + (i + 1)); } this.ReadLanguageResources(); this.pattern = pattern; this.origin = pattern.GetOriginPos(); if (symbolLinesCmdLine == null) { isCreating = true; this.symbolLinesCmdLine = new SymbolLinesCmdLine(); //系统坐标->机械坐标 PointD p = this.pattern.MachineRel(Properties.Settings.Default.LineEndX, Properties.Settings.Default.LineEndY); this.tbPointX.Text = p.X.ToString("0.000"); this.tbPointY.Text = p.Y.ToString("0.000"); this.rdoLine.Checked = true; this.cbxLineType.SelectedIndex = 0; this.heightControl1.SetupFluidProgram(pattern.Program); } else { isCreating = false; this.symbolLinesCmdLine = symbolLinesCmdLine; this.measureCmdLine = symbolLinesCmdLine.BindMHCmdLine.Clone() as MeasureHeightCmdLine; foreach (SymbolLine item in symbolLinesCmdLine.Symbols) { this.SymbolLinesCache.Add(item.Clone() as SymbolLine); } this.cbxLineType.SelectedIndex = (int)this.SymbolLinesCache[0].type; this.LoadPoints2ListBox(); //load lines to listboxLines this.LoadLines2ListBox(); this.heightControl1.SetupCmdLine(this.measureCmdLine); this.tbMHZPos.Text = this.measureCmdLine.ZPos.ToString("0.000"); } this.tbArcSpeed.Text = this.symbolLinesCmdLine.ArcSpeed.ToString(); this.listBoxLines.SelectedIndexChanged += ListBoxLines_SelectedIndexChanged; this.listBoxPoints.SelectedIndexChanged += ListBoxPoints_SelectedIndexChanged; this.cbxLineType.SelectedIndexChanged += CbxLineType_SelectedIndexChanged; this.listBoxLines.MouseDown += ListBoxLine_MouseDown; this.nudOffsetX.Maximum = 5; this.nudOffsetX.Minimum = -5; this.nudOffsetX.DecimalPlaces = 3; this.nudOffsetX.Increment = (decimal)0.001; this.nudOffsetY.Maximum = 5; this.nudOffsetY.Minimum = -5; this.nudOffsetY.DecimalPlaces = 3; this.nudOffsetY.Increment = (decimal)0.001; this.nudOffsetX.Value = (decimal)this.symbolLinesCmdLine.OffsetX; this.nudOffsetY.Value = (decimal)this.symbolLinesCmdLine.OffsetY; this.tbTransitionR.Text = 2.ToString("0.000"); this.listBoxPoints.MouseDown += ListBoxPoints_MouseDown; this.listBoxPoints.MouseDoubleClick += ListBoxPoints_MouseDoubleClick; this.heightControl1.canMeasure = false; this.heightControl1.canMeasure_way(); this.ReadLanguageResources(); }
/// <summary> /// Author: liyi /// Date: 2019/08/27 /// Description:用于将界面参数更新至传入的轨迹数组 /// </summary> /// <param name="cmdLines"></param> private void UpdateCmdLineParam(List <CmdLine> cmdLines) { if (cmdLines.Count <= 0) { return; } if (this.rdoIncrementWeight.Checked) { isConstantWeight = false; } else if (this.rdoConstantWeight.Checked) { isConstantWeight = true; } if (this.cbxRotate.SelectedIndex == -1) { this.cbxRotate.SelectedIndex = 0; } double rotateAngle = this.cbxRotate.SelectedIndex * 90; // 机械坐标 -> 系统坐标 PointD referencePoint = this.pattern.SystemRel(new PointD(this.tbRefX.Value, this.tbRefY.Value)); PointD offsetPoint = this.pattern.SystemRel(new PointD(this.tbXOffset.Value, this.tbYOffset.Value)); double offsetX = offsetPoint.X; //this.tbXOffset.Value; double offsetY = offsetPoint.Y; //this.tbYOffset.Value; foreach (CmdLine cmdLine in cmdLines) { //判断是否是胶量模式 //1.胶量模式,全部启用胶量模式 //2.非胶量模式,全部禁用胶量模式 //3.都有的状态,只增加胶量值,不更改模式 if (cmdLine is CircleCmdLine) { CircleCmdLine circleCmdLine = cmdLine as CircleCmdLine; circleCmdLine.Weight = GetNewValue(circleCmdLine.Weight, tbWeight.Value, isConstantWeight); PointD temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle); circleCmdLine.Start.X = temp.X; circleCmdLine.Start.Y = temp.Y; temp = GetNewPosition(circleCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle); circleCmdLine.End.X = temp.X; circleCmdLine.End.Y = temp.Y; temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle); circleCmdLine.Middle.X = temp.X; circleCmdLine.Middle.Y = temp.Y; temp = GetNewPosition(circleCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle); circleCmdLine.Center.X = temp.X; circleCmdLine.Center.Y = temp.Y; if (this.cbxLineType.SelectedIndex != -1) { circleCmdLine.LineStyle = (LineStyle)this.cmdLineType; } if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate) { circleCmdLine.IsWeightControl = this.cbIsWeightControl.Checked; } } else if (cmdLine is ArcCmdLine) { ArcCmdLine arcCmdLine = cmdLine as ArcCmdLine; arcCmdLine.Weight = GetNewValue(arcCmdLine.Weight, tbWeight.Value, isConstantWeight); PointD temp = GetNewPosition(arcCmdLine.Start, referencePoint, offsetX, offsetY, rotateAngle); arcCmdLine.Start.X = temp.X; arcCmdLine.Start.Y = temp.Y; temp = GetNewPosition(arcCmdLine.End, referencePoint, offsetX, offsetY, rotateAngle); arcCmdLine.End.X = temp.X; arcCmdLine.End.Y = temp.Y; temp = GetNewPosition(arcCmdLine.Middle, referencePoint, offsetX, offsetY, rotateAngle); arcCmdLine.Middle.X = temp.X; arcCmdLine.Middle.Y = temp.Y; temp = GetNewPosition(arcCmdLine.Center, referencePoint, offsetX, offsetY, rotateAngle); arcCmdLine.Center.X = temp.X; arcCmdLine.Center.Y = temp.Y; if (this.cbxLineType.SelectedIndex != -1) { arcCmdLine.LineStyle = (LineStyle)this.cmdLineType; } if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate) { arcCmdLine.IsWeightControl = this.cbIsWeightControl.Checked; } } else if (cmdLine is DotCmdLine) { DotCmdLine dotCmdLine = cmdLine as DotCmdLine; dotCmdLine.Weight = GetNewValue(dotCmdLine.Weight, tbWeight.Value, isConstantWeight); PointD temp = GetNewPosition(dotCmdLine.Position, referencePoint, offsetX, offsetY, rotateAngle); dotCmdLine.Position.X = temp.X; dotCmdLine.Position.Y = temp.Y; if (this.cbxDotType.SelectedIndex != -1) { dotCmdLine.DotStyle = (DotStyle)this.cmdDotType; } if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate) { dotCmdLine.IsWeightControl = this.cbIsWeightControl.Checked; } } else if (cmdLine is SnakeLineCmdLine) { SnakeLineCmdLine snakeLineCmdLine = cmdLine as SnakeLineCmdLine; if (this.cbxLineType.SelectedIndex != -1) { snakeLineCmdLine.LineStyle = (LineStyle)this.cmdLineType; } if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate) { snakeLineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked; } PointD temp = new PointD(); foreach (LineCoordinate item in snakeLineCmdLine.LineCoordinateList) { temp = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle); item.Start.X = temp.X; item.Start.Y = temp.Y; temp = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle); item.End.X = temp.X; item.End.Y = temp.Y; } } else if (cmdLine is LineCmdLine) { LineCmdLine lineCmdLine = cmdLine as LineCmdLine; if (this.cbxLineType.SelectedIndex != -1) { lineCmdLine.LineStyle = (LineStyle)this.cmdLineType; } for (int i = 0; i < lineCmdLine.LineCoordinateList.Count; i++) { lineCmdLine.LineCoordinateList[i].LineStyle = lineCmdLine.LineStyle; } if (this.cbIsWeightControl.CheckState != CheckState.Indeterminate) { lineCmdLine.IsWeightControl = this.cbIsWeightControl.Checked; } if (lineCmdLine.LineMethod == LineMethod.Single) { lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight); } else if (lineCmdLine.LineMethod == LineMethod.Multi) { lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight); } else if (lineCmdLine.LineMethod == LineMethod.Poly) { lineCmdLine.WholeWeight = GetNewValue(lineCmdLine.WholeWeight, tbWeight.Value, isConstantWeight); } PointD temp = new PointD(); foreach (LineCoordinate item in lineCmdLine.LineCoordinateList) { temp = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle); item.Start.X = temp.X; item.Start.Y = temp.Y; temp = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle); item.End.X = temp.X; item.End.Y = temp.Y; } } else if (cmdLine is MultiTracesCmdLine) { MultiTracesCmdLine multiTrace = cmdLine as MultiTracesCmdLine; PointD temp = new PointD(); foreach (var item in multiTrace.Traces) { if (item is TraceLine) { temp = GetNewPosition(item.Start, referencePoint, offsetX, offsetY, rotateAngle); item.Start.X = temp.X; item.Start.Y = temp.Y; temp = GetNewPosition(item.End, referencePoint, offsetX, offsetY, rotateAngle); item.End.X = temp.X; item.End.Y = temp.Y; } else if (item is TraceArc) { TraceArc traceArc = item as TraceArc; temp = GetNewPosition(traceArc.Start, referencePoint, offsetX, offsetY, rotateAngle); traceArc.Start.X = temp.X; traceArc.Start.Y = temp.Y; temp = GetNewPosition(traceArc.Mid, referencePoint, offsetX, offsetY, rotateAngle); traceArc.Mid.X = temp.X; traceArc.Mid.Y = temp.Y; temp = GetNewPosition(traceArc.End, referencePoint, offsetX, offsetY, rotateAngle); traceArc.End.X = temp.X; traceArc.End.Y = temp.Y; } } } else if (cmdLine is SymbolLinesCmdLine) { SymbolLinesCmdLine symbolLinesCmdLine = cmdLine as SymbolLinesCmdLine; PointD temp = new PointD(); double r = this.symbolLine1.GetPrm(); foreach (var item in symbolLinesCmdLine.Symbols) { item.transitionR = r; if (item.symbolType == SymbolType.Line) { temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle); item.symbolPoints[0].X = temp.X; item.symbolPoints[0].Y = temp.Y; temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle); item.symbolPoints[1].X = temp.X; item.symbolPoints[1].Y = temp.Y; } else if (item.symbolType == SymbolType.Arc) { temp = GetNewPosition(item.symbolPoints[0], referencePoint, offsetX, offsetY, rotateAngle); item.symbolPoints[0].X = temp.X; item.symbolPoints[0].Y = temp.Y; temp = GetNewPosition(item.symbolPoints[1], referencePoint, offsetX, offsetY, rotateAngle); item.symbolPoints[1].X = temp.X; item.symbolPoints[1].Y = temp.Y; temp = GetNewPosition(item.symbolPoints[2], referencePoint, offsetX, offsetY, rotateAngle); item.symbolPoints[2].X = temp.X; item.symbolPoints[2].Y = temp.Y; } } } } }
public SymbolLinesCmd(RunnableModule runnableModule, SymbolLinesCmdLine symbolLinesCmdLine /*, MeasureHeightCmd mhCmd*/) : base(runnableModule, symbolLinesCmdLine) { this.Valve = symbolLinesCmdLine.Valve; var structure = runnableModule.CommandsModule.program.ModuleStructure; this.symbols = new List <SymbolLine>(); this.arcSpeed = symbolLinesCmdLine.ArcSpeed; foreach (SymbolLine symbolLine in symbolLinesCmdLine.Symbols) { //此处计算轨迹旋转角没用,轨迹执行时再计算每段轨迹的起始角度和结束角度 SymbolLine newSymbolLine = symbolLine.Clone() as SymbolLine; for (int i = 0; i < newSymbolLine.symbolPoints.Count; i++) { newSymbolLine.symbolPoints[i] = structure.ToMachine(runnableModule, newSymbolLine.symbolPoints[i]); } this.symbols.Add(newSymbolLine); } // 添加每一段需要的测高 for (int i = 0; i < this.symbols.Count; i++) { ////轨迹首点测高 //if (i == 0) //{ // MeasureHeightCmd mhCmd = new MeasureHeightCmd(runnableModule, symbolLinesCmdLine.BindMHCmdLine); // mhCmd.Position.X = this.symbols[i].symbolPoints[0].X; // mhCmd.Position.Y = this.symbols[i].symbolPoints[0].Y; // this.symbols[i].MHCmdList.Add(mhCmd); //} //if (this.symbols[i].symbolType != SymbolType.Arc) //{ // for (int j = 0; j < this.symbols[i].MHCount; j++) // { // PointD newPosition = SymbolLineMathTools.GetScalePointOnLine(this.symbols[i].symbolPoints[0], this.symbols[i].symbolPoints[1], (double)(j+1) / this.symbols[i].MHCount); // MeasureHeightCmd mhCmd = new MeasureHeightCmd(runnableModule, symbolLinesCmdLine.BindMHCmdLine); // mhCmd.Position.X = newPosition.X; // mhCmd.Position.Y = newPosition.Y; // this.symbols[i].MHCmdList.Add(mhCmd); // } //} //圆弧测高只测圆弧的中点 if (this.symbols[i].symbolType == SymbolType.Arc) { MeasureHeightCmd mhCmd = new MeasureHeightCmd(runnableModule, symbolLinesCmdLine.BindMHCmdLine); mhCmd.Position.X = this.symbols[i].symbolPoints[1].X; mhCmd.Position.Y = this.symbols[i].symbolPoints[1].Y; this.symbols[i].MHCmdList.Add(mhCmd); } else { for (int j = 0; j < this.symbols[i].MHCount; j++) { PointD newPosition = SymbolLineMathTools.GetScalePointOnLine(this.symbols[i].symbolPoints[0], this.symbols[i].symbolPoints[1], (double)(j + 1) / (this.symbols[i].MHCount + 1)); MeasureHeightCmd mhCmd = new MeasureHeightCmd(runnableModule, symbolLinesCmdLine.BindMHCmdLine); mhCmd.Position.X = newPosition.X; mhCmd.Position.Y = newPosition.Y; this.symbols[i].MHCmdList.Add(mhCmd); } } } this.LineParam = this.RunnableModule.CommandsModule.Program.ProgramSettings.GetLineParam(symbolLinesCmdLine.LineStyle); this.OffsetX = symbolLinesCmdLine.OffsetX; this.OffsetY = symbolLinesCmdLine.OffsetY; }
/// <summary> /// 将程序指令解析为绘图指令,添加到绘图workpiece或者pattern中 /// </summary> /// <param name="cmdLine"></param> /// <param name="pattern"></param> private void Parse(CmdLine cmdLine, DrawPattern pattern) { if (cmdLine is ArcCmdLine) { ArcCmdLine arc = cmdLine as ArcCmdLine; PointF centerPosition = new PointF((float)arc.Center.X, (float)arc.Center.Y); PointF startPosition = new PointF((float)arc.Start.X, (float)arc.Start.Y); PointF endPosition = new PointF((float)arc.End.X, (float)arc.End.Y); float degree = (float)arc.Degree; ArcDrawCmd arcDrawCmd = new ArcDrawCmd(centerPosition, startPosition, endPosition, degree, arc.Enabled); pattern.Add(arcDrawCmd); } //如果是DoPattern指令 else if (cmdLine is DoCmdLine) { if (this._drawPatterns.Count <= 0) { pattern.Add(null); } else if (pattern.GetType().Equals(typeof(DrawWorkPiece))) { DoCmdLine doPattern = cmdLine as DoCmdLine; //判断是paternList里的哪一个pattern int index = 0; for (int i = 0; i < fluidProgram.Patterns.Count; i++) { if (fluidProgram.Patterns[i].Name.Equals(doPattern.PatternName)) { index = i; } } PointF origin = new PointF((float)doPattern.Origin.X, (float)doPattern.Origin.Y); DoPatternDrawCmd doPatternDrawCmd = new DoPatternDrawCmd(this._drawPatterns[index], origin, doPattern.Enabled); pattern.Add(doPatternDrawCmd); } else { pattern.Add(null); } } else if (cmdLine is StepAndRepeatCmdLine) { if (pattern.GetType().Equals(typeof(DrawWorkPiece))) { StepAndRepeatCmdLine array = cmdLine as StepAndRepeatCmdLine; //判断是paternList里的哪一个pattern int index = 0; for (int i = 0; i < fluidProgram.Patterns.Count; i++) { if (fluidProgram.Patterns[i].Name.Equals(array.PatternName)) { index = i; } } PointF[] points = new PointF[array.DoCmdLineList.Count]; for (int i = 0; i < array.DoCmdLineList.Count; i++) { points[i] = new PointF((float)array.DoCmdLineList[i].Origin.X, (float)array.DoCmdLineList[i].Origin.Y); } ArrayDrawCmd arrayDrawCmd = new ArrayDrawCmd(this._drawPatterns[index], points, array.Enabled); pattern.Add(arrayDrawCmd); } else { pattern.Add(null); } } else if (cmdLine is CircleCmdLine) { CircleCmdLine circle = cmdLine as CircleCmdLine; PointF centerPosition = new PointF((float)circle.Center.X, (float)circle.Center.Y); float radius = (float)Math.Sqrt(Math.Pow(Math.Abs(circle.Start.X - circle.Center.X), 2) + Math.Pow(Math.Abs(circle.Start.Y - circle.Center.Y), 2)); CircleDrawCmd circleDrawCmd = new CircleDrawCmd(centerPosition, radius, circle.Enabled); pattern.Add(circleDrawCmd); } else if (cmdLine is DoMultiPassCmdLine) { if (pattern.GetType().Equals(typeof(DrawWorkPiece))) { DoMultiPassCmdLine doMultiPass = cmdLine as DoMultiPassCmdLine; //判断是paternList里的哪一个pattern int index = 0; for (int i = 0; i < fluidProgram.Patterns.Count; i++) { if (fluidProgram.Patterns[i].Name.Equals(doMultiPass.PatternName)) { index = i; } } PointF position = new PointF((float)doMultiPass.Origin.X, (float)doMultiPass.Origin.Y); DoMultiPassDrawCmd doMultiDrawCmd = new DoMultiPassDrawCmd(this._drawPatterns[index], position, doMultiPass.Enabled); pattern.Add(doMultiDrawCmd); } else { pattern.Add(null); } } else if (cmdLine is DotCmdLine) { DotCmdLine dot = cmdLine as DotCmdLine; PointF centerPosition = new PointF((float)dot.Position.X, (float)dot.Position.Y); DotDrawCmd dotDrawCmd = new DotDrawCmd(centerPosition, dot.Enabled); pattern.Add(dotDrawCmd); } else if (cmdLine is MeasureHeightCmdLine) { MeasureHeightCmdLine height = cmdLine as MeasureHeightCmdLine; PointF position = new PointF((float)height.Position.X, (float)height.Position.Y); HeightDrawCmd heightDrawCmd = new HeightDrawCmd(position, height.Enabled); pattern.Add(heightDrawCmd); } ///包含line、lines和polyline else if (cmdLine is LineCmdLine) { LineCmdLine line = cmdLine as LineCmdLine; int jointCount = 0; if (line.LineCoordinateList.Count == 1) { PointF startPoint = new PointF((float)line.LineCoordinateList[0].Start.X, (float)line.LineCoordinateList[0].Start.Y); PointF endPoint = new PointF((float)line.LineCoordinateList[0].End.X, (float)line.LineCoordinateList[0].End.Y); LineDrawCmd lineDrawCmd = new LineDrawCmd(startPoint, endPoint, true, line.Enabled); pattern.Add(lineDrawCmd); } else if (line.LineCoordinateList.Count > 1) { Line2Points[] lines = new Line2Points[line.LineCoordinateList.Count]; for (int i = 0; i < line.LineCoordinateList.Count; i++) { PointF startPoint = new PointF((float)line.LineCoordinateList[i].Start.X, (float)line.LineCoordinateList[i].Start.Y); PointF endPoint = new PointF((float)line.LineCoordinateList[i].End.X, (float)line.LineCoordinateList[i].End.Y); lines[i] = new Line2Points(startPoint, endPoint); //判断是不是polyline(如果所有相邻线段首尾点一致,则为polyline) if (i > 0 && lines[i].StartPoint == lines[i - 1].EndPoint) { jointCount++; } } //如果是polyline if (jointCount == line.LineCoordinateList.Count - 1) { PointF[] points = new PointF[line.LineCoordinateList.Count + 1]; for (int i = 0; i < lines.Length + 1; i++) { if (i == 0) { points[i] = new PointF((float)lines[0].StartPoint.X, (float)lines[0].StartPoint.Y); } else { points[i] = new PointF((float)lines[i - 1].EndPoint.X, (float)lines[i - 1].EndPoint.Y); } } PolyLineDrawCmd polyLineDrawCmd = new PolyLineDrawCmd(points, line.Enabled); pattern.Add(polyLineDrawCmd); } //如果是lines else { LinesDrawCmd linesDrawCmd = new LinesDrawCmd(lines, true, line.Enabled); pattern.Add(linesDrawCmd); } } } else if (cmdLine is MarkCmdLine) { MarkCmdLine mark = cmdLine as MarkCmdLine; PointF position = new PointF((float)mark.PosInPattern.X, (float)mark.PosInPattern.Y); MarkDrawCmd markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.NormalMark); pattern.Add(markDrawCmd); } else if (cmdLine is BadMarkCmdLine) { BadMarkCmdLine mark = cmdLine as BadMarkCmdLine; PointF position = new PointF((float)mark.Position.X, (float)mark.Position.Y); MarkDrawCmd markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.BadMark); pattern.Add(markDrawCmd); } else if (cmdLine is NozzleCheckCmdLine) { NozzleCheckCmdLine mark = cmdLine as NozzleCheckCmdLine; PointF position = new PointF((float)mark.Position.X, (float)mark.Position.Y); MarkDrawCmd markDrawCmd = new MarkDrawCmd(position, mark.Enabled, MarkType.CheckDotMark); pattern.Add(markDrawCmd); } else if (cmdLine is SnakeLineCmdLine) { SnakeLineCmdLine snake = cmdLine as SnakeLineCmdLine; Line2Points[] lines = new Line2Points[snake.LineCoordinateList.Count]; for (int i = 0; i < snake.LineCoordinateList.Count; i++) { PointF startPoint = new PointF((float)snake.LineCoordinateList[i].Start.X, (float)snake.LineCoordinateList[i].Start.Y); PointF endPoint = new PointF((float)snake.LineCoordinateList[i].End.X, (float)snake.LineCoordinateList[i].End.Y); lines[i] = new Line2Points(startPoint, endPoint); } SnakeLineDrawCmd snakeLineDrawCmd = new SnakeLineDrawCmd(lines, true, snake.Enabled); pattern.Add(snakeLineDrawCmd); } else if (cmdLine is SymbolLinesCmdLine) { SymbolLinesCmdLine symbolLines = cmdLine as SymbolLinesCmdLine; SymbolLinesDrawCmd symbolLinesDrawCmd = new SymbolLinesDrawCmd(symbolLines.Symbols, symbolLines.Enabled); pattern.Add(symbolLinesDrawCmd); } else if (cmdLine is MultiTracesCmdLine) { MultiTracesCmdLine tracesCmdLine = cmdLine as MultiTracesCmdLine; MultiTracesDrawCmd tracesDrawCmd = new MultiTracesDrawCmd(tracesCmdLine.Traces, tracesCmdLine.Enabled); pattern.Add(tracesDrawCmd); } //如果是别的逻辑指令,为了保证和程序指令一致性,添加一个null进去 else { pattern.Add(null); } }