// 將 json 資訊讀入 shapes private void LoadInformationToShapes(List <Shape> shapes) { shapes.Clear(); string text = ReadFile(Constant.FILE_NAME); ShapesConverter converter = new ShapesConverter(); converter.ConvertToShapes(text); List <Shape> textToShapes = converter.Shapes; foreach (Shape shape in textToShapes) { shapes.Add(shape.Clone() as Shape); } }
// 儲存 shapes information 成 json file private void SaveFile(List <Shape> shapes, string directory) { ShapesConverter converter = new ShapesConverter(); converter.ConvertToText(shapes); string text = converter.Text; string currentDirectory = directory; string filePath = Constant.FILE_NAME; System.IO.StreamWriter file = new System.IO.StreamWriter(filePath, false); file.Write(text); file.Close(); file.Dispose(); }