当前位置: 首页>>代码示例>>C#>>正文


C# IRenderContext.DrawClippedLineSegments方法代码示例

本文整理汇总了C#中IRenderContext.DrawClippedLineSegments方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawClippedLineSegments方法的具体用法?C# IRenderContext.DrawClippedLineSegments怎么用?C# IRenderContext.DrawClippedLineSegments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRenderContext的用法示例。


在下文中一共展示了IRenderContext.DrawClippedLineSegments方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        /// <summary>
        /// Renders the series on the specified rendering context.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="model">The owner plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (Points.Count == 0)
            {
                return;
            }

            if (Points.Count % 2 != 0)
            {
                throw new InvalidOperationException("The number of points should be even.");
            }

            if (this.XAxis == null || this.YAxis == null)
            {
                throw new InvalidOperationException("Axis has not been defined.");
            }

            var clippingRect = GetClippingRect();

            var screenPoints = Points.Select(this.Transform).ToList();
            var verticalLines = new List<ScreenPoint>();

            for (int i = 0; i < screenPoints.Count; i += 2)
            {
                if (screenPoints[i].DistanceToSquared(screenPoints[i + 1]) < this.StrokeThickness)
                {
                    screenPoints[i] = new ScreenPoint(screenPoints[i].X - (this.StrokeThickness * 0.5), screenPoints[i].Y);
                    screenPoints[i + 1] = new ScreenPoint(screenPoints[i].X + (this.StrokeThickness * 0.5), screenPoints[i].Y);
                }

                if (this.ShowVerticals && i > 0 && Math.Abs(screenPoints[i - 1].X - screenPoints[i].X) < this.Epsilon)
                {
                    verticalLines.Add(screenPoints[i - 1]);
                    verticalLines.Add(screenPoints[i]);
                }
            }

            rc.DrawClippedLineSegments(clippingRect, screenPoints, this.ActualColor, this.StrokeThickness, this.LineStyle.GetDashArray(), this.LineJoin, false);
            rc.DrawClippedLineSegments(clippingRect, verticalLines, this.ActualColor, this.StrokeThickness / 3, LineStyle.Dash.GetDashArray(), this.LineJoin, false);

            rc.DrawMarkers(screenPoints, clippingRect, this.MarkerType, null, this.MarkerSize, this.MarkerFill, this.MarkerStroke, this.MarkerStrokeThickness);
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:47,代码来源:LineSegmentSeries.cs

示例2: Render

        /// <summary>
        /// Renders the series on the specified render context.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="model">The model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.Matrix == null)
            {
                return;
            }

            int m = this.Matrix.GetLength(0);
            int n = this.Matrix.GetLength(1);
            var p0 = this.Transform(0, 0);
            var p1 = this.Transform(n, m);

            if (this.image == null)
            {
                var pixels = new OxyColor[m, n];
                for (int i = 0; i < m; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        pixels[i, j] = Math.Abs(this.Matrix[m - 1 - i, j]) <= this.ZeroTolerance ? OxyColors.Transparent : this.NotZeroColor;
                    }
                }

                this.image = OxyImage.PngFromArgb(pixels);
            }

            var clip = this.GetClippingRect();
            var x0 = Math.Min(p0.X, p1.X);
            var y0 = Math.Min(p0.Y, p1.Y);
            var w = Math.Abs(p0.X - p1.X);
            var h = Math.Abs(p0.Y - p1.Y);
            rc.DrawClippedImage(clip, this.image, x0, y0, w, h, 1, false);


            var points = new List<ScreenPoint>();
            if (this.GridInterval > 0)
            {
                var p2 = this.Transform(this.GridInterval, this.GridInterval);
                if (Math.Abs(p2.Y - p0.Y) > this.MinimumGridLineDistance)
                {
                    for (int i = 1; i < n; i += this.GridInterval)
                    {
                        points.Add(this.Transform(0, i));
                        points.Add(this.Transform(n, i));
                    }
                }

                if (Math.Abs(p2.X - p0.X) > this.MinimumGridLineDistance)
                {
                    for (int j = 1; j < m; j += this.GridInterval)
                    {
                        points.Add(this.Transform(j, 0));
                        points.Add(this.Transform(j, m));
                    }
                }
            }

            if (this.ShowDiagonal)
            {
                points.Add(this.Transform(0, 0));
                points.Add(this.Transform(n, m));
            }

            rc.DrawClippedLineSegments(points, clip, this.GridColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true);

            if (this.BorderColor != null)
            {
                var borderPoints = new List<ScreenPoint>
                    {
                        this.Transform(0, 0),
                        this.Transform(m, 0),
                        this.Transform(0, n),
                        this.Transform(m, n),
                        this.Transform(0, 0),
                        this.Transform(0, n),
                        this.Transform(m, 0),
                        this.Transform(m, n)
                    };

                rc.DrawClippedLineSegments(
                    borderPoints, clip, this.BorderColor, 1, LineStyle.Solid, OxyPenLineJoin.Miter, true);
            }
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:88,代码来源:MatrixSeries.cs

