CloseAsync() public static method

Closes the form asynchronously in a different thread
public static CloseAsync ( Form form ) : void
form System.Windows.Forms.Form form to close
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Handle actuation of a widget - navigate, select language
        /// etc depending on what the widget represents
        /// </summary>
        /// <param name="widget">widget to actuate</param>
        /// <param name="handled">true if handled</param>
        private void handleWidgetSelection(Widget widget, ref bool handled)
        {
            if (widget.UserData is CultureInfo)
            {
                onLanguageSelected((CultureInfo)widget.UserData);
                handled = true;
            }
            else
            {
                handled = true;
                switch (widget.Value)
                {
                case "@Quit":
                    Windows.CloseAsync(this);
                    break;

                case "@CmdNextPage":
                    gotoNextPage();
                    break;

                case "@CmdPrevPage":
                    gotoPreviousPage();
                    break;

                default:
                    handled = false;
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Key press handler.  Process the ESC key to quit
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void _keyboardActuator_EvtKeyPress(object sender, KeyPressEventArgs e)
        {
            int c = e.KeyChar;

            if (c == 27)
            {
                Windows.CloseAsync(this);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// User selected a language from the list.  If reqd,
        /// ask the user to confirm the switch
        /// </summary>
        /// <param name="cultureInfo">Cultureinfo of the language selected</param>
        /// <returns>true on success</returns>
        private void onLanguageSelected(CultureInfo cultureInfo)
        {
            if (DialogUtils.ConfirmScanner(String.Format(R.GetString("ConfirmSwitchLanguage"), cultureInfo.DisplayName)))
            {
                Windows.SetVisible(this, false);

                var toastForm = new ToastForm(R.GetString("PleaseWait"), -1);
                Windows.SetWindowPosition(toastForm, Windows.WindowPosition.CenterScreen);
                toastForm.Show();

                Invoke(new MethodInvoker(delegate
                {
                    Context.ChangeCulture(cultureInfo);
                }));

                toastForm.Close();

                var prefs = ACATPreferences.Load();
                prefs.Language = cultureInfo.Name;
                prefs.Save();

                Windows.CloseAsync(this);
            }
        }