-
Notifications
You must be signed in to change notification settings - Fork 976
Expand file tree
/
Copy pathPlotView.Export.cs
More file actions
77 lines (69 loc) · 2.48 KB
/
Copy pathPlotView.Export.cs
File metadata and controls
77 lines (69 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="PlotBase.Export.cs" company="OxyPlot">
// Copyright (c) 2014 OxyPlot contributors
// </copyright>
// <summary>
// Represents a control that displays a <see cref="PlotModel" />.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace OxyPlot.Wpf
{
using System.Windows.Media.Imaging;
/// <summary>
/// Represents a control that displays a <see cref="PlotModel" />.
/// </summary>
public partial class PlotView
{
/// <summary>
/// Saves the PlotView as a bitmap.
/// </summary>
/// <param name="fileName">Name of the file.</param>
public void SaveBitmap(string fileName)
{
this.SaveBitmap(fileName, -1, -1);
}
/// <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>
public void SaveBitmap(string fileName, int width, int height)
{
if (width <= 0)
{
width = (int)this.ActualWidth;
}
if (height <= 0)
{
height = (int)this.ActualHeight;
}
PngExporter.Export(this.ActualModel, fileName, width, height);
}
/// <summary>
/// Saves the PlotView as xaml.
/// </summary>
/// <param name="fileName">Name of the file.</param>
public void SaveXaml(string fileName)
{
XamlExporter.Export(this.ActualModel, fileName, this.ActualWidth, this.ActualHeight);
}
/// <summary>
/// Renders the PlotView to xaml.
/// </summary>
/// <returns>The xaml.</returns>
public string ToXaml()
{
return XamlExporter.ExportToString(this.ActualModel, this.ActualWidth, this.ActualHeight);
}
/// <summary>
/// Renders the PlotView to a bitmap.
/// </summary>
/// <returns>A bitmap.</returns>
public BitmapSource ToBitmap()
{
var exporter = new PngExporter() { Width = (int)this.ActualWidth, Height = (int)this.ActualHeight };
return exporter.ExportToBitmap(this.ActualModel);
}
}
}