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

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