Splash.xaml.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Runtime.InteropServices;
  3. using System.Windows;
  4. using System.Windows.Interop;
  5. using MediaBrowser.Common.Logging;
  6. using MediaBrowser.Model.Progress;
  7. namespace MediaBrowser.Common.UI
  8. {
  9. /// <summary>
  10. /// Interaction logic for Splash.xaml
  11. /// </summary>
  12. public partial class Splash : Window
  13. {
  14. private const int GWL_STYLE = -16;
  15. private const int WS_SYSMENU = 0x80000;
  16. [DllImport("user32.dll", SetLastError = true)]
  17. private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
  18. [DllImport("user32.dll")]
  19. private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  20. public Splash(Progress<TaskProgress> progress)
  21. {
  22. InitializeComponent();
  23. progress.ProgressChanged += progress_ProgressChanged;
  24. }
  25. void progress_ProgressChanged(object sender, TaskProgress e)
  26. {
  27. // If logging has loaded, put a message in the log.
  28. if (Logger.LoggerInstance != null)
  29. {
  30. Logger.LogInfo(e.Description);
  31. }
  32. this.lblProgress.Content = e.Description;
  33. this.pbProgress.Value = (double)e.PercentComplete;
  34. }
  35. private void Splash_Loaded(object sender, RoutedEventArgs e)
  36. {
  37. var hwnd = new WindowInteropHelper(this).Handle;
  38. SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
  39. }
  40. }
  41. }