星火微课系统客户端
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.

CreateAMicroLessonWindow.xaml.cs 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using Common.system;
  2. using System;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Windows;
  6. using System.Windows.Forms;
  7. using System.Windows.Input;
  8. using XHWK.Model;
  9. using XHWK.WKTool.Config;
  10. namespace XHWK.WKTool
  11. {
  12. /// <summary>
  13. /// 创建微课
  14. /// </summary>
  15. public partial class CreateAMicroLessonWindow : Window
  16. {
  17. #region 字段
  18. private FolderBrowserDialog ofd;
  19. private DialogResult result;
  20. #endregion
  21. /// <summary>
  22. /// 创建微课
  23. /// </summary>
  24. public CreateAMicroLessonWindow()
  25. {
  26. InitializeComponent();
  27. if (!APP.CheckScreenCapturerRecorder())
  28. {
  29. MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  30. APP.InstallScreenCapturerRecorder();
  31. }
  32. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  33. }
  34. #region 事件
  35. /// <summary>
  36. /// 关闭
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. private void BtnDown_Click(object sender, RoutedEventArgs e)
  41. {
  42. MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
  43. if (dr == MessageBoxResult.OK)
  44. {
  45. System.Environment.Exit(0);
  46. }
  47. else
  48. {
  49. return;
  50. }
  51. }
  52. /// <summary>
  53. /// 浏览
  54. /// </summary>
  55. /// <param name="sender"></param>
  56. /// <param name="e"></param>
  57. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  58. {
  59. string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  60. ofd = new System.Windows.Forms.FolderBrowserDialog();
  61. result = ofd.ShowDialog();
  62. if (result == System.Windows.Forms.DialogResult.OK)
  63. {
  64. if (ofd.SelectedPath != "")
  65. {
  66. txbStoragePath.Text = ofd.SelectedPath;
  67. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  68. //string temp = ofd.SelectedPath;
  69. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  70. }
  71. }
  72. }
  73. /// <summary>
  74. /// 开始
  75. /// </summary>
  76. /// <param name="sender"></param>
  77. /// <param name="e"></param>
  78. private void BtnStart_Click(object sender, RoutedEventArgs e)
  79. {
  80. #region 合法性判断
  81. if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
  82. {
  83. MessageWindow.Show("讲解名称不可为空!");
  84. return;
  85. }
  86. if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  87. {
  88. MessageWindow.Show("路径不可为空!");
  89. return;
  90. }
  91. #endregion
  92. string wkpath=FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim()+"/";
  93. //读取微课数据
  94. APP.ReadWkData(wkpath);
  95. if(APP.WKData==null)
  96. {
  97. APP.WKData = new Model.Model_WKData();
  98. APP.WKData.WkPath = wkpath;
  99. APP.WKData.WkName = txbExplainName.Text;
  100. APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  101. }
  102. //创建文件夹
  103. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  104. //存储文件
  105. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
  106. APP.ReadDrawData();
  107. #region 微课不允许有多个视频 废弃
  108. ////判断微课是否存在,存在则询问
  109. //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
  110. //{
  111. // if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
  112. // {
  113. // MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  114. // if (dr == MessageBoxResult.OK)
  115. // {
  116. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  117. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  118. // APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
  119. // }
  120. // else
  121. // {
  122. // return;
  123. // }
  124. // }
  125. //}
  126. #endregion
  127. if (APP.W_XHMicroLessonSystemWindow == null)
  128. {
  129. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  130. //APP.W_XHMicroLessonSystemWindow .Topmost = true;
  131. }
  132. APP.W_XHMicroLessonSystemWindow.Show();
  133. this.Hide();
  134. }
  135. /// <summary>
  136. /// 窗体移动
  137. /// </summary>
  138. /// <param name="sender"></param>
  139. /// <param name="e"></param>
  140. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  141. {
  142. DragMove();
  143. }
  144. #endregion
  145. /// <summary>
  146. /// 检测APP更新
  147. /// </summary>
  148. private void getNewApp()
  149. {
  150. new Thread(o =>
  151. {
  152. string url = ZConfig.apiUrl + "/apprecord/get_new";
  153. string result = HttpHelper.PostAndRespStr(url, "{}");
  154. Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
  155. if (result != null && resultObj.code == 0)
  156. {
  157. if (resultObj.obj != null)
  158. {
  159. int versionCode = resultObj.obj.versioncode;
  160. int versionThis = ZConfig.versionCode;
  161. if (versionThis < versionCode)
  162. {
  163. Dispatcher.Invoke(new Action(() =>
  164. {
  165. appUpdateShow(resultObj.obj);
  166. }));
  167. }
  168. }
  169. }
  170. }).Start();
  171. }
  172. /// <summary>
  173. /// 应用更新
  174. /// </summary>
  175. /// <param name="app"></param>
  176. private void appUpdateShow(Model_App app)
  177. {
  178. AppUpdateWin win = new AppUpdateWin(app);
  179. win.Topmost = true;
  180. win.Owner = this;
  181. win.ShowDialog();
  182. }
  183. private void Window_Loaded(object sender, RoutedEventArgs e)
  184. {
  185. getNewApp();
  186. }
  187. }
  188. }