Exemple #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (keyValuePairs.Count != 0)
            {
                test = keyValuePairs.Dequeue();



                if (test.QUEUETYPE == 1)
                {
                    test.LABEL.Location = new System.Drawing.Point(gateA.Location.X - 200, gateA.Location.Y);
                    test.LABEL.Text     = test.DURATION.ToString();
                    test.LABEL.AutoSize = true;
                    test.ANIMATION      = simonImage;
                    test.POSX           = gateA.Location.X - 200;
                    test.POSY           = gateA.Location.Y + 15;
                    this.Controls.Add(test.LABEL);
                    thuonggia.Enqueue(test);
                }
                else if (test.QUEUETYPE == 2)
                {
                    test.LABEL.Location = new System.Drawing.Point(gateB.Location.X - 200, gateB.Location.Y);
                    test.LABEL.Text     = test.DURATION.ToString();
                    test.LABEL.AutoSize = true;
                    test.ANIMATION      = ninjaImage;
                    test.POSX           = gateB.Location.X - 200;
                    test.POSY           = gateB.Location.Y + 15;
                    this.Controls.Add(test.LABEL);
                    online.Enqueue(test);
                }
                else if (test.QUEUETYPE == 3)
                {
                    test.LABEL.Location = new System.Drawing.Point(gateC.Location.X - 200, gateC.Location.Y);
                    test.LABEL.Text     = test.DURATION.ToString();
                    test.LABEL.AutoSize = true;
                    test.ANIMATION      = hawImage;
                    test.POSX           = gateC.Location.X - 200;
                    test.POSY           = gateC.Location.Y + 15;
                    this.Controls.Add(test.LABEL);
                    thuong.Enqueue(test);
                }

                s.Add(test);
            }
            //label.Location = new System.Drawing.Point(label.Location.X + 20, label.Location.Y);
        }
