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

CreateAMicroLessonWindow.xaml.cs 7.5KB

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