星火直播PC
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.

ToolbarWindow.xaml.cs 31KB

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