コード例 #1
0
        /// <summary>
        /// Exports the specified <see cref="PlotModel" /> to the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="stream">The output stream.</param>
        public void Export(IPlotModel model, Stream stream)
        {
            using (var bm = new Bitmap(this.Width, this.Height))
            {
                using (var g = Graphics.FromImage(bm))
                {
                    if (this.Background.IsVisible())
                    {
                        using (var brush = this.Background.ToBrush())
                        {
                            g.FillRectangle(brush, 0, 0, this.Width, this.Height);
                        }
                    }

                    using (var rc = new GraphicsRenderContext(g)
                    {
                        RendersToScreen = false
                    })
                    {
                        model.Update(true);
                        model.Render(rc, this.Width, this.Height);
                    }

                    bm.Save(stream, ImageFormat.Png);
                }
            }
        }
コード例 #2
0
ファイル: PngExporter.cs プロジェクト: Microshaoft/MyOxyPlot
        /// <summary>
        /// Exports the specified <see cref="PlotModel" /> to a <see cref="Bitmap" />.
        /// </summary>
        /// <param name="model">The model to export.</param>
        /// <returns>A bitmap.</returns>
        public Bitmap ExportToBitmap(IPlotModel model)
        {
            var bm = new Bitmap(this.Width, this.Height);

            using (var g = Graphics.FromImage(bm))
            {
                if (model.Background.IsVisible())
                {
                    using (var brush = model.Background.ToBrush())
                    {
                        g.FillRectangle(brush, 0, 0, this.Width, this.Height);
                    }
                }

                using (var rc = new GraphicsRenderContext(g)
                {
                    RendersToScreen = false
                })
                {
                    model.Update(true);
                    model.Render(rc, new OxyRect(0, 0, this.Width, this.Height));
                }

                bm.SetResolution((float)this.Resolution, (float)this.Resolution);
                return(bm);
            }
        }
コード例 #3
0
 /// <summary>
 /// Creates an SVG string.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="width">The width (points).</param>
 /// <param name="height">The height (points).</param>
 /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param>
 /// <returns>A <see cref="string" />.</returns>
 public static string ToSvg(this PlotModel model, double width, double height, bool isDocument)
 {
     using (var g = Graphics.FromHwnd(IntPtr.Zero))
     {
         using (var rc = new GraphicsRenderContext(g) { RendersToScreen = false })
         {
             return OxyPlot.SvgExporter.ExportToString(model, width, height, isDocument, rc);
         }
     }
 }
コード例 #4
0
ファイル: PlotView.cs プロジェクト: TDControlsGroup/CLARA_RGA
        /// <summary>
        /// Initializes a new instance of the <see cref="PlotView" /> class.
        /// </summary>
        public PlotView()
        {
            this.renderContext = new GraphicsRenderContext();

            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            this.DoubleBuffered = true;
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
            this.PanCursor            = Cursors.Hand;
            this.ZoomRectangleCursor  = Cursors.SizeNWSE;
            this.ZoomHorizontalCursor = Cursors.SizeWE;
            this.ZoomVerticalCursor   = Cursors.SizeNS;
        }
コード例 #5
0
 /// <summary>
 /// Creates an SVG string.
 /// </summary>
 /// <param name="model">The model.</param>
 /// <param name="width">The width (points).</param>
 /// <param name="height">The height (points).</param>
 /// <param name="isDocument">if set to <c>true</c>, the xml headers will be included (?xml and !DOCTYPE).</param>
 /// <returns>A <see cref="string" />.</returns>
 public static string ToSvg(this PlotModel model, double width, double height, bool isDocument)
 {
     using (var g = Graphics.FromHwnd(IntPtr.Zero))
     {
         using (var rc = new GraphicsRenderContext(g)
         {
             RendersToScreen = false
         })
         {
             return(OxyPlot.SvgExporter.ExportToString(model, width, height, isDocument, rc));
         }
     }
 }
コード例 #6
0
ファイル: PlotView.cs プロジェクト: Microshaoft/MyOxyPlot
        /// <summary>
        /// Initializes a new instance of the <see cref="PlotView" /> class.
        /// </summary>
        public PlotView()
        {
            this.renderContext = new GraphicsRenderContext();

            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            this.DoubleBuffered = true;
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
            this.PanCursor            = Cursors.Hand;
            this.ZoomRectangleCursor  = Cursors.SizeNWSE;
            this.ZoomHorizontalCursor = Cursors.SizeWE;
            this.ZoomVerticalCursor   = Cursors.SizeNS;

            var DoCopy = new DelegatePlotCommand <OxyKeyEventArgs>((view, controller, args) => this.DoCopy(view, args));

            this.ActualController.BindKeyDown(OxyKey.C, OxyModifierKeys.Control, DoCopy);
        }
コード例 #7
0
        /// <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);
                }
            }
        }
コード例 #8
0
 protected override Image DoCreateChartImage()
 {
     var plotModel = new PlotModel("");
     var ls = new LineSeries("")
         {
             Points = Parameters.SeriaData.Select(t => new DataPoint(t.Key, t.Value) as IDataPoint).ToList()
         };
     plotModel.Series.Add(ls);
     plotModel.Axes.Add(new LinearAxis(AxisPosition.Left));
     plotModel.Axes.Add(new LinearAxis(AxisPosition.Bottom));
     var bitmap = new Bitmap(Parameters.ChartWidth, Parameters.ChartHeight);
     using (var graphics = Graphics.FromImage(bitmap))
     {
         var graphicsRenderContext = new GraphicsRenderContext { RendersToScreen = false };
         graphicsRenderContext.SetGraphicsTarget(graphics);
         plotModel.Update();
         plotModel.Render(graphicsRenderContext, Parameters.ChartWidth, Parameters.ChartHeight);
         return bitmap;
     }
 }
