Esempio n. 1
0
        private void tileClick(object sender, EventArgs e)
        {
            Console.WriteLine("oldSelectedTile changed from {0} to {1}", oldSelectedTile.ToString(), selectedTile.ToString());
            oldSelectedTile = selectedTile;


            foreach (TileSelector t in tilesPanel.Controls)
            {
                if (t.Location == oldSelectedTile)
                {
                    t.Image.Dispose();
                    t.Load(tileDirectory + t.Tag);
                    Console.WriteLine("oldTile reloaded from {0}", tileDirectory + t.Tag);
                }
            }

            TileSelector tile = (TileSelector)sender;

            Console.WriteLine("selectedTile changed from {0} to {1}", selectedTile.ToString(), tile.Location.ToString());
            selectedTile = tile.Location;
            Bitmap temp = (Bitmap)tile.Image;

            for (int x = 0; x < temp.Width; x += 2)
            {
                for (int y = 0; y < temp.Height; y += 2)
                {
                    temp.SetPixel(x, y, System.Drawing.Color.Blue);
                }
            }

            tile.Image = temp;
            tile.Refresh();
        }
Esempio n. 2
0
        private void tileClick(object sender, EventArgs e)
        {
            TileSelector sel = (TileSelector)sender;

            if (Control.ModifierKeys == Keys.Shift)
            {
                selectedTiles.Add(new SelectedTile((string)sel.Tag, sel.Location.X / 25, sel.Location.Y / 25));
            }
            //if no key is selected make sure the clear out the old selected tiles
            else
            {
                //refresh previously selected tiles
                foreach (TileSelector t in tilesPanel.Controls)
                {
                    foreach (SelectedTile s in selectedTiles)
                    {
                        if (t.Location.X == s.PositionX * 25 && t.Location.Y == s.PositionY * 25)
                        {
                            t.Image.Dispose();
                            t.Load(tileDirectory + t.Tag);
                            Console.WriteLine("oldTile reloaded from {0}", tileDirectory + t.Tag);
                        }
                    }
                }
                //empty the selected list
                selectedTiles.Clear();
                //add the newly select tile to the list
                selectedTiles.Add(new SelectedTile((string)sel.Tag, sel.Location.X / 25, sel.Location.Y / 25));
            }

            Bitmap temp = (Bitmap)sel.Image;

            for (int x = 0; x < temp.Width; x += 2)
            {
                for (int y = 0; y < temp.Height; y += 2)
                {
                    temp.SetPixel(x, y, System.Drawing.Color.Blue);
                }
            }

            sel.Image = temp;
            sel.Refresh();
        }