Exemplo n.º 1
0
        /// <summary>
        /// Handles when a key is being pressed while the <see cref="Control"/> has focus.
        /// This is called immediately before <see cref="Control.KeyPressed"/>.
        /// Override this method instead of using an event hook on <see cref="Control.KeyPressed"/> when possible.
        /// </summary>
        /// <param name="e">The event args.</param>
        protected override void OnKeyPressed(KeyEventArgs e)
        {
            base.OnKeyPressed(e);

            if (e.Code == KeyCode.Escape)
            {
                if (RequestEndDialog != null)
                {
                    RequestEndDialog.Raise(this, EventArgs.Empty);
                }
            }
            else
            {
                var asNumeric = e.Code.GetNumericKeyAsValue();
                if (!asNumeric.HasValue)
                {
                    return;
                }

                var value = asNumeric.Value - 1;
                if (value < 0)
                {
                    value = 10;
                }

                if (value < _responses.Length)
                {
                    if (SelectResponse != null)
                    {
                        SelectResponse.Raise(this, EventArgsHelper.Create(_responses[value]));
                    }
                }
            }
        }
Exemplo n.º 2
0
        void ResponseText_Clicked(object sender, MouseButtonEventArgs e)
        {
            var src      = (ResponseText)sender;
            var response = src.Response;

            if (response != null)
            {
                if (SelectResponse != null)
                {
                    SelectResponse.Raise(this, EventArgsHelper.Create(response));
                }
            }
        }