コード例 #9
0
ファイル: PngExporter.cs プロジェクト: ylatuya/oxyplot
        /// <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);
                }
            }
        }
コード例 #10
0
ファイル: SvgExporter.cs プロジェクト: Celderon/oxyplot
 /// <summary>
 /// Initializes a new instance of the <see cref="SvgExporter" /> class.
 /// </summary>
 public SvgExporter()
 {
     this.g = Graphics.FromHwnd(IntPtr.Zero);
     this.TextMeasurer = this.grc = new GraphicsRenderContext(this.g);
 }
コード例 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SvgExporter" /> class.
 /// </summary>
 public SvgExporter()
 {
     this.g            = Graphics.FromHwnd(IntPtr.Zero);
     this.TextMeasurer = this.grc = new GraphicsRenderContext(this.g);
 }
コード例 #12
0
 static void CreateSvg(int size, IconRenderer iconRenderer, string fileName)
 {
     using (var bm = new Bitmap(size, size))
     {
         using (var grx = new GraphicsRenderContext(Graphics.FromImage(bm)))
         {
             using (var s = File.Create(fileName))
             {
                 using (var rc = new SvgRenderContext(s, size, size, true, grx, OxyColors.Transparent))
                 {
                     iconRenderer.Render(rc, size);
                 }
             }
         }
     }
 }
コード例 #13
0
        static void CreateBitmap(int size, IconRenderer iconRenderer, string fileName, double cornerRadius = 0)
        {
            using (var bm = new Bitmap(size, size, PixelFormat.Format32bppArgb))
            {
                using (var g = Graphics.FromImage(bm))
                {
                    g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    g.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    g.PixelOffsetMode = PixelOffsetMode.HighQuality;
                    g.CompositingQuality = CompositingQuality.HighQuality;
                    g.CompositingMode = CompositingMode.SourceOver;
                    using (var rc = new GraphicsRenderContext(g) { RendersToScreen = false })
                    {
                        g.Clear(Color.Transparent);

                        if (cornerRadius > 0)
                        {
                            // TODO: no antialiasing on the clipping path?
                            var path = GetRoundedRect(new RectangleF(0, 0, size, size), (float)cornerRadius);
                            g.SetClip(path, CombineMode.Replace);
                        }

                        iconRenderer.Render(rc, size);
                    }

                    bm.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                }
            }
        }
コード例 #14
0
ファイル: PlotView.cs プロジェクト: benjaminrupp/oxyplot
        /// <summary>
        /// Initializes a new instance of the <see cref="PlotView" /> class.
        /// </summary>
        public PlotView()
        {
            this.renderContext = new GraphicsRenderContext();

            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            this.DoubleBuffered = true;
            // ReSharper restore DoNotCallOverridableMethodsInConstructor
            this.PanCursor = Cursors.Hand;
            this.ZoomRectangleCursor = Cursors.SizeNWSE;
            this.ZoomHorizontalCursor = Cursors.SizeWE;
            this.ZoomVerticalCursor = Cursors.SizeNS;
        }
コード例 #15
0
ファイル: PngExporter.cs プロジェクト: Celderon/oxyplot
        /// <summary>
        /// Exports the specified <see cref="PlotModel" /> to the specified <see cref="Stream" />.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="stream">The output stream.</param>
        public void Export(IPlotModel model, Stream stream)
        {
            using (var bm = new Bitmap(this.Width, this.Height))
            {
                using (var g = Graphics.FromImage(bm))
                {
                    if (this.Background.IsVisible())
                    {
                        using (var brush = this.Background.ToBrush())
                        {
                            g.FillRectangle(brush, 0, 0, this.Width, this.Height);
                        }
                    }

                    using (var rc = new GraphicsRenderContext(g) { RendersToScreen = false })
                    {
                        model.Update(true);
                        model.Render(rc, this.Width, this.Height);
                    }

                    bm.Save(stream, ImageFormat.Png);
                }
            }
        }
コード例 #16
0
ファイル: PngExporter.cs プロジェクト: huoxudong125/oxyplot
        /// <summary>
        /// Exports the specified <see cref="PlotModel" /> to a <see cref="Bitmap" />.
        /// </summary>
        /// <param name="model">The model to export.</param>
        /// <returns>A bitmap.</returns>
        public Bitmap ExportToBitmap(IPlotModel model)
        {
            var bm = new Bitmap(this.Width, this.Height);
            using (var g = Graphics.FromImage(bm))
            {
                if (this.Background.IsVisible())
                {
                    using (var brush = this.Background.ToBrush())
                    {
                        g.FillRectangle(brush, 0, 0, this.Width, this.Height);
                    }
                }

                using (var rc = new GraphicsRenderContext(g) { RendersToScreen = false })
                {
                    model.Update(true);
                    model.Render(rc, this.Width, this.Height);
                }

                bm.SetResolution(this.Resolution, this.Resolution);
                return bm;
            }
        }