1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
1+ using FreeFrame . Components . Shapes ;
2+ using OpenTK . Mathematics ;
43using System . Text ;
5- using System . Text . RegularExpressions ;
6- using System . Threading . Tasks ;
74using System . Xml ;
8- using FreeFrame . Components . Shapes ;
9- using OpenTK . Mathematics ;
105
116namespace FreeFrame . Components
127{
138 public static class Importer
149 {
10+ /// <summary>
11+ /// Import shapes list and timeline from a stream
12+ /// </summary>
13+ /// <param name="pStream">Given stream</param>
14+ /// <returns>Shape list and timeline</returns>
15+ /// <exception cref="Exception">If something went wrong in the importation</exception>
1516 static private ( List < Shape > , SortedDictionary < int , List < Shape > > , bool ) ImportFromStream ( Stream pStream )
1617 {
1718 List < Shape > shapes = new List < Shape > ( ) ;
@@ -68,6 +69,13 @@ static private (List<Shape>, SortedDictionary<int, List<Shape>>, bool) ImportFro
6869 }
6970 return ( shapes , new SortedDictionary < int , List < Shape > > ( ) , compatibilityFlag ) ;
7071 }
72+
73+ /// <summary>
74+ /// Import shapes list and timeline from a file path
75+ /// </summary>
76+ /// <param name="pFilename">File path</param>
77+ /// <returns>Shape list and timeline</returns>
78+ /// <exception cref="ArgumentException">If file cannot be found</exception>
7179 static public ( List < Shape > , SortedDictionary < int , List < Shape > > , bool ) ImportFromFile ( string pFilename )
7280 {
7381 if ( ! File . Exists ( pFilename ) )
@@ -77,16 +85,27 @@ static public (List<Shape>, SortedDictionary<int, List<Shape>>, bool) ImportFrom
7785
7886 return ImportFromStream ( new MemoryStream ( byteArray ) ) ;
7987 }
88+
89+ /// <summary>
90+ /// Import shapes list and timeline from a string
91+ /// </summary>
92+ /// <param name="pString">Given string</param>
93+ /// <returns>Shape list and timeline</returns>
8094 static public ( List < Shape > , SortedDictionary < int , List < Shape > > , bool ) ImportFromString ( string pString )
8195 {
8296 byte [ ] byteArray = Encoding . UTF8 . GetBytes ( pString ) ;
8397
8498 return ImportFromStream ( new MemoryStream ( byteArray ) ) ;
8599 }
86100
101+ /// <summary>
102+ /// Export a given shape list into an svg file
103+ /// </summary>
104+ /// <param name="shapes">Shape list</param>
105+ /// <param name="clientSize">Window size</param>
106+ /// <param name="path">File path</param>
87107 static public void ExportToFile ( List < Shape > shapes , Vector2i clientSize , string path )
88108 {
89-
90109 using ( FileStream fs = new FileStream ( path , FileMode . Create ) )
91110 {
92111 byte [ ] bytes = Encoding . ASCII . GetBytes ( $@ "<?xml version=""1.0"" encoding=""utf-8"" ?>
@@ -107,6 +126,11 @@ static public void ExportToFile(List<Shape> shapes, Vector2i clientSize, string
107126 }
108127 }
109128
129+ /// <summary>
130+ /// Convert from a string to an Color4 value
131+ /// </summary>
132+ /// <param name="hexadecimal">hexadecimal string</param>
133+ /// <returns>Color4 value</returns>
110134 static public Color4 HexadecimalToRGB ( string hexadecimal )
111135 {
112136 float r = Convert . ToInt32 ( hexadecimal . Substring ( 1 , 2 ) , 16 ) / 255f ;
0 commit comments