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


C# OxyRect.Contains方法代码示例

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


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

示例1: RenderPointLabels

        /// <summary>
        /// Renders the point labels.
        /// </summary>
        /// <param name="rc">The render context.</param>
        /// <param name="clippingRect">The clipping rect.</param>
        protected void RenderPointLabels(IRenderContext rc, OxyRect clippingRect)
        {
            int index = -1;
            foreach (var point in this.Points)
            {
                index++;

                if (!this.IsValidPoint(point, this.XAxis, this.YAxis))
                {
                    continue;
                }

                var pt = this.XAxis.Transform(point.X, point.Y, this.YAxis);
                pt.Y -= this.LabelMargin;

                if (!clippingRect.Contains(pt))
                {
                    continue;
                }

                var s = StringHelper.Format(
                    this.ActualCulture, this.LabelFormatString, this.GetItem(index), point.X, point.Y);

#if SUPPORTLABELPLACEMENT
                    switch (this.LabelPlacement)
                    {
                        case LabelPlacement.Inside:
                            pt = new ScreenPoint(rect.Right - this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalTextAlign.Right;
                            break;
                        case LabelPlacement.Middle:
                            pt = new ScreenPoint((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalTextAlign.Center;
                            break;
                        case LabelPlacement.Base:
                            pt = new ScreenPoint(rect.Left + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalTextAlign.Left;
                            break;
                        default: // Outside
                            pt = new ScreenPoint(rect.Right + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
                            ha = HorizontalTextAlign.Left;
                            break;
                    }
#endif

                rc.DrawClippedText(
                    clippingRect,
                    pt,
                    s,
                    this.ActualTextColor,
                    this.ActualFont,
                    this.ActualFontSize,
                    this.ActualFontWeight,
                    0,
                    HorizontalTextAlign.Center,
                    VerticalTextAlign.Bottom);
            }
        }
开发者ID:jgodinez,项目名称:OxyPlot.2DGraphLib.MonoTouch,代码行数:63,代码来源:LineSeries.cs

示例2: GetNearestPoint

        /// <summary>
        ///     Gets the point on the series that is nearest the specified point.
        /// </summary>
        /// <param name="point">The point.</param>
        /// <param name="interpolate">
        ///     Interpolate the series if this flag is set to <c>true</c>.
        /// </param>
        /// <returns>A TrackerHitResult for the current hit.</returns>
        public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate)
        {
            foreach (var v in this.Values)
            {
                if (double.IsNaN(v) || v < this.XAxis.ActualMinimum || v > this.XAxis.ActualMaximum)
                {
                    continue;
                }

                double x = this.XAxis.Transform(v);
                var r = new OxyRect(
                    x - this.symbolSize.Width / 2,
                    this.symbolPosition - this.symbolSize.Height,
                    this.symbolSize.Width,
                    this.symbolSize.Height);
                if (r.Contains(point))
                {
                    var text = StringHelper.Format(this.ActualCulture, this.TrackerFormatString, null, this.Title, v);

                    return new TrackerHitResult(
                        this,
                        new DataPoint(v, double.NaN),
                        new ScreenPoint(x, this.symbolPosition - this.symbolSize.Height)) { Text = text };
                }
            }

            return null;
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:36,代码来源:FlagSeries.cs

示例3: DrawClippedText

        /// <summary>
        /// Draws the clipped text.
        /// </summary>
        /// <param name="rc">The rendering context.</param>
        /// <param name="clippingRectangle">The clipping rectangle.</param>
        /// <param name="p">The position.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font.</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="horizontalAlignment">The horizontal align.</param>
        /// <param name="verticalAlignment">The vertical align.</param>
        /// <param name="maxSize">Size of the max.</param>
        public static void DrawClippedText(
            this IRenderContext rc,
            OxyRect clippingRectangle,
            ScreenPoint p,
            string text,
            OxyColor fill,
            string fontFamily = null,
            double fontSize = 10,
            double fontWeight = 500,
            double rotate = 0,
            HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
            VerticalAlignment verticalAlignment = VerticalAlignment.Top,
            OxySize? maxSize = null)
        {
            if (rc.SetClip(clippingRectangle))
            {
                rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
                rc.ResetClip();
                return;
            }

            // fall back simply check position
            if (clippingRectangle.Contains(p.X, p.Y))
            {
                rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
            }
        }
开发者ID:jwolfm98,项目名称:HardwareMonitor,代码行数:42,代码来源:RenderingExtensions.cs

示例4: DrawClippedText

 /// <summary>
 /// Draws the clipped text.
 /// </summary>
 /// <param name="rc">The rendering context.</param>
 /// <param name="clippingRectangle">The clipping rectangle.</param>
 /// <param name="p">The position.</param>
 /// <param name="text">The text.</param>
 /// <param name="fill">The fill color.</param>
 /// <param name="fontFamily">The font family.</param>
 /// <param name="fontSize">Size of the font.</param>
 /// <param name="fontWeight">The font weight.</param>
 /// <param name="rotate">The rotation angle.</param>
 /// <param name="horizontalAlignment">The horizontal align.</param>
 /// <param name="verticalAlignment">The vertical align.</param>
 /// <param name="maxSize">Size of the max.</param>
 public static void DrawClippedText(
     this IRenderContext rc,
     OxyRect clippingRectangle,
     ScreenPoint p,
     string text,
     OxyColor fill,
     string fontFamily = null,
     double fontSize = 10,
     double fontWeight = 500,
     double rotate = 0,
     HorizontalTextAlign horizontalAlignment = HorizontalTextAlign.Left,
     VerticalTextAlign verticalAlignment = VerticalTextAlign.Top,
     OxySize? maxSize = null)
 {
     if (clippingRectangle.Contains(p.X, p.Y))
     {
         rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
     }
 }
开发者ID:jgodinez,项目名称:OxyPlot.2DGraphLib.MonoTouch,代码行数:34,代码来源:RenderingExtensions.cs

示例5: AddContourLabels

        /// <summary>
        /// The add contour labels.
        /// </summary>
        /// <param name="contour">
        /// The contour.
        /// </param>
        /// <param name="pts">
        /// The pts.
        /// </param>
        /// <param name="clippingRect">
        /// The clipping rect.
        /// </param>
        /// <param name="contourLabels">
        /// The contour labels.
        /// </param>
        private void AddContourLabels(
            Contour contour, ScreenPoint[] pts, OxyRect clippingRect, List<ContourLabel> contourLabels)
        {
            // todo: support label spacing and label step
            if (pts.Length < 2)
            {
                return;
            }

            // Calculate position and angle of the label
            double i = (pts.Length - 1) * 0.5;
            var i0 = (int)i;
            int i1 = i0 + 1;
            double dx = pts[i1].X - pts[i0].X;
            double dy = pts[i1].Y - pts[i0].Y;
            double x = pts[i0].X + (dx * (i - i0));
            double y = pts[i0].Y + (dy * (i - i0));
            if (!clippingRect.Contains(x, y))
            {
                return;
            }

            var pos = new ScreenPoint(x, y);
            double angle = Math.Atan2(dy, dx) * 180 / Math.PI;
            if (angle > 90)
            {
                angle -= 180;
            }

            if (angle < -90)
            {
                angle += 180;
            }

            string text = contour.ContourLevel.ToString(this.LabelFormatString, this.ActualCulture);
            contourLabels.Add(new ContourLabel { Position = pos, Angle = angle, Text = text });
        }
开发者ID:jgodinez,项目名称:OxyPlot.2DGraphLib.MonoTouch,代码行数:52,代码来源:ContourSeries.cs


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