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

4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
4 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. if (!APP.CheckScreenCapturerRecorder())
  27. {
  28. MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“English-OK-Next>-Next>Install”完成安装!");
  29. APP.InstallScreenCapturerRecorder();
  30. }
  31. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  32. APP.FFmpeg.GetMToFFmpeg();
  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. {
  99. WkPath = wkpath,
  100. WkName = txbExplainName.Text,
  101. WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  102. };
  103. }
  104. //创建文件夹
  105. FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  106. FileToolsCommon.DeleteDirectory(wkpath + "temp");
  107. FileToolsCommon.DeleteDirectory(wkpath + "temprs");
  108. //存储文件
  109. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
  110. APP.ReadDrawData();
  111. #region 微课不允许有多个视频 废弃
  112. ////判断微课是否存在,存在则询问
  113. //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
  114. //{
  115. // if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
  116. // {
  117. // MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  118. // if (dr == MessageBoxResult.OK)
  119. // {
  120. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  121. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  122. // APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
  123. // }
  124. // else
  125. // {
  126. // return;
  127. // }
  128. // }
  129. //}
  130. #endregion
  131. if (APP.W_XHMicroLessonSystemWindow == null)
  132. {
  133. //double proportion = 1036.0 / 1276.0;
  134. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  135. //APP.W_XHMicroLessonSystemWindow.Width = proportion * (PrimaryScreen.ScaleScreenSize().Height-40);
  136. //APP.W_XHMicroLessonSystemWindow.Height =/*1276-*/ PrimaryScreen.ScaleScreenSize().Height-40;
  137. //APP.W_XHMicroLessonSystemWindow .Topmost = true;
  138. }
  139. APP.W_XHMicroLessonSystemWindow.Show();
  140. Hide();
  141. }
  142. private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  143. private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  144. /// <summary>
  145. /// 窗体移动
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  150. {
  151. DragMove();
  152. }
  153. #endregion
  154. /// <summary>
  155. /// 检测APP更新
  156. /// </summary>
  157. private void getNewApp()
  158. {
  159. new Thread(o =>
  160. {
  161. string url = APP.apiUrl + "/apprecord/get_new";
  162. string result = HttpHelper.PostAndRespStr(url, "{}");
  163. Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
  164. if (result != null && resultObj.code == 0)
  165. {
  166. if (resultObj.obj != null)
  167. {
  168. try
  169. {
  170. int versionCode = resultObj.obj.versioncode;
  171. int versionThis = int.Parse(FileToolsCommon.GetConfigValue("VersionCode"));
  172. if (versionThis < versionCode)
  173. {
  174. Dispatcher.Invoke(new Action(() =>
  175. {
  176. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  177. FileToolsCommon.CreateDirectory(pathTemp);
  178. appUpdateShow(resultObj.obj);
  179. }));
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. LogHelper.WriteErrLog("【检查更新】(getNewApp)版本号错误:" + ex.Message, ex);
  185. }
  186. }
  187. }
  188. }).Start();
  189. }
  190. /// <summary>
  191. /// 应用更新
  192. /// </summary>
  193. /// <param name="app"></param>
  194. private void appUpdateShow(Model_App app)
  195. {
  196. AppUpdateWin win = new AppUpdateWin(app)
  197. {
  198. Topmost = true,
  199. Owner = this
  200. };
  201. win.ShowDialog();
  202. }
  203. private void Window_Loaded(object sender, RoutedEventArgs e)
  204. {
  205. getNewApp();
  206. }
  207. }
  208. }