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


C# OxyColor.IsVisible方法代码示例

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


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

示例1: ExportToString

        /// <summary>
        /// Export the specified plot model to an xaml string.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        /// <returns>A xaml string.</returns>
        public static string ExportToString(IPlotModel model, double width, double height, OxyColor background)
        {
            var g = new Grid();
            if (background.IsVisible())
            {
                g.Background = background.ToBrush();
            }

            var c = new Canvas();
            g.Children.Add(c);

            var size = new Size(width, height);
            g.Measure(size);
            g.Arrange(new Rect(0, 0, width, height));
            g.UpdateLayout();

            var rc = new ShapesRenderContext(c) { UseStreamGeometry = false };
            model.Update(true);
            model.Render(rc, width, height);

            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
                XamlWriter.Save(c, xw);
            }

            return sb.ToString();
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:37,代码来源:XamlExporter.cs

示例2: DrawEllipse

        /// <summary>
        /// Draws an ellipse.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The thickness.</param>
        public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.SetAlias(false);
            var convertedRectangle = rect.Convert();
            if (fill.IsVisible())
            {
                this.SetFill(fill);
                using (var path = new CGPath())
                {
                    path.AddEllipseInRect(convertedRectangle);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Fill);
            }

            if (stroke.IsVisible() && thickness > 0)
            {
                this.SetStroke(stroke, thickness);

                using (var path = new CGPath())
                {
                    path.AddEllipseInRect(convertedRectangle);
                    this.gctx.AddPath(path);
                }

                this.gctx.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:36,代码来源:CoreGraphicsRenderContext.cs

示例3: PdfRenderContext

 /// <summary>
 /// Initializes a new instance of the <see cref="PdfRenderContext" /> class.
 /// </summary>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="background">The background color.</param>
 public PdfRenderContext(double width, double height, OxyColor background)
 {
     this.RendersToScreen = false;
     this.doc = new PdfDocument();
     var page = new PdfPage { Width = new XUnit(width), Height = new XUnit(height) };
     this.doc.AddPage(page);
     this.g = XGraphics.FromPdfPage(page);
     if (background.IsVisible())
     {
         this.g.DrawRectangle(ToBrush(background), 0, 0, width, height);
     }
 }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:18,代码来源:PdfRenderContext.cs

示例4: SaveBitmap

        /// <summary>
        /// Saves the PlotView as a bitmap.
        /// </summary>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        public void SaveBitmap(string fileName, int width, int height, OxyColor background)
        {
            if (width <= 0)
            {
                width = (int)this.ActualWidth;
            }

            if (height <= 0)
            {
                height = (int)this.ActualHeight;
            }

            if (!background.IsVisible())
            {
                background = this.Background.ToOxyColor();
            }

            PngExporter.Export(this.ActualModel, fileName, width, height, background);
        }
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:26,代码来源:PlotBase.Export.cs

示例5: DrawEllipse

        /// <summary>
        /// Draws an ellipse.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The thickness.</param>
        public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            // center of ellipse
            var ex = rect.Left + (rect.Width / 2.0);
            var ey = rect.Top + (rect.Height / 2.0);

            // ellipse dimensions
            var ew = rect.Width;
            var eh = rect.Height;

            if (fill.IsVisible())
            {
                this.g.Save();

                this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
                this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0, eh / 2.0 == 1.0

                this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
                this.g.ClosePath();
                this.g.SetSourceColor(fill);
                this.g.Fill();
                this.g.Restore();
            }

            if (stroke.IsVisible() && thickness > 0)
            {
                this.g.Save();

                // g.SmoothingMode = SmoothingMode.HighQuality; // TODO
                this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
                this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0

                // for height: eh / 2.0 == 1.0
                this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
                this.g.SetSourceColor(stroke);
                this.g.LineWidth = thickness * 2.0 / ew;
                this.g.Stroke();
                this.g.Restore();
            }
        }
