星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

CreateAMicroLessonWindow.xaml.cs 7.7KB

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