Exemple #2
0
        private void timer2_Tick(object sender, EventArgs e)
        {
            //counter++;
            foreach (HanhKhach x in s.ToList <HanhKhach>())
            {
                x.LABEL.Location = new Point(x.LABEL.Location.X + 20, x.LABEL.Location.Y);
                if (x.LABEL.Location.X >= gateA.Location.X - 20)
                //if (counter >= 10)
                {
                    x.LABEL.Location = new Point(gateA.Location.X - 20, x.LABEL.Location.Y);

                    if (x.QUEUETYPE == 1)
                    {
                        if (thuonggia.Count != 0 && thuonggiainprocess.Count == 0)
                        {
                            HanhKhach a = thuonggia.Dequeue();
                            thuonggiainprocess.Enqueue(a);
                        }
                        if (thuonggiainprocess.Count != 0)
                        {
                            if (x.ID == thuonggiainprocess.Peek().ID)
                            {
                                x.DURATION  -= 1;
                                x.LABEL.Text = x.DURATION.ToString();

                                if (x.DURATION == 0)
                                {
                                    //x.LABEL.Visible = false;
                                    this.Controls.Remove(x.LABEL);
                                    s.Remove(x);
                                    n--;
                                    thuonggiainprocess.Dequeue();
                                    if (x.TYPE == 1)
                                    {
                                        thuonggiaNumber -= 1;
                                    }
                                    else if (x.TYPE == 2)
                                    {
                                        onlineNumber -= 1;
                                    }
                                    else if (x.TYPE == 3)
                                    {
                                        thuongNumber -= 1;
                                    }
                                    txtthuonggianumber.Text = thuonggiaNumber.ToString();
                                    txtonlinenumber.Text    = onlineNumber.ToString();
                                    txtthuongnumber.Text    = thuongNumber.ToString();
                                    if (thuonggia.Count != 0 && thuonggiainprocess.Count == 0)
                                    {
                                        HanhKhach a = thuonggia.Dequeue();
                                        thuonggiainprocess.Enqueue(a);
                                    }
                                }
                            }

                            if (thuonggia.Count != 0 && thuonggiainprocess.Count != 0 && onlineinprocess.Count == 0 && online.Count == 0)
                            {
                                HanhKhach c = thuonggia.Dequeue();
                                c.QUEUETYPE      = 2;
                                c.LABEL.Location = new Point(c.LABEL.Location.X, gateB.Location.Y);
                                c.POSY           = gateB.Location.Y + 15;
                                online.Enqueue(c);
                            }
                            if (thuonggia.Count != 0 && thuonggiainprocess.Count != 0 && thuonginprocess.Count == 0 && thuong.Count == 0)
                            {
                                HanhKhach b = thuonggia.Dequeue();
                                b.QUEUETYPE      = 3;
                                b.LABEL.Location = new Point(b.LABEL.Location.X, gateC.Location.Y);
                                b.POSY           = gateC.Location.Y + 15;
                                thuong.Enqueue(b);
                            }
                        }
                    }
                    else if (x.QUEUETYPE == 2)
                    {
                        if (online.Count != 0 && onlineinprocess.Count == 0)
                        {
                            HanhKhach a = online.Dequeue();
                            onlineinprocess.Enqueue(a);
                        }
                        if (onlineinprocess.Count != 0)
                        {
                            if (x.ID == onlineinprocess.Peek().ID)
                            {
                                x.DURATION  -= 1;
                                x.LABEL.Text = x.DURATION.ToString();

                                if (x.DURATION == 0)
                                {
                                    //x.LABEL.Visible = false;

                                    this.Controls.Remove(x.LABEL);
                                    s.Remove(x);
                                    n--;
                                    if (x.TYPE == 1)
                                    {
                                        thuonggiaNumber -= 1;
                                    }
                                    else if (x.TYPE == 2)
                                    {
                                        onlineNumber -= 1;
                                    }
                                    else if (x.TYPE == 3)
                                    {
                                        thuongNumber -= 1;
                                    }
                                    txtthuonggianumber.Text = thuonggiaNumber.ToString();
                                    txtonlinenumber.Text    = onlineNumber.ToString();
                                    txtthuongnumber.Text    = thuongNumber.ToString();
                                    onlineinprocess.Dequeue();
                                    if (online.Count != 0 && onlineinprocess.Count == 0)
                                    {
                                        HanhKhach a = online.Dequeue();
                                        onlineinprocess.Enqueue(a);
                                    }
                                }
                            }

                            if (online.Count != 0 && onlineinprocess.Count != 0 && thuonggiainprocess.Count == 0 && thuonggia.Count == 0)
                            {
                                HanhKhach c = online.Dequeue();
                                c.QUEUETYPE      = 1;
                                c.LABEL.Location = new Point(c.LABEL.Location.X, gateA.Location.Y);
                                c.POSY           = gateA.Location.Y + 15;
                                thuonggia.Enqueue(c);
                            }
                            if (online.Count != 0 && onlineinprocess.Count != 0 && thuonginprocess.Count == 0 && thuong.Count == 0)
                            {
                                HanhKhach b = online.Dequeue();
                                b.QUEUETYPE      = 3;
                                b.LABEL.Location = new Point(b.LABEL.Location.X, gateC.Location.Y);
                                b.POSY           = gateC.Location.Y + 15;
                                thuong.Enqueue(b);
                            }
                        }
                    }
                    else if (x.QUEUETYPE == 3)
                    {
                        if (thuong.Count != 0 && thuonginprocess.Count == 0)
                        {
                            HanhKhach a = thuong.Dequeue();
                            thuonginprocess.Enqueue(a);
                        }
                        if (thuonginprocess.Count != 0)
                        {
                            if (x.ID == thuonginprocess.Peek().ID)
                            {
                                x.DURATION  -= 1;
                                x.LABEL.Text = x.DURATION.ToString();

                                if (x.DURATION == 0)
                                {
                                    //x.LABEL.Visible = false;

                                    this.Controls.Remove(x.LABEL);

                                    thuonginprocess.Dequeue();
                                    s.Remove(x);
                                    n--;

                                    if (x.TYPE == 1)
                                    {
                                        thuonggiaNumber -= 1;
                                    }
                                    else if (x.TYPE == 2)
                                    {
                                        onlineNumber -= 1;
                                    }
                                    else if (x.TYPE == 3)
                                    {
                                        thuongNumber -= 1;
                                    }
                                    txtthuonggianumber.Text = thuonggiaNumber.ToString();
                                    txtonlinenumber.Text    = onlineNumber.ToString();
                                    txtthuongnumber.Text    = thuongNumber.ToString();
                                    if (thuong.Count != 0 && thuonginprocess.Count == 0)
                                    {
                                        HanhKhach a = thuong.Dequeue();
                                        thuonginprocess.Enqueue(a);
                                    }
                                }
                            }
                            if (thuong.Count != 0 && thuonginprocess.Count != 0 && thuonggiainprocess.Count == 0 /*&& thuonggia.Count == 0*/)
                            {
                                HanhKhach c = thuong.Dequeue();
                                c.QUEUETYPE      = 1;
                                c.LABEL.Location = new Point(c.LABEL.Location.X, gateA.Location.Y);
                                c.POSY           = gateA.Location.Y + 15;
                                thuonggia.Enqueue(c);
                            }
                            if (thuong.Count != 0 && thuonginprocess.Count != 0 && onlineinprocess.Count == 0 /*&& online.Count == 0*/)
                            {
                                HanhKhach b = thuong.Dequeue();
                                b.QUEUETYPE      = 2;
                                b.LABEL.Location = new Point(b.LABEL.Location.X, gateB.Location.Y);
                                b.POSY           = gateB.Location.Y + 15;
                                online.Enqueue(b);
                            }
                        }
                    }
                }
            }
        }