星火微课系统客户端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

CreateAMicroLessonWindow.xaml.cs 9.0KB

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