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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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. //存储文件
  106. FileToolsCommon.SetConfigValue("VideoSavePath", txbStoragePath.Text);
  107. APP.ReadDrawData();
  108. #region 微课不允许有多个视频 废弃
  109. ////判断微课是否存在,存在则询问
  110. //if (APP.WKDataList != null&& APP.WKDataList.Count>0)
  111. //{
  112. // if (APP.WKDataList.Exists(x => x.WkName == APP.WKData.WkName))
  113. // {
  114. // MessageBoxResult dr = MessageWindow.Show("此微课已存在是否覆盖?", "提示", MessageBoxButton.OKCancel);
  115. // if (dr == MessageBoxResult.OK)
  116. // {
  117. // FileToolsCommon.DeleteDirectory(APP.WKData.WkPath);
  118. // FileToolsCommon.CreateDirectory(APP.WKData.WkPath);
  119. // APP.WKDataList.RemoveAll(x => x.WkName == APP.WKData.WkName);
  120. // }
  121. // else
  122. // {
  123. // return;
  124. // }
  125. // }
  126. //}
  127. #endregion
  128. if (APP.W_XHMicroLessonSystemWindow == null)
  129. {
  130. //double proportion = 1036.0 / 1276.0;
  131. APP.W_XHMicroLessonSystemWindow = new XHMicroLessonSystemWindow();
  132. //APP.W_XHMicroLessonSystemWindow.Width = proportion * (PrimaryScreen.ScaleScreenSize().Height-40);
  133. //APP.W_XHMicroLessonSystemWindow.Height =/*1276-*/ PrimaryScreen.ScaleScreenSize().Height-40;
  134. //APP.W_XHMicroLessonSystemWindow .Topmost = true;
  135. }
  136. APP.W_XHMicroLessonSystemWindow.Show();
  137. Hide();
  138. }
  139. private double screeHeight = SystemParameters.FullPrimaryScreenHeight;
  140. private double screeWidth = SystemParameters.FullPrimaryScreenWidth;
  141. /// <summary>
  142. /// 窗体移动
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  147. {
  148. DragMove();
  149. }
  150. #endregion
  151. /// <summary>
  152. /// 检测APP更新
  153. /// </summary>
  154. private void getNewApp()
  155. {
  156. new Thread(o =>
  157. {
  158. string url = APP.apiUrl + "/apprecord/get_new";
  159. string result = HttpHelper.PostAndRespStr(url, "{}");
  160. Model.ResultVo<Model_App> resultObj = JsonHelper.JsonToObj<Model.ResultVo<Model_App>>(result);
  161. if (result != null && resultObj.code == 0)
  162. {
  163. if (resultObj.obj != null)
  164. {
  165. try
  166. {
  167. int versionCode = resultObj.obj.versioncode;
  168. int versionThis = int.Parse(FileToolsCommon.GetConfigValue("VersionCode"));
  169. if (versionThis < versionCode)
  170. {
  171. Dispatcher.Invoke(new Action(() =>
  172. {
  173. appUpdateShow(resultObj.obj);
  174. }));
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. LogHelper.WriteErrLog("【检查更新】(getNewApp)版本号错误:" + ex.Message, ex);
  180. }
  181. }
  182. }
  183. }).Start();
  184. }
  185. /// <summary>
  186. /// 应用更新
  187. /// </summary>
  188. /// <param name="app"></param>
  189. private void appUpdateShow(Model_App app)
  190. {
  191. AppUpdateWin win = new AppUpdateWin(app)
  192. {
  193. Topmost = true,
  194. Owner = this
  195. };
  196. win.ShowDialog();
  197. }
  198. private void Window_Loaded(object sender, RoutedEventArgs e)
  199. {
  200. getNewApp();
  201. }
  202. }
  203. }