本文整理汇总了C#中PlotModel类的典型用法代码示例。如果您正苦于以下问题:C# PlotModel类的具体用法?C# PlotModel怎么用?C# PlotModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlotModel类属于命名空间,在下文中一共展示了PlotModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Export
/// <summary>
/// Exports the specified plot model to a xaml file.
/// </summary>
/// <param name="model">The model.</param>
/// <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 static void Export(PlotModel model, string fileName, double width, double height, OxyColor background)
{
using (var w = new StreamWriter(fileName))
{
w.Write(ExportToString(model, width, height, background));
}
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:15,代码来源:XamlExporter.cs
示例2: Export
/// <summary>
/// Exports the specified model to a file.
/// </summary>
/// <param name="model">
/// The model.
/// </param>
/// <param name="path">
/// The path.
/// </param>
/// <param name="width">
/// The width (points).
/// </param>
/// <param name="height">
/// The height (points).
/// </param>
public static void Export(PlotModel model, string path, double width, double height)
{
using (FileStream s = File.Create(path))
{
Export(model, s, width, height);
}
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:22,代码来源:PdfExporter.cs
示例3: Render
/// <summary>
/// Renders the polygon annotation.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="model">The plot model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
base.Render(rc, model);
this.screenPosition = this.Transform(this.X, this.Y);
// clip to the area defined by the axes
var clippingRectangle = this.GetClippingRect();
rc.DrawMarker(clippingRectangle, this.screenPosition, this.Shape, this.CustomOutline, this.Size, this.Fill, this.Stroke, this.StrokeThickness);
if (!string.IsNullOrEmpty(this.Text))
{
var dx = -(int)this.TextHorizontalAlignment * (this.Size + this.TextMargin);
var dy = -(int)this.TextVerticalAlignment * (this.Size + this.TextMargin);
var textPosition = this.screenPosition + new ScreenVector(dx, dy);
rc.DrawClippedText(
clippingRectangle,
textPosition,
this.Text,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
this.TextRotation,
this.TextHorizontalAlignment,
this.TextVerticalAlignment);
}
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:34,代码来源:PointAnnotation.cs
示例4: ExportToString_TestPlot_ValidSvgString
public void ExportToString_TestPlot_ValidSvgString()
{
var plotModel = new PlotModel { Title = "Test plot" };
plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
var svg = SvgExporter.ExportToString(plotModel, 800, 500, false);
SvgAssert.IsValidElement(svg);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:7,代码来源:SvgExporterTests.cs
示例5: 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
示例6: Render
/// <summary>
/// Renders the polygon annotation.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="model">The plot model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
base.Render(rc, model);
this.screenRectangle = new OxyRect(this.Transform(this.X - (this.Width / 2), this.Y - (this.Height / 2)), this.Transform(this.X + (this.Width / 2), this.Y + (this.Height / 2)));
// clip to the area defined by the axes
var clippingRectangle = this.GetClippingRect();
rc.DrawClippedEllipse(
clippingRectangle,
this.screenRectangle,
this.GetSelectableFillColor(this.Fill),
this.GetSelectableColor(this.Stroke),
this.StrokeThickness);
if (!string.IsNullOrEmpty(this.Text))
{
var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center);
rc.DrawClippedText(
clippingRectangle,
textPosition,
this.Text,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
this.TextRotation,
this.TextHorizontalAlignment,
this.TextVerticalAlignment);
}
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:37,代码来源:EllipseAnnotation.cs
示例7: AddAxisTwice
public void AddAxisTwice()
{
var model = new PlotModel();
var axis = new LinearAxis();
model.Axes.Add(axis);
Assert.Throws<InvalidOperationException>(() => model.Axes.Add(axis));
}
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:7,代码来源:PlotModelTests.cs
示例8: Export
/// <summary>
/// Exports the specified plot model to a file.
/// </summary>
/// <param name="model">The model to export.</param>
/// <param name="fileName">The file name.</param>
/// <param name="width">The width of the output bitmap.</param>
/// <param name="height">The height of the output bitmap.</param>
/// <param name="background">The background color. The default value is <c>null</c>.</param>
/// <param name="resolution">The resolution (resolution). The default value is 96.</param>
public static void Export(PlotModel model, string fileName, int width, int height, OxyColor background, int resolution = 96)
{
using (var s = File.Create(fileName))
{
Export(model, s, width, height, background, resolution);
}
}
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:16,代码来源:PngExporter.cs
示例9: 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
示例10: Save
public static void Save(PlotModel model, string path, double width, double height)
{
using (var s = File.OpenWrite(path))
{
Save(model, s, width, height);
}
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:7,代码来源:PdfPlotWriter.cs
示例11: B11_Backgrounds
public void B11_Backgrounds()
{
var plot = new PlotModel("Backgrounds");
plot.Axes.Add(new LinearAxis(AxisPosition.Bottom, "X-axis"));
var yaxis1 = new LinearAxis(AxisPosition.Left, "Y1") { Key = "Y1", StartPosition = 0, EndPosition = 0.5 };
var yaxis2 = new LinearAxis(AxisPosition.Left, "Y2") { Key = "Y2", StartPosition = 0.5, EndPosition = 1 };
plot.Axes.Add(yaxis1);
plot.Axes.Add(yaxis2);
Action<LineSeries> addExamplePoints = ls =>
{
ls.Points.Add(new DataPoint(3, 13));
ls.Points.Add(new DataPoint(10, 47));
ls.Points.Add(new DataPoint(30, 23));
ls.Points.Add(new DataPoint(40, 65));
ls.Points.Add(new DataPoint(80, 10));
};
var ls1 = new LineSeries { Background = OxyColors.LightSeaGreen, YAxisKey = "Y1" };
addExamplePoints(ls1);
plot.Series.Add(ls1);
var ls2 = new LineSeries { Background = OxyColors.LightSkyBlue, YAxisKey = "Y2" };
addExamplePoints(ls2);
plot.Series.Add(ls2);
// OxyAssert.AreEqual(plot, "B11");
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:28,代码来源:PlotModelTests.cs
示例12: AreEqual
/// <summary>
/// Asserts that a plot is equal to the plot stored in the "baseline" folder.
/// 1. Renders the plot to file.svg
/// 2. If the baseline does not exist, the current plot is copied to the baseline folder.
/// 3. Checks that the svg file is equal to a baseline svg.
/// </summary>
/// <param name="plot">The plot.</param>
/// <param name="name">The name of the baseline file.</param>
public static void AreEqual(PlotModel plot, string name)
{
// string name = new System.Diagnostics.StackFrame(1).GetMethod().Name;
string path = name + ".svg";
string baseline = @"baseline\" + path;
using (var s = File.Create(path))
{
var rc = new ShapesRenderContext(null);
SvgExporter.Export(plot, s, 800, 500, false, rc);
}
if (!Directory.Exists("baseline"))
{
Directory.CreateDirectory("baseline");
}
if (!File.Exists(baseline))
{
File.Copy(path, baseline);
return;
}
var baselineSvg = File.ReadAllText(baseline);
var actualSvg = File.ReadAllText(path);
Assert.IsTrue(string.Equals(baselineSvg, actualSvg), "Actual svg is not equal to baseline (" + Path.GetFullPath(baseline) + ")");
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:35,代码来源:OxyAssert.cs
示例13: Export
/// <summary>
/// Exports the specified plot model to a xaml file.
/// </summary>
/// <param name="model">The model.</param>
/// <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 static void Export(PlotModel model, string fileName, double width, double height, OxyColor background)
{
using (var sw = new StreamWriter(fileName))
{
var xw = XmlWriter.Create(sw, new XmlWriterSettings { Indent = true });
Export(model, xw, width, height, background);
}
}
开发者ID:apmKrauser,项目名称:RCUModulTest,代码行数:16,代码来源:XamlExporter.cs
示例14: AddAxisToDifferentModels
public void AddAxisToDifferentModels()
{
var model1 = new PlotModel();
var model2 = new PlotModel();
var axis = new LinearAxis();
model1.Axes.Add(axis);
Assert.Throws<InvalidOperationException>(() => model2.Axes.Add(axis));
}
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:8,代码来源:PlotModelTests.cs
示例15: ExportToString_TestPlot_ValidSvgString
public void ExportToString_TestPlot_ValidSvgString()
{
var plotModel = new PlotModel("Test plot");
plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
var rc = new ShapesRenderContext(null);
var svg = SvgExporter.ExportToString(plotModel, 800, 500, false, rc);
SvgAssert.IsValidElement(svg);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:8,代码来源:SvgExporterTests.cs
示例16: GetFromOtherThread
public void GetFromOtherThread()
{
var model = new PlotModel();
var plotView = new PlotView { Model = model };
PlotModel actualModel = null;
Task.Factory.StartNew(() => actualModel = plotView.ActualModel).Wait();
Assert.AreEqual(model, actualModel);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:8,代码来源:PlotViewTests.cs
示例17: Export
/// <summary>
/// Exports the specified plot model to a stream.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="stream">The stream.</param>
/// <param name="width">The width.</param>
/// <param name="height">The height.</param>
/// <param name="background">The background.</param>
/// <param name="resolution">The resolution.</param>
public static void Export(PlotModel model, Stream stream, int width, int height, OxyColor background = null, int resolution = 96)
{
var bmp = ExportToBitmap(model, width, height, background);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
encoder.Save(stream);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:18,代码来源:PngExporter.cs
示例18: Export_Unicode
public void Export_Unicode()
{
var model = new PlotModel { Title = "Unicode support ☺", DefaultFont = "Arial" };
model.Axes.Add(new LinearAxis { Title = "λ", Position = AxisPosition.Bottom });
model.Axes.Add(new LinearAxis { Title = "Ж", Position = AxisPosition.Left });
var exporter = new PdfExporter { Width = 400, Height = 400 };
using (var stream = File.OpenWrite("Unicode.pdf"))
{
exporter.Export(model, stream);
}
}
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:11,代码来源:PdfExporterTests.cs
示例19: Export_TestPlot_ValidSvgString
public void Export_TestPlot_ValidSvgString()
{
var plotModel = new PlotModel { Title = "Test plot" };
const string FileName = "SvgExporterTests_Plot1.svg";
plotModel.Series.Add(new FunctionSeries(Math.Sin, 0, Math.PI * 8, 200, "Math.Sin"));
using (var s = File.Create(FileName))
{
SvgExporter.Export(plotModel, s, 800, 500, true);
}
SvgAssert.IsValidFile(FileName);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:12,代码来源:SvgExporterTests.cs
示例20: AutoPlotMargins
public void AutoPlotMargins()
{
var plot = new PlotModel { Title = "Auto PlotMargins" };
var verticalAxis = new LinearAxis { Position = AxisPosition.Left };
var horizontalAxis = new LinearAxis { Position = AxisPosition.Bottom };
plot.Axes.Add(verticalAxis);
plot.Axes.Add(horizontalAxis);
plot.UpdateAndRenderToNull(800, 600);
Assert.That(plot.ActualPlotMargins.Left, Is.EqualTo(26).Within(1), "left");
Assert.That(plot.ActualPlotMargins.Top, Is.EqualTo(0).Within(1), "top");
Assert.That(plot.ActualPlotMargins.Right, Is.EqualTo(0).Within(1), "right");
Assert.That(plot.ActualPlotMargins.Bottom, Is.EqualTo(21).Within(1), "bottom");
}
开发者ID:huoxudong125,项目名称:oxyplot,代码行数:13,代码来源:PlotModelTests.cs
注:本文中的PlotModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论