星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

CreateAMicroLessonWindow.xaml.cs 12KB

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 1 Jahr
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using Common.system;
  2. using System;
  3. using System.Threading;
  4. using System.Threading.Tasks;
  5. using System.Windows;
  6. using System.Windows.Forms;
  7. using System.Windows.Input;
  8. using XHWK.Model;
  9. namespace XHWK.WKTool
  10. {
  11. using system;
  12. /// <summary>
  13. /// 创建微课
  14. /// </summary>
  15. public partial class CreateAMicroLessonWindow
  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. ResizeMode = ResizeMode.NoResize;
  28. txbStoragePath.Text = FileToolsCommon.GetConfigValue("VideoSavePath");
  29. var versionCode = FileToolsCommon.GetConfigValue("VersionCode");
  30. var versionName = FileToolsCommon.GetConfigValue("VersionName");
  31. var isDebug = FileToolsCommon.GetConfigValue("IsDebug");
  32. var debugStr = "测试版";
  33. if (isDebug == "1")
  34. {
  35. debugStr = "测试版";
  36. }
  37. else if (isDebug == "0")
  38. {
  39. debugStr = "正式版";
  40. }
  41. versionLabel.Content = debugStr + " v" + versionName + "(" + versionCode + ")";
  42. LoadingCarouseImg();
  43. }
  44. #region 轮播图
  45. /// <summary>
  46. /// 图片宽度,每次切换的宽度
  47. /// </summary>
  48. private double _imgWidth = 502.00;
  49. /// <summary>
  50. /// 轮播时移动增加的宽度
  51. /// </summary>
  52. private double _imgMove = 1;
  53. /// <summary>
  54. /// 当前展示的图片序号Index从0开始
  55. /// </summary>
  56. private int _imgNumIndex;
  57. /// <summary>
  58. /// 加载录播图
  59. /// </summary>
  60. private void LoadingCarouseImg()
  61. {
  62. new Thread(() =>
  63. {
  64. Thread.Sleep(3000);
  65. Dispatcher.Invoke(() =>
  66. {
  67. _imgWidth = ImgCarouse1.ActualWidth;
  68. _imgMove = _imgWidth / 250.00;
  69. CarouseImg();
  70. //timesCarouse = new System.Timers.Timer(2000);
  71. //timesCarouse.Elapsed += TimesCarouse_Elapsed; ;
  72. //timesCarouse.Start();
  73. });
  74. }).Start();
  75. }
  76. /// <summary>
  77. /// 轮播图
  78. /// </summary>
  79. private void CarouseImg()
  80. {
  81. new Thread(() =>
  82. {
  83. while (true)
  84. {
  85. for (double i = _imgMove; i < _imgWidth; i += _imgMove)
  86. {
  87. var i1 = i;
  88. Dispatcher.Invoke(() =>
  89. {
  90. if (Math.Abs(
  91. i1 + _imgMove) < _imgWidth)
  92. {
  93. //图片移动轮播
  94. SplCarouse.Margin = new Thickness(SplCarouse.Margin.Left - _imgMove, 0, 0, 0);
  95. }
  96. else
  97. {
  98. if (_imgNumIndex >= 2)
  99. {
  100. _imgNumIndex = 0;
  101. SplCarouse.Margin = new Thickness(0, 0, 0, 0);
  102. }
  103. else
  104. {
  105. _imgNumIndex++;
  106. SplCarouse.Margin = new Thickness(-(_imgNumIndex * _imgWidth), 0, 0, 0);
  107. }
  108. }
  109. });
  110. Thread.Sleep(3);
  111. }
  112. bool isBreak = false;
  113. Dispatcher.Invoke(() =>
  114. {
  115. if (this.Visibility != Visibility.Visible)
  116. {
  117. SplCarouse.Margin = new Thickness(0);
  118. isBreak = true;
  119. }
  120. });
  121. Thread.Sleep(5000);
  122. if (isBreak)
  123. {
  124. break;
  125. }
  126. }
  127. }).Start();
  128. }
  129. #endregion 轮播图
  130. #region 事件
  131. /// <summary>
  132. /// 关闭
  133. /// </summary>
  134. /// <param name="sender">
  135. /// </param>
  136. /// <param name="e">
  137. /// </param>
  138. private void BtnDown_Click(object sender, RoutedEventArgs e)
  139. {
  140. MessageBoxResult dr = MessageWindow.Show("确定退出系统?", "提示", MessageBoxButton.OKCancel);
  141. if (dr == MessageBoxResult.OK)
  142. {
  143. Environment.Exit(0);
  144. }
  145. }
  146. /// <summary>
  147. /// 浏览
  148. /// </summary>
  149. /// <param name="sender">
  150. /// </param>
  151. /// <param name="e">
  152. /// </param>
  153. private void BtnBrowse_Click(object sender, RoutedEventArgs e)
  154. {
  155. //string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
  156. _ofd = new FolderBrowserDialog();
  157. _result = _ofd.ShowDialog();
  158. if (_result == System.Windows.Forms.DialogResult.OK)
  159. {
  160. if (_ofd.SelectedPath != "")
  161. {
  162. txbStoragePath.Text = _ofd.SelectedPath;
  163. }
  164. }
  165. }
  166. private bool _isPressButton;
  167. /// <summary>
  168. /// 开始
  169. /// </summary>
  170. /// <param name="sender">
  171. /// </param>
  172. /// <param name="e">
  173. /// </param>
  174. private async void BtnStart_Click(object sender, RoutedEventArgs e)
  175. {
  176. #region 防止连击
  177. if (_isPressButton)
  178. {
  179. return;
  180. }
  181. else
  182. {
  183. _isPressButton = true;
  184. new Thread(() =>
  185. {
  186. Thread.Sleep(500);
  187. _isPressButton = false;
  188. }).Start();
  189. }
  190. #endregion 防止连击
  191. #region 合法性判断
  192. if (string.IsNullOrWhiteSpace(txbExplainName.Text.Trim()))
  193. {
  194. MessageWindow.Show("讲解名称不可为空!");
  195. return;
  196. }
  197. if (string.IsNullOrWhiteSpace(txbStoragePath.Text.Trim()))
  198. {
  199. MessageWindow.Show("路径不可为空!");
  200. return;
  201. }
  202. try
  203. {
  204. FileToolsCommon.CreateDirectory(txbStoragePath.Text.Trim());
  205. }
  206. catch (Exception)
  207. {
  208. MessageWindow.Show("路径无法访问,解决方案:\r\n1,检查路径是否可访问。\r\n2,关闭杀毒软件或信任软件。");
  209. return;
  210. }
  211. #endregion 合法性判断
  212. LblCreate.Visibility = Visibility.Visible;
  213. string wkpath = FileToolsCommon.GetLegalPath(txbStoragePath.Text) + txbExplainName.Text.Trim() + "/";
  214. string storagePath = txbStoragePath.Text;
  215. string wkName = txbExplainName.Text;
  216. await Task.Run(() =>
  217. {
  218. try
  219. {
  220. //读取微课数据
  221. App.ReadWkData(wkpath);
  222. if (App.WKData == null)
  223. {
  224. App.WKData = new Model_WKData
  225. {
  226. WkPath = wkpath,
  227. WkName = wkName,
  228. WkCreateDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
  229. };
  230. }
  231. try
  232. {
  233. //创建文件夹
  234. FileToolsCommon.CreateDirectory(App.WKData.WkPath);
  235. FileToolsCommon.DeleteDirectory(wkpath + "temp");
  236. FileToolsCommon.DeleteDirectory(wkpath + "_temppath");
  237. }
  238. catch (Exception ex)
  239. {
  240. LogHelper.WriteErrLog("【微课创建课程】文件夹创建删除失败:" + ex.Message, ex);
  241. }
  242. //存储文件
  243. FileToolsCommon.SetConfigValue("VideoSavePath", storagePath);
  244. App.ReadDrawData();
  245. }
  246. catch (Exception ex)
  247. {
  248. LogHelper.WriteErrLog("【微课创建课程】读取课堂数据失败:" + ex.Message, ex);
  249. }
  250. });
  251. if (App.W_XHMicroLessonSystemWindow == null)
  252. {
  253. App.W_XHMicroLessonSystemWindow = new MainWindow();
  254. }
  255. App.W_XHMicroLessonSystemWindow.Show();
  256. LblCreate.Visibility = Visibility.Hidden;
  257. Hide();
  258. }
  259. /// <summary>
  260. /// 窗体移动
  261. /// </summary>
  262. /// <param name="sender">
  263. /// </param>
  264. /// <param name="e">
  265. /// </param>
  266. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  267. {
  268. DragMove();
  269. }
  270. #endregion 事件
  271. /// <summary>
  272. /// 检测APP更新
  273. /// </summary>
  274. private void GetNewApp()
  275. {
  276. new Thread(o =>
  277. {
  278. //读取本地
  279. App.ReadServiceAddressData();
  280. int versionThis = int.Parse(FileToolsCommon.GetConfigValue("VersionCode"));
  281. if (versionThis < 0)
  282. {
  283. //软件是否更新,版本号小于0不更新
  284. return;
  285. }
  286. string url = App.apiUrl + "/sapi/apprecord/get_new";
  287. string result = HttpHelper.PostAndRespStr(url, "{}");
  288. var resultObj = JsonHelper.JsonToObj<ResultVo<Model_App>>(result);
  289. if (result != null && resultObj.code == 0)
  290. {
  291. if (resultObj.obj != null)
  292. {
  293. try
  294. {
  295. int versionCode = resultObj.obj.versioncode;
  296. if (versionThis < versionCode)
  297. {
  298. Dispatcher.Invoke(() =>
  299. {
  300. string pathTemp = AppDomain.CurrentDomain.BaseDirectory + "Temp\\";
  301. FileToolsCommon.CreateDirectory(pathTemp);
  302. AppUpdateShow(resultObj.obj);
  303. });
  304. }
  305. }
  306. catch (Exception ex)
  307. {
  308. LogHelper.WriteErrLog("【检查更新】(getNewApp)版本号错误:" + ex.Message, ex);
  309. }
  310. }
  311. }
  312. }).Start();
  313. }
  314. /// <summary>
  315. /// 应用更新
  316. /// </summary>
  317. /// <param name="app">
  318. /// </param>
  319. private void AppUpdateShow(Model_App app)
  320. {
  321. AppUpdateWin win = new AppUpdateWin(app)
  322. {
  323. Topmost = true,
  324. Owner = this
  325. };
  326. win.Show();
  327. }
  328. private void Window_Loaded(object sender, RoutedEventArgs e)
  329. {
  330. GetNewApp();
  331. }
  332. private void Window_Closed(object sender, EventArgs e)
  333. {
  334. Environment.Exit(0);
  335. }
  336. }
  337. }