Пример #1
0
        protected void OpenDesignerLoad(string fileName, string level)
        {
            Designer.LoadLevel(fileName, level);
            int rows = Designer.GetRowCount();
            int cols = Designer.GetColumnCount();

            View.DesignerLoadLevel();

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    View.CreateLevelGridButton(r, c, Designer.WhatsAt(r, c));
                }
            }
        }
Пример #2
0
        public void Save(string fileName, IDesign filable)
        {
            List <string> theGrid = new List <string>();
            int           rows    = filable.GetRowCount();
            int           cols    = filable.GetColumnCount();
            StringBuilder sb      = new StringBuilder();

            for (int r = 0; r < rows; r++)
            {
                for (int c = 0; c < cols; c++)
                {
                    sb.Append((char)filable.WhatsAt(r, c));
                }
                sb.Append(',');
            }
            sb.Remove(sb.Length - 1, 1); //remove the last ,

            string compressed = Convert.Compress(sb.ToString());

            string[] fileLines = { "<" + FileManager.STATS + "></" + FileManager.STATS + ">",
                                   "<" + FileManager.GRID + ">" + compressed + "</" + FileManager.GRID + ">" };
            File.WriteAllLines(DIR + fileName + EXTENSION, fileLines);
        }