开发者ID:Celderon,项目名称:oxyplot,代码行数:47,代码来源:GraphicsRenderContext.cs

示例6: Export

        /// <summary>
        /// Exports the specified plot model to a xml writer.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="writer">The xml writer.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        private static void Export(IPlotModel model, XmlWriter writer, double width, double height, OxyColor background)
        {
            var c = new Canvas();
            if (background.IsVisible())
            {
                c.Background = background.ToBrush();
            }

            c.Measure(new Size(width, height));
            c.Arrange(new Rect(0, 0, width, height));

            var rc = new CanvasRenderContext(c) { UseStreamGeometry = false };

            rc.TextFormattingMode = TextFormattingMode.Ideal;

            model.Update(true);
            model.Render(rc, width, height);

            c.UpdateLayout();

            XamlWriter.Save(c, writer);
        }
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:30,代码来源:XamlExporter.cs

示例7: DrawRectangle

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.paint.Reset();
            {
                if (fill.IsVisible())
                {
                    this.SetFill(fill);
                    this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
                }

                if (stroke.IsVisible())
                {
                    this.SetStroke(stroke, thickness, aliased: true);
                    this.canvas.DrawRect(this.ConvertAliased(rect.Left), this.ConvertAliased(rect.Top), this.ConvertAliased(rect.Right), this.ConvertAliased(rect.Bottom), this.paint);
                }
            }
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:24,代码来源:CanvasRenderContext.cs

示例8: DrawPolygon

        /// <summary>
        /// Draws a polygon. The polygon can have stroke and/or fill.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">If set to <c>true</c> the shape will be aliased.</param>
        public override void DrawPolygon(IList<ScreenPoint> points, OxyColor fill, OxyColor stroke, double thickness, double[] dashArray, OxyPenLineJoin lineJoin, bool aliased)
        {
            this.paint.Reset();
            {
                this.path.Reset();
                {
                    this.SetPath(points, aliased);
                    this.path.Close();

                    if (fill.IsVisible())
                    {
                        this.SetFill(fill);
                        this.canvas.DrawPath(this.path, this.paint);
                    }

                    if (stroke.IsVisible())
                    {
                        this.SetStroke(stroke, thickness, dashArray, lineJoin, aliased);
                        this.canvas.DrawPath(this.path, this.paint);
                    }
                }
            }
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:33,代码来源:CanvasRenderContext.cs

示例9: DrawEllipses

        /// <summary>
        /// Draws the collection of ellipses, where all have the same stroke and fill.
        /// This performs better than calling DrawEllipse multiple times.
        /// </summary>
        /// <param name="rectangles">The rectangles.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public override void DrawEllipses(IList<OxyRect> rectangles, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.paint.Reset();
            {
                foreach (var rect in rectangles)
                {
                    if (fill.IsVisible())
                    {
                        this.SetFill(fill);
                        this.canvas.DrawOval(this.Convert(rect), this.paint);
                    }

                    if (stroke.IsVisible())
                    {
                        this.SetStroke(stroke, thickness);
                        this.canvas.DrawOval(this.Convert(rect), this.paint);
                    }
                }
            }
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:28,代码来源:CanvasRenderContext.cs

示例10: DrawRectangle

        /// <summary>
        /// Draws a rectangle.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            this.SetAlias(true);
            var convertedRect = rect.ConvertAliased();

            if (fill.IsVisible())
            {
                this.SetFill(fill);
                var path = new CGPath();
                path.AddRect(convertedRect);
                this.gctx.AddPath(path);
                this.gctx.DrawPath(CGPathDrawingMode.Fill);
            }

            if (stroke.IsVisible() && thickness > 0)
            {
                this.SetStroke(stroke, thickness);

                var path = new CGPath();
                path.AddRect(convertedRect);
                this.gctx.AddPath(path);
                this.gctx.DrawPath(CGPathDrawingMode.Stroke);
            }
        }
