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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. using Common.system;
  2. using System;
  3. using System.Threading;
  4. using System.Windows;
  5. using System.Windows.Forms;
  6. using System.Windows.Input;
  7. using XHWK.Model;
  8. namespace XHWK.WKTool
  9. {
  10. /// <summary>
  11. /// 创建微课
  12. /// </summary>
  13. public partial class CreateAMicroLessonWindow : Window
  14. {
  15. #region 字段
  16. private FolderBrowserDialog ofd;
  17. private DialogResult result;
  18. #endregion
  19. /// <summary>
  20. /// 创建微课
  21. /// </summary>
  22. public CreateAMicroLessonWindow()
  23. {
  24. InitializeComponent();
  25. if (APP.SkinStyle == "Blue")
  26. {
  27. GridTitle.Visibility = Visibility.Visible;
  28. GridTitle_Black.Visibility = Visibility.Collapsed;
  29. }
  30. else if (APP.SkinStyle == "Black")
  31. {
  32. GridTitle.Visibility = Visibility.Collapsed;
  33. GridTitle_Black.Visibility = Visibility.Visible;
  34. }
  35. else
  36. {
  37. GridTitle.Visibility = Visibility.Visible;
  38. GridTitle_Black.Visibility = Visibility.Collapsed;
  39. }
  40. ResizeMode = ResizeMode.NoResize;
  41. new Thread(o =>
  42. {
  43. if (!FileToolsCommon.IsExistDirectory(FileToolsCommon.GetFileAbsolutePath("/ffmpeg/")))
  44. {
  45. try
  46. {
  47. //根据系统解压ffmpeg
  48. if (Environment.Is64BitOperatingSystem)
  49. {
  50. //64
  51. ZipHelper.UnZip(FileToolsCommon.GetFileAbsolutePath("/ffmpegx64.zip"), FileToolsCommon.GetFileAbsolutePath());
  52. }
  53. else
  54. {
  55. //32
  56. ZipHelper.UnZip(FileToolsCommon.GetFileAbsolutePath("/ffmpegx32.zip"), FileToolsCommon.GetFileAbsolutePath());
  57. }
  58. }
  59. catch (Exception)
  60. {
  61. ZipHelper.UnZip(FileToolsCommon.GetFileAbsolutePath("/ffmpegx64.zip"), FileToolsCommon.GetFileAbsolutePath());
  62. }
  63. }
  64. }).Start();
  65. if (!APP.CheckScreenCapturerRecorder())
  66. {
  67. MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
  68. APP.InstallScreenCapturerRecorder();
  69. }
  70. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  71. //APP.FFmpeg.GetMToFFmpeg();
  72. }
  73. #region 事件
  74. /// <summary>
  75. /// 关闭
  76. /// </summary>
  77. /// <param name="sender"></param>
  78. /// <param name="e"></param>
  79. private void BtnDown_Click(object sender, RoutedEventArgs e)
  80. {
  81. MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
  82. if (dr == MessageBoxResult.OK)
  83. {
  84. System.Environment.Exit(0);
  85. }
  86. else
  87. {
  88. return;
  89. }
  90. }
  91. /// <summary>
  92. /// 浏览
  93. /// </summary>
  94. /// <param name="sender"></param>
  95. /// <param name="e"></param>
  96. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  97. {
  98. //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  99. ofd = new FolderBrowserDialog();
  100. result = ofd.ShowDialog();
  101. if (result == System.Windows.Forms.DialogResult.OK)
  102. {
  103. if (ofd.SelectedPath != "")
  104. {
  105. txbStoragePath.Text = ofd.SelectedPath;
  106. //string ApplicationData = ZConfig.dataPath + "fileStorageAddress.txt";
  107. //string temp = ofd.SelectedPath;
  108. //System.IO.File.WriteAllText(ApplicationData, temp, Encoding.Default);
  109. }
  110. }
  111. }
  112. /// <summary>
  113. /// 开始
  114. /// </summary>
  115. /// <param name="sender"></param>
  116. /// <param name="e"></param>
  117. private void BtnStart_Click(object sender, RoutedEventArgs e)
  118. {
  119. #region 合法性判断
  120. if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
  121. {
  122. MessageWindow.Show("讲解名称不可为空!");
  123. return;
  124. }
  125. if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  126. {
  127. MessageWindow.Show("路径不可为空!");
  128. return;
  129. }
  130. #endregion
  131. string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
  132. //读取微课数据
  133. APP.ReadWkData(wkpath);
  134. if (APP.WKData == null)
  135. {
  136. APP.WKData = new Model.Model_WKData
  137. {
  138. WkPath = wkpath,
  139. WkName = txbExplainName.Text,
  140. WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  141. };
  142. }
  143. //创建文件夹
  144. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  145. FileToolsCommon.DeleteDirectory(wkpath + "temp");
  146. FileToolsCommon.DeleteDirectory(wkpath + "temprs");
  147. //存储文件
  148. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
  149. APP.ReadDrawData();
  150. #region 微课不允许有多个视频 废弃
  151. ////判断微课是否存在,存在则询问
  152. //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
  153. //{
  154. // if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
  155. // {
  156. // MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  157. // if (dr == MessageBoxResult.OK)
  158. // {
  159. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  160. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  161. // APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
  162. // }
  163. // else
  164. // {
  165. // return;
  166. // }
  167. // }
  168. //}
  169. #endregion
  170. if (APP.W_XHMicroLessonSystemWindow == null)
  171. {
  172. //double proportion = 1036.0 / 1276.0;
  173. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  174. //APP.W_XHMicroLessonSystemWindow.Width = proportion * (PrimaryScreen.ScaleScreenSize().Height-40);
  175. //APP.W_XHMicroLessonSystemWindow.Height =/*1276-*/ PrimaryScreen.ScaleScreenSize().Height-40;
  176. //APP.W_XHMicroLessonSystemWindow .Topmost = true;
  177. }
  178. APP.W_XHMicroLessonSystemWindow.Show();
  179. Hide();
  180. }
  181. private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  182. private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  183. /// <summary>
  184. /// 窗体移动
  185. /// </summary>
  186. /// <param name="sender"></param>
  187. /// <param name="e"></param>
  188. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  189. {
  190. DragMove();
  191. }
  192. #endregion
  193. /// <summary>
  194. /// 检测APP更新
  195. /// </summary>
  196. private void getNewApp()
  197. {
  198. new Thread(o =>
  199. {
  200. int versionThis = int.Parse(FileToolsCommon.GetConfigValue("VersionCode"));
  201. if (versionThis < 0)
  202. {
  203. //软件是否更新,版本号小于0不更新
  204. return;
  205. }
  206. string url = APP.apiUrl + "/apprecord/get_new";
  207. string result = HttpHelper.PostAndRespStr(url, "{}");
  208. Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
  209. if (result != null && resultObj.code == 0)
  210. {
  211. if (resultObj.obj != null)
  212. {
  213. try
  214. {
  215. int versionCode = resultObj.obj.versioncode;
  216. if (versionThis < versionCode)
  217. {
  218. Dispatcher.Invoke(new Action(() =>
  219. {
  220. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  221. FileToolsCommon.CreateDirectory(pathTemp);
  222. appUpdateShow(resultObj.obj);
  223. }));
  224. }
  225. }
  226. catch (Exception ex)
  227. {
  228. LogHelper.WriteErrLog("【检查更新】(getNewApp)版本号错误:" + ex.Message, ex);
  229. }
  230. }
  231. }
  232. }).Start();
  233. }
  234. /// <summary>
  235. /// 应用更新
  236. /// </summary>
  237. /// <param name="app"></param>
  238. private void appUpdateShow(Model_App app)
  239. {
  240. AppUpdateWin win = new AppUpdateWin(app)
  241. {
  242. Topmost = true,
  243. Owner = this
  244. };
  245. win.ShowDialog();
  246. }
  247. private void Window_Loaded(object sender, RoutedEventArgs e)
  248. {
  249. getNewApp();
  250. }
  251. }
  252. }