Beispiel #1
0
        //отрисовка при ходе
        private void  Drow(int x, int y, int x1, int y1)
        {
            Graphics g      = PanelChess.CreateGraphics();
            int      square = 50;
            Bitmap   b      = new Bitmap(@"figures2.png");

            b.MakeTransparent(Color.FromArgb(100, 100, 100));
            Size      size   = new Size(square, square);
            Point     point  = new Point(x * square, y * square);
            Point     point1 = new Point(x1 * square, y1 * square);
            Rectangle r      = new Rectangle(point, size);
            Rectangle r2     = new Rectangle(point1, size);

            if ((x % 2 == 0 && y % 2 == 0) || (x % 2 != 0 && y % 2 != 0))
            {
                g.FillRectangle(Brushes.Chocolate, r);
            }
            else
            {
                g.FillRectangle(Brushes.White, r);
            }
            if ((x1 % 2 == 0 && y1 % 2 == 0) || (x1 % 2 != 0 && y1 % 2 != 0))
            {
                g.FillRectangle(Brushes.Chocolate, r2);
            }
            else
            {
                g.FillRectangle(Brushes.White, r2);
            }

            for (int i = 0; i < figures.Count; i++)
            {
                Rectangle sorce = new Rectangle(figures[i].Position_Figures_On_Picture, figures[i].Position_Figyre_On_Picture_Down, 50, 50);
                Rectangle dest  = new Rectangle(figures[i].Position_X * 50, figures[i].Positiont_Y * 50, 50, 50);
                g.DrawImage(b, dest, sorce, GraphicsUnit.Pixel);
            }

            g.Dispose();
        }
Beispiel #2
0
        // отрисовка при запуске
        public void PaintTable(object sender, PaintEventArgs e)
        {
            Graphics g         = PanelChess.CreateGraphics();
            int      square    = 50;
            int      size_cage = 8;
            Bitmap   b         = new Bitmap(@"figures2.png");

            b.MakeTransparent(Color.FromArgb(100, 100, 100));
            Size size = new Size(square, square);

            //рісуєм доску

            for (int i = 0; i < size_cage; i++)
            {
                for (int j = 0; j < size_cage; j++)
                {
                    Point     point = new Point(j * square, i * square);
                    Rectangle r     = new Rectangle(point, size);
                    if ((i % 2 == 0 && j % 2 == 0) || (i % 2 != 0 && j % 2 != 0))
                    {
                        g.FillRectangle(Brushes.Chocolate, r);
                    }
                    else
                    {
                        g.FillRectangle(Brushes.White, r);
                    }
                }
            }

            for (int i = 0; i < figures.Count; i++)
            {
                Rectangle sorce = new Rectangle(figures[i].Position_Figures_On_Picture, figures[i].Position_Figyre_On_Picture_Down, 50, 50);
                Rectangle dest  = new Rectangle(figures[i].Position_X * 50, figures[i].Positiont_Y * 50, 50, 50);
                g.DrawImage(b, dest, sorce, GraphicsUnit.Pixel);
            }

            g.Dispose();
        }