示例#1
0
 /// <summary>
 /// Displays the form as instructed by the VendingMachine class and hides if the
 /// program is at another stage which needs a different form to be displayed
 /// <param name="sender">standard sender object which is VendingMachine in this case</param>
 /// <param name="e"> NextStageEventArgs which contains information about the current
 /// stage and atate of the program</param>
 /// </summary>
 public void gotoSlotSelection(object sender, VendingMachine.NextStageEventArgs e)
 {
     if (e.UI_Stage == VendingMachine.e_CurrentUIstage.START_STAGE)
     {
         this.Show();
     }
     else
     {
         this.Hide();
     }
 }
示例#2
0
        /*     private void CountDown_Event(object sender, System.EventArgs e)
         *   {
         *       if (timeout_outvalue > 0)
         *       {
         *           timeout_outvalue = timeout_outvalue - 1;
         *           TimerLabel.Text  = Convert.ToString(timeout_outvalue);
         */
/*
 *              //Money received correctly and change has been dispensed
 *              if (timeout_outvalue == 57)
 *              {
 *                  receivedLBL.Visible = true;
 *                  Received_AmountLBL.Visible = true;
 *          //        ReceiveMoney1.AmountPayed += 30;
 *              }
 *              //Printing the receipt
 *              if (timeout_outvalue == 56)
 *              {
 *                  Printing_ReceiptLBL.Visible = true;
 *              }
 *
 *              //Payment process complete
 *              if (timeout_outvalue == 54)
 *              {
 *                  TransDone_Pic.Visible = true;
 *
 *              }
 *              //Inform user to insert device and charge in the opened slot
 *              if (timeout_outvalue == 53)
 *              {
 *                  ChargeDevicePn.Visible = true;
 *                  label8.Visible = true;
 *                  label9.Visible = true;
 *                  label10.Visible = true;
 *                  label11.Visible = true;
 *                  label12.Visible = true;
 *                  label2.Visible = true;
 *              }
 *
 *              if (timeout_outvalue == 50)
 *              {
 *                  transtimeout.Stop();
 *                  TimerLabel.Visible = false;
 *                  //Form1 MainWindow = new Form1();
 *                 // MainWindow.FormClosed += new FormClosedEventHandler(MainWindow_FormClosed);
 *                  //MainWindow.Show();
 *
 *           //       Slots_trans[(int)selectedSlot].Slot_status = 1;
 *                  this.Hide();
 *                  this.Close();
 *              }
 * */
//          }
//     }
        /// <summary>
        /// Displays the form as instructed by the VendingMachine class and hides if the
        /// program is at another stage which needs a different form to be displayed
        /// <param name="sender">standard sender object which is VendingMachine in this case</param>
        /// <param name="e"> NextStageEventArgs which contains information about the current
        /// stage and atate of the program</param>
        /// </summary>
        public void gotoPayment(object sender, VendingMachine.NextStageEventArgs e)
        {
            if (e.UI_Stage == VendingMachine.e_CurrentUIstage.PAYMENT_STAGE)
            {
                this.Show();
                switch (e.UI_Stage_State)
                {
                case VendingMachine.e_CurrentUIstageState.WAITING_FOR_INPUT:
                {
                    PaymentInstructLabel.Text  = "*Please Insert via the Bill Collector or Coin Acceptor";
                    receivedLBL.Text           = "Insert  ";
                    receivedLBL.Visible        = true;
                    Received_AmountLBL.Text    = "R" + QikTop.vending.getMoneyCharged();
                    Received_AmountLBL.Visible = true;
                    Console.WriteLine("Transact: Insert money");
                    DateTime start = DateTime.Now;
                    while ((DateTime.Now - start).TotalMilliseconds < 2000)
                    {
                        Application.DoEvents();
                    }
                    break;
                }

                case VendingMachine.e_CurrentUIstageState.USER_ERROR:
                {
                    PaymentInstructLabel.Text  = "Timed Out";
                    receivedLBL.Visible        = false;
                    Received_AmountLBL.Visible = false;
                    Console.WriteLine("Transact: Insert money error");
                    break;
                }

                case VendingMachine.e_CurrentUIstageState.HARDWARE_ERROR:
                {
                    PaymentInstructLabel.Text  = "Hardware Failure!";
                    receivedLBL.Visible        = false;
                    Received_AmountLBL.Visible = false;
                    Console.WriteLine("Transact: Insert money error");
                    break;
                }

                case VendingMachine.e_CurrentUIstageState.DONE:
                {
                    receivedLBL.Text           = "Received  ";
                    receivedLBL.Visible        = true;
                    Received_AmountLBL.Text    = "R" + QikTop.vending.getMoneyReceived();
                    Received_AmountLBL.Visible = true;
                    Console.WriteLine("Transact: Received money");
                    DateTime start = DateTime.Now;
                    while ((DateTime.Now - start).TotalMilliseconds < 2000)
                    {
                        Application.DoEvents();
                    }
                    break;
                }
                }
            }

            else if (e.UI_Stage == VendingMachine.e_CurrentUIstage.PRINT_RECEIPT_STAGE || e.UI_Stage == VendingMachine.e_CurrentUIstage.DISPENSE_CHANGE_STAGE)
            {
                switch (e.UI_Stage_State)
                {
                case VendingMachine.e_CurrentUIstageState.GENERATING_FEEDBACK:
                {
                    Printing_ReceiptLBL.Visible = true;
                    Console.WriteLine("Transact: Dispensing change. Printing receipt");
                    DateTime start = DateTime.Now;
                    while ((DateTime.Now - start).TotalMilliseconds < 2000)
                    {
                        Application.DoEvents();
                    }
                    break;
                }

                case VendingMachine.e_CurrentUIstageState.DONE:
                {
                    TransDone_Pic.Visible = true;
                    Console.WriteLine("Transact: payment process done");
                    DateTime start = DateTime.Now;
                    while ((DateTime.Now - start).TotalMilliseconds < 2000)
                    {
                        Application.DoEvents();
                    }
                    break;
                }
                }
            }
            else if (e.UI_Stage == VendingMachine.e_CurrentUIstage.INSERT_DEVICE_STAGE)
            {
                ChargeDevicePn.Visible = true;
                label8.Visible         = true;
                label9.Visible         = true;
                label10.Visible        = true;
                label11.Visible        = true;
                label12.Visible        = true;
                label2.Visible         = true;
                Console.WriteLine("Transact: Insert device");
                DateTime start = DateTime.Now;
                while ((DateTime.Now - start).TotalMilliseconds < 2000)
                {
                    Application.DoEvents();
                }
            }
            else
            {
                this.Hide();  //hide form
                timeout_outvalue = 0;
                TimerLabel.Text  = Convert.ToString(timeout_outvalue);

                //Money received correctly and change has been dispensed
                receivedLBL.Visible        = false;
                Received_AmountLBL.Text    = "";
                Received_AmountLBL.Visible = false;

                //Printing the receipt
                Printing_ReceiptLBL.Visible = false;

                //Payment feedback picture
                TransDone_Pic.Visible = false;

                //Proceed with charging panel
                ChargeDevicePn.Visible = false;
                label8.Visible         = false;
                label9.Visible         = false;
                label10.Visible        = false;
                label11.Visible        = false;
                label12.Visible        = false;
                label2.Visible         = false;
            }
        }
