终端一体化运控平台
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 

91 righe
3.2 KiB

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