星火微课系统客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

FileDirectoryWindow.xaml.cs 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. using Common.system;
  2. using Org.BouncyCastle.Asn1.Crmf;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Collections.ObjectModel;
  6. using System.Diagnostics;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using XHWK.Model;
  12. using XHWK.WKTool.DAL;
  13. namespace XHWK.WKTool
  14. {
  15. /// <summary>
  16. /// 文件目录
  17. /// </summary>
  18. public partial class FileDirectoryWindow : Window
  19. {
  20. /// <summary>
  21. /// 视频模型
  22. /// </summary>
  23. List<Model_Video> model_VideoList =null;
  24. internal FileDirectoryData pageData = new FileDirectoryData();
  25. /// <summary>
  26. /// 文件目录
  27. /// </summary>
  28. public FileDirectoryWindow()
  29. {
  30. InitializeComponent();
  31. Initialize();
  32. }
  33. /// <summary>
  34. /// 初始化
  35. /// </summary>
  36. public void Initialize()
  37. {
  38. //加载视频列表
  39. LoadingVideoList();
  40. int i = 1;
  41. bool isColour = true;
  42. //显示视频
  43. foreach (Model_Video videoinfo in model_VideoList)
  44. {
  45. //是否已上传
  46. //videoinfo.IsUpload;
  47. //录制时间
  48. //videoinfo.RSTime;
  49. //文件大小
  50. //videoinfo.VideoSize;
  51. //文件缩略图路径
  52. //videoinfo.ThumbnailPath;
  53. //文件唯一标示 上传事件筛选需要上传的视频
  54. //videoinfo.FileGuid;
  55. //文件存储路径
  56. //videoinfo.VidePath;
  57. string colour = "#FFFFFF";
  58. if (isColour==true)
  59. {
  60. colour = "#FFFFFF";
  61. isColour = false;
  62. }
  63. else
  64. {
  65. colour = "#E6F1FF";
  66. isColour = true;
  67. }
  68. string vis = "Visible";
  69. string cos = "Collapsed";
  70. if(!videoinfo.IsUpload)
  71. {
  72. vis= "Collapsed";
  73. cos= "Visible";
  74. }
  75. pageData.menuList.Add(new FileDirectoryModel()
  76. {
  77. SerialNumber = i,
  78. VideoName = Common.system.FileToolsCommon.GetIOFileName(videoinfo.VideoPath),
  79. VideoDuration = 0,
  80. VideoSize = videoinfo.VideoSize,
  81. VideoTime = videoinfo.RSTime,
  82. IsEnabled = false,
  83. Path = videoinfo.VideoPath,
  84. Colour = colour,
  85. Visi = vis,
  86. Coll=cos,
  87. FileGuid= videoinfo.FileGuid,
  88. }) ; ;
  89. i++;
  90. }
  91. txbSum.Text = pageData.menuList.Count.ToString();
  92. DataContext = pageData;
  93. }
  94. /// <summary>
  95. /// 加载视频列表
  96. /// </summary>
  97. public void LoadingVideoList()
  98. {
  99. model_VideoList = new List<Model_Video>();
  100. foreach(Model_WKData Vdata in APP.WKDataList)
  101. {
  102. if (Vdata.VideoList == null)
  103. continue;
  104. foreach(Model_Video videoinfo in Vdata.VideoList)
  105. {
  106. model_VideoList.Add(videoinfo);
  107. }
  108. }
  109. }
  110. /// <summary>
  111. /// 关闭
  112. /// </summary>
  113. /// <param name="sender"></param>
  114. /// <param name="e"></param>
  115. private void btnDown_Click(object sender, RoutedEventArgs e)
  116. {
  117. this.Hide();
  118. }
  119. /// <summary>
  120. /// 窗口移动
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  125. {
  126. DragMove();
  127. }
  128. /// <summary>
  129. /// 上传
  130. /// </summary>
  131. /// <param name="sender"></param>
  132. /// <param name="e"></param>
  133. private void BtnUpload_Click(object sender, RoutedEventArgs e)
  134. {
  135. List<Button> buttons = FindChilds<Button>(listView1, "btnUpload");
  136. for (int i = 0; i < buttons.Count; i++)
  137. {
  138. if (buttons[i] == sender)
  139. {
  140. DAL_Upload dAL_Upload = new DAL_Upload();
  141. string msg = string.Empty;
  142. bool isOK= dAL_Upload.UploadVideo(pageData.menuList[i].FileGuid,out msg);
  143. if(isOK)
  144. {
  145. pageData.menuList[i].Visi = "Visible";
  146. pageData.menuList[i].Coll = "Collapsed";
  147. }
  148. else
  149. {
  150. System.Windows.Forms.MessageBox.Show(msg, "", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
  151. return;
  152. }
  153. }
  154. }
  155. }
  156. /// <summary>
  157. /// 删除
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void BtnDelete_Click(object sender, RoutedEventArgs e)
  162. {
  163. List<Button> buttons = FindChilds<Button>(listView1, "btnDelete");
  164. for (int i = 0; i < buttons.Count; i++)
  165. {
  166. if (buttons[i] == sender)
  167. {
  168. }
  169. }
  170. }
  171. /// <summary>
  172. /// 播放
  173. /// </summary>
  174. /// <param name="sender"></param>
  175. /// <param name="e"></param>
  176. private void BtnPlay_Click(object sender, RoutedEventArgs e)
  177. {
  178. List<Button> buttons = FindChilds<Button>(listView1, "btnPlay");
  179. for (int i = 0; i < buttons.Count; i++)
  180. {
  181. if (buttons[i] == sender)
  182. {
  183. try
  184. {
  185. ProcessStartInfo psi = new ProcessStartInfo(pageData.menuList[i].Path);
  186. Process pro = new Process
  187. {
  188. StartInfo = psi
  189. };
  190. pro.Start();
  191. }
  192. catch (Exception ex)
  193. {
  194. LogHelper.WriteErrLog("FileDirectoryWindow【BtnPlay_Click】" + ex.Message, ex);
  195. MessageBox.Show(ex.Message);
  196. return;
  197. }
  198. }
  199. }
  200. }
  201. public static List<T> FindChilds<T>(DependencyObject parent, string childName)
  202. where T : DependencyObject
  203. {
  204. List<T> list = new List<T>();
  205. if (parent == null)
  206. {
  207. return list;
  208. }
  209. int childrenCount = VisualTreeHelper.GetChildrenCount(parent);
  210. for (int i = 0; i < childrenCount; i++)
  211. {
  212. DependencyObject child = VisualTreeHelper.GetChild(parent, i);
  213. // 如果子控件不是需查找的控件类型
  214. T childType = child as T;
  215. if (childType == null)
  216. {
  217. // 在下一级控件中递归查找
  218. List<T> findChildList = FindChilds<T>(child, childName);
  219. for (int j = 0; j < findChildList.Count; j++)
  220. {
  221. }
  222. list.AddRange(FindChilds<T>(child, childName));
  223. }
  224. else if (!string.IsNullOrEmpty(childName))
  225. {
  226. FrameworkElement frameworkElement = child as FrameworkElement;
  227. // 如果控件名称符合参数条件
  228. if (frameworkElement != null && frameworkElement.Name == childName)
  229. {
  230. list.Add((T)child);
  231. }
  232. }
  233. else
  234. {
  235. // 查找到了控件
  236. list.Add((T)child);
  237. }
  238. }
  239. return list;
  240. }
  241. /// <summary>
  242. /// 修改
  243. /// </summary>
  244. /// <param name="sender"></param>
  245. /// <param name="e"></param>
  246. private void BtnModify_Click(object sender, RoutedEventArgs e)
  247. {
  248. List<Button> buttons = FindChilds<Button>(listView1, "btnModify");
  249. for (int i = 0; i < buttons.Count; i++)
  250. {
  251. if (buttons[i] == sender)
  252. {
  253. pageData.menuList[i].IsEnabled = true;
  254. }
  255. }
  256. }
  257. }
  258. public class FileDirectoryData : NotifyModel
  259. {
  260. public ObservableCollection<FileDirectoryModel> menuList { get; set; }
  261. public FileDirectoryData()
  262. {
  263. menuList = new ObservableCollection<FileDirectoryModel>();
  264. }
  265. }
  266. public class FileDirectoryModel : NotifyModel
  267. {
  268. private int _serialNumber;
  269. /// <summary>
  270. /// 序号
  271. /// </summary>
  272. public int SerialNumber
  273. {
  274. get => _serialNumber;
  275. set
  276. {
  277. _serialNumber = value;
  278. OnPropertyChanged("SerialNumber");
  279. }
  280. }
  281. private string _videoName;
  282. /// <summary>
  283. /// 视频名称
  284. /// </summary>
  285. public string VideoName
  286. {
  287. get => _videoName;
  288. set
  289. {
  290. _videoName = value;
  291. OnPropertyChanged("VideoName");
  292. }
  293. }
  294. private int _videoDuration;
  295. /// <summary>
  296. /// 视频时长
  297. /// </summary>
  298. public int VideoDuration
  299. {
  300. get => _videoDuration;
  301. set
  302. {
  303. _videoDuration = value;
  304. OnPropertyChanged("VideoDuration");
  305. }
  306. }
  307. private string _videoSize;
  308. /// <summary>
  309. /// 视频大小
  310. /// </summary>
  311. public string VideoSize
  312. {
  313. get => _videoSize;
  314. set
  315. {
  316. _videoSize = value;
  317. OnPropertyChanged("VideoSize");
  318. }
  319. }
  320. private string _videoTime;
  321. /// <summary>
  322. /// 日期
  323. /// </summary>
  324. public string VideoTime
  325. {
  326. get => _videoTime;
  327. set
  328. {
  329. _videoTime = value;
  330. OnPropertyChanged("VideoTime");
  331. }
  332. }
  333. private string _colour;
  334. /// <summary>
  335. /// 颜色
  336. /// </summary>
  337. public string Colour
  338. {
  339. get => _colour;
  340. set
  341. {
  342. _colour = value;
  343. OnPropertyChanged("Colour");
  344. }
  345. }
  346. private bool _isEnabled;
  347. /// <summary>
  348. /// 是否可编辑
  349. /// </summary>
  350. public bool IsEnabled
  351. {
  352. get => _isEnabled;
  353. set
  354. {
  355. _isEnabled = value;
  356. OnPropertyChanged("IsEnabled");
  357. }
  358. }
  359. public string Path { get; set; }
  360. private string _visi;
  361. /// <summary>
  362. /// 显示
  363. /// </summary>
  364. public string Visi
  365. {
  366. get => _visi;
  367. set
  368. {
  369. _visi = value;
  370. OnPropertyChanged("Visi");
  371. }
  372. }
  373. private string _coll;
  374. /// <summary>
  375. /// 显示
  376. /// </summary>
  377. public string Coll
  378. {
  379. get => _coll;
  380. set
  381. {
  382. _coll = value;
  383. OnPropertyChanged("Coll");
  384. }
  385. }
  386. /// <summary>
  387. /// 唯一编号
  388. /// </summary>
  389. public string FileGuid { get; set; }
  390. }
  391. }