星火直播PC
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

ToolbarWindow.xaml.cs 28KB

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