SvgWindow.cs :  » GUI » SharpVectorGraphics » SharpVectors » Dom » Svg » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GUI » SharpVectorGraphics 
SharpVectorGraphics » SharpVectors » Dom » Svg » SvgWindow.cs
using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Text;
using System.Windows.Forms;
using System.Xml;

using SharpVectors.Collections;
using SharpVectors.Dom.Svg.Rendering;
using SharpVectors.Dom.Events;
using SharpVectors.Xml;

namespace SharpVectors.Dom.Svg{
  public class SvgWindow : ISvgWindow
  {
    #region Contructors
    [Obsolete("This constructor is obsolete and will be removed in future versions.")]
    public SvgWindow(long innerWidth, long innerHeight)
    {
      this.innerWidth = innerWidth;
      this.innerHeight = innerHeight;
    }

    public SvgWindow(long innerWidth, long innerHeight, ISvgRenderer renderer)
    {
      this.renderer = renderer;
      if(this.renderer != null)
      {
        this.renderer.Window = this;
      }

      this.innerWidth = innerWidth;
      this.innerHeight = innerHeight;
    }

    public SvgWindow(SvgWindow parentWindow, long innerWidth, long innerHeight) : this(innerWidth, innerHeight, parentWindow.Renderer)
    {
      this.parentWindow = parentWindow;
    }

    public SvgWindow(Control control, ISvgRenderer renderer)
    {
      if ( control == null )
      {
        throw new NullReferenceException( "control cannot be null" );
      }
      else
      {
        this.control = control;
        this.renderer = renderer;
        this.renderer.Window = this;
      }
    }
    #endregion
        
    #region Private fields
    private Control control = null;
    private Hashtable referencedWindows = new Hashtable();
    private Hashtable referencedFiles = new Hashtable();
    #endregion

    #region Public properties
    private SvgWindow parentWindow = null;
    public SvgWindow ParentWindow
    {
      get
      {
        return parentWindow;
      }
    }

    private ISvgRenderer renderer;
    public ISvgRenderer Renderer
    {
      get { return renderer; }
      set { renderer = value; }
    }
    #endregion

    #region Public methods
    /// <summary>
    /// Create and assign an empty SvgDocument to this window.  This is needed only in situations where the library user needs to create an SVG DOM tree outside of the usual LoadSvgDocument mechanism.
    /// </summary>
    public SvgDocument CreateEmptySvgDocument()
    {
      return document = new SvgDocument(this);
    }
    #endregion

    #region Implementation of ISvgWindow
    private long innerWidth;
    public long InnerWidth
    {
      get
      {
        if(control != null)
        {
          return control.Width;
        }
        else
        {
          return innerWidth;
        }
      }
      set
      {
        this.innerWidth = value;
      }
    }

    private long innerHeight;
    public long InnerHeight
    {
      get
      {
        if(control != null)
        {
          return control.Height;
        }
        else
        {
          return innerHeight;
        }
      }
      set
      {
        this.innerHeight = value;
      }
    }

    public XmlDocumentFragment ParseXML(string source, XmlDocument document)
    {
      XmlDocumentFragment frag = document.CreateDocumentFragment();
      frag.InnerXml = source;
      return frag;
    }

    public string PrintNode(System.Xml.XmlNode node)
    {
      return node.OuterXml;
    }

    public SharpVectors.Dom.Stylesheets.IStyleSheet DefaultStyleSheet
    {
      get
      {
        return null;
      }
    }

    private SvgDocument document;
    public ISvgDocument Document
    {
      get
      {
        return document;
      }
      set
      {
        document = (SvgDocument)value;
      }
    }

    public void Alert(string message)
    {
      MessageBox.Show(message);
    }

    public string Src
    {
      get
      {
        return (document != null) ? document.Url : String.Empty;
      }
      set
      {
        Uri uri = new Uri(new Uri(Application.ExecutablePath), value);

        document = new SvgDocument(this);
        document.Load(uri.AbsoluteUri);
      }
    }

    /// <summary>
    /// This is expected to be called by the host
    /// </summary>
    /// <param name="width">The new width of the control</param>
    /// <param name="height">The new height of the control</param>
    public void Resize(int innerWidth, int innerHeight) 
    {
      this.innerWidth = innerWidth;
      this.innerHeight = innerHeight;
      if (Document != null && Document.RootElement != null)
        (Document.RootElement as SvgSvgElement).Resize();
    }
    #endregion
  }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.