Exemple #1
0
        public PathGeometry GetFigures(CanvasInfo info)
        {
            PathGeometry geometry     = new PathGeometry();
            int          dashesXCount = (int)(info.HeigthCenter / info.Step);
            int          dashesYCount = (int)(info.WidthCenter / info.Step);

            for (int i = 1; i < dashesXCount + 1; ++i)
            {
                PathFigure up = new PathFigure()
                {
                    StartPoint = new Point(0, info.HeigthCenter - (info.Step * i))
                };
                PathFigure down = new PathFigure()
                {
                    StartPoint = new Point(0, info.HeigthCenter + (info.Step * i))
                };
                up.Segments.Add(new LineSegment(new Point(info.Width, up.StartPoint.Y), true));
                down.Segments.Add(new LineSegment(new Point(info.Width, down.StartPoint.Y), true));
                geometry.Figures.Add(up);
                geometry.Figures.Add(down);
            }
            for (int i = 1; i < dashesYCount + 1; ++i)
            {
                PathFigure left = new PathFigure()
                {
                    StartPoint = new Point(info.WidthCenter - (info.Step * i), 0)
                };
                PathFigure rigth = new PathFigure()
                {
                    StartPoint = new Point(info.WidthCenter + (info.Step * i), 0)
                };
                left.Segments.Add(new LineSegment(new Point(left.StartPoint.X, info.Heigth), true));
                rigth.Segments.Add(new LineSegment(new Point(rigth.StartPoint.X, info.Heigth), true));
                geometry.Figures.Add(left);
                geometry.Figures.Add(rigth);
            }
            return(geometry);
        }
        private void Draw(double _step)
        {
            CanvasInfo     info    = new CanvasInfo(MyCanvas.ActualWidth, MyCanvas.ActualHeight, _step);
            GraficsCreator creator = new GraficsCreator(info);
            var            lines   = creator.DrawBackground();

            var rectancles = creator.DrawRectancles(rectancleInfos);
            int i          = 0;

            foreach (var path in rectancles)
            {
                if (SavedRectancles.Count <= i)
                {
                    SavedRectancles.Add(path);
                }
                else
                {
                    SavedRectancles[i].Data = path.Data;
                }
                ++i;
            }

            var labels = creator.DrawLabels();

            MyCanvas.Children.Clear();
            foreach (var item in lines)
            {
                MyCanvas.Children.Add(item);
            }
            foreach (var item in SavedRectancles)
            {
                MyCanvas.Children.Add(item);
            }
            foreach (var item in labels)
            {
                MyCanvas.Children.Add(item);
            }
        }
Exemple #3
0
 public GraficsCreator(CanvasInfo _info)
 {
     info = _info;
 }