Esempio n. 1
0
        //
        //
        //
        #endregion//Public Methods


        #region no Private Methods
        // *****************************************************************
        // ****                     Private Methods                     ****
        // *****************************************************************
        //
        //
        //
        //
        #endregion//Private Methods


        #region Event Handlers
        // *****************************************************************
        // ****                     Event Handlers                     ****
        // *****************************************************************
        //
        //
        // ****         textBox_KeyUp     ****
        //
        /// <summary>
        /// Handles when a user types into the textbox.
        /// </summary>
        private void textBox_KeyUp(object sender, KeyEventArgs e)
        {
            TextBox tb = (TextBox)sender;       // sender of this event is text box

            if (e.KeyCode == Keys.Enter)
            {   // "enter key" was pressed!
                // Generate a parameter change request for our associated engine.
                string newValueStr = tb.Text;
                try
                {
                    // Test the format!
                    int newValue = Convert.ToInt32(tb.Text);
                    //int hubID = 1;  // id of the display hub that holds this
                    m_RemoteEngineHub.HubEventEnqueue(EngineEventArgs.RequestParameterChange(m_ParameterInfo, newValue)); //, hubID));
                    ParameterName.Focus();                                                                                // take focus from textbox.
                }
                catch (Exception)
                {   // Failed restore old value
                    tb.Text           = m_Memory.ToString();
                    IsUserInputActive = false;
                    tb.ForeColor      = TextColorDefault;
                }
                IsUserInputActive = false;
            }
            else if (e.KeyCode == Keys.Escape)
            {   // "escape key"
                tb.Text           = m_Memory.ToString();
                IsUserInputActive = false;
                tb.ForeColor      = TextColorDefault;
            }
            else
            {                                 // the key pressed was NOT the enter key.
                if (!IsUserInputActive)
                {                             // first time we started typing here.
                    // tb.Clear();
                    IsUserInputActive = true; // flag that user is typing.
                    tb.ForeColor      = TextColorHiLite;
                }
            }
        }//end textBox_KeyUp()