Пример #1
0
        public void CorrectData(string xAxisName, string yAxisName, string toString)
        {
            GraphAxis testObject = new GraphAxis(xAxisName, yAxisName);

            Assert.Equal(xAxisName, testObject.XAxisName);
            Assert.Equal(yAxisName, testObject.YAxisName);
            Assert.Equal(toString, testObject.ToString());
        }
Пример #2
0
        private Path DrawAxisLine(Point start, Point end, GraphAxis axis, DashData dashData, double dpi)
        {
            FormattedText text = new FormattedText(axis.ToString(),
                                                   CultureInfo.CurrentCulture,
                                                   FlowDirection.LeftToRight,
                                                   new Typeface("Arial"),
                                                   16,
                                                   Brushes.Black, dpi);

            Geometry textGeometry;

            if (axis == GraphAxis.X)
            {
                textGeometry = text.BuildGeometry(new Point(end.X - 10, end.Y + 15));
            }
            else
            {
                textGeometry = text.BuildGeometry(new Point(end.X - 20, end.Y));
            }

            GeometryGroup lineGroup = new GeometryGroup();
            double        theta     = Math.Atan2((end.Y - start.Y), (end.X - start.X)) * 180 / Math.PI;

            PathGeometry pathGeometry = new PathGeometry();
            PathFigure   pathFigure   = new PathFigure {
                StartPoint = end
            };

            Point       lpoint = new Point(end.X + 6, end.Y + 15);
            Point       rpoint = new Point(end.X - 6, end.Y + 15);
            LineSegment seg1   = new LineSegment {
                Point = lpoint
            };

            pathFigure.Segments.Add(seg1);

            LineSegment seg2 = new LineSegment {
                Point = rpoint
            };

            pathFigure.Segments.Add(seg2);

            LineSegment seg3 = new LineSegment {
                Point = end
            };

            pathFigure.Segments.Add(seg3);

            pathGeometry.Figures.Add(pathFigure);
            RotateTransform transform = new RotateTransform {
                Angle = theta + 90, CenterX = end.X, CenterY = end.Y
            };

            pathGeometry.Transform = transform;
            lineGroup.Children.Add(pathGeometry);

            AddDashesToLine(lineGroup, axis, dashData, dpi);

            LineGeometry connectorGeometry = new LineGeometry {
                StartPoint = start, EndPoint = end
            };

            lineGroup.Children.Add(connectorGeometry);
            lineGroup.Children.Add(textGeometry);
            Path path = new Path {
                Data = lineGroup, StrokeThickness = 1
            };

            path.Stroke = path.Fill = Brushes.Black;

            return(path);
        }