Exemplo n.º 1
0
 public static Svg ParseSvgFromReader(TextReader reader, ISvgColorMapper pSVGColorMapper)
 {
     try {
         var     xmlReader  = XmlReader.Create(reader);
         Picture picture    = new Picture();
         var     svgHandler = new SVGHandler(picture, pSVGColorMapper);
         svgHandler.Parse(xmlReader);
         Svg svg = new Svg(picture, svgHandler.getBounds(), svgHandler.getComputedBounds());
         return(svg);
     } catch (Exception e) {
         throw new SVGParseException(e);
     }
 }
Exemplo n.º 2
0
 public static Svg ParseSvgFromReader(TextReader reader, ISvgColorMapper pSVGColorMapper)
 {
     try {
         var xmlReader = XmlReader.Create (reader);
         Picture picture = new Picture();
         var svgHandler = new SVGHandler (picture, pSVGColorMapper);
         svgHandler.Parse (xmlReader);
         Svg svg = new Svg(picture, svgHandler.getBounds(), svgHandler.getComputedBounds());
         return svg;
     } catch (Exception e) {
         throw new SVGParseException(e);
     }
 }
Exemplo n.º 3
0
 public static Svg ParseSvgFromReader(TextReader reader, ISvgColorMapper pSVGColorMapper)
 {
     try {
         var readerSettings = new XmlReaderSettings();
         readerSettings.XmlResolver   = null;
         readerSettings.DtdProcessing = DtdProcessing.Ignore;
         var     xmlReader  = XmlReader.Create(reader, readerSettings);
         Picture picture    = new Picture();
         var     svgHandler = new SVGHandler(picture, pSVGColorMapper);
         svgHandler.Parse(xmlReader);
         Svg svg = new Svg(picture, svgHandler.getBounds(), svgHandler.getComputedBounds());
         return(svg);
     } catch (Exception e) {
         throw new SVGParseException(e);
     }
 }
Exemplo n.º 4
0
		public static Svg ParseSvgFromReader (TextReader reader, ISvgColorMapper pSVGColorMapper)
		{
			try {
				var readerSettings = new XmlReaderSettings();
				readerSettings.XmlResolver = null;
				readerSettings.DtdProcessing = DtdProcessing.Ignore;
				var xmlReader = XmlReader.Create (reader, readerSettings);
				Picture picture = new Picture();
				var svgHandler = new SVGHandler (picture, pSVGColorMapper);
				svgHandler.Parse (xmlReader);
				Svg svg = new Svg(picture, svgHandler.getBounds(), svgHandler.getComputedBounds());
				return svg;
			} catch (Exception e) {
				throw new SVGParseException(e);
			}
		}
Exemplo n.º 5
0
    void OnGUI()
    {
        EditorGUILayout.BeginVertical();

        GUILayout.Space(10);

        GUILayout.Label("Add a new Spline to your scene");

        GUILayout.Space(10);

        toggleSVG = EditorGUILayout.Toggle("Use SVG", toggleSVG);

        GUILayout.Space(5);

        fileSource = EditorGUILayout.ObjectField(fileSource, typeof(Object), false, GUILayout.Width(200)) as Object;

        GUILayout.Space(10);

        if (GUILayout.Button("New Spline", GUILayout.Width(200)))
        {
            if (toggleSVG)
            {
                if (fileSource != null)
                {
                    SVGHandler.ConvertToSplines(AssetDatabase.GetAssetPath(fileSource));
                }
            }
            else
            {
                Instantiate(splinePrefab);
            }

            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }

        EditorGUILayout.EndVertical();
    }
Exemplo n.º 6
0
    // What to do when the user wants to export a SVG file
    private void exportHandler(object sender, EventArgs e)
    {
        Stream stream;
        SaveFileDialog saveFileDialog = new SaveFileDialog();

        saveFileDialog.Filter = "SVG files|*.svg";
        saveFileDialog.RestoreDirectory = true;

        if(saveFileDialog.ShowDialog() == DialogResult.OK)
        {
            if((stream = saveFileDialog.OpenFile()) != null)
            {
                SVGHandler drawhandler = new SVGHandler();

                drawhandler.Draw(shapes);

                using(StreamWriter writer = new StreamWriter(stream))
                {
                    foreach (string s in drawhandler.SVGOutput)
                        writer.WriteLine(s);
                }
            }
        }
    }