/// <summary> /// /// </summary> /// <param name="shape"></param> /// <returns></returns> public static double GetParameter(this Shape shape) { var visitor = new ComputeParameterVisitor(); shape.Accept(visitor); return(visitor.Parameter); }
/// <summary> /// /// </summary> /// <param name="shape"></param> /// <returns></returns> public static double GetArea(this Shape shape) { var visitor = new ComputeAreaVisitor(); shape.Accept(visitor); return(visitor.Area); }
/// <summary> /// Loads the shapes from the file. /// </summary> public void Load() { currentLine = string.Empty; while ((currentLine = streamReader.ReadLine()) != null) { Shape shape = CreateShapeFromLine(currentLine); shape.Accept(this); shapeList.Add(shape); } streamReader.Close(); }
public override void Visit(ShapeComposite shapeComposite) { // For now we know groups are always 2 shapes big int childCount = 2; for (int i = 0; i < childCount; i++) { currentLine = streamReader.ReadLine(); Shape shape = CreateShapeFromLine(currentLine); shape.Accept(this); shapeComposite.AddChild(shape); } }
public override void Visit(ShapeDecorator shapeDecorator) { string[] lineSplit = SplitCurrentLine(); string text = lineSplit[2]; ShapeDecorator.OrnamentPosition position; Enum.TryParse(lineSplit[1], out position); currentLine = streamReader.ReadLine(); Shape shape = CreateShapeFromLine(currentLine); shape.Accept(this); shapeDecorator.decoratedShape = shape; shapeDecorator.ornament = text; shapeDecorator.position = position; }
public void Generate() { //TODO:Generate string fileName = File.FromFilePath; //TODO:Generate switch (Shape.LayerType) { case ProWrite.Core.LayerType.Image: case ProWrite.Core.LayerType.Text: case ProWrite.Core.LayerType.Paint: log.Debug("Begin Generate " + Shape.LayerType.ToString() + "."); UFEPaintVisitor.Instance.ImageFile = fileName; Shape.Accept(UFEPaintVisitor.Instance); if (fileName == null) { throw new Exception("Generate shape file is failure!"); } if (!System.IO.File.Exists(fileName)) { throw new Exception("Generate shape file is failure!"); } log.Debug("End Generate " + Shape.LayerType.ToString() + "."); break; case ProWrite.Core.LayerType.Video: case ProWrite.Core.LayerType.DynamicText: case ProWrite.Core.LayerType.DynamicVideo: break; } if (Sign.Controller.Connection.Mode != ProWrite.UFE.ConnectionMode.Tcp) { File.Content = IOHelper.ReadAllBytes(File.FromFilePath); } File.Size = IOHelper.GetFileLength(File.FromFilePath); }
public void Process(Shape shape) { shape.Accept(_visitor); }
public void Do() { ResizeVisitor resizeVisitor = new ResizeVisitor(width, height); shape.Accept(resizeVisitor); }
//double dispathch public void Export2(Shape shape) { Exporter exporter = new Exporter(); shape.Accept(exporter); }
public void Do() { MoveVisitor moveVisitor = new MoveVisitor(velocity); shape.Accept(moveVisitor); }