星火直播PC
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

ToolbarWindow.xaml.cs 31KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15. using XHZB.Model;
  16. using Common.ZB;
  17. using XHZB.Desktop.Utils;
  18. using Common.system;
  19. using System.Windows.Media.Animation;
  20. using System.Threading;
  21. using XHZB.Desktop.WebSocket;
  22. namespace XHZB.Desktop
  23. {
  24. /// <summary>
  25. /// ToolbarWindow.xaml 的交互逻辑
  26. /// </summary>
  27. public partial class ToolbarWindow : Window
  28. {
  29. #region 字段
  30. /// <summary>
  31. /// 屏幕宽
  32. /// </summary>
  33. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  34. /// <summary>
  35. /// 屏幕高
  36. /// </summary>
  37. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  38. /// <summary>
  39. /// 工具栏数据
  40. /// </summary>
  41. internal ToolbarModel pageData = new ToolbarModel();
  42. /// <summary>
  43. /// 是否已打开课堂工具二级列表
  44. /// </summary>
  45. private bool heibanshow = false;
  46. #endregion
  47. #region 初始化
  48. public ToolbarWindow()
  49. {
  50. InitializeComponent();
  51. txbName.Text = APP.LoginUser.username;
  52. heiban_btn.Click += Heiban_btn_Click;
  53. pizhu_btn.Click += Pizhu_btn_Click;
  54. Topmost = true;
  55. Left = pwidth - 300;
  56. Top = (pHeight - 568) / 2;
  57. pageData.menuList.Add(new ToolbarMenu()
  58. {
  59. Name = "个人空间",
  60. Pic = "../Images/ToolBar/我的备课@2x.png"
  61. });
  62. pageData.menuList.Add(new ToolbarMenu()
  63. {
  64. Name = "直播",
  65. Pic = "../Images/ToolBar/直播@2x.png"
  66. });
  67. pageData.menuList.Add(new ToolbarMenu()
  68. {
  69. Name = "抢答点名",
  70. Pic = "../Images/ToolBar/抢答@2x.png"
  71. });
  72. pageData.menuList.Add(new ToolbarMenu()
  73. {
  74. Name = "课堂工具",
  75. Pic = "../Images/ToolBar/黑板01@2x.png"
  76. });
  77. pageData.menuList.Add(new ToolbarMenu()
  78. {
  79. Name = "本节考勤",
  80. Pic = "../Images/ToolBar/本节考勤01@2x.png"
  81. });
  82. pageData.menuList.Add(new ToolbarMenu()
  83. {
  84. Name = "结束课堂",
  85. Pic = "../Images/ToolBar/下课@2x.png"
  86. });
  87. DataContext = pageData;
  88. Thread t = new Thread(new ThreadStart(startSocket))
  89. {
  90. IsBackground = true
  91. };
  92. t.Start();
  93. }
  94. #endregion
  95. #region 事件
  96. /// <summary>
  97. /// 模块点击
  98. /// </summary>
  99. /// <param name="sender"></param>
  100. /// <param name="e"></param>
  101. private void toolbar_item_Click(object sender, RoutedEventArgs e)
  102. {
  103. int clickindex = 0;
  104. List<Button> buttons = VTHelper.FindChilds<Button>(toolbar_list, "toolbar_item");
  105. for (int i = 0; i < buttons.Count; i++)
  106. {
  107. if (buttons[i] == sender)
  108. {
  109. clickindex = i;
  110. break;
  111. }
  112. }
  113. ToolbarMenu item = pageData.menuList[clickindex];
  114. if (clickindex == 0)//个人空间
  115. {
  116. try
  117. {
  118. //HideLevel2();
  119. if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
  120. {
  121. APP.W_UserCenterWindow.Focus();
  122. }
  123. else
  124. {
  125. APP.W_UserCenterWindow = new UserCenterWindow();
  126. APP.W_UserCenterWindow.Show();
  127. APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
  128. }
  129. //IsOpenUserCenterWindow = true;
  130. }
  131. catch (Exception ex)
  132. {
  133. //IsOpenUserCenterWindow = false;
  134. //userCenterWindow = null;
  135. LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
  136. }
  137. }
  138. else if (clickindex == 1)//直播
  139. {
  140. //HideLevel2();
  141. pageData.tongping = !pageData.tongping;
  142. if (pageData.tongping)
  143. {
  144. //tongpingBegin();
  145. if (StartLive(out string ErrMessage))
  146. {
  147. pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
  148. pageData.menuList[1].Name = "正在直播";
  149. if (APP.W_CameraWindow == null)
  150. {
  151. APP.W_CameraWindow = new CameraWindow();
  152. APP.W_CameraWindow.Topmost = true;
  153. APP.W_CameraWindow.Left = pwidth - 300;
  154. APP.W_CameraWindow.Top = 0;
  155. }
  156. APP.W_CameraWindow.Show();
  157. }
  158. else
  159. {
  160. pageData.tongping = !pageData.tongping;
  161. MessageWindow.Show(ErrMessage);
  162. }
  163. }
  164. //else
  165. //{
  166. // EndLive();
  167. // pageData.menuList[1].Pic = "../Images/ToolBar/直播@2x.png";
  168. // pageData.menuList[1].Name = "直播";
  169. // APP.W_CameraWindow.Hide();
  170. //}
  171. }
  172. else if (clickindex == 2)//抢答点名
  173. {
  174. //HideLevel2();
  175. try
  176. {
  177. //#region 关闭冲突页面
  178. //if (IsOpenRollCallWindow)
  179. //{
  180. // return;
  181. //}
  182. //else
  183. //{
  184. // CloseOrHideWindowPage();
  185. //}
  186. //#endregion 关闭冲突页面
  187. if (APP.W_RollCallWindow == null)
  188. {
  189. APP.W_RollCallWindow = new RollCallWindow();
  190. //APP.W_RollCallWindow.click_closeClick += RollCallWindow_click_closeClick;
  191. }
  192. else
  193. {
  194. //APP.W_RollCallWindow.Initialize();
  195. }
  196. APP.W_RollCallWindow.Owner = this;
  197. //ZSocketServer.getInstance().addWin(rollCallWindow);
  198. //IsOpenRollCallWindow = true;
  199. APP.W_RollCallWindow.Show();
  200. }
  201. catch (Exception ex)
  202. {
  203. //IsOpenRollCallWindow = false;
  204. //rollCallWindow = null;
  205. LogHelper.WriteErrLog("【抢答点名(toolbar_item_Click)" + ex.Message, ex);
  206. }
  207. }
  208. else if (clickindex == 3)//课堂工具。
  209. {
  210. try
  211. {
  212. heibanshow = !heibanshow;
  213. List<DependencyObject> list = new List<DependencyObject>
  214. {
  215. heiban_btn,
  216. pizhu_btn
  217. };
  218. //if (tangceshow)
  219. //{
  220. // tangceshow = !tangceshow;
  221. // List<DependencyObject> lists = new List<DependencyObject>
  222. // {
  223. // import_word_btn,
  224. // jietu_btn
  225. // };
  226. // hideOrShow(tangceshow, tangceTool, lists);
  227. //}
  228. hideOrShow(heibanshow, ketangTool, list);
  229. }
  230. catch (Exception ex)
  231. {
  232. LogHelper.WriteErrLog("【课堂工具(toolbar_item_Click)" + ex.Message, ex);
  233. }
  234. }
  235. else if (clickindex == 4)//本节考勤
  236. {
  237. //HideLevel2();
  238. try
  239. {
  240. showKaoqin();
  241. }
  242. catch (Exception ex)
  243. {
  244. LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
  245. }
  246. }
  247. else if (clickindex == 5)//结束课堂。
  248. {
  249. if (MessageWindow.Show("是否结束课堂?", "提示", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
  250. {
  251. closeAction();
  252. }
  253. }
  254. }
  255. /// <summary>
  256. /// 个人空间关闭
  257. /// </summary>
  258. /// <param name="sender"></param>
  259. /// <param name="e"></param>
  260. private void UserCenterWindow_Closed(object sender, EventArgs e)
  261. {
  262. APP.W_UserCenterWindow = null;
  263. //IsOpenUserCenterWindow = false;
  264. }
  265. /// <summary>
  266. /// 考勤
  267. /// </summary>
  268. private void showKaoqin()
  269. {
  270. //if (
  271. // attendanceWindow != null &&
  272. // !attendanceWindow.IsFocused
  273. // )
  274. //{
  275. // attendanceWindow.Focus();
  276. //}
  277. //else
  278. //{
  279. try
  280. {
  281. #region 关闭冲突页面
  282. //if (IsOpenAttendanceWindow)
  283. //{
  284. // return;
  285. //}
  286. //else
  287. //{
  288. // CloseOrHideWindowPage();
  289. //}
  290. #endregion 关闭冲突页面
  291. if (APP.W_AttendanceWindow == null)
  292. {
  293. APP.W_AttendanceWindow = new AttendanceWindow
  294. {
  295. Owner = this
  296. };
  297. //APP.W_AttendanceWindow.Closed += AttendanceWindow_Closed;
  298. }
  299. else
  300. {
  301. //APP.W_AttendanceWindow.Initialize();
  302. }
  303. //IsOpenAttendanceWindow = true;
  304. APP.W_AttendanceWindow.Show();
  305. }
  306. catch (Exception ex)
  307. {
  308. //IsOpenAttendanceWindow = false;
  309. //attendanceWindow = null;
  310. LogHelper.WriteErrLog("【考勤(toolbar_item_Click)" + ex.Message, ex);
  311. }
  312. //}
  313. }
  314. /// <summary>
  315. /// 黑板
  316. /// </summary>
  317. /// <param name="sender"></param>
  318. /// <param name="e"></param>
  319. private void Heiban_btn_Click(object sender, RoutedEventArgs e)
  320. {
  321. try
  322. {
  323. heibanshow = !heibanshow;
  324. #region 关闭冲突页面
  325. //CloseOrHideWindowPage();
  326. #endregion 关闭冲突页面
  327. List<DependencyObject> list = new List<DependencyObject>
  328. {
  329. heiban_btn,
  330. pizhu_btn
  331. };
  332. hideOrShow(heibanshow, ketangTool, list);
  333. if (APP.W_ZBlackboardWindow == null)
  334. {
  335. APP.W_ZBlackboardWindow = new ZBlackboardWindow
  336. {
  337. Topmost = true,
  338. Width = pwidth,
  339. Height = pHeight,
  340. Left = 0,
  341. Top = 0,
  342. Owner = this
  343. };
  344. //APP.W_ZBlackboardWindow.click_closeClick += BlackboardWin2_click_closeClick;
  345. }
  346. //ZSocketServer.getInstance().addWin(blackboardWin2);
  347. APP.W_ZBlackboardWindow.ShowDialog();
  348. }
  349. catch (Exception ex)
  350. {
  351. LogHelper.WriteErrLog("【黑板(Heiban_btn_Click)" + ex.Message, ex);
  352. }
  353. }
  354. /// <summary>
  355. /// 批注
  356. /// </summary>
  357. /// <param name="sender"></param>
  358. /// <param name="e"></param>
  359. private void Pizhu_btn_Click(object sender, RoutedEventArgs e)
  360. {
  361. try
  362. {
  363. heibanshow = !heibanshow;
  364. #region 关闭冲突页面
  365. //CloseOrHideWindowPage();
  366. #endregion 关闭冲突页面
  367. List<DependencyObject> list = new List<DependencyObject>
  368. {
  369. heiban_btn,
  370. pizhu_btn
  371. };
  372. hideOrShow(heibanshow, ketangTool, list);
  373. if (APP.W_PracticeWindow == null)
  374. {
  375. APP.W_PracticeWindow = new PracticeWindow();
  376. APP.W_PracticeWindow.click_closeClick += PracticeWin_click_closeClick;
  377. APP.W_PracticeWindow.Topmost = true;//zhangxueyang
  378. APP.W_PracticeWindow.Width = pwidth;
  379. APP.W_PracticeWindow.Height = pHeight;
  380. APP.W_PracticeWindow.Left = 0;
  381. APP.W_PracticeWindow.Top = 0;
  382. APP.W_PracticeWindow.Unloaded += PracticeWin_Unloaded;
  383. }
  384. APP.W_PracticeWindow.Owner = this;//zhangxueyang
  385. Hide();
  386. addimage();
  387. //ZSocketServer.getInstance().addWin(practiceWin);
  388. APP.W_PracticeWindow.ShowDialog();
  389. }
  390. catch (Exception ex)
  391. {
  392. LogHelper.WriteErrLog("【批注(Pizhu_btn_Click)" + ex.Message, ex);
  393. }
  394. }
  395. /// <summary>
  396. /// 添加截图到批注
  397. /// </summary>
  398. private void addimage()
  399. {
  400. string ImagePath = ImageHelper.GetTempImagePath();
  401. ImageHelper.GetScreenshot(new System.Drawing.Rectangle(0, 0, 0, 0), ImagePath,false,out BitmapImage bitmapImage,-1);
  402. APP.W_PracticeWindow.addImage(ImagePath);
  403. }
  404. /// <summary>
  405. /// 批注关闭
  406. /// </summary>
  407. private void PracticeWin_click_closeClick()
  408. {
  409. APP.W_PracticeWindow = null;
  410. }
  411. /// <summary>
  412. /// 批注关闭时显示工具栏
  413. /// </summary>
  414. /// <param name="sender"></param>
  415. /// <param name="e"></param>
  416. private void PracticeWin_Unloaded(object sender, RoutedEventArgs e)
  417. {
  418. Show();
  419. }
  420. /// <summary>
  421. /// 结束课堂
  422. /// </summary>
  423. private void closeAction()
  424. {
  425. //MyApp.myloading.Show();//加载等待
  426. try
  427. {
  428. //#region 加载通知栏图标
  429. //System.Windows.Forms.NotifyIcon ico = new System.Windows.Forms.NotifyIcon
  430. //{
  431. // Icon = new System.Drawing.Icon(FileToolsCommon.GetFileAbsolutePath("favicon256.ico")),
  432. // //this.Icon.DoubleClick += Icon_DoubleClick;//双击恢复 暂无
  433. // Visible = true
  434. //};
  435. //#endregion 加载通知栏图标
  436. //WindowState = WindowState.Minimized;
  437. //#region 关闭已打开窗口
  438. //pageData.tongping = !pageData.tongping;
  439. ////停止屏幕共享
  440. //if (pageData.tongping)
  441. //{
  442. // tongpingEnd();
  443. // pageData.menuList[1].Pic = "../Images/MainInterface/屏幕共享@2x.png";
  444. // pageData.menuList[1].Name = "屏幕共享";
  445. // gridAnimated.Visibility = Visibility.Collapsed;
  446. //}
  447. //if (blackboardWin2 != null)
  448. //{
  449. // blackboardWin2.Close();
  450. //}
  451. //if (rollCallWindow != null)
  452. //{
  453. // rollCallWindow.Close();
  454. //}
  455. //if (classroomExamWindow != null)
  456. //{
  457. // classroomExamWindow.Close();
  458. //}
  459. //if (classReportWindow != null)
  460. //{
  461. // classReportWindow.Close();
  462. //}
  463. //if (practiceWin != null)
  464. //{
  465. // practiceWin.Close();
  466. //}
  467. //if (classroomQuestionsWindow != null)
  468. //{
  469. // classroomQuestionsWindow.Close();
  470. //}
  471. //if (jietuWindow != null)
  472. //{
  473. // jietuWindow.Close();
  474. //}
  475. //if (attendanceWindow != null)
  476. //{
  477. // attendanceWindow.Close();
  478. //}
  479. //if (userCenterWindow != null)
  480. //{
  481. // userCenterWindow.Close();
  482. //}
  483. //#endregion 关闭已打开窗口
  484. //new Thread(o =>
  485. //{
  486. // StopNginx();
  487. // string msg = ZSocketMsgManger.classEnd();
  488. // ZSocketServer.getInstance().SendMessage(msg);
  489. // #region 清除没有上线人数的课堂数据
  490. // /*
  491. // * 上传本地数据库数据
  492. // * 判断该节课是否有人上线 若没人在线删除本节课数据。
  493. // * 可能存在多节课 1.多节课都没人上线,删除所有数据不上传。 2.多节课有上线的有没上线的情况,删除没有上线人数课的数据,将其余数据上传。
  494. // *
  495. // *
  496. // *
  497. // */
  498. // List<ClassData> classDataList = new List<ClassData>();
  499. // classDataList = ZSqliteManger.queryClassData();//取所有数据
  500. // if (classDataList.Count > 0)
  501. // {
  502. // for (int i = 0; i < classDataList.Count; i++)
  503. // {
  504. // if ("startclass".Equals(classDataList[i].api))//获取每节课的课堂id
  505. // {
  506. // List<ClassData> classroomidDataList = new List<ClassData>();
  507. // classroomidDataList = ZSqliteManger.queryClassRoomidData(classDataList[i].roomid);//取该节课的所有数据
  508. // for (int j = 0; j < classroomidDataList.Count; j++)
  509. // {
  510. // if ("sign".Equals(classroomidDataList[j].api))//若存在上线学生跳出循环
  511. // {
  512. // break;
  513. // }
  514. // if (j + 1 == classroomidDataList.Count)//若遍历完所有数据仍没有上线学生,删除该课堂id下所有数据
  515. // {
  516. // ZSqliteManger.clearClassData(classroomidDataList[j].roomid);
  517. // if (classroomidDataList[j].roomid == ZCommonData.roomid)
  518. // {
  519. // try
  520. // {
  521. // string path = ZConfig.classRoomImagePath();
  522. // if (Directory.Exists(path))
  523. // {
  524. // Directory.Delete(path, true);
  525. // }
  526. // }
  527. // catch (Exception ex)
  528. // {
  529. // LogHelper.WriteErrLog("ToolbarWindow(删除无效课堂文件夹报错:)" + ex.Message, ex);
  530. // }
  531. // }
  532. // }
  533. // }
  534. // }
  535. // }
  536. // classDataList = new List<ClassData>();
  537. // classDataList = ZSqliteManger.queryClassData();//取所有数据
  538. // }
  539. // #endregion
  540. // if (classDataList.Count > 0)
  541. // {
  542. // bool isRoomid = false;
  543. // for (int i = 0; i < classDataList.Count; i++)
  544. // {
  545. // if (classDataList[i].roomid == ZCommonData.roomid)
  546. // {
  547. // isRoomid = true;
  548. // }
  549. // }
  550. // if (isRoomid)
  551. // {
  552. // Dictionary<string, object> stopclass = new Dictionary<string, object>
  553. // {
  554. // { "roomid", ZCommonData.roomid },
  555. // { "endtime", ZNumUtil.unixTime() }
  556. // };
  557. // ZCommonData.askid = ZNumUtil.randomNum();
  558. // ZSqliteManger.insertClassData(new ClassData()
  559. // {
  560. // unix = ZNumUtil.unixTime(),
  561. // roomid = ZCommonData.roomid,
  562. // api = "stopclass",
  563. // json = ZJsonHelper.ToJson(stopclass),
  564. // askid = ZCommonData.askid
  565. // });
  566. // }
  567. // }
  568. // ZSocketServer.getInstance().Dispose();
  569. // if (classDataList.Count > 0)
  570. // {
  571. // MyApp.ZipFile();
  572. // }
  573. //else
  574. //{
  575. EndLive();
  576. //}
  577. WSocketClient.getInstance().SendMessage(SocketMsgManger.NolineMsg());
  578. Dispatcher.Invoke(new Action(() =>
  579. {
  580. System.Environment.Exit(0);
  581. }));
  582. }
  583. catch (Exception ex)
  584. {
  585. LogHelper.WriteErrLog("【ToolbarWindow】(closeAction)" + ex.Message, ex);
  586. }
  587. }
  588. /// <summary>
  589. /// 二级工具栏打开隐藏
  590. /// </summary>
  591. /// <param name="toolShow"></param>
  592. /// <param name="target"></param>
  593. /// <param name="contentList"></param>
  594. private void hideOrShow(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
  595. {
  596. Storyboard story = new Storyboard();
  597. DoubleAnimation da = new DoubleAnimation();
  598. if (toolShow)
  599. {
  600. da.From = 0;
  601. da.To = 173;
  602. }
  603. else
  604. {
  605. da.From = 173.0;
  606. da.To = 0.0;
  607. }
  608. //可选属性:是否往返播放
  609. da.AutoReverse = false;
  610. //da.RepeatBehavior = RepeatBehavior.Forever;
  611. //da.RepeatBehavior = new RepeatBehavior(2);
  612. da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
  613. Storyboard.SetTarget(da, target);
  614. Storyboard.SetTargetProperty(da, new PropertyPath("Width"));
  615. story.Children.Add(da);
  616. foreach (DependencyObject item in contentList)
  617. {
  618. DoubleAnimation da2 = new DoubleAnimation();
  619. if (toolShow)
  620. {
  621. da2.From = 0;
  622. da2.To = 1.0;
  623. }
  624. else
  625. {
  626. da2.From = 1.0;
  627. da2.To = 0.0;
  628. }
  629. da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  630. Storyboard.SetTarget(da2, item);
  631. Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
  632. story.Children.Add(da2);
  633. }
  634. story.Begin();
  635. }
  636. /// <summary>
  637. /// 工具栏打开与缩放
  638. /// </summary>
  639. /// <param name="toolShow"></param>
  640. /// <param name="target"></param>
  641. /// <param name="contentList"></param>
  642. private void hideOrShowToolbar(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
  643. {
  644. if (txbName.Visibility == Visibility.Visible)
  645. {
  646. txbName.Visibility = Visibility.Collapsed;
  647. //if ("正在共享".Equals(pageData.menuList[1].Name))
  648. //{
  649. // gridAnimated.Visibility = Visibility.Collapsed;
  650. //}
  651. }
  652. else
  653. {
  654. txbName.Visibility = Visibility.Visible;
  655. //if("正在共享".Equals(pageData.menuList[1].Name))
  656. //{
  657. // gridAnimated.Visibility = Visibility.Visible;
  658. //}
  659. }
  660. Storyboard story = new Storyboard();
  661. DoubleAnimation da = new DoubleAnimation();
  662. if (toolShow)
  663. {
  664. da.From = 0;
  665. da.To = 670;
  666. }
  667. else
  668. {
  669. da.From = 670;
  670. da.To = 0.0;
  671. }
  672. //可选属性:是否往返播放
  673. da.AutoReverse = false;
  674. //da.RepeatBehavior = RepeatBehavior.Forever;
  675. //da.RepeatBehavior = new RepeatBehavior(2);
  676. da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
  677. Storyboard.SetTarget(da, target);
  678. Storyboard.SetTargetProperty(da, new PropertyPath("Height"));
  679. story.Children.Add(da);
  680. foreach (DependencyObject item in contentList)
  681. {
  682. DoubleAnimation da2 = new DoubleAnimation();
  683. if (toolShow)
  684. {
  685. da2.From = 0;
  686. da2.To = 1.0;
  687. }
  688. else
  689. {
  690. da2.From = 1.0;
  691. da2.To = 0.0;
  692. }
  693. da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  694. Storyboard.SetTarget(da2, item);
  695. Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
  696. story.Children.Add(da2);
  697. }
  698. story.Begin();
  699. }
  700. private void toolbar_win_Closed(object sender, EventArgs e)
  701. {
  702. }
  703. private void toolbar_win_ContentRendered(object sender, EventArgs e)
  704. {
  705. }
  706. private void toolbar_win_Loaded(object sender, RoutedEventArgs e)
  707. {
  708. }
  709. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  710. {
  711. }
  712. private int time = NumUtil.unixTime();
  713. private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  714. {
  715. int temptime = NumUtil.unixTime();
  716. if (temptime - time < 1)
  717. {
  718. pageData.IsOpen = !pageData.IsOpen;
  719. List<DependencyObject> list = new List<DependencyObject>
  720. {
  721. toolbar_list
  722. };
  723. hideOrShowToolbar(pageData.IsOpen, toolbar, list);
  724. if (!pageData.IsOpen)
  725. {
  726. if (heibanshow)
  727. {
  728. List<DependencyObject> list3 = new List<DependencyObject>();
  729. heibanshow = false;
  730. list3.Add(heiban_btn);
  731. list3.Add(pizhu_btn);
  732. hideOrShow(heibanshow, ketangTool, list3);
  733. }
  734. }
  735. }
  736. }
  737. /// <summary>
  738. /// 工具栏移动事件
  739. /// </summary>
  740. /// <param name="sender"></param>
  741. /// <param name="e"></param>
  742. private void Rectangle_MouseMove(object sender, MouseEventArgs e)
  743. {
  744. if (e.LeftButton == MouseButtonState.Pressed)
  745. {
  746. DragMove();
  747. }
  748. }
  749. #endregion
  750. #region 方法
  751. /// <summary>
  752. /// 启动WS
  753. /// </summary>
  754. private void startSocket()
  755. {
  756. WSocketClient.getInstance().StartWsClient();
  757. }
  758. #endregion
  759. #region 直播
  760. /// <summary>
  761. /// 直播间节点和房号
  762. /// </summary>
  763. string NodeKey = "live/test";
  764. /// <summary>
  765. /// 开始直播
  766. /// </summary>
  767. public bool StartLive(out string ErrMessage)
  768. {
  769. try
  770. {
  771. WSocketClient.getInstance().SendMessage(SocketMsgManger.GetIntoMsg());
  772. NodeKey = "live/1";
  773. System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
  774. //开始直播
  775. if(APP.FFmpeg.StartLiveRecordingVideo(APP.RTMPServerPath, NodeKey, DesktopSize,out ErrMessage))
  776. {
  777. return true;
  778. }
  779. else
  780. {
  781. return false;
  782. }
  783. }
  784. catch (Exception ex)
  785. {
  786. ErrMessage = "无法开始直播:" + ex.Message;
  787. LogHelper.WriteErrLog(ErrMessage, ex);
  788. return false;
  789. }
  790. }
  791. /// <summary>
  792. /// 结束直播
  793. /// </summary>
  794. public void EndLive()
  795. {
  796. APP.FFmpeg.StopLive();
  797. }
  798. #endregion
  799. }
  800. /// <summary>
  801. /// 工具栏模型
  802. /// </summary>
  803. public class ToolbarModel : NotifyModel
  804. {
  805. public ObservableCollection<ToolbarMenu> menuList { get; set; }
  806. internal bool _tongping = false;
  807. public bool tongping
  808. {
  809. get => _tongping;
  810. set { _tongping = value; OnPropertyChanged("tongping"); }
  811. }
  812. internal bool _IsOpen = true;
  813. public bool IsOpen
  814. {
  815. get => _IsOpen;
  816. set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
  817. }
  818. public ToolbarModel()
  819. {
  820. menuList = new ObservableCollection<ToolbarMenu>();
  821. }
  822. }
  823. /// <summary>
  824. /// 工具栏菜单模型
  825. /// </summary>
  826. public class ToolbarMenu : NotifyModel
  827. {
  828. internal string _name;
  829. public string Name
  830. {
  831. get => _name;
  832. set { _name = value; OnPropertyChanged("Name"); }
  833. }
  834. internal string _Pic;
  835. public string Pic
  836. {
  837. get => _Pic;
  838. set { _Pic = value; OnPropertyChanged("Pic"); }
  839. }
  840. }
  841. }