private static uint GetColor(RealmTile tile)
 {
     if (tile.Region == RealmTileRegion.Spawn)
     {
         return(0xffff0000);
     }
     return(RealmTileTypes.color[tile.TileId]);
 }
 private void pic_MouseMove(object sender, MouseEventArgs e)
 {
     if (mode == Mode.Erase && (MouseButtons & MouseButtons.Left) != 0)
     {
         Point center = e.Location;
         for (int y = -10; y <= 10; y++)
         {
             for (int x = -10; x <= 10; x++)
             {
                 if (x * x + y * y <= 10 * 10)
                 {
                     tiles[center.X + x, center.Y + y].Terrain   = RealmTerrainType.None;
                     tiles[center.X + x, center.Y + y].Elevation = 0;
                     tiles[center.X + x, center.Y + y].Biome     = "ocean";
                     tiles[center.X + x, center.Y + y].TileObj   = "";
                     tiles[center.X + x, center.Y + y].TileId    = RealmTileTypes.DeepWater;
                     tiles[center.X + x, center.Y + y].Region    = RealmTileRegion.None;
                     tiles[center.X + x, center.Y + y].Name      = "";
                     bmp.SetPixel(center.X + x, center.Y + y, Color.FromArgb(
                                      (int)GetColor(tiles[center.X + x, center.Y + y])));
                 }
             }
         }
         pic.Invalidate();
         pic2.Invalidate();
     }
     else if (mode == Mode.Average && (MouseButtons & MouseButtons.Left) != 0)
     {
         Point center = e.Location;
         Dictionary <RealmTile, int> dict = new Dictionary <RealmTile, int>();
         for (int y = -10; y <= 10; y++)
         {
             for (int x = -10; x <= 10; x++)
             {
                 if (x * x + y * y <= 10 * 10)
                 {
                     RealmTile t = tiles[center.X + x, center.Y + y];
                     if (dict.ContainsKey(t))
                     {
                         dict[t]++;
                     }
                     else
                     {
                         dict[t] = 0;
                     }
                 }
             }
         }
         int       maxOccurance = dict.Values.Max();
         RealmTile targetTile   = dict.First(t => t.Value == maxOccurance).Key;
         for (int y = -10; y <= 10; y++)
         {
             for (int x = -10; x <= 10; x++)
             {
                 if (x * x + y * y <= 10 * 10)
                 {
                     tiles[center.X + x, center.Y + y] = targetTile;
                     bmp.SetPixel(center.X + x, center.Y + y, Color.FromArgb(
                                      (int)GetColor(tiles[center.X + x, center.Y + y])));
                 }
             }
         }
         pic.Invalidate();
         pic2.Invalidate();
     }
 }