开发者ID:gutyoh,项目名称:oxyplot,代码行数:31,代码来源:MonoTouchRenderContext.cs

示例11: SetStroke

        /// <summary>
        /// Sets the stroke of the specified shape.
        /// </summary>
        /// <param name="shape">The shape.</param>
        /// <param name="stroke">The stroke.</param>
        /// <param name="thickness">The thickness.</param>
        /// <param name="lineJoin">The line join.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="aliased">aliased if set to <c>true</c>.</param>
        private void SetStroke(
            Shape shape,
            OxyColor stroke,
            double thickness,
            OxyPenLineJoin lineJoin = OxyPenLineJoin.Miter,
            IEnumerable<double> dashArray = null,
            bool aliased = false)
        {
            if (stroke.IsVisible() && thickness > 0)
            {
                shape.Stroke = this.GetCachedBrush(stroke);

                switch (lineJoin)
                {
                    case OxyPenLineJoin.Round:
                        shape.StrokeLineJoin = PenLineJoin.Round;
                        break;
                    case OxyPenLineJoin.Bevel:
                        shape.StrokeLineJoin = PenLineJoin.Bevel;
                        break;

                    // The default StrokeLineJoin is Miter
                }

                shape.StrokeThickness = thickness;

                if (dashArray != null)
                {
                    shape.StrokeDashArray = CreateDashArrayCollection(dashArray);
                }

                if (aliased)
                {
                    // shape.UseLayoutRounding = aliased;
                }
            }
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:46,代码来源:SilverlightRenderContext.cs

示例12: DrawRectangle

        /// <summary>
        /// Draws the rectangle.
        /// </summary>
        /// <param name="rect">The rectangle.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        public void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            var el = new Rectangle();
            if (stroke.IsVisible())
            {
                el.Stroke = new SolidColorBrush(stroke.ToColor());
                el.StrokeThickness = thickness;
            }

            if (fill.IsVisible())
            {
                el.Fill = new SolidColorBrush(fill.ToColor());
            }

            el.Width = rect.Width;
            el.Height = rect.Height;
            Canvas.SetLeft(el, rect.Left);
            Canvas.SetTop(el, rect.Top);
            this.Add(el, rect.Left, rect.Top);
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:27,代码来源:SilverlightRenderContext.cs

示例13: DrawPolygon

        /// <summary>
        /// Draws the polygon from the specified points. The polygon can have stroke and/or fill.
        /// </summary>
        /// <param name="points">The points.</param>
        /// <param name="fill">The fill color.</param>
        /// <param name="stroke">The stroke color.</param>
        /// <param name="thickness">The stroke thickness.</param>
        /// <param name="dashArray">The dash array.</param>
        /// <param name="lineJoin">The line join type.</param>
        /// <param name="aliased">if set to <c>true</c> the shape will be aliased.</param>
        public void DrawPolygon(
            IList<ScreenPoint> points,
            OxyColor fill,
            OxyColor stroke,
            double thickness,
            double[] dashArray,
            OxyPenLineJoin lineJoin,
            bool aliased)
        {
            var po = new Polygon();
            this.SetStroke(po, stroke, thickness, lineJoin, dashArray, aliased);

            if (fill.IsVisible())
            {
                po.Fill = this.GetCachedBrush(fill);
            }

            var pc = new PointCollection();
            foreach (var p in points)
            {
                pc.Add(p.ToPoint(aliased));
            }

            po.Points = pc;

            this.Add(po);
        }
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:37,代码来源:SilverlightRenderContext.cs

示例14: 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

示例15: ToBrush

        /// <summary>
        /// Converts an OxyColor to a brush.
        /// </summary>
        /// <param name="fill">The fill color.</param>
        /// <returns>The brush.</returns>
        private static XBrush ToBrush(OxyColor fill)
        {
            if (fill.IsVisible())
            {
                return new XSolidBrush(ToColor(fill));
            }

            return null;
        }
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:14,代码来源:PdfRenderContext.cs


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