Пример #1
0
        void CreateConfiguration(Point start, Point end, List<Point> vertices)
        {
            StartPoint = start;
            EndPoint = end;
            Vertices = vertices;

            if (CurrentDrawing != null)
            {
                CurrentDrawing.Canvas = null;
            }
            CurrentDrawing = new Drawing(canvas1);
            CurrentDrawing.Behavior = new Dragger();
            CurrentDrawing.CoordinateGrid.Visible = false;
            CurrentDrawing.CoordinateSystem.UnitLength = 20;
            CurrentDrawing.CoordinateSystem.MoveTo(vertices.Midpoint().Minus());

            List<IFigure> points = new List<IFigure>();
            foreach (var vertex in vertices)
            {
                var point = Factory.CreateFreePoint(CurrentDrawing, vertex);
                points.Add(point);
                Actions.Add(CurrentDrawing, point);
            }

            Polygon = Factory.CreatePolygon(CurrentDrawing, points);
            Actions.Add(CurrentDrawing, Polygon);
            var polygonStyle = Polygon.Style as ShapeStyle;
            polygonStyle.Fill = new SolidColorBrush(Colors.Cyan);

            Start = Factory.CreateFreePoint(CurrentDrawing, start);
            End = Factory.CreateFreePoint(CurrentDrawing, end);

            Actions.Add(CurrentDrawing, Start);
            Actions.Add(CurrentDrawing, End);
            var pointStyle = Start.Style as PointStyle;
            pointStyle.Fill = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0));

            Route = new Route()
            {
                Dependencies = new List<IFigure>()
                {
                    Start,
                    End,
                    Polygon
                },
                Drawing = CurrentDrawing
            };

            Actions.Add(CurrentDrawing, Route);
        }
Пример #2
0
        void CreateConfiguration(Point start, Point end, List<Point> vertices)
        {
            StartPoint = start;
            EndPoint = end;
            Vertices = vertices;

            if (CurrentDrawing != null)
            {
                CurrentDrawing.Canvas = null;
            }
            CurrentDrawing = new Drawing(canvas1);
            CurrentDrawing.CoordinateSystem.UnitLength = 24;
            CurrentDrawing.Behavior = new IntegralDragger();
            CurrentDrawing.ActionManager.CollectionChanged += ActionManager_CollectionChanged;
            CurrentDrawing.SelectionChanged += new System.EventHandler<Drawing.SelectionChangedEventArgs>(CurrentDrawing_SelectionChanged);

            var points = new List<FreePoint>();
            points.AddRange(
                from i in vertices
                select Factory.CreateFreePoint(CurrentDrawing, i));
            Actions.AddMany(CurrentDrawing, points.Cast<IFigure>());

            int j = 0;
            foreach (var p in points)
            {
                p.Name = (j++).ToString();
                p.ShowName = true;
            }

            Polygon = Factory.CreatePolygon(CurrentDrawing, points.Cast<IFigure>().ToArray());
            Polygon.Shape.Fill = new SolidColorBrush(Colors.Yellow);
            Actions.Add(CurrentDrawing, Polygon);

            Start = Factory.CreateFreePoint(CurrentDrawing, start);
            End = Factory.CreateFreePoint(CurrentDrawing, end);

            Start.Name = "s";
            Start.ShowName = true;
            End.Name = "e";
            End.ShowName = true;

            points = new List<FreePoint>()
                {
                    Start,
                    End
                };

            Actions.AddMany(CurrentDrawing, points.Cast<IFigure>());
            Segment = Factory.CreateSegment(CurrentDrawing, points.Cast<IFigure>().ToArray());
            Segment.Shape.Stroke = new SolidColorBrush(Colors.LightGray);
            Actions.Add(CurrentDrawing, Segment);

            Route = new Route()
            {
                Dependencies = new List<IFigure>()
                    {
                        Start,
                        End,
                        Polygon
                    },
                Drawing = CurrentDrawing
            };

            Actions.Add(CurrentDrawing, Route);
        }