示例3: RenderPoints

        /// <summary>
        /// Renders the points as line, broken line and markers.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="clippingRect">The clipping rectangle.</param>
        /// <param name="points">The points to render.</param>
        protected void RenderPoints(IRenderContext rc, OxyRect clippingRect, ICollection<DataPoint> points)
        {
            var pointEnumerator = points.GetEnumerator();
            var lastValidPoint = new ScreenPoint?();
            var areBrokenLinesRendered = this.BrokenLineThickness > 0 && this.BrokenLineStyle != LineStyle.None;
            var dashArray = areBrokenLinesRendered ? this.BrokenLineStyle.GetDashArray() : null;
            var broken = areBrokenLinesRendered ? new List<ScreenPoint>(2) : null;

            if (this.contiguousScreenPointsBuffer == null)
            {
                this.contiguousScreenPointsBuffer = new List<ScreenPoint>(points.Count);
            }

            while (pointEnumerator.MoveNext() && this.ExtractNextContiguousLineSegment(pointEnumerator, ref lastValidPoint, broken, this.contiguousScreenPointsBuffer))
            {
                if (areBrokenLinesRendered)
                {
                    if (broken.Count > 0)
                    {
                        var actualBrokenLineColor = this.BrokenLineColor.IsAutomatic()
                                                        ? this.ActualColor
                                                        : this.BrokenLineColor;

                        rc.DrawClippedLineSegments(
                            clippingRect,
                            broken,
                            actualBrokenLineColor,
                            this.BrokenLineThickness,
                            dashArray,
                            this.LineJoin,
                            false);
                        broken.Clear();
                    }
                }
                else
                {
                    lastValidPoint = null;
                }

                if (this.Decimator != null)
                {
                    if (this.decimatorBuffer == null)
                    {
                        this.decimatorBuffer = new List<ScreenPoint>(this.contiguousScreenPointsBuffer.Count);
                    }
                    else
                    {
                        this.decimatorBuffer.Clear();
                    }

                    this.Decimator(this.contiguousScreenPointsBuffer, this.decimatorBuffer);
                    this.RenderLineAndMarkers(rc, clippingRect, this.decimatorBuffer);
                }
                else
                {
                    this.RenderLineAndMarkers(rc, clippingRect, this.contiguousScreenPointsBuffer);
                }

                this.contiguousScreenPointsBuffer.Clear();
            }
        }
开发者ID:Keyabob,项目名称:MMG,代码行数:67,代码来源:LineSeries.cs

