public void RunGlyLoadSaveTest() { const string filename = "test.gly"; CodeList codes = RasterLib.RasterApi.CreateCodes(); //Create some codeString const string cubeCode1 = "Testx4,Size3D4 4 4 4;PenColorD4 255 255 255 255;FillRect 0 0 0 4 4 4"; const string cubeCode2 = "Testx8,Size3D4 8 8 8;PenColorD4 255 255 255 255;FillRect 0 0 0 8 8 8"; //Add them to codes codes.AddCode(RasterLib.RasterApi.CreateCode(cubeCode1)); codes.AddCode(RasterLib.RasterApi.CreateCode(cubeCode2)); //Write them to file RasterLib.RasterApi.CodesToGly(filename, codes); //Then read them back CodeList codes2 = RasterLib.RasterApi.GlyToCodes(filename); Assert.IsTrue(codes.Count == codes2.Count); for (int i = 0; i < codes.Count; i++) { string code1 = codes.GetCode(i).codeString; string code2 = codes2.GetCode(i).codeString; Assert.IsTrue(String.CompareOrdinal(code1, code2) == 0); } }
//Read and return series of Glyphics codeString from a file public static CodeList GlyToCodes(string filename) { CodeList codes = new CodeList(); using (var file = new System.IO.StreamReader(filename)) { string line; while ((line = file.ReadLine()) != null) { string codeString = line; //if (!line.Contains(",")) codeString = "noname," + codeString; Console.WriteLine("Loading " + codeString.Split('*')[0].Split(',')[0]); Code code = new Code(codeString); codes.AddCode(code); } } return(codes); }