private void InitGraph()
        {
            // Set horizontal and vertical clip factor to different values.
            ViewportRestrictionCallback enlargeCallback = (proposedBound) =>
            {
                if (proposedBound.IsEmpty)
                {
                    return(proposedBound);
                }
                return(CoordinateUtilities.RectZoom(proposedBound, proposedBound.GetCenter(), 1, 1.05));
            };

            BpsChart.ViewportClipToBoundsEnlargeFactor = 1;
            PpsChart.ViewportClipToBoundsEnlargeFactor = 1;
            BpsChart.Viewport.FitToViewRestrictions
            .Add(new InjectionDelegateRestriction(BpsChart.Viewport, enlargeCallback));
            PpsChart.Viewport.FitToViewRestrictions
            .Add(new InjectionDelegateRestriction(PpsChart.Viewport, enlargeCallback));

            // Disable zoom and pan
            BpsChart.Children.Remove(BpsChart.MouseNavigation);
            BpsChart.Children.Remove(BpsChart.KeyboardNavigation);
            BpsChart.Children.Remove(BpsChart.HorizontalAxisNavigation);
            BpsChart.Children.Remove(BpsChart.VerticalAxisNavigation);
            BpsChart.DefaultContextMenu.RemoveFromPlotter();

            PpsChart.Children.Remove(PpsChart.MouseNavigation);
            PpsChart.Children.Remove(PpsChart.KeyboardNavigation);
            PpsChart.Children.Remove(PpsChart.HorizontalAxisNavigation);
            PpsChart.Children.Remove(PpsChart.VerticalAxisNavigation);
            PpsChart.DefaultContextMenu.RemoveFromPlotter();

            ResetLineChart(BpsChart);
            ResetLineChart(PpsChart);
        }
예제 #2
0
        public override void Render(DrawingContext dc, Point screenPoint)
        {
            FormattedText textToDraw = new FormattedText(Text, Thread.CurrentThread.CurrentCulture,
                                                         FlowDirection.LeftToRight, new Typeface("Arial"), 12, Brushes.Black);

            double width  = textToDraw.Width;
            double height = textToDraw.Height;

            const double verticalShift = -20;             // px

            Rect bounds = RectExtensions.FromCenterSize(new Point(screenPoint.X, screenPoint.Y + verticalShift - height / 2),
                                                        new Size(width, height));

            Point loc = bounds.Location;

            bounds = CoordinateUtilities.RectZoom(bounds, 1.05, 1.15);

            dc.DrawLine(new Pen(Brushes.Black, 1), Point.Add(screenPoint, new Vector(0, verticalShift)), screenPoint);
            dc.DrawRectangle(Brushes.White, new Pen(Brushes.Black, 1), bounds);
            dc.DrawText(textToDraw, loc);
        }