示例#1
0
        public Form1()
        {
            InitializeComponent();
            // Initialize the user-defined button,
            // including defining handler for Click message,
            // location and size.
            myButtonObject myButton  = new myButtonObject();
            EventHandler   myHandler = new EventHandler(myButton_Click_1);

            myButton.Click   += myHandler;
            myButton.Location = new System.Drawing.Point(20, 20);
            myButton.Size     = new System.Drawing.Size(101, 101);
            this.Controls.Add(myButton);
        }
示例#2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (sinal == 1)
            {
                if (flpAjuda1.Controls.Count < n1)
                {
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda1.Controls.Add(myButton);
                }
                else if (aumenta && zoom < 10)
                {
                    picSinal.Image = Properties.Resources.maisCor;

                    timer1.Interval   = 250;
                    picSinal.Size     = new Size(picSinal.Width + 2, picSinal.Height + 2);
                    picSinal.Location = new Point(picSinal.Location.X - 1, picSinal.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (!aumenta && zoom > 0)
                {
                    timer1.Interval   = 250;
                    picSinal.Size     = new Size(picSinal.Width - 2, picSinal.Height - 2);
                    picSinal.Location = new Point(picSinal.Location.X + 1, picSinal.Location.Y + 1);
                    zoom--;
                }
                else if (flpAjuda2.Controls.Count < n2)
                {
                    picSinal.Image  = Properties.Resources.mais;
                    timer1.Interval = 750;
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda2.Controls.Add(myButton);
                }
                else
                {
                    timer1.Enabled = false;
                }
            }
            else if (sinal == 2)
            {
                if (flpAjuda1.Controls.Count < n1 && !cheio)
                {
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda1.Controls.Add(myButton);
                }
                else if (aumenta && zoom < 10)
                {
                    picSinal.Image    = Properties.Resources.menosCor;
                    timer1.Interval   = 250;
                    picSinal.Size     = new Size(picSinal.Width + 2, picSinal.Height + 2);
                    picSinal.Location = new Point(picSinal.Location.X - 1, picSinal.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (!aumenta && zoom > 0)
                {
                    timer1.Interval   = 250;
                    picSinal.Size     = new Size(picSinal.Width - 2, picSinal.Height - 2);
                    picSinal.Location = new Point(picSinal.Location.X + 1, picSinal.Location.Y + 1);
                    zoom--;
                }
                else if (flpAjuda1.Controls.Count != (n1 - n2) && flpAjuda1.Controls.Count != 0)
                {
                    picSinal.Image  = Properties.Resources.menos;
                    timer1.Interval = 750;
                    cheio           = true;
                    flpAjuda1.Controls.RemoveAt(flpAjuda1.Controls.Count - 1);
                }
                else if (flpAjuda1.Controls.Count == (n1 - n2))
                {
                    timer1.Enabled = false;
                }
            }
            else if (sinal == 3)
            {
                #region X1
                if (flpAjuda1.Controls.Count < n1)
                {
                    x1 = true;
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda1.Controls.Add(myButton);
                }
                else if (x1 && aumenta && zoom < 10)
                {
                    picX1.Visible   = true;
                    timer1.Interval = 250;
                    picX1.Size      = new Size(picX1.Width + 2, picX1.Height + 2);
                    picX1.Location  = new Point(picX1.Location.X - 1, picX1.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (x1 && !aumenta && zoom > 0)
                {
                    timer1.Interval = 250;
                    picX1.Size      = new Size(picX1.Width - 2, picX1.Height - 2);
                    picX1.Location  = new Point(picX1.Location.X + 1, picX1.Location.Y + 1);
                    zoom--;
                }
                #endregion
                #region X2
                else if (flpAjuda2.Controls.Count < n1 && n2 >= 2)
                {
                    x1 = false;
                    x2 = true;
                    timer1.Interval = 750;
                    aumenta         = true;
                    zoom            = 0;
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda2.Controls.Add(myButton);
                }
                else if (x2 && aumenta && zoom < 10)
                {
                    picX2.Visible   = true;
                    timer1.Interval = 250;
                    picX2.Size      = new Size(picX2.Width + 2, picX2.Height + 2);
                    picX2.Location  = new Point(picX2.Location.X - 1, picX2.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (x2 && !aumenta && zoom > 0)
                {
                    timer1.Interval = 250;
                    picX2.Size      = new Size(picX2.Width - 2, picX2.Height - 2);
                    picX2.Location  = new Point(picX2.Location.X + 1, picX2.Location.Y + 1);
                    zoom--;
                }
                #endregion
                #region X3
                else if (flpAjuda3.Controls.Count < n1 && n2 >= 3)
                {
                    x2 = false;
                    x3 = true;
                    timer1.Interval = 750;
                    aumenta         = true;
                    zoom            = 0;
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda3.Controls.Add(myButton);
                }
                else if (x3 && aumenta && zoom < 10)
                {
                    picX3.Visible   = true;
                    timer1.Interval = 250;
                    picX3.Size      = new Size(picX3.Width + 2, picX3.Height + 2);
                    picX3.Location  = new Point(picX3.Location.X - 1, picX3.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (x3 && !aumenta && zoom > 0)
                {
                    timer1.Interval = 250;
                    picX3.Size      = new Size(picX3.Width - 2, picX3.Height - 2);
                    picX3.Location  = new Point(picX3.Location.X + 1, picX3.Location.Y + 1);
                    zoom--;
                }
                #endregion
                #region X4
                else if (flpAjuda4.Controls.Count < n1 && n2 >= 4)
                {
                    x3 = false;
                    x4 = true;
                    timer1.Interval = 750;
                    aumenta         = true;
                    zoom            = 0;
                    myButtonObject myButton = new myButtonObject();
                    myButton.Size = new System.Drawing.Size(30, 30);
                    flpAjuda4.Controls.Add(myButton);
                }
                else if (x4 && aumenta && zoom < 10)
                {
                    picX4.Visible   = true;
                    timer1.Interval = 250;
                    picX4.Size      = new Size(picX4.Width + 2, picX4.Height + 2);
                    picX4.Location  = new Point(picX4.Location.X - 1, picX4.Location.Y - 1);
                    zoom++;
                    if (zoom == 10)
                    {
                        aumenta = !aumenta;
                    }
                }
                else if (x4 && !aumenta && zoom > 0)
                {
                    timer1.Interval = 250;
                    picX4.Size      = new Size(picX4.Width - 2, picX4.Height - 2);
                    picX4.Location  = new Point(picX4.Location.X + 1, picX4.Location.Y + 1);
                    zoom--;
                }
                #endregion
                else
                {
                    timer1.Enabled = false;
                }
            }
        }