using System;
using System.Windows;
using System.Windows.Media;
using SharpVectors.Renderers.Wpf;
namespace SharpVectors.Converters
{
///
/// This is the base class for all
/// SVG to WPF converters.
///
public abstract class SvgConverter : DependencyObject, IDisposable
{
#region Private Fields
private bool _saveXaml;
private bool _saveZaml;
private bool _useFrameXamlWriter;
private WpfDrawingSettings _wpfSettings;
#endregion
#region Constructors and Destrutor
///
/// Initializes a new instance of the class.
///
///
/// Initializes a new instance of the class
/// with the default parameters and settings.
///
protected SvgConverter()
: this(null)
{
}
///
/// Initializes a new instance of the class
/// with the specified drawing or rendering settings.
///
///
/// This specifies the settings used by the rendering or drawing engine.
/// If this is , the default settings is used.
///
protected SvgConverter(WpfDrawingSettings settings)
{
_saveXaml = true;
_saveZaml = false;
_wpfSettings = settings;
if (_wpfSettings == null)
{
_wpfSettings = new WpfDrawingSettings();
}
}
///
/// Initializes a new instance of the class
/// with the specified drawing or rendering settings and the saving options.
///
///
/// This specifies whether to save result object tree in XAML file.
///
///
/// This specifies whether to save result object tree in ZAML file. The
/// ZAML is simply a G-Zip compressed XAML format, similar to the SVGZ.
///
///
/// This specifies the settings used by the rendering or drawing engine.
/// If this is , the default settings is used.
///
protected SvgConverter(bool saveXaml, bool saveZaml,
WpfDrawingSettings settings) : this(settings)
{
_saveXaml = saveXaml;
_saveZaml = SaveZaml;
}
///
/// This allows a converter to attempt to free resources and perform
/// other cleanup operations before the converter is reclaimed by
/// garbage collection.
///
~SvgConverter()
{
this.Dispose(false);
}
#endregion
#region Public Properties
///
/// Gets or sets a value indicating whether to save the conversion
/// output to the XAML file.
///
///
/// This is if the conversion output is saved
/// to the XAML file; otherwise, it is .
/// The default depends on the converter.
///
public bool SaveXaml
{
get
{
return _saveXaml;
}
set
{
_saveXaml = value;
}
}
///
/// Gets or sets a value indicating whether to save the conversion
/// output to the ZAML file.
///
///
/// This is if the conversion output is saved
/// to the ZAML file; otherwise, it is .
/// The default depends on the converter.
///
///
/// The ZAML is simply a G-Zip compressed XAML format, similar to the
/// SVGZ.
///
public bool SaveZaml
{
get
{
return _saveZaml;
}
set
{
_saveZaml = value;
}
}
///
/// Gets or sets a value indicating whether to use the .NET framework
/// version of the XAML writer.
///
///
/// This is if the .NET framework version of the
/// XAML writer is used; otherwise, a customized XAML writer,
/// , is used. The default is .
///
///
/// The customized XAML writer is optimized for the conversion process,
/// and it is recommended as the writer, unless in cases where it fails
/// to produce accurate result.
///
public bool UseFrameXamlWriter
{
get
{
return _useFrameXamlWriter;
}
set
{
_useFrameXamlWriter = value;
}
}
///
/// Gets the settings used by the rendering or drawing engine.
///
///
/// An instance of specifying all
/// the options for rendering or drawing.
///
public WpfDrawingSettings DrawingSettings
{
get
{
return _wpfSettings;
}
}
#endregion
#region IDisposable Members
///
/// This releases all resources used by the object.
///
///
/// This releases all resources used by the object.
///
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
///
/// This releases the unmanaged resources used by the
/// and optionally releases the managed resources.
///
///
/// This is if managed resources should be
/// disposed; otherwise, .
///
protected virtual void Dispose(bool disposing)
{
}
#endregion
}
}