public virtual void ExecuteFigureCreationCommand(string[] splitFigString) { switch (splitFigString[0]) { case "vertex": { Vector3D location = Vector3D.Parse(splitFigString[1]); currentFigure = new Vertex(location); break; } case "segment": { Vector3D a = Vector3D.Parse(splitFigString[1]); Vector3D b = Vector3D.Parse(splitFigString[2]); currentFigure = new LineSegment(a, b); break; } case "triangle": { Vector3D a = Vector3D.Parse(splitFigString[1]); Vector3D b = Vector3D.Parse(splitFigString[2]); Vector3D c = Vector3D.Parse(splitFigString[3]); currentFigure = new Triangle(a, b, c); break; } } this.EndCommandExecuted = false; }
public void ExecuteCommand(string commandStr) { string[] splitCommand = commandStr.Split(FigureController.separators, StringSplitOptions.RemoveEmptyEntries); if (this.currentFigure == null) { this.ExecuteFigureCreationCommand(splitCommand); } else if (splitCommand[0] == "end") { this.currentFigure = null; this.EndCommandExecuted = true; } else { this.ExecuteFigureInstanceCommand(splitCommand); } }
public FigureController() { this.currentFigure = null; this.EndCommandExecuted = false; }