Commit ebba7b35 authored by Tebjan Halm's avatar Tebjan Halm
Browse files

Merge pull request #67 from csmoore/master

Support for `"display=none"` #66
parents f099da1a c04111fc
......@@ -97,6 +97,9 @@ namespace Svg
/// </summary>
protected override void Render(SvgRenderer renderer)
{
if (!Visible || !Displayable)
return;
if (Width.Value > 0.0f && Height.Value > 0.0f && this.Href != null)
{
using (Image b = GetImage(this.Href))
......
......@@ -94,7 +94,7 @@ namespace Svg
/// <param name="renderer">The <see cref="SvgRenderer"/> object to render to.</param>
protected override void Render(SvgRenderer renderer)
{
if (this.Path != null && this.Visible)
if ((this.Path != null) && this.Visible && this.Displayable)
{
this.PushTransforms(renderer);
this.SetClip(renderer);
......
......@@ -26,6 +26,30 @@ namespace Svg
set { this.Attributes["visibility"] = value; }
}
/// <summary>
/// Gets or sets a value to determine whether the element will be rendered.
/// Needed to support SVG attribute display="none"
/// </summary>
[SvgAttribute("display")]
public virtual string Display
{
get { return this.Attributes["display"] as string; }
set { this.Attributes["display"] = value; }
}
// Displayable - false if attribute display="none", true otherwise
protected virtual bool Displayable
{
get
{
string checkForDisplayNone = this.Attributes["display"] as string;
if ((!string.IsNullOrEmpty(checkForDisplayNone)) && (checkForDisplayNone == "none"))
return false;
else
return true;
}
}
/// <summary>
/// Gets or sets the fill <see cref="SvgPaintServer"/> of this element.
/// </summary>
......
......@@ -68,6 +68,9 @@ namespace Svg
/// <param name="graphics">The <see cref="Graphics"/> object to render to.</param>
protected override void Render(SvgRenderer renderer)
{
if (!Visible || !Displayable)
return;
this.PushTransforms(renderer);
this.SetClip(renderer);
base.RenderChildren(renderer);
......
......@@ -80,6 +80,9 @@ namespace Svg
protected override void Render(SvgRenderer renderer)
{
if (!Visible || !Displayable)
return;
this.PushTransforms(renderer);
SvgVisualElement element = (SvgVisualElement)this.OwnerDocument.IdManager.GetElementById(this.ReferencedElement);
......
......@@ -43,8 +43,14 @@ namespace Svg
{
throw new ArgumentOutOfRangeException("value must be a string.");
}
return (string)value == "visible" ? true : false;
// Note: currently only used by SvgVisualElement.Visible but if
// conversion is used elsewhere these checks below will need to change
string visibility = (string)value;
if ((visibility == "hidden") || (visibility == "collapse"))
return false;
else
return true;
}
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment