private void verify(double[] labels)
        {
            LegendY legend = (LegendY)TestLegendYScroller.Legend;

            if (labels.Length != legend.LabelValues.Length)
            {
                System.Diagnostics.Debugger.Break();
                throw new Exception("There should be " + labels.Length + " legends, but there were " + legend.LabelValues.Length + ".");
            }
            for (int legendValueIndex = 0; legendValueIndex < labels.Length; legendValueIndex++)
            {
                if (labels[legendValueIndex] != Math.Round(legend.LabelValues[legendValueIndex], 3))
                {
                    System.Diagnostics.Debugger.Break();
                    throw new Exception("Legend[" + legendValueIndex + "] should be '" + labels[legendValueIndex] +
                                        "' but was '" + Math.Round(legend.LabelValues[legendValueIndex], 3) + "'");
                }
            }
        }
        //      -------

        /// <summary>
        /// Renders the horizontal x-grid-line to the drawingContext, one line for each label in YLegend.
        /// </summary>
        protected override void OnCreateVisual(DrawingContext drawingContext, double width, double height, DrawingVisual _)
        {
            LegendY legendy = (LegendY)LegendScrollerY.Legend;
            //grid-lines use only 1 dimension. Both for x and y grid-line,
            double minDisplayValue = MinDisplayValues[0];

            // Create a GuidelineSet to get the lines exactly on a pixel
            GuidelineSet guidelines   = new GuidelineSet();
            double       halfPenWidth = StrokePen.Thickness / 2;

            foreach (double lableValue in legendy.LabelValues !)
            {
                double yPos = height - (ScaleY * (lableValue - minDisplayValue));
                guidelines.GuidelinesY.Add(yPos + halfPenWidth);
            }

            drawingContext.PushGuidelineSet(guidelines);
            foreach (double lableValue in legendy.LabelValues)
            {
                double yPos = height - (ScaleY * (lableValue - minDisplayValue));
                drawingContext.DrawLine(StrokePen, new Point(0, yPos), new Point(width, yPos));
            }
            drawingContext.Pop();
        }
Example #3
0
 /// <summary>
 /// Constructor using any x-axis legend
 /// </summary>
 public LegendScrollerY(LegendY legend) : base(legend)
 {
 }
Example #4
0
 /// <summary>
 /// Dummy constructor allowing public constructor to call TraceCreateStart() before construtor gets executed
 /// </summary>
 private LegendScrollerYTraced(DummyTraceClass dummyArgument, LegendY legendY) : base(legendY)
 {
 }