示例#3
0
 /// <summary>
 /// Displays the form as instructed by the VendingMachine class and hides if the
 /// program is at another stage which needs a different form to be displayed
 /// <param name="sender">standard sender object which is VendingMachine in this case</param>
 /// <param name="e"> NextStageEventArgs which contains information about the current
 /// stage and atate of the program</param>
 /// </summary>
 public void gotoSlotSelection(object sender, VendingMachine.NextStageEventArgs e)
 {
     if (e.UI_Stage == VendingMachine.e_CurrentUIstage.SLOT_SELECTION_STAGE)
     {
         this.Show();
         SlotButtonPanel.Enabled = true;
         SelectLockerPn.Visible  = true;
         ChargePeriodPn.Visible  = false;
         SetPasswordPn.Enabled   = false;
         SetPasswordPn.Visible   = false;
         for (int i = 0; i < VendingMachine.NumSlots; i++)
         {
             if (i < QikTop.vending.AvailableSlots.Count)
             {
                 Locker_status.ElementAt(QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1).BackColor = Color.White;
                 Locker_status[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Text = "Available";
                 if (e.ChargingOrRetrieving == VendingMachine.e_ChargingOrRetrieving.CHARGING)
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = true;
                 }
                 else
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = false;
                 }
             }
             if (i < QikTop.vending.BusySlots.Count)
             {
                 Locker_status[QikTop.vending.BusySlots.ElementAt(i).getID() - 1].BackColor = Color.Red;
                 Locker_status[QikTop.vending.BusySlots.ElementAt(i).getID() - 1].Text      = "Busy Charging";
                 if (e.ChargingOrRetrieving == VendingMachine.e_ChargingOrRetrieving.CHARGING)
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = false;
                 }
                 else
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = true;
                 }
             }
             if (i < QikTop.vending.FinishedSlots.Count)
             {
                 Locker_status[QikTop.vending.FinishedSlots.ElementAt(i).getID() - 1].BackColor = Color.Red;
                 Locker_status[QikTop.vending.FinishedSlots.ElementAt(i).getID() - 1].Text      = "Waiting Retrieve";
                 if (e.ChargingOrRetrieving == VendingMachine.e_ChargingOrRetrieving.CHARGING)
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = false;
                 }
                 else
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = true;
                 }
             }
             if (i < QikTop.vending.OverdueSlots.Count)
             {
                 Locker_status[QikTop.vending.OverdueSlots.ElementAt(i).getID() - 1].BackColor = Color.Red;
                 Locker_status[QikTop.vending.OverdueSlots.ElementAt(i).getID() - 1].Text      = "Waiting Retrieve";
                 if (e.ChargingOrRetrieving == VendingMachine.e_ChargingOrRetrieving.CHARGING)
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = false;
                 }
                 else
                 {
                     Locker_buttons[QikTop.vending.AvailableSlots.ElementAt(i).getID() - 1].Enabled = true;
                 }
             }
         }
     }
     else if (e.UI_Stage == VendingMachine.e_CurrentUIstage.CHARGE_TIME_STAGE)
     {
         this.Show();
         SelectLockerPn.Visible  = false;
         SlotButtonPanel.Enabled = false;
         ChargePeriodPn.Visible  = true;
         SetPasswordPn.Enabled   = false;
         SetPasswordPn.Visible   = false;
     }
     else if (e.UI_Stage == VendingMachine.e_CurrentUIstage.PASSWORD_GENERATION_STAGE)
     {
         this.Show();
         SelectLockerPn.Visible  = false;
         SlotButtonPanel.Enabled = false;
         ChargePeriodPn.Visible  = false;
         SetPasswordPn.Enabled   = true;
         SetPasswordPn.Location  = new Point(0, 402);
         SetPasswordPn.Visible   = true;
     }
     else
     {
         this.Hide();
     }
 }