frmOfficalWebsiteVideo.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.UI
  10. {
  11. public partial class frmOfficalWebsiteVideo : Form
  12. {
  13. public frmOfficalWebsiteVideo()
  14. {
  15. InitializeComponent();
  16. }
  17. /// <summary>
  18. /// 本窗口是否打开,已打开返回true;
  19. /// </summary>
  20. /// <returns></returns>
  21. public static bool IsDialogOpen()
  22. {
  23. bool bResult = false;
  24. foreach (System.Windows.Forms.Form frm in System.Windows.Forms.Application.OpenForms)
  25. {
  26. if (frm.Name == typeof(frmOfficalWebsiteVideo).Name)
  27. {
  28. bResult = true;
  29. break;
  30. }
  31. }
  32. return bResult;
  33. }
  34. /// <summary>
  35. /// 获取对话框句柄对象(窗口已打开返回对象,否则返回null);
  36. /// </summary>
  37. /// <returns></returns>
  38. public static frmOfficalWebsiteVideo GetDialogHandler()
  39. {
  40. frmOfficalWebsiteVideo handler = null;
  41. foreach (System.Windows.Forms.Form frm in System.Windows.Forms.Application.OpenForms)
  42. {
  43. if (frm.Name == typeof(frmOfficalWebsiteVideo).Name)
  44. {
  45. handler = (frmOfficalWebsiteVideo)frm;
  46. break;
  47. }
  48. }
  49. return handler;
  50. }
  51. /// <summary>
  52. /// 设置窗口要显示的视频地址;
  53. /// </summary>
  54. /// <param name="video_url">视频地址</param>
  55. public static void SetVideo(string video_url)
  56. {
  57. try
  58. {
  59. frmOfficalWebsiteVideo handler = GetDialogHandler();
  60. if (handler == null)
  61. {
  62. handler = new frmOfficalWebsiteVideo();
  63. handler.webBrowser1.Url = new Uri(video_url);
  64. handler.Show();
  65. }
  66. else
  67. {
  68. handler.Activate();
  69. handler.webBrowser1.Url = new Uri(video_url);
  70. }
  71. }
  72. catch (Exception ex)
  73. {
  74. System.Diagnostics.Debug.WriteLine(ex.Message);
  75. }
  76. }
  77. }
  78. }