Exemplo n.º 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);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The constructor.
        /// </summary>
        public WaveformPanel()
        {
            this.Series = series;

            InitializeComponent();

            DoubleBuffered = true;

            gridPen.DashStyle = DashStyle.Dash;

            dimHorz.Orth             = dimVert;
            dimVert.Orth             = dimHorz;
            dimHorz.DisplayInversion = false;
            dimVert.DisplayInversion = true;
            dimHorz.GetPanelSize     = () => Size;
            dimVert.GetPanelSize     = () => Size;
            dimHorz.TransposePointF  = p => p;
            dimVert.TransposePointF  = p => new PointF(p.Y, p.X);
            dimHorz.StringFormat     =
                new StringFormat(StringFormatFlags.DirectionVertical);
            dimVert.StringFormat = StringFormat.GenericDefault;
            dimHorz.Intersect    = curx =>
                                   Series.DimVert.IndexToUnit(PixelToIndex(curx));
            dimVert.Intersect = cury =>
            {
                double?index = series.DimVert.UnitToIndexLimited(
                    dimVert.PixelToUnit(cury),
                    (int)PixelToIndex(0),
                    (int)PixelToIndex(Width));
                return(index == null ? index :
                       series.DimHorz.IndexToUnit(index ?? 0));
            };

            dimHorz.RefreshPan(ScrollEventType.EndScroll);
            dimVert.RefreshPan(ScrollEventType.EndScroll);

            Refresh();
        }