示例#1
0
 private void StartNumberTextBox_TextChanged(object sender, EventArgs e)
 {
     StartNumberTBErrorProvider.Clear();
     try
     {
         startNumber = Int32.Parse(StartNumberTextBox.Text);
     }
     catch (Exception ex)
     {
         StartNumberTBErrorProvider.SetError(StartNumberTextBox, ex.Message);
     }
 }
示例#2
0
        //parsing the text from controls in order to set an error message to the rigth control if there is incorrect data in that control
        private int TextBoxTextParse(Control control)
        {
            int retValue = 0;

            try
            {
                retValue = Int32.Parse(control.Text);
            }
            catch (Exception ex)
            {
                StartNumberTBErrorProvider.SetError(control, ex.Message);
            }
            return(retValue);
        }
示例#3
0
 private void CreateCircularQueueButton_Click(object sender, EventArgs e)
 {
     //if there are no incorrect input data, we can generate a CircularBuffer
     if ((StartNumberTBErrorProvider.GetError(this.StartNumberTextBox) == "") && (MaxQueueCountTBErrorProvider.GetError(this.MaxQueueCountTextBox) == "") && (maxQueueCount > 0))
     {
         //change text boxes and CreateCircularQueueButton states to avoid the data changing and recreating of the CircularBuffer
         ChangeControlState(MaxQueueCountTextBox, StartNumberTextBox, CreateCircularQueueButton);
         //creating CircularBuffer and seting the start points to generate numbers
         CircularBuffer = new ThreadSafeCircularQueue(maxQueueCount);
         //show message about successfully created CircularBuffer
         QueueIsGeneratedLabel.Visible = true;
         //enable the Start buttons for both generation and picking threads
         ChangeControlState(StartGenerateNumbersButton, StartPickNumbersButton);
     }
 }