RightCardControl.xaml.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745
  1. using DraggAnimatedPanelExample;
  2. using GeekDesk.Constant;
  3. using GeekDesk.Control.Other;
  4. using GeekDesk.Control.Windows;
  5. using GeekDesk.Plugins.EveryThing;
  6. using GeekDesk.Util;
  7. using GeekDesk.ViewModel;
  8. using GeekDesk.ViewModel.Temp;
  9. using HandyControl.Controls;
  10. using Newtonsoft.Json.Linq;
  11. using System;
  12. using System.Collections.ObjectModel;
  13. using System.Diagnostics;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Reflection;
  17. using System.Threading;
  18. using System.Windows;
  19. using System.Windows.Controls;
  20. using System.Windows.Input;
  21. using System.Windows.Media;
  22. using System.Windows.Media.Animation;
  23. using System.Windows.Threading;
  24. namespace GeekDesk.Control.UserControls.PannelCard
  25. {
  26. /// <summary>
  27. /// RightCardControl.xaml 的交互逻辑
  28. /// </summary>
  29. public partial class RightCardControl : UserControl
  30. {
  31. private AppData appData = MainWindow.appData;
  32. ListBoxDragDropManager<IconInfo> dragMgr;
  33. //private Thread dropCheckThread = null;
  34. public RightCardControl()
  35. {
  36. InitializeComponent();
  37. this.Loaded += RightCardControl_Loaded;
  38. }
  39. private void RightCardControl_Loaded(object sender, RoutedEventArgs e)
  40. {
  41. this.dragMgr = new ListBoxDragDropManager<IconInfo>(this.IconListBox);
  42. }
  43. //#region 图标拖动
  44. //DelegateCommand<int[]> _swap;
  45. //public DelegateCommand<int[]> SwapCommand
  46. //{
  47. // get
  48. // {
  49. // if (_swap == null)
  50. // _swap = new DelegateCommand<int[]>(
  51. // (indexes) =>
  52. // {
  53. // DROP_ICON = true;
  54. // if (appData.AppConfig.IconSortType != SortType.CUSTOM
  55. // && (dropCheckThread == null || !dropCheckThread.IsAlive))
  56. // {
  57. // dropCheckThread = new Thread(() =>
  58. // {
  59. // do
  60. // {
  61. // DROP_ICON = false;
  62. // Thread.Sleep(1000);
  63. // } while (DROP_ICON);
  64. // MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
  65. // App.Current.Dispatcher.Invoke(() =>
  66. // {
  67. // if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
  68. // || MainWindow.mainWindow.Opacity != 1)
  69. // {
  70. // Growl.WarningGlobal("已将图标排序规则重置为自定义!");
  71. // }
  72. // else
  73. // {
  74. // Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
  75. // }
  76. // });
  77. // });
  78. // dropCheckThread.Start();
  79. // }
  80. // int fromS = indexes[0];
  81. // int to = indexes[1];
  82. // ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
  83. // var elementSource = iconList[to];
  84. // var dragged = iconList[fromS];
  85. // iconList.Remove(dragged);
  86. // iconList.Insert(to, dragged);
  87. // }
  88. // );
  89. // return _swap;
  90. // }
  91. //}
  92. //#endregion 图标拖动
  93. private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  94. {
  95. if (appData.AppConfig.IconBatch_NoWrite)
  96. {
  97. return;
  98. }
  99. if (appData.AppConfig.DoubleOpen)
  100. {
  101. IconClick(sender, e);
  102. }
  103. }
  104. private void Icon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  105. {
  106. //Console.WriteLine("选中:" + IconListBox.SelectedItems.Count);
  107. if (appData.AppConfig.IconBatch_NoWrite)
  108. {
  109. //查找checkbox更改选中状态
  110. Panel p = sender as Panel;
  111. var ens = p.Children.OfType<CheckBox>();
  112. foreach (CheckBox cb in ens)
  113. {
  114. cb.IsChecked = !cb.IsChecked;
  115. }
  116. return;
  117. }
  118. if (!appData.AppConfig.DoubleOpen)
  119. {
  120. IconClick(sender, e);
  121. }
  122. }
  123. /// <summary>
  124. /// 图标点击事件
  125. /// </summary>
  126. /// <param name="sender"></param>
  127. /// <param name="e"></param>
  128. private void IconClick(object sender, MouseButtonEventArgs e)
  129. {
  130. if (!RunTimeStatus.SEARCH_BOX_HIDED_300) return;
  131. if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
  132. {
  133. IconInfo icon = (IconInfo)((Panel)sender).Tag;
  134. if (icon.AdminStartUp)
  135. {
  136. ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  137. }
  138. else
  139. {
  140. ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
  141. }
  142. }
  143. else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
  144. {
  145. IconInfo icon = (IconInfo)((Panel)sender).Tag;
  146. if (icon.AdminStartUp)
  147. {
  148. ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  149. }
  150. else
  151. {
  152. ProcessUtil.StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
  153. }
  154. }
  155. }
  156. /// <summary>
  157. /// 管理员方式启动
  158. /// </summary>
  159. /// <param name="sender"></param>
  160. /// <param name="e"></param>
  161. private void IconAdminStart(object sender, RoutedEventArgs e)
  162. {
  163. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  164. ProcessUtil.StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  165. }
  166. /// <summary>
  167. /// 打开文件所在位置
  168. /// </summary>
  169. /// <param name="sender"></param>
  170. /// <param name="e"></param>
  171. private void ShowInExplore(object sender, RoutedEventArgs e)
  172. {
  173. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  174. ProcessUtil.StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
  175. }
  176. /// <summary>
  177. /// 拖动添加项目
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void Wrap_Drop(object sender, DragEventArgs e)
  182. {
  183. Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
  184. if (dropObject == null) return;
  185. foreach (object obj in dropObject)
  186. {
  187. string path = (string)obj;
  188. IconInfo iconInfo = CommonCode.GetIconInfoByPath(path);
  189. MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
  190. }
  191. CommonCode.SortIconList();
  192. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  193. }
  194. /// <summary>
  195. /// 从列表删除图标
  196. /// </summary>
  197. /// <param name="sender"></param>
  198. /// <param name="e"></param>
  199. private void RemoveIcon(object sender, RoutedEventArgs e)
  200. {
  201. appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
  202. }
  203. private void SystemContextMenu(object sender, RoutedEventArgs e)
  204. {
  205. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  206. DirectoryInfo[] folders = new DirectoryInfo[1];
  207. folders[0] = new DirectoryInfo(icon.Path);
  208. ShellContextMenu scm = new ShellContextMenu();
  209. System.Drawing.Point p = System.Windows.Forms.Cursor.Position;
  210. p.X -= 80;
  211. p.Y -= 80;
  212. scm.ShowContextMenu(folders, p);
  213. }
  214. /// <summary>
  215. /// 弹出Icon属性修改面板
  216. /// </summary>
  217. /// <param name="sender"></param>
  218. /// <param name="e"></param>
  219. private void PropertyConfig(object sender, RoutedEventArgs e)
  220. {
  221. IconInfo info = (IconInfo)((MenuItem)sender).Tag;
  222. switch (info.IconType)
  223. {
  224. case IconType.URL:
  225. IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
  226. urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
  227. break;
  228. default:
  229. IconInfoDialog dialog = new IconInfoDialog(info);
  230. dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "MainWindowDialog");
  231. break;
  232. }
  233. }
  234. private void MenuIcon_MouseEnter(object sender, MouseEventArgs e)
  235. {
  236. RunTimeStatus.MOUSE_ENTER_ICON = true;
  237. if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
  238. {
  239. ThreadPool.QueueUserWorkItem(state =>
  240. {
  241. this.Dispatcher.BeginInvoke(new Action(() =>
  242. {
  243. IconInfo info = (sender as Panel).Tag as IconInfo;
  244. MyPoptipContent.Text = info.Content;
  245. MyPoptip.VerticalOffset = 30;
  246. Thread.Sleep(50);
  247. if (!RunTimeStatus.ICONLIST_MOUSE_WHEEL)
  248. {
  249. MyPoptip.IsOpen = true;
  250. }
  251. }));
  252. });
  253. }
  254. double width = appData.AppConfig.ImageWidth;
  255. double height = appData.AppConfig.ImageHeight;
  256. width += width * 0.15;
  257. height += height * 0.15;
  258. ThreadPool.QueueUserWorkItem(state =>
  259. {
  260. this.Dispatcher.BeginInvoke(new Action(() =>
  261. {
  262. ImgStoryBoard(sender, (int)width, (int)height, 1, true);
  263. }));
  264. });
  265. }
  266. private void MenuIcon_MouseLeave(object sender, MouseEventArgs e)
  267. {
  268. RunTimeStatus.MOUSE_ENTER_ICON = false;
  269. MyPoptip.IsOpen = false;
  270. ThreadPool.QueueUserWorkItem(state =>
  271. {
  272. this.Dispatcher.BeginInvoke(new Action(() =>
  273. {
  274. ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260);
  275. }));
  276. });
  277. }
  278. private void ImgStoryBoard(object sender, int height, int width, int milliseconds, bool checkRmStoryboard = false)
  279. {
  280. if (appData.AppConfig.PMModel) return;
  281. //int count = 0;
  282. //Panel sp = sender as Panel;
  283. //Image img = sp.Children[0] as Image;
  284. //int nowH = (int)img.Height;
  285. //bool isSmall = nowH > height;
  286. //if (!isSmall)
  287. //{
  288. // img.Height = height;
  289. // img.Width = width;
  290. // return;
  291. //}
  292. //double subLen = (double)Math.Abs(nowH - height) / (double)milliseconds;
  293. //new Thread(() =>
  294. //{
  295. // this.Dispatcher.Invoke(() =>
  296. // {
  297. // while (count < milliseconds)
  298. // {
  299. // if (!isSmall)
  300. // {
  301. // img.Height += subLen;
  302. // img.Width += subLen;
  303. // } else
  304. // {
  305. // //if (img.Height > 1)
  306. // //{
  307. // // img.Height -= 1;
  308. // // img.Width -= 1;
  309. // //}
  310. // Application.Current.Dispatcher.Invoke(DispatcherPriority.Background,
  311. // new Action(delegate {
  312. // img.Height -= subLen;
  313. // img.Width -= subLen;
  314. // }));
  315. // //img.Height -= subLen;
  316. // //img.Width -= subLen;
  317. // }
  318. // count++;
  319. // Thread.Sleep(1);
  320. // }
  321. // img.Height = height;
  322. // img.Width = width;
  323. // });
  324. //}).Start();
  325. Panel sp = sender as Panel;
  326. DependencyObject dos = sp.Parent;
  327. Image img = null;
  328. foreach (var imgBak in sp.Children.OfType<Image>())
  329. {
  330. img = (Image)imgBak;
  331. }
  332. if (img == null) return;
  333. double afterHeight = img.Height;
  334. double afterWidth = img.Width;
  335. //动画定义
  336. Storyboard myStoryboard = new Storyboard();
  337. DoubleAnimation heightAnimation = new DoubleAnimation
  338. {
  339. From = afterHeight,
  340. To = height,
  341. Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
  342. };
  343. DoubleAnimation widthAnimation = new DoubleAnimation
  344. {
  345. From = afterWidth,
  346. To = width,
  347. Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
  348. };
  349. Timeline.SetDesiredFrameRate(heightAnimation, 60);
  350. Timeline.SetDesiredFrameRate(widthAnimation, 60);
  351. Storyboard.SetTarget(widthAnimation, img);
  352. Storyboard.SetTargetProperty(widthAnimation, new PropertyPath("Width"));
  353. Storyboard.SetTarget(heightAnimation, img);
  354. Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
  355. myStoryboard.Children.Add(heightAnimation);
  356. myStoryboard.Children.Add(widthAnimation);
  357. CheckRemoveStoryboard crs = new CheckRemoveStoryboard
  358. {
  359. sb = myStoryboard,
  360. sp = sp,
  361. heightAnimation = heightAnimation,
  362. widthAnimation = widthAnimation,
  363. img = img,
  364. isMouseOver = !checkRmStoryboard
  365. };
  366. heightAnimation.Completed += (s, e) =>
  367. {
  368. if (checkRmStoryboard)
  369. {
  370. ThreadStart ts = new ThreadStart(crs.Remove);
  371. System.Threading.Thread t = new System.Threading.Thread(ts);
  372. t.IsBackground = true;
  373. t.Start();
  374. }
  375. else
  376. {
  377. img.BeginAnimation(WidthProperty, null);
  378. img.BeginAnimation(HeightProperty, null);
  379. }
  380. };
  381. img.BeginAnimation(WidthProperty, widthAnimation);
  382. img.BeginAnimation(HeightProperty, heightAnimation);
  383. //###################################################################
  384. //myStoryboard.Completed += (s, e) =>
  385. //{
  386. // if (checkRmStoryboard)
  387. // {
  388. // ThreadStart ts = new ThreadStart(crs.Remove);
  389. // System.Threading.Thread t = new System.Threading.Thread(ts);
  390. // t.Start();
  391. // }
  392. // else
  393. // {
  394. // myStoryboard.Remove();
  395. // }
  396. //};
  397. //myStoryboard.Begin();
  398. }
  399. private class CheckRemoveStoryboard
  400. {
  401. public Storyboard sb;
  402. public Panel sp;
  403. public Image img;
  404. public DoubleAnimation heightAnimation;
  405. public DoubleAnimation widthAnimation;
  406. public bool isMouseOver;
  407. public void Remove()
  408. {
  409. while (true)
  410. {
  411. if (sp.IsMouseOver == isMouseOver)
  412. {
  413. App.Current.Dispatcher.Invoke((Action)(() =>
  414. {
  415. img.BeginAnimation(WidthProperty, null);
  416. img.BeginAnimation(HeightProperty, null);
  417. //heightAnimation.FillBehavior = FillBehavior.Stop;
  418. //widthAnimation.FillBehavior = FillBehavior.Stop;
  419. }));
  420. return;
  421. }
  422. else
  423. {
  424. System.Threading.Thread.Sleep(500);
  425. }
  426. }
  427. }
  428. }
  429. public void RemoveSB(Object sb)
  430. {
  431. Storyboard sb2 = sb as Storyboard;
  432. System.Threading.Thread.Sleep(500);
  433. sb2.Remove();
  434. }
  435. /// <summary>
  436. /// 添加URL项目
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void AddUrlIcon(object sender, RoutedEventArgs e)
  441. {
  442. IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
  443. urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
  444. }
  445. /// <summary>
  446. /// 添加系统项目
  447. /// </summary>
  448. /// <param name="sender"></param>
  449. /// <param name="e"></param>
  450. private void AddSystemIcon(object sender, RoutedEventArgs e)
  451. {
  452. SystemItemWindow.Show();
  453. }
  454. public void VisibilitySearchCard(Visibility vb)
  455. {
  456. VerticalCard.Visibility = vb;
  457. if (vb == Visibility.Visible)
  458. {
  459. WrapCard.Visibility = Visibility.Collapsed;
  460. }
  461. else
  462. {
  463. WrapCard.Visibility = Visibility.Visible;
  464. }
  465. }
  466. /// <summary>
  467. /// 搜索Card点击事件
  468. /// </summary>
  469. /// <param name="sender"></param>
  470. /// <param name="e"></param>
  471. private void VerticalCard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  472. {
  473. //隐藏搜索框
  474. if (RunTimeStatus.SEARCH_BOX_SHOW)
  475. {
  476. MainWindow.mainWindow.HidedSearchBox();
  477. }
  478. }
  479. /// <summary>
  480. /// 设置光标
  481. /// </summary>
  482. /// <param name="sender"></param>
  483. /// <param name="e"></param>
  484. private void CursorPanel_MouseEnter(object sender, MouseEventArgs e)
  485. {
  486. this.Cursor = Cursors.Hand;
  487. }
  488. /// <summary>
  489. /// 设置光标
  490. /// </summary>
  491. /// <param name="sender"></param>
  492. /// <param name="e"></param>
  493. private void CursorPanel_MouseLeave(object sender, MouseEventArgs e)
  494. {
  495. this.Cursor = Cursors.Arrow;
  496. }
  497. /// <summary>
  498. /// 锁定/解锁主面板
  499. /// </summary>
  500. /// <param name="sender"></param>
  501. /// <param name="e"></param>
  502. private void LockAppPanel(object sender, RoutedEventArgs e)
  503. {
  504. RunTimeStatus.LOCK_APP_PANEL = !RunTimeStatus.LOCK_APP_PANEL;
  505. }
  506. private void WrapCard_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
  507. {
  508. if (RunTimeStatus.LOCK_APP_PANEL)
  509. {
  510. CardLockCM.Header = "解锁主面板";
  511. }
  512. else
  513. {
  514. CardLockCM.Header = "锁定主面板";
  515. }
  516. }
  517. private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  518. {
  519. if (PDDialog.Visibility == Visibility.Visible)
  520. {
  521. RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
  522. PDDialog.ClearVal();
  523. PDDialog.ErrorMsg.Visibility = Visibility.Collapsed;
  524. PDDialog.PasswordGrid.Visibility = Visibility.Visible;
  525. PDDialog.HintGrid.Visibility = Visibility.Collapsed;
  526. PDDialog.count = 0;
  527. PDDialog.SetFocus();
  528. }
  529. else
  530. {
  531. RunTimeStatus.SHOW_MENU_PASSWORDBOX = false;
  532. PDDialog.ClearVal();
  533. MainWindow.mainWindow.Focus();
  534. }
  535. }
  536. /// <summary>
  537. /// 菜单结果icon 列表鼠标滚轮预处理时间
  538. /// 主要使用自定义popup解决卡顿问题解决卡顿问题
  539. /// 以及滚动条首尾切换菜单
  540. /// </summary>
  541. /// <param name="sender"></param>
  542. /// <param name="e"></param>
  543. private void IconListBox_MouseWheel(object sender, MouseWheelEventArgs e)
  544. {
  545. //控制在滚动时不显示popup 否则会在低GPU性能机器上造成卡顿
  546. MyPoptip.IsOpen = false;
  547. if (RunTimeStatus.ICONLIST_MOUSE_WHEEL)
  548. {
  549. RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 500;
  550. }
  551. else
  552. {
  553. RunTimeStatus.ICONLIST_MOUSE_WHEEL = true;
  554. new Thread(() =>
  555. {
  556. while (RunTimeStatus.MOUSE_WHEEL_WAIT_MS > 0)
  557. {
  558. Thread.Sleep(1);
  559. RunTimeStatus.MOUSE_WHEEL_WAIT_MS -= 1;
  560. }
  561. if (RunTimeStatus.MOUSE_ENTER_ICON)
  562. {
  563. this.Dispatcher.BeginInvoke(new Action(() =>
  564. {
  565. MyPoptip.IsOpen = true;
  566. }));
  567. }
  568. RunTimeStatus.MOUSE_WHEEL_WAIT_MS = 100;
  569. RunTimeStatus.ICONLIST_MOUSE_WHEEL = false;
  570. }).Start();
  571. }
  572. //修改菜单时不切换菜单
  573. if (RunTimeStatus.IS_MENU_EDIT) return;
  574. //切换菜单
  575. System.Windows.Controls.ScrollViewer scrollViewer = sender as System.Windows.Controls.ScrollViewer;
  576. if (scrollViewer == null)
  577. {
  578. //在card 上获取的事件
  579. scrollViewer = ScrollUtil.FindSimpleVisualChild<System.Windows.Controls.ScrollViewer>(IconListBox);
  580. }
  581. if (e.Delta < 0)
  582. {
  583. int index = MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex;
  584. if (ScrollUtil.IsBootomScrollView(scrollViewer))
  585. {
  586. if (index < MainWindow.mainWindow.LeftCard.MenuListBox.Items.Count - 1)
  587. {
  588. index++;
  589. }
  590. else
  591. {
  592. index = 0;
  593. }
  594. MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex = index;
  595. scrollViewer.ScrollToVerticalOffset(0);
  596. }
  597. }
  598. else if (e.Delta > 0)
  599. {
  600. if (ScrollUtil.IsTopScrollView(scrollViewer))
  601. {
  602. int index = MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex;
  603. if (index > 0)
  604. {
  605. index--;
  606. }
  607. else
  608. {
  609. index = MainWindow.mainWindow.LeftCard.MenuListBox.Items.Count - 1;
  610. }
  611. MainWindow.mainWindow.LeftCard.MenuListBox.SelectedIndex = index;
  612. scrollViewer.ScrollToVerticalOffset(0);
  613. }
  614. }
  615. }
  616. /// <summary>
  617. /// menu结果ICON鼠标移动事件
  618. /// </summary>
  619. /// <param name="sender"></param>
  620. /// <param name="e"></param>
  621. private void MenuIcon_MouseMove(object sender, MouseEventArgs e)
  622. {
  623. //防止移动后不刷新popup content
  624. IconInfo info = (sender as Panel).Tag as IconInfo;
  625. MyPoptipContent.Text = info.Content;
  626. MyPoptip.VerticalOffset = 30;
  627. }
  628. /// <summary>
  629. /// 控制图标标题显示及隐藏
  630. /// </summary>
  631. /// <param name="sender"></param>
  632. /// <param name="e"></param>
  633. private void ShowTitle_Click(object sender, RoutedEventArgs e)
  634. {
  635. appData.AppConfig.ShowIconTitle = !appData.AppConfig.ShowIconTitle;
  636. }
  637. /// <summary>
  638. /// 批量操作
  639. /// </summary>
  640. /// <param name="sender"></param>
  641. /// <param name="e"></param>
  642. private void BatchHandle(object sender, RoutedEventArgs e)
  643. {
  644. if (!appData.AppConfig.IconBatch_NoWrite)
  645. {
  646. //开启批量操作时把所有的状态更改为未选中
  647. foreach(var ic in IconListBox.Items)
  648. {
  649. IconInfo info = ic as IconInfo;
  650. info.IsChecked_NoWrite = false;
  651. }
  652. }
  653. appData.AppConfig.IconBatch_NoWrite = !appData.AppConfig.IconBatch_NoWrite;
  654. IconListBox.SelectionMode = SelectionMode.Multiple;
  655. }
  656. private void IconListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  657. {
  658. //Console.WriteLine(sender.ToString());
  659. }
  660. }
  661. }