コード例 #1
0
ファイル: FileControler.cs プロジェクト: lvendrame/p-atack
        public static void Save(string pstr_FullPathFileName, MatrixMapCell mtxMapCell, List <Brick> lstBricks, int pint_TileWidth, int pint_TileHeight)
        {
            string path = FileControler.GetPath(pstr_FullPathFileName);

            SaveBricks(lstBricks, path);
            MapInformation info        = new MapInformation(mtxMapCell, lstBricks, pint_TileWidth, pint_TileHeight);
            XmlSerializer  xSerializer = new XmlSerializer(typeof(MapInformation));

            System.IO.StreamWriter sWriter = new System.IO.StreamWriter(pstr_FullPathFileName, false);
            xSerializer.Serialize(sWriter, info);
            sWriter.Close();
        }
コード例 #2
0
ファイル: FileControler.cs プロジェクト: lvendrame/p-atack
        private static void SaveBricks(List <Brick> lstBricks, string path)
        {
            DirectoryInfo dir = new DirectoryInfo(path);

            path = Path.Combine(path, "Bricks");
            if (!Directory.Exists(path))
            {
                dir.CreateSubdirectory("Bricks");
            }

            for (int i = 0; i < lstBricks.Count; i++)
            {
                Brick brk = lstBricks[i];
                if (brk.IsNew && FileControler.GetPath(brk.ImagePath) != path)
                {
                    brk.Image.Save(Path.Combine(path, brk.ImagePath));
                }
                brk.IsNew     = false;
                brk.ImagePath = FileControler.GetFileName(brk.ImagePath);
            }
        }