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

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