Commit c04111fc authored by C Moore's avatar C Moore
Browse files

Requested Changes from PR #67 Review

Moved Display="none" hack & Added .Render check for : if (!Visible ||
!Displayable)

Also, minor change to logic of SvgBoolConverter so bad visibility values
(other than "hidden" or "collapse") wouldn't accidentally hide element
parent e82abc8f
......@@ -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);
......
......@@ -22,15 +22,7 @@ namespace Svg
[SvgAttribute("visibility")]
public virtual bool Visible
{
// Add a check for display="none" (that also affects/sets Visible)
get
{
string checkForDisplayNone = this.Attributes["display"] as string;
if ((!string.IsNullOrEmpty(checkForDisplayNone)) && (checkForDisplayNone == "none"))
return false;
else
return (this.Attributes["visibility"] == null) ? true : (bool)this.Attributes["visibility"];
}
get { return (this.Attributes["visibility"] == null) ? true : (bool)this.Attributes["visibility"]; }
set { this.Attributes["visibility"] = value; }
}
......@@ -45,6 +37,19 @@ namespace Svg
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,7 +68,7 @@ namespace Svg
/// <param name="graphics">The <see cref="Graphics"/> object to render to.</param>
protected override void Render(SvgRenderer renderer)
{
if (!Visible)
if (!Visible || !Displayable)
return;
this.PushTransforms(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