/// <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])); } } } }
/// <summary> /// Handles when the Close button on the form is clicked. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SFML.Window.MouseButtonEventArgs"/> instance containing the event data.</param> protected override void CloseButtonClicked(object sender, MouseButtonEventArgs e) { // Since we have to let the server know what our chat state is, we can't just close the window. Instead, // make a request to the server that we want to end the chat dialog. If the server allows it, then it // will eventually close. if (RequestEndDialog != null) { RequestEndDialog.Raise(this, EventArgs.Empty); } }