/* Reflect all the figures and groups in the scene.*/ public void ReflectScene(ReflectOrientation reflectOrientation) { SceneRectangle sceneRectangle = CalculateSceneCircumscribingRectangle(); var pointSceneCenter = new ScenePoint { X = (sceneRectangle.Vertex1.X + sceneRectangle.Vertex2.X) / 2.0, Y = (sceneRectangle.Vertex1.Y + sceneRectangle.Vertex2.Y) / 2.0 }; foreach (var figure in _figures) { var points = figure.Value.Points; GeneralMethodsFigure.ReflectFigure(reflectOrientation, pointSceneCenter, ref points); figure.Value.Points = points; } foreach (var composite in _compositeFigures) { foreach (var compositeFigures in composite.Value.ChildFigures) { var points = compositeFigures.Points; GeneralMethodsFigure.ReflectFigure(reflectOrientation, pointSceneCenter, ref points); compositeFigures.Points = points; } } }
public void Reflect(ReflectOrientation orientation) { SceneRectangle circumscribingRectangle = CalculateCircumscribingRectangle(); var pointSceneCenter = new ScenePoint { X = (circumscribingRectangle.Vertex1.X + circumscribingRectangle.Vertex2.X) / 2.0, Y = (circumscribingRectangle.Vertex1.Y + circumscribingRectangle.Vertex2.Y) / 2.0 }; foreach (var figure in _childFigures) { var points = figure.Points; GeneralMethodsFigure.ReflectFigure(orientation, pointSceneCenter, ref points); figure.Points = points; } }
/* Reflect figure or group 'name'.*/ public void Reflect(string name, ReflectOrientation reflectOrientation) { IFigure figure; ICompositeFigure compositeFigure; if (_figures.TryGetValue(name, out figure)) { figure.Reflect(reflectOrientation); } else if (_compositeFigures.TryGetValue(name, out compositeFigure)) { compositeFigure.Reflect(reflectOrientation); } else { throw new BadName(); } }
public static void ReflectFigure(ReflectOrientation orientation, ScenePoint centerFigure, ref ScenePoint[] points) { if (orientation == ReflectOrientation.Vertical) { for (var i = 0; i < points.Length; i++) { points[i].X += (centerFigure.X - points[i].X) * 2; } } if (orientation == ReflectOrientation.Horizontal) { for (var i = 0; i < points.Length; i++) { points[i].Y += (centerFigure.Y - points[i].Y) * 2; } } }
public void AppendLine(string line) { var match = RecognizeRegex.Match(line); if (match.Success) { var matchOrientation = Regex.Match(line, @"(vertically|horizontally)"); if (matchOrientation.Success) { if (matchOrientation.Value == "vertically") { _orientation = ReflectOrientation.Vertical; } else { _orientation = ReflectOrientation.Horizontal; } } _name = line.Remove(match.Index, match.Length).Trim(); } }
public void Reflect(ReflectOrientation orientation) { //Do nothing }
public void Reflect(ReflectOrientation orientation) { GeneralMethodsFigure.ReflectFigure(orientation, CenterFigure(), ref _points); }
public ReflectCommand(string name, ReflectOrientation orientation) { _name = name; _orientation = orientation; }