SvgForeignObject.cs 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System.Drawing;
  2. using System.Drawing.Drawing2D;
  3. #pragma warning disable
  4. namespace Svg
  5. {
  6. /// <summary>
  7. /// The �foreignObject� element allows for inclusion of a foreign namespace which has its graphical content drawn by a different user agent
  8. /// </summary>
  9. [SvgElement("foreignObject")]
  10. public class SvgForeignObject : SvgVisualElement
  11. {
  12. public SvgForeignObject()
  13. {
  14. }
  15. /// <summary>
  16. /// Gets the <see cref="GraphicsPath"/> for this element.
  17. /// </summary>
  18. /// <value></value>
  19. public override System.Drawing.Drawing2D.GraphicsPath Path(ISvgRenderer renderer)
  20. {
  21. return GetPaths(this, renderer);
  22. }
  23. /// <summary>
  24. /// Gets the bounds of the element.
  25. /// </summary>
  26. /// <value>The bounds.</value>
  27. public override System.Drawing.RectangleF Bounds
  28. {
  29. get
  30. {
  31. var r = new RectangleF();
  32. foreach (var c in this.Children)
  33. {
  34. if (c is SvgVisualElement)
  35. {
  36. // First it should check if rectangle is empty or it will return the wrong Bounds.
  37. // This is because when the Rectangle is Empty, the Union method adds as if the first values where X=0, Y=0
  38. if (r.IsEmpty)
  39. {
  40. r = ((SvgVisualElement)c).Bounds;
  41. }
  42. else
  43. {
  44. var childBounds = ((SvgVisualElement)c).Bounds;
  45. if (!childBounds.IsEmpty)
  46. {
  47. r = RectangleF.Union(r, childBounds);
  48. }
  49. }
  50. }
  51. }
  52. return r;
  53. }
  54. }
  55. protected override bool Renderable { get { return false; } }
  56. ///// <summary>
  57. ///// Renders the <see cref="SvgElement"/> and contents to the specified <see cref="Graphics"/> object.
  58. ///// </summary>
  59. ///// <param name="renderer">The <see cref="Graphics"/> object to render to.</param>
  60. //protected override void Render(SvgRenderer renderer)
  61. //{
  62. // if (!Visible || !Displayable)
  63. // return;
  64. // this.PushTransforms(renderer);
  65. // this.SetClip(renderer);
  66. // base.RenderChildren(renderer);
  67. // this.ResetClip(renderer);
  68. // this.PopTransforms(renderer);
  69. //}
  70. public override SvgElement DeepCopy()
  71. {
  72. return DeepCopy<SvgForeignObject>();
  73. }
  74. public override SvgElement DeepCopy<T>()
  75. {
  76. var newObj = base.DeepCopy<T>() as SvgForeignObject;
  77. if (this.Fill != null)
  78. newObj.Fill = this.Fill.DeepCopy() as SvgPaintServer;
  79. return newObj;
  80. }
  81. }
  82. }
  83. #pragma warning restore