Example #1
0
 internal static void ShowBlockingLoading(IWin32Window Owner, bool WaitForNext, string LoadingText, int? ProgressMaxValue, EventHandler CancelHandler)
 {
     LoadingForm.waitForNext = WaitForNext;
       if (LoadingForm.mainForm != null)
       {
     if (string.IsNullOrEmpty(LoadingText))
       return;
     LoadingForm.mainForm.lStatus.Text = LoadingText;
       }
       else
       {
     IWin32Window localOwner = (IWin32Window) null;
     LoadingForm lf = new LoadingForm();
     if (Owner != null && Owner is Form)
     {
       (Owner as Form).Enabled = false;
       lf.Owner = Owner as Form;
       lf.StartPosition = FormStartPosition.Manual;
       lf.Top = (Owner as Form).Top + (Owner as Form).Height / 2 - lf.Height / 2;
       lf.Left = (Owner as Form).Left + (Owner as Form).Width / 2 - lf.Width / 2;
       lf.ShowInTaskbar = false;
       localOwner = Owner;
     }
     else
     {
       WinAPI.RECT lpRect;
       WinAPI.GetWindowRect(Common.PlayerWindowHandle, out lpRect);
       lf.StartPosition = FormStartPosition.Manual;
       lf.Top = lpRect.Top + (lpRect.Bottom - lpRect.Top) / 2 - lf.Height / 2;
       lf.Left = lpRect.Left + (lpRect.Right - lpRect.Left) / 2 - lf.Width / 2;
       lf.ShowInTaskbar = false;
       WinAPI.EnableWindow(Common.PlayerWindow.Handle, false);
       localOwner = (IWin32Window) Common.PlayerWindow;
     }
     if (ProgressMaxValue.HasValue)
     {
       lf.pbMain.Style = ProgressBarStyle.Blocks;
       lf.pbMain.Maximum = ProgressMaxValue.Value;
       lf.pbMain.Minimum = 0;
     }
     else
       lf.pbMain.Style = ProgressBarStyle.Marquee;
     LoadingForm.lastOwner = Owner;
     if (!string.IsNullOrEmpty(LoadingText))
       lf.lStatus.Text = LoadingText;
     LoadingForm.mainForm = lf;
     if (CancelHandler == null)
     {
       lf.btnCancel.Visible = false;
       Label label = lf.lStatus;
       int num = label.Width + (lf.btnCancel.Width + 4);
       label.Width = num;
     }
     else
       lf.btnCancel.Click += (EventHandler) ((ls, le) =>
       {
     if (LoadingForm.Cancel == null)
       return;
     LoadingForm.Cancel((object) lf, new EventArgs());
       });
     lf.FormClosing += (FormClosingEventHandler) ((ls, le) =>
     {
       if (LoadingForm.lastOwner != null && LoadingForm.lastOwner is Form)
       {
     (LoadingForm.lastOwner as Form).Enabled = true;
     (LoadingForm.lastOwner as Form).Activate();
       }
       if (!(localOwner is NativeWindow))
     return;
       WinAPI.EnableWindow(Common.PlayerWindowHandle, true);
       WinAPI.SetForegroundWindow(Common.PlayerWindowHandle);
     });
     lf.Show(localOwner);
       }
 }
Example #2
0
 internal static void HideBlockingLoading()
 {
     if (!LoadingForm.waitForNext)
       {
     if (LoadingForm.mainForm != null)
       LoadingForm.mainForm.Close();
     LoadingForm.mainForm = (LoadingForm) null;
       }
       else
       {
     LoadingForm.waitForNext = false;
     LoadingForm.mainForm.lStatus.Text = "Загрузка...";
       }
 }