Esempio n. 1
0
        /// <summary>
        /// Create a new dialog or use an existing one if its still valid
        /// </summary>
        /// <param name="Text"></param>
        /// <returns></returns>
        public static void ShowLoading(string Text, IWin32Window owner = null)
        {
            log.Info(Text);
            // create form on ui thread
            MainV2.instance.BeginInvokeIfRequired((Action) delegate
            {
                uiSemaphoreSlim.Wait();
                try
                {
                    if (Instance != null && !Instance.IsDisposed)
                    {
                        Instance.Text = Text;
                        return;
                    }

                    log.Info("Create Instance");

                    Loading frm = new Loading();
                    if (owner == null)
                    {
                        frm.TopMost = true;
                    }
                    frm.StartPosition = FormStartPosition.CenterParent;
                    frm.Closing      += Frm_Closing;

                    // set instance
                    Instance = frm;
                    // set text
                    Instance.label1.Text = Text;

                    ThemeManager.ApplyThemeTo(frm);
                    frm.Show(owner);
                    frm.Focus();
                }
                finally
                {
                    uiSemaphoreSlim.Release();
                }
            });
        }
Esempio n. 2
0
        /// <summary>
        /// Create a new dialog or use an existing one if its still valid
        /// </summary>
        /// <param name="Text"></param>
        /// <returns></returns>
        public static void ShowLoading(string Text, IWin32Window owner = null)
        {
            //if (MainV2.MONO)
            {
                log.Info(Text);
                //return;
            }

            // ensure we only have one instance at a time
            lock (locker)
            {
                if (Instance != null && !Instance.IsDisposed)
                {
                    Instance.Text = Text;
                    return;
                }

                log.Info("Create Instance");
                // create form on ui thread
                MainV2.instance.Invoke((MethodInvoker) delegate
                {
                    Loading frm = new Loading();
                    if (owner == null)
                    {
                        frm.TopMost = true;
                    }
                    frm.StartPosition = FormStartPosition.CenterParent;
                    frm.Closing      += Frm_Closing;

                    // set instance
                    Instance = frm;
                    // set text
                    Instance.label1.Text = Text;

                    ThemeManager.ApplyThemeTo(frm);
                    frm.Show(owner);
                    frm.Focus();
                });
            }
        }