예제 #1
0
        private void Panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (!loaded)
            {
                return;
            }
            if (!Panel1.Bounds.Contains(Panel1.PointToClient(Cursor.Position)))
            {
                return;
            }
            Point chunkpoint = new Point((e.X + HScrollBar1.Value) / 32, (e.Y + VScrollBar1.Value) / 32);

            if (e.Button == MouseButtons.Left)
            {
                TileIndex ti = new TileIndex();
                ti.XFlip  = checkBox1.Checked;
                ti.Rotate = (byte)domainUpDown1.SelectedIndex;
                ti.Tile   = (ushort)tileList1.SelectedIndex;
                map[chunkpoint.X, chunkpoint.Y] = ti;
            }
            if (chunkpoint != lastchunkpoint)
            {
                DrawLevel();
            }
            lastchunkpoint = chunkpoint;
        }
예제 #2
0
        internal void DrawLevel()
        {
            if (!loaded)
            {
                return;
            }
            LevelGfx.Clear(palette[0]);
            LevelImg8bpp.Clear();
            Point pnlcur = Panel1.PointToClient(Cursor.Position);

            for (int y = Math.Max(VScrollBar1.Value / 32, 0); y <= Math.Min((VScrollBar1.Value + (Panel1.Height - 1)) / 32, map.GetLength(1) - 1); y++)
            {
                for (int x = Math.Max(HScrollBar1.Value / 32, 0); x <= Math.Min((HScrollBar1.Value + (Panel1.Width - 1)) / 32, map.GetLength(0) - 1); x++)
                {
                    if (map[x, y].Tile < tiles.Count)
                    {
                        LevelImg8bpp.DrawBitmapComposited(flippedtiles[map[x, y].List][map[x, y].Tile], new Point(x * 32 - HScrollBar1.Value, y * 32 - VScrollBar1.Value));
                    }
                }
            }
            LevelGfx.DrawImage(LevelImg8bpp.ToBitmap(palette), 0, 0, LevelImg8bpp.Width, LevelImg8bpp.Height);
            BitmapBits bmp2 = new BitmapBits(tiles[tileList1.SelectedIndex]);

            bmp2.Rotate((byte)domainUpDown1.SelectedIndex);
            bmp2.Flip(checkBox1.Checked, false);
            LevelGfx.DrawImage(bmp2.ToBitmap(palette),
                               new Rectangle((((pnlcur.X + HScrollBar1.Value) / 32) * 32) - HScrollBar1.Value, (((pnlcur.Y + VScrollBar1.Value) / 32) * 32) - VScrollBar1.Value, 32, 32),
                               0, 0, 32, 32,
                               GraphicsUnit.Pixel, imageTransparency);
            PanelGfx.DrawImage(LevelBmp, 0, 0, Panel1.Width, Panel1.Height);
        }
예제 #3
0
        private void Panel1_MouseClick_1(object sender, EventArgs e)
        {
            string fila = "";
            string columna = "";
            int    SizeSquare = 36;
            int    i, j;

            i = (Panel1.PointToClient(Cursor.Position).X) / SizeSquare;
            j = (Panel1.PointToClient(Cursor.Position).Y) / SizeSquare;

            fila = (8 - j).ToString();

            switch (i + 1)
            {
            case 1:
                columna = "a";
                break;

            case 2:
                columna = "b";
                break;

            case 3:
                columna = "c";
                break;

            case 4:
                columna = "d";
                break;

            case 5:
                columna = "e";
                break;

            case 6:
                columna = "f";
                break;

            case 7:
                columna = "g";
                break;

            case 8:
                columna = "h";
                break;

            default:
                columna = "x";
                break;
            }



            if (FetOrigen == false)
            {
                // un torn mes
                ply++;

                OrigenX   = j;
                OrigenY   = i;
                FetOrigen = true;
                DibuixaQuadrat(i, j);

                figMou = tauler[OrigenX, OrigenY];

                if ((ply + 1) % 2 != 0)
                {
                    tb_PGN.Text = tb_PGN.Text + ((ply + 1) / 2) + "." + figMouAPrint(figMou);
                }
                else
                {
                    tb_PGN.Text = tb_PGN.Text + figMouAPrint(figMou);
                }
            }
            else
            {
                DestiX    = j;
                DestiY    = i;
                FetOrigen = false;
                tauler[DestiX, DestiY]   = tauler[OrigenX, OrigenY];
                tauler[OrigenX, OrigenY] = 0;
                DibuixaCassella(OrigenX, OrigenY);
                DibuixaCassella(DestiX, DestiY);

                tb_PGN.Text = tb_PGN.Text + columna + fila + " ";
            }
        }