示例#1
0
        /// <summary>
        /// Draws a scope cursor.
        /// </summary>
        private void DrawCursor(RectangleRange rectangleRange, ScopeCursor cursor)
        {
            using (CreateContextState())
            {
                ClipToRange(rectangleRange);

                DrawCursorLinesAndMarkers(rectangleRange, cursor);

                foreach (var tick in cursor.XTicks ?? new ScopeCursorValueTick[0])
                {
                    var tickPosition = new PointD(tick.Value, cursor.Position.Y);
                    DrawCursorTickLines(rectangleRange, tick, tickPosition, ScopeCursorLines.X, cursor.Color);
                    DrawCaptions(rectangleRange, tick.Captions, tickPosition);
                }

                foreach (var tick in cursor.YTicks ?? new ScopeCursorValueTick[0])
                {
                    var tickPosition = new PointD(cursor.Position.X, tick.Value);
                    DrawCursorTickLines(rectangleRange, tick, tickPosition, ScopeCursorLines.Y, cursor.Color);
                    DrawCaptions(rectangleRange, tick.Captions, tickPosition);
                }

                DrawCaptions(rectangleRange, cursor.Captions, cursor.Position.CairoPoint);
            }
        }
示例#2
0
 /// <summary>
 /// Initializes an instance of this class.
 /// </summary>
 /// <param name="cursor">The cursor this object belongs to.</param>
 /// <param name="selectedLines">A value indicating which lines are selected.</param>
 public ScopeCursorSelection(ScopeCursor cursor, ScopeCursorLines selectedLines)
 {
     Cursor        = cursor;
     SelectedLines = selectedLines;
 }
示例#3
0
        /// <summary>
        /// Draws the lines and markers of a scope cursor.
        /// </summary>
        private void DrawCursorLinesAndMarkers(RectangleRange rectangleRange, ScopeCursor cursor)
        {
            var userToDeviceMatrix = rectangleRange.Matrix;

            var position = cursor.Position;
            var lines    = cursor.Lines;
            var markers  = cursor.Markers;
            var color    = cursor.Color;

            using (CreateContextState())
            {
                Context.SetSourceColor(color);

                using (CreateContextState(userToDeviceMatrix))
                {
                    if ((lines & ScopeCursorLines.X) != ScopeCursorLines.None)
                    {
                        AddLinePath(new PointD(position.X, rectangleRange.MinY), new PointD(position.X, rectangleRange.MaxY));
                    }
                }

                Context.LineWidth = (cursor.HighlightedLines & ScopeCursorLines.X) != ScopeCursorLines.None
                    ? _cursorHighlightLineWidth : _cursorLineWidth;
                Context.SetDash(
                    cursor.LineWeight == ScopeCursorLineWeight.Low ? _cursorLineLowWeightDashes
                    : cursor.LineWeight == ScopeCursorLineWeight.Medium ? _cursorLineMediumWeightDashes
                    : new double[0],
                    0);
                Context.Stroke();

                using (CreateContextState(userToDeviceMatrix))
                {
                    if ((lines & ScopeCursorLines.Y) != ScopeCursorLines.None)
                    {
                        AddLinePath(new PointD(rectangleRange.MinX, position.Y), new PointD(rectangleRange.MaxX, position.Y));
                    }
                }

                Context.LineWidth = (cursor.HighlightedLines & ScopeCursorLines.Y) != ScopeCursorLines.None
                    ? _cursorHighlightLineWidth : _cursorLineWidth;
                Context.Stroke();

                if ((markers & ScopeCursorMarkers.XLeft) != ScopeCursorMarkers.None)
                {
                    AddXCursorMarkerPairPathFromCurrentPosition(
                        userToDeviceMatrix.TransformPoint(position.X, rectangleRange.MaxY),
                        userToDeviceMatrix.TransformPoint(position.X, rectangleRange.MinY),
                        ScopeHorizontalAlignment.Right);
                }

                if ((markers & ScopeCursorMarkers.XRight) != ScopeCursorMarkers.None)
                {
                    AddXCursorMarkerPairPathFromCurrentPosition(
                        userToDeviceMatrix.TransformPoint(position.X, rectangleRange.MaxY),
                        userToDeviceMatrix.TransformPoint(position.X, rectangleRange.MinY),
                        ScopeHorizontalAlignment.Left);
                }

                if ((markers & ScopeCursorMarkers.YUpper) != ScopeCursorMarkers.None)
                {
                    AddYCursorMarkerPairPathFromCurrentPosition(
                        userToDeviceMatrix.TransformPoint(rectangleRange.MinX, position.Y),
                        userToDeviceMatrix.TransformPoint(rectangleRange.MaxX, position.Y),
                        ScopeVerticalAlignment.Bottom);
                }

                if ((markers & ScopeCursorMarkers.YLower) != ScopeCursorMarkers.None)
                {
                    AddYCursorMarkerPairPathFromCurrentPosition(
                        userToDeviceMatrix.TransformPoint(rectangleRange.MinX, position.Y),
                        userToDeviceMatrix.TransformPoint(rectangleRange.MaxX, position.Y),
                        ScopeVerticalAlignment.Top);
                }

                Context.LineWidth = _cursorMarkersLineWidth;
                Context.FillPreserve();
                Context.Stroke();
            }
        }