ACAT.Lib.Core.Utility.Windows.SetVisible C# (CSharp) Метод

SetVisible() публичный статический Метод

Sets the visibility of the control This is just a helper function that takes care of cross-thread invokations that would result in .NET exceptions.
public static SetVisible ( Control control, bool visible ) : void
control System.Windows.Forms.Control
visible bool
Результат void
        public static void SetVisible(Control control, bool visible)
        {
            if (control.InvokeRequired)
            {
                control.Invoke(new setVisible(SetVisible), control, visible);
            }
            else
            {
                control.Visible = visible;
            }
        }

Usage Example

Пример #1
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);
            }
        }