Esempio n. 1
0
        protected void AdapteBlockSizeAccordingToMapSize()
        {
            Rectangle r            = Screen.GetWorkingArea(this);
            int       newBlockSize = blockSize;

            while (newBlockSize > 1 && (map.GetWidth() * newBlockSize > r.Width || map.GetHeight() * newBlockSize > r.Height))
            {
                newBlockSize = newBlockSize / 2;
            }
            if (newBlockSize != blockSize)
            {
                ChangeBlockSize(newBlockSize);
            }
        }
Esempio n. 2
0
 public void LoadMapFromFile(string filename)
 {
     //Open the stream and read it back.
     using (FileStream fs = File.OpenRead(filename))
     {
         BinaryFormatter formatter = new BinaryFormatter();
         PositionMap     newMap    = (PositionMap)formatter.Deserialize(fs);
         if (newMap != null)
         {
             map = newMap;
             map.RestoreArrayFromList();//从List恢复内容到数组
             mapWidth  = map.GetWidth();
             mapHeight = map.GetHeight();
             ChangeMapSize(mapWidth, mapHeight);
             AdapteBlockSizeAccordingToMapSize();
             ClearTags();
             drawMap();
         }
         fs.Close();
     }
 }