示例#1
0
        /// <summary>
        /// StopSeating Script Button
        /// </summary>
        /// <param name="sender">ScanButton</param>
        /// <param name="e"></param>
        private void ButtonStopSeatingScript_Click(object sender, EventArgs e)
        {
            // Stop Seating Script
            ScanButton scan = (ScanButton)sender;

            stopSeating(scan);

            // Reset ScanButton Text & Update EventHandlers (Scan Table on ScanButton.Click)
            scan.Text = GlobalSettings.ButtonSettings.ScanButtonLabel;
            RemoveClickEvent(scan);
            scan.Click += SessionHandler.ControlButton_Click;
            scan.Refresh();

            // Remove worker from active worker list
            activeWorkers.Remove(scan.TableHandle);
        }
示例#2
0
        /// <summary>
        /// Evaluation of seating success after worker completed/got cancelled
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            BackgroundSeatingWorker result = (BackgroundSeatingWorker)sender;

            if (e.Error != null)
            {
                //MessageBox.Show(e.Error.StackTrace.ToString()); // Debug
            }
            // Reset Buttons after worker got cancelled (either b/c we got a seat or something went wrong)
            else if (e.Cancelled)
            {
                // Adjust Click Delegates and Text after Seat was successfully found
                ScanButton scan = result.scanButton;
                scan.Text = GlobalSettings.ButtonSettings.ScanButtonLabel;

                // Clean up delegates and adjust accordingly
                // If seating script runs, clicking on ScanButton stops seating script
                // If seating script is off, clicking on ScanButton scans table
                RemoveClickEvent(scan);
                scan.Click += SessionHandler.ControlButton_Click;
                scan.Refresh();
                activeWorkers.Remove(scan.TableHandle);

                // Update ContextMenu for ScanButton (switch between "start seatingscript" and "stop seatingscript"
                foreach (ToolStripMenuItem tsmi in scan.ContextMenuStrip.Items)
                {
                    if (tsmi.Text.Contains("SeatingScript"))
                    {
                        tsmi.Text = GlobalSettings.SeatingScript.StartSeatingScriptLabel;
                        break;
                    }
                }
            }
            else
            {
                // No exception in DoWork.
                try
                {
                    // Seat was found!
                    success.Play();
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.ToString());
                }
            }
        }