星火微课系统客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CreateAMicroLessonWindow.xaml.cs 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using Common.system;
  2. using System;
  3. using System.Windows;
  4. using System.Windows.Forms;
  5. using System.Windows.Input;
  6. namespace XHWK.WKTool
  7. {
  8. /// <summary>
  9. /// 创建微课
  10. /// </summary>
  11. public partial class CreateAMicroLessonWindow : Window
  12. {
  13. #region 字段
  14. private FolderBrowserDialog ofd;
  15. private DialogResult result;
  16. #endregion
  17. /// <summary>
  18. /// 创建微课
  19. /// </summary>
  20. public CreateAMicroLessonWindow()
  21. {
  22. InitializeComponent();
  23. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  24. }
  25. #region 事件
  26. /// <summary>
  27. /// 关闭
  28. /// </summary>
  29. /// <param name="sender"></param>
  30. /// <param name="e"></param>
  31. private void BtnDown_Click(object sender, RoutedEventArgs e)
  32. {
  33. MessageBoxResult dr = System.Windows.MessageBox.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
  34. if (dr == MessageBoxResult.OK)
  35. {
  36. System.Environment.Exit(0);
  37. }
  38. else
  39. {
  40. return;
  41. }
  42. }
  43. /// <summary>
  44. /// 浏览
  45. /// </summary>
  46. /// <param name="sender"></param>
  47. /// <param name="e"></param>
  48. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  49. {
  50. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  51. ofd = new System.Windows.Forms.FolderBrowserDialog();
  52. result = ofd.ShowDialog();
  53. if (result == System.Windows.Forms.DialogResult.OK)
  54. {
  55. if (ofd.SelectedPath != "")
  56. {
  57. txbStoragePath.Text = ofd.SelectedPath;
  58. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  59. //string temp = ofd.SelectedPath;
  60. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  61. }
  62. }
  63. }
  64. /// <summary>
  65. /// 开始
  66. /// </summary>
  67. /// <param name="sender"></param>
  68. /// <param name="e"></param>
  69. private void BtnStart_Click(object sender, RoutedEventArgs e)
  70. {
  71. #region 合法性判断
  72. if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
  73. {
  74. System.Windows.MessageBox.Show("讲解名称不可为空!");
  75. return;
  76. }
  77. if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  78. {
  79. System.Windows.MessageBox.Show("路径不可为空!");
  80. return;
  81. }
  82. APP.WKData.WkPath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
  83. if (APP.UserInfo != null)
  84. {
  85. if (!string.IsNullOrWhiteSpace(APP.UserInfo.Username))
  86. {
  87. //判断课程是否存在
  88. if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
  89. {
  90. MessageBoxResult dr = System.Windows.MessageBox.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  91. if (dr == MessageBoxResult.OK)
  92. {
  93. FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  94. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  95. APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
  96. }
  97. else
  98. {
  99. return;
  100. }
  101. }
  102. APP.WKData.WkPath += APP.UserInfo.Username + "/";
  103. }
  104. }
  105. #endregion
  106. //创建文件夹
  107. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  108. //存储文件
  109. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
  110. APP.WKData.WkName = txbExplainName.Text;
  111. APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  112. if (APP.W_XHMicroLessonSystemWindow == null)
  113. {
  114. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  115. //APP.W_XHMicroLessonSystemWindow .Topmost = true;
  116. }
  117. this.Hide();
  118. APP.W_XHMicroLessonSystemWindow.ShowDialog();
  119. }
  120. /// <summary>
  121. /// 窗体移动
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  126. {
  127. DragMove();
  128. }
  129. #endregion
  130. }
  131. }