コード例 #1
0
        /// <summary>
        /// Draw a horizontal or vertical cursor on the display in a dimension-
        /// agnostic fashion.
        /// </summary>
        /// <param name="e">
        /// The paint event arguments, including clipping information and
        /// a graphics object.
        /// </param>
        /// <param name="dim">The dimension of the cursor being drawn.</param>
        void DrawCursor(PaintEventArgs e, DisplayDimension dim)
        {
            System.Drawing.Point curOnDisplay =
                PointToClient(Cursor.Position),
                                 curPix = dim.TransposePoint(curOnDisplay);
            e.Graphics.DrawLine(
                cursorPen,
                dim.TransposePointF(new PointF(curPix.X, 0)),
                dim.TransposePointF(new PointF(curPix.X, dim.PanelPixels.Y)));

            double  curUnitX = dim.PixelToUnit(curPix.X);
            SIValue curUnit  = dim.SeriesDim.GetNewSIValue();

            curUnit.Value = curUnitX;

            PointF textPos = dim.TransposePointF(
                new PointF(curPix.X - 20, curPix.Y + 10));

            e.Graphics.DrawString(curUnit.ToString(),
                                  axisTextFont, axisTextBrush,
                                  textPos, dim.StringFormat);

            double?yintersect = dim.Intersect(curPix.X);

            if (yintersect != null)
            {
                PointF foundPos = new PointF(curPix.X,
                                             dim.Orth.UnitToPixel(yintersect ?? 0));
                textPos    = foundPos;
                textPos.X += 10;
                textPos    = dim.TransposePointF(textPos);

                SIValue orthsi = dim.Orth.SeriesDim.GetNewSIValue();
                orthsi.Value = yintersect ?? 0;

                PointF crossPos1 = foundPos,
                       crossPos2 = foundPos;
                crossPos1.X -= 5;
                crossPos2.X += 5;
                crossPos1    = dim.TransposePointF(crossPos1);
                crossPos2    = dim.TransposePointF(crossPos2);

                e.Graphics.DrawString(orthsi.ToString(), axisTextFont,
                                      axisTextBrush, textPos, dim.Orth.StringFormat);

                e.Graphics.DrawLine(cursorPen,
                                    crossPos1, crossPos2);
            }
        }
コード例 #2
0
        /// <summary>
        /// Draw a grid in a dimension-agnostic fashion (ie. this is reused for
        /// both horizontal and vertical grids).
        /// </summary>
        /// <param name="e">
        /// The paint event arguments, including clipping information and
        /// a graphics object.
        /// </param>
        /// <param name="dim">The dimension of the grid being drawn.</param>
        void DrawGrid(PaintEventArgs e, DisplayDimension dim)
        {
            SIValue si = dim.SeriesDim.GetNewSIValue();

            dim.IterateGrid((pixel1, unit, drawText) =>
            {
                PointF first = dim.TransposePointF(new PointF(pixel1, 0)),
                second       = dim.TransposePointF(new PointF(pixel1, dim.PanelPixels.Y));
                e.Graphics.DrawLine(gridPen, first, second);
                if (drawText)
                {
                    si.Value = unit;
                    e.Graphics.DrawString(si.ToString(),
                                          axisTextFont, axisTextBrush, first, dim.StringFormat);
                }
            });
        }