Example #1
0
        public void Delbox()
        {
            BoxCard box;
            int     i = 0;

            do
            {
                if (panel1.Controls[i] is BoxCard)
                {
                    box       = (BoxCard)panel1.Controls[i];
                    box.Image = null;
                    box       = new BoxCard();
                    box       = null;
                    panel1.Controls.Remove(panel1.Controls[i]);
                    i = 0;
                }
                i++;
            } while (panel1.Controls.Count != i);
            box       = (BoxCard)panel1.Controls[0];
            box.Image = null;
            box       = new BoxCard();
            box       = null;
            panel1.Controls.Remove(panel1.Controls[0]);
            GC.Collect();
            Gen();
        }
Example #2
0
        private void box_MouseDown(object sender, MouseEventArgs e)
        {
            BoxCard box = (BoxCard)sender;

            box.BringToFront();
            box.Image = new Bitmap(@"Card\" + box.valueC + @"\" + box.Suit + @".png");
            box.Size  = new Size(box.Size.Width + 50, box.Size.Height + 50);
            drag      = true;
            offsetX   = e.Location.X;
            offsetY   = e.Location.Y;
        }
Example #3
0
        public void Gen()
        {
            string[] suit = { "Booba", "Cherva", "Cross", "Pica" };
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    BoxCard box = new BoxCard
                    {
                        Parent    = panel1,
                        Location  = new System.Drawing.Point(this.Width - this.Width / 4, this.Height - this.Height / 2),
                        Name      = "Cards" + CardsName[i],
                        Size      = new System.Drawing.Size(765 / 3, 1054 / 3),
                        TabIndex  = 0,
                        TabStop   = false,
                        Suit      = suit[j],
                        valueC    = CardsName[i],
                        Image     = new Bitmap(@"Card\fon.png"),
                        BackColor = Color.Transparent,
                        SizeMode  = PictureBoxSizeMode.StretchImage
                    };
                    box.MouseDown += new System.Windows.Forms.MouseEventHandler(this.box_MouseDown);
                    box.MouseUp   += new System.Windows.Forms.MouseEventHandler(this.box_MouseUp);
                    box.MouseMove += new System.Windows.Forms.MouseEventHandler(this.box_MouseMove);
                }
            }
            Random ran = new Random();

            for (int i = 0; i < 100; i++)
            {
                int temp = ran.Next(0, panel1.Controls.Count);
                if (panel1.Controls[temp] is BoxCard)
                {
                    BoxCard box = (BoxCard)panel1.Controls[temp];
                    box.BringToFront();
                }
            }
        }