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


C# OxyColor.ToXwtColor方法代码示例

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


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

示例1: DrawEllipse

        /// <summary>
        /// Draws an ellipse.
        /// </summary>
        /// <param name="rect">The rectangle defining the extents of the ellipse.</param>
        /// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the extents will not be filled.</param>
        /// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the extents will not be stroked.</param>
        /// <param name="thickness">The thickness (in device independent units, 1/96 inch).</param>
        public override void DrawEllipse(OxyRect rect,
                                    OxyColor fill,
                                    OxyColor stroke,
                                    double thickness)
        {
            var ex = rect.Left + (rect.Width / 2.0);
            var ey = rect.Top + (rect.Height / 2.0);

            if (fill.IsVisible ()) {
                Context.Save ();
                Context.SetColor (fill.ToXwtColor ());

                Context.Translate (ex, ey);
                Context.Scale (1.0, -rect.Height / rect.Width);
                Context.Arc (0.0, 0.0, rect.Width / 2.0, 0, 360);

                Context.ClosePath ();
                Context.Fill ();
                Context.Restore ();
            }

            if (stroke.IsVisible () && thickness > 0) {
                Context.Save ();
                Context.SetColor (stroke.ToXwtColor ());
                Context.SetLineWidth (thickness);

                Context.Translate (ex, ey);
                Context.Scale (1.0, -rect.Height / rect.Width);
                Context.Arc (0.0, 0.0, rect.Width / 2.0, 0, 360);

                Context.ClosePath ();
                Context.Stroke ();
                Context.Restore ();
            }
        }
开发者ID:oxyplot,项目名称:oxyplot-xwt,代码行数:42,代码来源:GraphicsRenderContext.cs

示例2: DrawRectangle

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">The rectangle to draw.</param>
        /// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the rectangle will not be filled.</param>
        /// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the rectangle will not be stroked.</param>
        /// <param name="thickness">The stroke thickness (in device independent units, 1/96 inch).</param>
        public override void DrawRectangle(OxyRect rect,
                                      OxyColor fill,
                                      OxyColor stroke,
                                      double thickness)
        {
            if (fill.IsVisible ()) {
                Context.Save ();
                Context.Rectangle (rect.ToXwtRect (false));
                Context.SetColor (fill.ToXwtColor ());
                Context.Fill ();
                Context.Restore ();
            }

            if (stroke.IsVisible () && thickness > 0) {
                Context.Save ();
                Context.SetColor (stroke.ToXwtColor ());
                Context.SetLineWidth (thickness);
                Context.Rectangle (rect.ToXwtRect (false));
                Context.Stroke ();
                Context.Restore ();
            }
        }
开发者ID:oxyplot,项目名称:oxyplot-xwt,代码行数:29,代码来源:GraphicsRenderContext.cs

示例3: DrawText

        /// <summary>
        /// Draws text.
        /// </summary>
        /// <param name="p">The position.</param>
        /// <param name="text">The text.</param>
        /// <param name="fill">The text color.</param>
        /// <param name="fontFamily">The font family.</param>
        /// <param name="fontSize">Size of the font (in device independent units, 1/96 inch).</param>
        /// <param name="fontWeight">The font weight.</param>
        /// <param name="rotate">The rotation angle.</param>
        /// <param name="halign">The horizontal alignment.</param>
        /// <param name="valign">The vertical alignment.</param>
        /// <param name="maxSize">The maximum size of the text (in device independent units, 1/96 inch).</param>
        public override void DrawText(ScreenPoint p,
                                 string text,
                                 OxyColor fill,
                                 string fontFamily,
                                 double fontSize,
                                 double fontWeight,
                                 double rotate,
                                 HorizontalAlignment halign,
                                 VerticalAlignment valign,
                                 OxySize? maxSize)
        {
            Context.Save ();

            var layout = new TextLayout ();
            layout.Font = GetCachedFont (fontFamily, fontSize, fontWeight);
            layout.Text = text;

            var size = layout.GetSize ();
            if (maxSize != null) {
                size.Width = Math.Min (size.Width, maxSize.Value.Width);
                size.Height = Math.Min (size.Height, maxSize.Value.Height);
            }

            double dx = 0;
            if (halign == HorizontalAlignment.Center) {
                dx = -size.Width / 2;
            }

            if (halign == HorizontalAlignment.Right) {
                dx = -size.Width;
            }

            double dy = 0;
            if (valign == VerticalAlignment.Middle) {
                dy = -size.Height / 2;
            }

            if (valign == VerticalAlignment.Bottom) {
                dy = -size.Height;
            }

            Context.Translate (p.X, p.Y);
            if (Math.Abs (rotate) > double.Epsilon) {
                Context.Rotate (rotate);
            }

            Context.Translate (dx, dy);

            Context.SetColor (fill.ToXwtColor ());
            Context.DrawTextLayout (layout, 0, 0);

            Context.Restore ();
        }
开发者ID:oxyplot,项目名称:oxyplot-xwt,代码行数:66,代码来源:GraphicsRenderContext.cs

示例4: DrawPolygon

        /// <summary>
        /// Draws a polygon.
        /// </summary>
        /// <param name="points">The points defining the polygon.</param>
        /// <param name="fill">The fill color. If set to <c>OxyColors.Undefined</c>, the polygon will not be filled.</param>
        /// <param name="stroke">The stroke color. If set to <c>OxyColors.Undefined</c>, the polygon will not be stroked.</param>
        /// <param name="thickness">The stroke thickness (in device independent units, 1/96 inch).</param>
        /// <param name="dashArray">The dash array (in device independent units, 1/96 inch).</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">If set to <c>true</c> the polygon will be aliased.</param>
        public override void DrawPolygon(IList<ScreenPoint> points,
                                    OxyColor fill,
                                    OxyColor stroke,
                                    double thickness,
                                    double[] dashArray,
                                    LineJoin lineJoin,
                                    bool aliased)
        {
            if (fill.IsVisible () && points.Count >= 2) {
                // g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; // TODO: Smoothing modes
                Context.Save ();
                Context.SetColor (fill.ToXwtColor ());
                //Context.LineJoin = lineJoin.ToLineJoin();
                Context.SetLineWidth (thickness);
                if (dashArray != null)
                    Context.SetLineDash (0, Array.ConvertAll (dashArray, x => x * thickness));

                Context.MoveTo (points [0].ToXwtPoint (aliased));
                foreach (var point in points.Skip(1)) {
                    Context.LineTo (point.ToXwtPoint (aliased));
                }

                // g.LineTo(points[0].ToPointD(aliased));
                Context.ClosePath ();
                Context.Fill ();
                Context.Restore ();
            }

            if (stroke.IsVisible () && thickness > 0 && points.Count >= 2) {
                // g.SmoothingMode = aliased ? SmoothingMode.None : SmoothingMode.HighQuality; // TODO: Smoothing modes
                Context.Save ();
                Context.SetColor (stroke.ToXwtColor ());
                //Context.LineJoin = lineJoin.ToLineJoin();
                Context.SetLineWidth (thickness);
                if (dashArray != null)
                    Context.SetLineDash (0, Array.ConvertAll (dashArray, x => x * thickness));

                Context.MoveTo (points [0].ToXwtPoint (aliased));
                foreach (var point in points.Skip(1)) {
                    Context.LineTo (point.ToXwtPoint (aliased));
                }

                Context.ClosePath ();
                Context.Stroke ();
                Context.Restore ();
            }
        }
开发者ID:oxyplot,项目名称:oxyplot-xwt,代码行数:57,代码来源:GraphicsRenderContext.cs


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