Splash.xaml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows;
  7. using System.Windows.Controls;
  8. using System.Windows.Data;
  9. using System.Windows.Documents;
  10. using System.Windows.Input;
  11. using System.Runtime.InteropServices;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Interop;
  15. using System.Windows.Shapes;
  16. using MediaBrowser.Model.Progress;
  17. namespace MediaBrowser.Common.UI
  18. {
  19. /// <summary>
  20. /// Interaction logic for Splash.xaml
  21. /// </summary>
  22. public partial class Splash : Window
  23. {
  24. private const int GWL_STYLE = -16;
  25. private const int WS_SYSMENU = 0x80000;
  26. [DllImport("user32.dll", SetLastError = true)]
  27. private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
  28. [DllImport("user32.dll")]
  29. private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
  30. public Splash(Progress<TaskProgress> progress)
  31. {
  32. InitializeComponent();
  33. progress.ProgressChanged += progress_ProgressChanged;
  34. }
  35. void progress_ProgressChanged(object sender, TaskProgress e)
  36. {
  37. this.lblProgress.Content = e.Description;
  38. this.pbProgress.Value = (double)e.PercentComplete;
  39. }
  40. private void Splash_Loaded(object sender, RoutedEventArgs e)
  41. {
  42. var hwnd = new WindowInteropHelper(this).Handle;
  43. SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
  44. }
  45. }
  46. }