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


C# PlotModel.Render方法代码示例

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


在下文中一共展示了PlotModel.Render方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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(PlotModel model, double width, double height, OxyColor background = null)
        {
            var g = new Grid();
            if (background != null)
            {
                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();
            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:aleksanderkobylak,项目名称:oxyplot,代码行数:37,代码来源:XamlExporter.cs

示例2: Export

 /// <summary>
 /// Exports the specified model to a stream.
 /// </summary>
 /// <param name="model">
 /// The model.
 /// </param>
 /// <param name="s">
 /// The stream.
 /// </param>
 /// <param name="width">
 /// The width (points).
 /// </param>
 /// <param name="height">
 /// The height (points).
 /// </param>
 public static void Export(PlotModel model, Stream s, double width, double height)
 {
     using (var rc = new PdfRenderContext(width, height, model.Background))
     {
         model.Update();
         model.Render(rc, width, height);
         rc.Save(s);
     }
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:24,代码来源:PdfExporter.cs

示例3: Export

        /// <summary>
        /// The export.
        /// </summary>
        /// <param name="model">
        /// The model.
        /// </param>
        /// <param name="fileName">
        /// The file name.
        /// </param>
        /// <param name="width">
        /// The width.
        /// </param>
        /// <param name="height">
        /// The height.
        /// </param>
        /// <param name="background">
        /// The background.
        /// </param>
        public static void Export(PlotModel model, string fileName, int width, int height, Brush background = null)
        {
            using (var bm = new Bitmap(width, height))
            {
                using (Graphics g = Graphics.FromImage(bm))
                {
                    if (background != null)
                    {
                        g.FillRectangle(background, 0, 0, width, height);
                    }

                    var rc = new GraphicsRenderContext { RendersToScreen = false };
                    rc.SetGraphicsTarget(g);
                    model.Update();
                    model.Render(rc, width, height);
                    bm.Save(fileName, ImageFormat.Png);
                }
            }
        }
开发者ID:jwolfm98,项目名称:HardwareMonitor,代码行数:37,代码来源:PngExporter.cs

示例4: Export

        /// <summary>
        ///     Exports the specified plot model to an xps file.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="fileName">The file name.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background color.</param>
        public static void Export(
            PlotModel model, string fileName, double width, double height, OxyColor background = null)
        {
            using (var xpsPackage = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite))
            {
                using (var doc = new XpsDocument(xpsPackage))
                {
                    var canvas = new Canvas { Width = width, Height = height, Background = background.ToBrush() };
                    canvas.Measure(new Size(width, height));
                    canvas.Arrange(new Rect(0, 0, width, height));

                    var rc = new ShapesRenderContext(canvas);
                    model.Update();
                    model.Render(rc, width, height);

                    canvas.UpdateLayout();

                    var xpsdw = XpsDocument.CreateXpsDocumentWriter(doc);
                    xpsdw.Write(canvas);
                }
            }
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:30,代码来源:XpsExporter.cs

示例5: ExportToBitmap

        /// <summary>
        /// Exports the specified plot model to a bitmap.
        /// </summary>
        /// <param name="model">The plot model.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="background">The background.</param>
        /// <param name="dpi">The resolution.</param>
        /// <returns>A bitmap.</returns>
        public static BitmapSource ExportToBitmap(PlotModel model, int width, int height, OxyColor background = null, int dpi = 96)
        {
            var canvas = new Canvas { Width = width, Height = height, Background = background.ToBrush() };
            canvas.Measure(new Size(width, height));
            canvas.Arrange(new Rect(0, 0, width, height));

            var rc = new ShapesRenderContext(canvas) { RendersToScreen = false };
            model.Update();
            model.Render(rc, width, height);

            canvas.UpdateLayout();

            var bmp = new RenderTargetBitmap(width, height, dpi, dpi, PixelFormats.Pbgra32);
            bmp.Render(canvas);
            return bmp;

            // alternative implementation:
            // http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.rendertargetbitmap.aspx
            // var dv = new DrawingVisual();
            // using (var ctx = dv.RenderOpen())
            // {
            //    var vb = new VisualBrush(canvas);
            //    ctx.DrawRectangle(vb, null, new Rect(new Point(), new Size(width, height)));
            // }
            // bmp.Render(dv);
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:35,代码来源:PngExporter.cs

示例6: Print

        /// <summary>
        ///     Prints the specified plot model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="width">The width (using the actual media width if not specified).</param>
        /// <param name="height">The height (using the actual media height if not specified).</param>
        public static void Print(PlotModel model, double width = double.NaN, double height = double.NaN)
        {
            PrintDocumentImageableArea area = null;
            var xpsDocumentWriter = PrintQueue.CreateXpsDocumentWriter(ref area);
            if (xpsDocumentWriter != null)
            {
                if (double.IsNaN(width))
                {
                    width = area.MediaSizeWidth;
                }

                if (double.IsNaN(height))
                {
                    height = area.MediaSizeHeight;
                }

                var canvas = new Canvas { Width = width, Height = height };
                canvas.Measure(new Size(width, height));
                canvas.Arrange(new Rect(0, 0, width, height));

                var rc = new ShapesRenderContext(canvas);
                model.Update();
                model.Render(rc, width, height);

                canvas.UpdateLayout();

                xpsDocumentWriter.Write(canvas);
            }
        }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:35,代码来源:XpsExporter.cs

示例7: Save

 public static void Save(PlotModel model, Stream s, double width, double height)
 {
     var svgrc = new PdfRenderContext(width, height);
     model.Render(svgrc);
     svgrc.Save(s);
 }
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:6,代码来源:PdfPlotWriter.cs


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