// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) 2014 OxyPlot contributors
//
//
// Provides extension methods for .
//
// --------------------------------------------------------------------------------------------------------------------
namespace OxyPlot.Tests
{
using System.Diagnostics;
using System.IO;
///
/// Provides extension methods for .
///
public static class PortableDocumentExtensions
{
///
/// Saves the document at the specified path.
///
/// The document.
/// The path.
/// Open Windows explorer on the specified path if set to true.
public static void Save(this PortableDocument doc, string path, bool explore = false)
{
var directory = Path.GetDirectoryName(path);
if (directory != null && !Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
using (var stream = File.Create(path))
{
doc.Save(stream);
}
if (explore)
{
Process.Start("explorer.exe", "/select," + path);
}
}
///
/// Draws a cross at the specified position.
///
/// The document.
/// The center x-coordinate.
/// The center y-coordinate.
/// The size of the cross.
public static void DrawCross(this PortableDocument doc, double x, double y, double size = 10)
{
doc.MoveTo(x - size, y);
doc.LineTo(x + size, y);
doc.MoveTo(x, y - size);
doc.LineTo(x, y + size);
doc.Stroke(false);
}
}
}