示例4: Render

        /// <summary>
        /// Renders the LineSeries on the specified rendering context.
        /// </summary>
        /// <param name="rc">
        /// The rendering context.
        /// </param>
        /// <param name="model">
        /// The owner plot model.
        /// </param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.Points.Count == 0)
            {
                return;
            }

            this.VerifyAxes();

            var clippingRect = this.GetClippingRect();

            Action<IList<ScreenPoint>, IList<ScreenPoint>> renderPoints = (lpts, mpts) =>
                {
                    var lineStyle = this.ActualLineStyle;

                    // clip the line segments with the clipping rectangle
                    if (this.StrokeThickness > 0 && lineStyle != LineStyle.None)
                    {
                        var verticalStrokeThickness = double.IsNaN(this.VerticalStrokeThickness)
                                                          ? this.StrokeThickness
                                                          : this.VerticalStrokeThickness;
                        if (!verticalStrokeThickness.Equals(this.StrokeThickness) || this.VerticalLineStyle != lineStyle)
                        {
                            var hlpts = new List<ScreenPoint>();
                            var vlpts = new List<ScreenPoint>();
                            for (int i = 0; i + 2 < lpts.Count; i += 2)
                            {
                                hlpts.Add(lpts[i]);
                                hlpts.Add(lpts[i + 1]);
                                vlpts.Add(lpts[i + 1]);
                                vlpts.Add(lpts[i + 2]);
                            }

                            rc.DrawClippedLineSegments(
                                hlpts, 
                                clippingRect, 
                                this.GetSelectableColor(this.ActualColor), 
                                this.StrokeThickness, 
                                lineStyle, 
                                this.LineJoin, 
                                false);
                            rc.DrawClippedLineSegments(
                                vlpts, 
                                clippingRect, 
                                this.GetSelectableColor(this.ActualColor), 
                                verticalStrokeThickness, 
                                this.VerticalLineStyle, 
                                this.LineJoin, 
                                false);
                        }
                        else
                        {
                            rc.DrawClippedLine(
                                lpts, 
                                clippingRect, 
                                0, 
                                this.GetSelectableColor(this.ActualColor), 
                                this.StrokeThickness, 
                                lineStyle, 
                                this.LineJoin, 
                                false);
                        }
                    }

                    if (this.MarkerType != MarkerType.None)
                    {
                        rc.DrawMarkers(
                            mpts, 
                            clippingRect, 
                            this.MarkerType, 
                            this.MarkerOutline, 
                            new[] { this.MarkerSize }, 
                            this.MarkerFill, 
                            this.MarkerStroke, 
                            this.MarkerStrokeThickness);
                    }
                };

            // Transform all points to screen coordinates
            // Render the line when invalid points occur
            var linePoints = new List<ScreenPoint>();
            var markerPoints = new List<ScreenPoint>();
            double previousY = double.NaN;
            foreach (var point in this.Points)
            {
                if (!this.IsValidPoint(point, this.XAxis, this.YAxis))
                {
                    renderPoints(linePoints, markerPoints);
                    linePoints.Clear();
                    markerPoints.Clear();
                    previousY = double.NaN;
//.........这里部分代码省略.........
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:101,代码来源:StairStepSeries.cs

示例5: Render

        /// <summary>
        /// Renders the series on the specified rendering context.
        /// </summary>
        /// <param name="rc">
        /// The rendering context.
        /// </param>
        /// <param name="model">
        /// The owner plot model.
        /// </param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.Points.Count == 0)
            {
                return;
            }

            this.VerifyAxes();

            var clippingRect = this.GetClippingRect();
            var transformedPoints = new List<ScreenPoint>();
            var lineBreakSegments = new List<ScreenPoint>();

            ScreenPoint lastValidPoint = default(ScreenPoint);
            bool isBroken = false;
            var renderBrokenLineSegments = this.BrokenLineThickness > 0 && this.BrokenLineStyle != LineStyle.None;

            // Transform all points to screen coordinates
            // Render the line when invalid points occur
            foreach (var point in this.Points)
            {
                if (!this.IsValidPoint(point, this.XAxis, this.YAxis))
                {
                    this.RenderPoints(rc, clippingRect, transformedPoints);
                    transformedPoints.Clear();
                    isBroken = true;
                    continue;
                }

                var pt = this.XAxis.Transform(point.X, point.Y, this.YAxis);
                transformedPoints.Add(pt);

                if (renderBrokenLineSegments)
                {
                    if (isBroken)
                    {
                        lineBreakSegments.Add(lastValidPoint);
                        lineBreakSegments.Add(pt);
                        isBroken = false;
                    }

                    lastValidPoint = pt;
                }
            }

            // Render the remaining points
            this.RenderPoints(rc, clippingRect, transformedPoints);

            if (renderBrokenLineSegments)
            {
                // Render line breaks
                rc.DrawClippedLineSegments(
                    lineBreakSegments, 
                    clippingRect, 
                    this.BrokenLineColor, 
                    this.BrokenLineThickness, 
                    this.BrokenLineStyle, 
                    this.LineJoin, 
                    false);
            }

            if (this.LabelFormatString != null)
            {
                // render point labels (not optimized for performance)
                this.RenderPointLabels(rc, clippingRect);
            }

            if (this.LineLegendPosition != LineLegendPosition.None && this.Points.Count > 0
                && !string.IsNullOrEmpty(this.Title))
            {
                // renders a legend on the line
                this.RenderLegendOnLine(rc, clippingRect);
            }
        }
开发者ID:jwolfm98,项目名称:HardwareMonitor,代码行数:83,代码来源:LineSeries.cs

示例6: Render

        /// <summary>
        /// Renders the LineSeries on the specified rendering context.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="model">The owner plot model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.ActualPoints.Count == 0)
            {
                return;
            }

            this.VerifyAxes();

            var clippingRect = this.GetClippingRect();
            var dashArray = this.ActualDashArray;
            var verticalLineDashArray = this.VerticalLineStyle.GetDashArray();
            var lineStyle = this.ActualLineStyle;
            var verticalStrokeThickness = double.IsNaN(this.VerticalStrokeThickness)
                                              ? this.StrokeThickness
                                              : this.VerticalStrokeThickness;

            var actualColor = this.GetSelectableColor(this.ActualColor);

            Action<IList<ScreenPoint>, IList<ScreenPoint>> renderPoints = (lpts, mpts) =>
                {
                    // clip the line segments with the clipping rectangle
                    if (this.StrokeThickness > 0 && lineStyle != LineStyle.None)
                    {
                        if (!verticalStrokeThickness.Equals(this.StrokeThickness) || this.VerticalLineStyle != lineStyle)
                        {
                            // TODO: change to array
                            var hlpts = new List<ScreenPoint>();
                            var vlpts = new List<ScreenPoint>();
                            for (int i = 0; i + 2 < lpts.Count; i += 2)
                            {
                                hlpts.Add(lpts[i]);
                                hlpts.Add(lpts[i + 1]);
                                vlpts.Add(lpts[i + 1]);
                                vlpts.Add(lpts[i + 2]);
                            }

                            rc.DrawClippedLineSegments(
                                clippingRect,
                                hlpts,
                                actualColor,
                                this.StrokeThickness,
                                dashArray,
                                this.LineJoin,
                                false);
                            rc.DrawClippedLineSegments(
                                clippingRect,
                                vlpts,
                                actualColor,
                                verticalStrokeThickness,
                                verticalLineDashArray,
                                this.LineJoin,
                                false);
                        }
                        else
                        {
                            rc.DrawClippedLine(
                                clippingRect,
                                lpts,
                                0,
                                actualColor,
                                this.StrokeThickness,
                                dashArray,
                                this.LineJoin,
                                false);
                        }
                    }

                    if (this.MarkerType != MarkerType.None)
                    {
                        rc.DrawMarkers(
                            clippingRect,
                            mpts,
                            this.MarkerType,
                            this.MarkerOutline,
                            new[] { this.MarkerSize },
                            this.MarkerFill,
                            this.MarkerStroke,
                            this.MarkerStrokeThickness);
                    }
                };

            // Transform all points to screen coordinates
            // Render the line when invalid points occur
            var linePoints = new List<ScreenPoint>();
            var markerPoints = new List<ScreenPoint>();
            double previousY = double.NaN;
            foreach (var point in this.ActualPoints)
            {
                if (!this.IsValidPoint(point))
                {
                    renderPoints(linePoints, markerPoints);
                    linePoints.Clear();
                    markerPoints.Clear();
                    previousY = double.NaN;
//.........这里部分代码省略.........
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:101,代码来源:StairStepSeries.cs

示例7: Render

        /// <summary>
        /// Renders the series on the specified render context.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="model">The model.</param>
        public override void Render(IRenderContext rc, PlotModel model)
        {
            if (this.Matrix == null)
            {
                return;
            }

            int m = this.Matrix.GetLength(0);
            int n = this.Matrix.GetLength(1);
            var p0 = this.Transform(0, 0);
            var p1 = this.Transform(n, m);

            // note matrix index [i,j] maps to image index [j,i]
            if (this.image == null)
            {
                var pixels = new OxyColor[n, m];
                for (int i = 0; i < m; i++)
                {
                    for (int j = 0; j < n; j++)
                    {
                        pixels[j, i] = Math.Abs(this.Matrix[i, j]) <= this.ZeroTolerance ? OxyColors.Transparent : this.NotZeroColor;
                    }
                }

                this.image = OxyImage.Create(pixels, ImageFormat.Png);
            }

            var clip = this.GetClippingRect();
            var x0 = Math.Min(p0.X, p1.X);
            var y0 = Math.Min(p0.Y, p1.Y);
            var w = Math.Abs(p0.X - p1.X);
            var h = Math.Abs(p0.Y - p1.Y);
            rc.DrawClippedImage(clip, this.image, x0, y0, w, h, 1, false);

            var points = new List<ScreenPoint>();
            if (this.GridInterval > 0)
            {
                var p2 = this.Transform(this.GridInterval, this.GridInterval);
                if (Math.Abs(p2.Y - p0.Y) > this.MinimumGridLineDistance)
                {
                    for (int i = 1; i < n; i += this.GridInterval)
                    {
                        points.Add(this.Transform(0, i));
                        points.Add(this.Transform(n, i));
                    }
                }

                if (Math.Abs(p2.X - p0.X) > this.MinimumGridLineDistance)
                {
                    for (int j = 1; j < m; j += this.GridInterval)
                    {
                        points.Add(this.Transform(j, 0));
                        points.Add(this.Transform(j, m));
                    }
                }
            }

            if (this.ShowDiagonal)
            {
                points.Add(this.Transform(0, 0));
                points.Add(this.Transform(n, m));
            }

            rc.DrawClippedLineSegments(clip, points, this.GridColor, 1, null, LineJoin.Miter, true);

            if (this.BorderColor.IsVisible())
            {
                var borderPoints = new[]
                    {
                        this.Transform(0, 0),
                        this.Transform(m, 0),
                        this.Transform(0, n),
                        this.Transform(m, n),
                        this.Transform(0, 0),
                        this.Transform(0, n),
                        this.Transform(m, 0),
                        this.Transform(m, n)
                    };

                rc.DrawClippedLineSegments(clip, borderPoints, this.BorderColor, 1, null, LineJoin.Miter, true);
            }
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:87,代码来源:MatrixSeries.cs

示例8: RenderPoints

        /// <summary>
        /// Renders the points as line, broken line and markers.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="clippingRect">The clipping rectangle.</param>
        /// <param name="points">The points to render.</param>
        protected void RenderPoints(IRenderContext rc, OxyRect clippingRect, IList<DataPoint> points)
        {
            var lastValidPoint = new ScreenPoint?();
            var areBrokenLinesRendered = this.BrokenLineThickness > 0 && this.BrokenLineStyle != LineStyle.None;
            var dashArray = areBrokenLinesRendered ? this.BrokenLineStyle.GetDashArray() : null;
            var broken = areBrokenLinesRendered ? new List<ScreenPoint>(2) : null;

            if (this.contiguousScreenPointsBuffer == null)
            {
                this.contiguousScreenPointsBuffer = new List<ScreenPoint>(points.Count);
            }

            int startIdx = 0;
            double xmax = double.MaxValue;

            if (this.IsXMonotonic)
            {
                // determine render range
                var xmin = this.XAxis.ActualMinimum;
                xmax = this.XAxis.ActualMaximum;
                this.WindowStartIndex = this.UpdateWindowStartIndex(points, point => point.X, xmin, this.WindowStartIndex);

                startIdx = this.WindowStartIndex;
            }

            for (int i = startIdx; i < points.Count; i++)
            {
                if (!this.ExtractNextContiguousLineSegment(points, ref i, ref lastValidPoint, xmax, broken, this.contiguousScreenPointsBuffer))
                {
                    break;
                }

                if (areBrokenLinesRendered)
                {
                    if (broken.Count > 0)
                    {
                        var actualBrokenLineColor = this.BrokenLineColor.IsAutomatic()
                                                        ? this.ActualColor
                                                        : this.BrokenLineColor;

                        rc.DrawClippedLineSegments(
                            clippingRect,
                            broken,
                            actualBrokenLineColor,
                            this.BrokenLineThickness,
                            dashArray,
                            this.LineJoin,
                            false);
                        broken.Clear();
                    }
                }
                else
                {
                    lastValidPoint = null;
                }

                if (this.Decimator != null)
                {
                    if (this.decimatorBuffer == null)
                    {
                        this.decimatorBuffer = new List<ScreenPoint>(this.contiguousScreenPointsBuffer.Count);
                    }
                    else
                    {
                        this.decimatorBuffer.Clear();
                    }

                    this.Decimator(this.contiguousScreenPointsBuffer, this.decimatorBuffer);
                    this.RenderLineAndMarkers(rc, clippingRect, this.decimatorBuffer);
                }
                else
                {
                    this.RenderLineAndMarkers(rc, clippingRect, this.contiguousScreenPointsBuffer);
                }

                this.contiguousScreenPointsBuffer.Clear();
            }
        }
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:84,代码来源:LineSeries.cs


注:本文中的IRenderContext.DrawClippedLineSegments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。