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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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. namespace XHZB.Desktop
  22. {
  23. /// <summary>
  24. /// ToolbarWindow.xaml 的交互逻辑
  25. /// </summary>
  26. public partial class ToolbarWindow : Window
  27. {
  28. #region 字段
  29. /// <summary>
  30. /// 屏幕宽
  31. /// </summary>
  32. internal double pwidth = SystemParameters.PrimaryScreenWidth;
  33. /// <summary>
  34. /// 屏幕高
  35. /// </summary>
  36. internal double pHeight = SystemParameters.PrimaryScreenHeight;
  37. /// <summary>
  38. /// 工具栏数据
  39. /// </summary>
  40. internal ToolbarModel pageData = new ToolbarModel();
  41. /// <summary>
  42. /// 是否已打开课堂工具二级列表
  43. /// </summary>
  44. private bool heibanshow = false;
  45. #endregion
  46. #region 初始化
  47. public ToolbarWindow()
  48. {
  49. InitializeComponent();
  50. txbName.Text = APP.LoginUser.username;
  51. heiban_btn.Click += Heiban_btn_Click;
  52. pizhu_btn.Click += Pizhu_btn_Click;
  53. Topmost = true;
  54. Left = pwidth - 300;
  55. Top = (pHeight - 568) / 2;
  56. pageData.menuList.Add(new ToolbarMenu()
  57. {
  58. Name = "个人空间",
  59. Pic = "../Images/ToolBar/我的备课@2x.png"
  60. });
  61. pageData.menuList.Add(new ToolbarMenu()
  62. {
  63. Name = "直播",
  64. Pic = "../Images/ToolBar/直播@2x.png"
  65. });
  66. pageData.menuList.Add(new ToolbarMenu()
  67. {
  68. Name = "抢答点名",
  69. Pic = "../Images/ToolBar/抢答@2x.png"
  70. });
  71. pageData.menuList.Add(new ToolbarMenu()
  72. {
  73. Name = "课堂工具",
  74. Pic = "../Images/ToolBar/黑板01@2x.png"
  75. });
  76. pageData.menuList.Add(new ToolbarMenu()
  77. {
  78. Name = "本节考勤",
  79. Pic = "../Images/ToolBar/本节考勤01@2x.png"
  80. });
  81. pageData.menuList.Add(new ToolbarMenu()
  82. {
  83. Name = "结束课堂",
  84. Pic = "../Images/ToolBar/下课@2x.png"
  85. });
  86. DataContext = pageData;
  87. Thread t = new Thread(new ThreadStart(startSocket))
  88. {
  89. IsBackground = true
  90. };
  91. t.Start();
  92. }
  93. #endregion
  94. #region 事件
  95. /// <summary>
  96. /// 模块点击
  97. /// </summary>
  98. /// <param name="sender"></param>
  99. /// <param name="e"></param>
  100. private void toolbar_item_Click(object sender, RoutedEventArgs e)
  101. {
  102. int clickindex = 0;
  103. List<Button> buttons = VTHelper.FindChilds<Button>(toolbar_list, "toolbar_item");
  104. for (int i = 0; i < buttons.Count; i++)
  105. {
  106. if (buttons[i] == sender)
  107. {
  108. clickindex = i;
  109. break;
  110. }
  111. }
  112. ToolbarMenu item = pageData.menuList[clickindex];
  113. if (clickindex == 0)//个人空间
  114. {
  115. try
  116. {
  117. //HideLevel2();
  118. if (APP.W_UserCenterWindow != null && !APP.W_UserCenterWindow.IsFocused)
  119. {
  120. APP.W_UserCenterWindow.Focus();
  121. }
  122. else
  123. {
  124. APP.W_UserCenterWindow = new UserCenterWindow();
  125. APP.W_UserCenterWindow.Show();
  126. APP.W_UserCenterWindow.Closed += UserCenterWindow_Closed;
  127. }
  128. //IsOpenUserCenterWindow = true;
  129. }
  130. catch (Exception ex)
  131. {
  132. //IsOpenUserCenterWindow = false;
  133. //userCenterWindow = null;
  134. LogHelper.WriteErrLog("【个人空间(toolbar_item_Click)" + ex.Message, ex);
  135. }
  136. }
  137. else if (clickindex == 1)//直播
  138. {
  139. //HideLevel2();
  140. pageData.tongping = !pageData.tongping;
  141. if (pageData.tongping)
  142. {
  143. //tongpingBegin();
  144. if (StartLive(out string ErrMessage))
  145. {
  146. pageData.menuList[1].Pic = "../Images/ToolBar/img_shared_1.gif";
  147. pageData.menuList[1].Name = "正在直播";
  148. if (APP.W_CameraWindow == null)
  149. {
  150. APP.W_CameraWindow = new CameraWindow();
  151. APP.W_CameraWindow.Topmost = true;
  152. APP.W_CameraWindow.Left = pwidth - 300;
  153. APP.W_CameraWindow.Top = 0;
  154. }
  155. APP.W_CameraWindow.Show();
  156. }
  157. else
  158. {
  159. pageData.tongping = !pageData.tongping;
  160. MessageWindow.Show(ErrMessage);
  161. }
  162. }
  163. else
  164. {
  165. //tongpingEnd();
  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. Dispatcher.Invoke(new Action(() =>
  574. {
  575. System.Environment.Exit(0);
  576. }));
  577. //}).Start();
  578. }
  579. catch (Exception ex)
  580. {
  581. LogHelper.WriteErrLog("【ToolbarWindow】(closeAction)" + ex.Message, ex);
  582. }
  583. }
  584. /// <summary>
  585. /// 二级工具栏打开隐藏
  586. /// </summary>
  587. /// <param name="toolShow"></param>
  588. /// <param name="target"></param>
  589. /// <param name="contentList"></param>
  590. private void hideOrShow(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
  591. {
  592. Storyboard story = new Storyboard();
  593. DoubleAnimation da = new DoubleAnimation();
  594. if (toolShow)
  595. {
  596. da.From = 0;
  597. da.To = 173;
  598. }
  599. else
  600. {
  601. da.From = 173.0;
  602. da.To = 0.0;
  603. }
  604. //可选属性:是否往返播放
  605. da.AutoReverse = false;
  606. //da.RepeatBehavior = RepeatBehavior.Forever;
  607. //da.RepeatBehavior = new RepeatBehavior(2);
  608. da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
  609. Storyboard.SetTarget(da, target);
  610. Storyboard.SetTargetProperty(da, new PropertyPath("Width"));
  611. story.Children.Add(da);
  612. foreach (DependencyObject item in contentList)
  613. {
  614. DoubleAnimation da2 = new DoubleAnimation();
  615. if (toolShow)
  616. {
  617. da2.From = 0;
  618. da2.To = 1.0;
  619. }
  620. else
  621. {
  622. da2.From = 1.0;
  623. da2.To = 0.0;
  624. }
  625. da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  626. Storyboard.SetTarget(da2, item);
  627. Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
  628. story.Children.Add(da2);
  629. }
  630. story.Begin();
  631. }
  632. /// <summary>
  633. /// 工具栏打开与缩放
  634. /// </summary>
  635. /// <param name="toolShow"></param>
  636. /// <param name="target"></param>
  637. /// <param name="contentList"></param>
  638. private void hideOrShowToolbar(bool toolShow, DependencyObject target, List<DependencyObject> contentList)
  639. {
  640. if (txbName.Visibility == Visibility.Visible)
  641. {
  642. txbName.Visibility = Visibility.Collapsed;
  643. //if ("正在共享".Equals(pageData.menuList[1].Name))
  644. //{
  645. // gridAnimated.Visibility = Visibility.Collapsed;
  646. //}
  647. }
  648. else
  649. {
  650. txbName.Visibility = Visibility.Visible;
  651. //if("正在共享".Equals(pageData.menuList[1].Name))
  652. //{
  653. // gridAnimated.Visibility = Visibility.Visible;
  654. //}
  655. }
  656. Storyboard story = new Storyboard();
  657. DoubleAnimation da = new DoubleAnimation();
  658. if (toolShow)
  659. {
  660. da.From = 0;
  661. da.To = 670;
  662. }
  663. else
  664. {
  665. da.From = 670;
  666. da.To = 0.0;
  667. }
  668. //可选属性:是否往返播放
  669. da.AutoReverse = false;
  670. //da.RepeatBehavior = RepeatBehavior.Forever;
  671. //da.RepeatBehavior = new RepeatBehavior(2);
  672. da.Duration = new Duration(TimeSpan.FromSeconds(0.3));
  673. Storyboard.SetTarget(da, target);
  674. Storyboard.SetTargetProperty(da, new PropertyPath("Height"));
  675. story.Children.Add(da);
  676. foreach (DependencyObject item in contentList)
  677. {
  678. DoubleAnimation da2 = new DoubleAnimation();
  679. if (toolShow)
  680. {
  681. da2.From = 0;
  682. da2.To = 1.0;
  683. }
  684. else
  685. {
  686. da2.From = 1.0;
  687. da2.To = 0.0;
  688. }
  689. da2.Duration = new Duration(TimeSpan.FromSeconds(0.1));
  690. Storyboard.SetTarget(da2, item);
  691. Storyboard.SetTargetProperty(da2, new PropertyPath("Opacity"));
  692. story.Children.Add(da2);
  693. }
  694. story.Begin();
  695. }
  696. private void toolbar_win_Closed(object sender, EventArgs e)
  697. {
  698. }
  699. private void toolbar_win_ContentRendered(object sender, EventArgs e)
  700. {
  701. }
  702. private void toolbar_win_Loaded(object sender, RoutedEventArgs e)
  703. {
  704. }
  705. private void Window_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
  706. {
  707. }
  708. private int time = NumUtil.unixTime();
  709. private void Rectangle_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  710. {
  711. int temptime = NumUtil.unixTime();
  712. if (temptime - time < 1)
  713. {
  714. pageData.IsOpen = !pageData.IsOpen;
  715. List<DependencyObject> list = new List<DependencyObject>
  716. {
  717. toolbar_list
  718. };
  719. hideOrShowToolbar(pageData.IsOpen, toolbar, list);
  720. if (!pageData.IsOpen)
  721. {
  722. if (heibanshow)
  723. {
  724. List<DependencyObject> list3 = new List<DependencyObject>();
  725. heibanshow = false;
  726. list3.Add(heiban_btn);
  727. list3.Add(pizhu_btn);
  728. hideOrShow(heibanshow, ketangTool, list3);
  729. }
  730. }
  731. }
  732. }
  733. /// <summary>
  734. /// 工具栏移动事件
  735. /// </summary>
  736. /// <param name="sender"></param>
  737. /// <param name="e"></param>
  738. private void Rectangle_MouseMove(object sender, MouseEventArgs e)
  739. {
  740. if (e.LeftButton == MouseButtonState.Pressed)
  741. {
  742. DragMove();
  743. }
  744. }
  745. #endregion
  746. #region 方法
  747. /// <summary>
  748. /// 启动WS
  749. /// </summary>
  750. private void startSocket()
  751. {
  752. //ZSocketServer.getInstance().startWsServer();
  753. }
  754. #endregion
  755. #region 直播
  756. /// <summary>
  757. /// 直播间节点和房号
  758. /// </summary>
  759. string NodeKey = "live/test";
  760. /// <summary>
  761. /// 开始直播
  762. /// </summary>
  763. public bool StartLive(out string ErrMessage)
  764. {
  765. try
  766. {
  767. //NodeKey=Node+Key;
  768. System.Drawing.Size DesktopSize = PrimaryScreen.DESKTOP;
  769. //开始直播
  770. if(APP.FFmpeg.StartLiveRecordingVideo(APP.RTMPServerPath, NodeKey, DesktopSize,out ErrMessage))
  771. {
  772. return true;
  773. }
  774. else
  775. {
  776. return false;
  777. }
  778. }
  779. catch (Exception ex)
  780. {
  781. ErrMessage = "无法开始直播:" + ex.Message;
  782. LogHelper.WriteErrLog(ErrMessage, ex);
  783. return false;
  784. }
  785. }
  786. /// <summary>
  787. /// 结束直播
  788. /// </summary>
  789. public void EndLive()
  790. {
  791. APP.FFmpeg.StopLive();
  792. }
  793. #endregion
  794. }
  795. /// <summary>
  796. /// 工具栏模型
  797. /// </summary>
  798. public class ToolbarModel : NotifyModel
  799. {
  800. public ObservableCollection<ToolbarMenu> menuList { get; set; }
  801. internal bool _tongping = false;
  802. public bool tongping
  803. {
  804. get => _tongping;
  805. set { _tongping = value; OnPropertyChanged("tongping"); }
  806. }
  807. internal bool _IsOpen = true;
  808. public bool IsOpen
  809. {
  810. get => _IsOpen;
  811. set { _IsOpen = value; OnPropertyChanged("IsOpen"); }
  812. }
  813. public ToolbarModel()
  814. {
  815. menuList = new ObservableCollection<ToolbarMenu>();
  816. }
  817. }
  818. /// <summary>
  819. /// 工具栏菜单模型
  820. /// </summary>
  821. public class ToolbarMenu : NotifyModel
  822. {
  823. internal string _name;
  824. public string Name
  825. {
  826. get => _name;
  827. set { _name = value; OnPropertyChanged("Name"); }
  828. }
  829. internal string _Pic;
  830. public string Pic
  831. {
  832. get => _Pic;
  833. set { _Pic = value; OnPropertyChanged("Pic"); }
  834. }
  835. }
  836. }