星火直播PC
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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