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

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. using Common.system;
  2. using System;
  3. using System.Diagnostics;
  4. using System.Threading;
  5. using System.Windows;
  6. using System.Windows.Forms;
  7. using System.Windows.Input;
  8. using XHWK.Model;
  9. using XHWK.WKTool.Config;
  10. namespace XHWK.WKTool
  11. {
  12. /// <summary>
  13. /// 创建微课
  14. /// </summary>
  15. public partial class CreateAMicroLessonWindow : Window
  16. {
  17. #region 字段
  18. private FolderBrowserDialog ofd;
  19. private DialogResult result;
  20. #endregion
  21. /// <summary>
  22. /// 创建微课
  23. /// </summary>
  24. public CreateAMicroLessonWindow()
  25. {
  26. InitializeComponent();
  27. if (!APP.CheckScreenCapturerRecorder())
  28. {
  29. MessageWindow.Show("首次运行需安装环境,请在确定后依次点击“OK-Next>-Next>Install”完成安装!");
  30. APP.InstallScreenCapturerRecorder();
  31. }
  32. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  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. APP.WKData.WkPath = wkpath;
  99. APP.WKData.WkName = txbExplainName.Text;
  100. APP.WKData.WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
  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. this.Hide();
  137. }
  138. double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  139. 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 = ZConfig.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. int versionCode = resultObj.obj.versioncode;
  165. int versionThis = ZConfig.versionCode;
  166. if (versionThis < versionCode)
  167. {
  168. Dispatcher.Invoke(new Action(() =>
  169. {
  170. appUpdateShow(resultObj.obj);
  171. }));
  172. }
  173. }
  174. }
  175. }).Start();
  176. }
  177. /// <summary>
  178. /// 应用更新
  179. /// </summary>
  180. /// <param name="app"></param>
  181. private void appUpdateShow(Model_App app)
  182. {
  183. AppUpdateWin win = new AppUpdateWin(app);
  184. win.Topmost = true;
  185. win.Owner = this;
  186. win.ShowDialog();
  187. }
  188. private void Window_Loaded(object sender, RoutedEventArgs e)
  189. {
  190. getNewApp();
  191. }
  192. }
  193. }