コード例 #1
0
        /* 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;
                }
            }
        }
コード例 #2
0
        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;
            }
        }
コード例 #3
0
        /* 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();
            }
        }
コード例 #4
0
        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;
                }
            }
        }
コード例 #5
0
        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();
            }
        }
コード例 #6
0
 public void Reflect(ReflectOrientation orientation)
 {
     //Do nothing
 }
コード例 #7
0
 public void Reflect(ReflectOrientation orientation)
 {
     GeneralMethodsFigure.ReflectFigure(orientation, CenterFigure(), ref _points);
 }
コード例 #8
0
 public ReflectCommand(string name, ReflectOrientation orientation)
 {
     _name        = name;
     _orientation = orientation;
 }