终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

100 lines
3.4 KiB

  1. using BPASmartClient.CustomResource.Pages.Model;
  2. using BPASmartClient.Helper;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading;
  10. using System.Threading.Tasks;
  11. using System.Windows;
  12. using System.Windows.Controls;
  13. using System.Windows.Data;
  14. using System.Windows.Documents;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Imaging;
  18. using System.Windows.Shapes;
  19. namespace BPASmartClient.CustomResource.Pages.View
  20. {
  21. /// <summary>
  22. /// LoginView.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class LoginView : Window
  25. {
  26. public LoginView()
  27. {
  28. InitializeComponent();
  29. grid.Visibility = Visibility.Collapsed;
  30. Username.SelectionStart = Username.Text.Trim().Length;
  31. this.Loaded += LoginView_Loaded;
  32. ActionManage.GetInstance.Register(new Action(() =>
  33. {
  34. if (this.IsVisible)
  35. {
  36. this.DialogResult = true;
  37. this.Close();
  38. }
  39. }), "LoginOk", true);
  40. ActionManage.GetInstance.Register(new Action(() => { this.DialogResult = false; this.Close(); }), "ExitAction", true);
  41. }
  42. private void LoginView_Loaded(object sender, RoutedEventArgs e)
  43. {
  44. string path = $"{AppDomain.CurrentDomain.BaseDirectory}Videos\\Login.mp4";
  45. if (File.Exists(path))
  46. {
  47. player.Source = new Uri(path); // 绑定视频文件
  48. this.WindowState = WindowState.Maximized;
  49. player.LoadedBehavior = MediaState.Manual; // 交互式控制
  50. player.Loaded += new RoutedEventHandler(media_Loaded); // 添加元素加载完成事件 -- 自动开始播放
  51. player.MediaEnded += new RoutedEventHandler(media_MediaEnded); // 添加媒体播放结束事件 -- 重新播放
  52. player.Unloaded += new RoutedEventHandler(media_Unloaded);// 添加元素卸载完成事件 -- 停止播放
  53. player.MediaOpened += Player_MediaOpened;//已播放事件
  54. }
  55. }
  56. private void Player_MediaOpened(object sender, RoutedEventArgs e)
  57. {
  58. grid.Visibility = Visibility.Visible;
  59. Username.Focus();
  60. }
  61. private void media_Loaded(object sender, RoutedEventArgs e)
  62. {
  63. (sender as MediaElement).Play();
  64. }
  65. private void media_MediaEnded(object sender, RoutedEventArgs e)
  66. {
  67. // MediaElement需要先停止播放才能再开始播放,
  68. // 否则会停在最后一帧不动
  69. (sender as MediaElement).Stop();
  70. (sender as MediaElement).Play();
  71. }
  72. private void media_Unloaded(object sender, RoutedEventArgs e)
  73. {
  74. (sender as MediaElement).Stop();
  75. }
  76. private void PasswordBox_PasswordChanged(object sender, RoutedEventArgs e)
  77. {
  78. this.markText.Visibility = this.pb.Password.Length > 0 ? Visibility.Collapsed : Visibility.Visible;
  79. }
  80. private void TextBox_KeyDown(object sender, KeyEventArgs e)
  81. {
  82. if (e.Key == Key.Enter) pb.Focus();
  83. }
  84. private void pb_KeyDown(object sender, KeyEventArgs e)
  85. {
  86. if (e.Key == Key.Enter) ActionManage.GetInstance.Send("EnterLogin");
  87. }
  88. }
  89. }