RightCardControl.xaml.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822
  1. using DraggAnimatedPanelExample;
  2. using GeekDesk.Constant;
  3. using GeekDesk.Control.Other;
  4. using GeekDesk.Control.Windows;
  5. using GeekDesk.Util;
  6. using GeekDesk.ViewModel;
  7. using HandyControl.Controls;
  8. using System;
  9. using System.Collections.ObjectModel;
  10. using System.Diagnostics;
  11. using System.IO;
  12. using System.Threading;
  13. using System.Windows;
  14. using System.Windows.Controls;
  15. using System.Windows.Input;
  16. using System.Windows.Media;
  17. using System.Windows.Media.Animation;
  18. using System.Windows.Threading;
  19. namespace GeekDesk.Control.UserControls.PannelCard
  20. {
  21. /// <summary>
  22. /// RightCardControl.xaml 的交互逻辑
  23. /// </summary>
  24. public partial class RightCardControl : UserControl
  25. {
  26. private AppData appData = MainWindow.appData;
  27. ListBoxDragDropManager<IconInfo> dragMgr;
  28. //private Thread dropCheckThread = null;
  29. public RightCardControl()
  30. {
  31. InitializeComponent();
  32. this.Loaded += RightCardControl_Loaded;
  33. }
  34. private void RightCardControl_Loaded(object sender, RoutedEventArgs e)
  35. {
  36. this.dragMgr = new ListBoxDragDropManager<IconInfo>(this.IconListBox);
  37. }
  38. //#region 图标拖动
  39. //DelegateCommand<int[]> _swap;
  40. //public DelegateCommand<int[]> SwapCommand
  41. //{
  42. // get
  43. // {
  44. // if (_swap == null)
  45. // _swap = new DelegateCommand<int[]>(
  46. // (indexes) =>
  47. // {
  48. // DROP_ICON = true;
  49. // if (appData.AppConfig.IconSortType != SortType.CUSTOM
  50. // && (dropCheckThread == null || !dropCheckThread.IsAlive))
  51. // {
  52. // dropCheckThread = new Thread(() =>
  53. // {
  54. // do
  55. // {
  56. // DROP_ICON = false;
  57. // Thread.Sleep(1000);
  58. // } while (DROP_ICON);
  59. // MainWindow.appData.AppConfig.IconSortType = SortType.CUSTOM;
  60. // App.Current.Dispatcher.Invoke(() =>
  61. // {
  62. // if (MainWindow.mainWindow.Visibility == Visibility.Collapsed
  63. // || MainWindow.mainWindow.Opacity != 1)
  64. // {
  65. // Growl.WarningGlobal("已将图标排序规则重置为自定义!");
  66. // }
  67. // else
  68. // {
  69. // Growl.Warning("已将图标排序规则重置为自定义!", "MainWindowGrowl");
  70. // }
  71. // });
  72. // });
  73. // dropCheckThread.Start();
  74. // }
  75. // int fromS = indexes[0];
  76. // int to = indexes[1];
  77. // ObservableCollection<IconInfo> iconList = appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList;
  78. // var elementSource = iconList[to];
  79. // var dragged = iconList[fromS];
  80. // iconList.Remove(dragged);
  81. // iconList.Insert(to, dragged);
  82. // }
  83. // );
  84. // return _swap;
  85. // }
  86. //}
  87. //#endregion 图标拖动
  88. private void Icon_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  89. {
  90. if (appData.AppConfig.DoubleOpen)
  91. {
  92. IconClick(sender, e);
  93. }
  94. }
  95. private void Icon_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
  96. {
  97. if (!appData.AppConfig.DoubleOpen)
  98. {
  99. IconClick(sender, e);
  100. }
  101. }
  102. /// <summary>
  103. /// 图标点击事件
  104. /// </summary>
  105. /// <param name="sender"></param>
  106. /// <param name="e"></param>
  107. private void IconClick(object sender, MouseButtonEventArgs e)
  108. {
  109. if (appData.AppConfig.DoubleOpen && e.ClickCount >= 2)
  110. {
  111. IconInfo icon = (IconInfo)((Panel)sender).Tag;
  112. if (icon.AdminStartUp)
  113. {
  114. StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  115. }
  116. else
  117. {
  118. StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
  119. }
  120. }
  121. else if (!appData.AppConfig.DoubleOpen && e.ClickCount == 1)
  122. {
  123. IconInfo icon = (IconInfo)((Panel)sender).Tag;
  124. if (icon.AdminStartUp)
  125. {
  126. StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  127. }
  128. else
  129. {
  130. StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
  131. }
  132. }
  133. }
  134. /// <summary>
  135. /// 管理员方式启动
  136. /// </summary>
  137. /// <param name="sender"></param>
  138. /// <param name="e"></param>
  139. private void IconAdminStart(object sender, RoutedEventArgs e)
  140. {
  141. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  142. StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  143. }
  144. /// <summary>
  145. /// 打开文件所在位置
  146. /// </summary>
  147. /// <param name="sender"></param>
  148. /// <param name="e"></param>
  149. private void ShowInExplore(object sender, RoutedEventArgs e)
  150. {
  151. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  152. StartIconApp(icon, IconStartType.SHOW_IN_EXPLORE);
  153. }
  154. private void StartIconApp(IconInfo icon, IconStartType type, bool useRelativePath = false)
  155. {
  156. try
  157. {
  158. using (Process p = new Process())
  159. {
  160. string startArg = icon.StartArg;
  161. if (startArg != null && Constants.SYSTEM_ICONS.ContainsKey(startArg))
  162. {
  163. StartSystemApp(startArg, type);
  164. }
  165. else
  166. {
  167. string path;
  168. if (useRelativePath)
  169. {
  170. string fullPath = Path.Combine(Constants.APP_DIR, icon.RelativePath);
  171. path = Path.GetFullPath(fullPath);
  172. } else
  173. {
  174. path = icon.Path;
  175. }
  176. p.StartInfo.FileName = path;
  177. if (!StringUtil.IsEmpty(startArg))
  178. {
  179. p.StartInfo.Arguments = startArg;
  180. }
  181. if (icon.IconType == IconType.OTHER)
  182. {
  183. if (!File.Exists(path) && !Directory.Exists(path))
  184. {
  185. //如果没有使用相对路径 那么使用相对路径启动一次
  186. if (!useRelativePath)
  187. {
  188. StartIconApp(icon, type, true);
  189. return;
  190. } else
  191. {
  192. HandyControl.Controls.Growl.WarningGlobal("程序启动失败(文件路径不存在或已删除)!");
  193. return;
  194. }
  195. }
  196. p.StartInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("\\"));
  197. switch (type)
  198. {
  199. case IconStartType.ADMIN_STARTUP:
  200. //p.StartInfo.Arguments = "1";//启动参数
  201. p.StartInfo.Verb = "runas";
  202. //p.StartInfo.CreateNoWindow = false; //设置显示窗口
  203. p.StartInfo.UseShellExecute = true;//不使用操作系统外壳程序启动进程
  204. //p.StartInfo.ErrorDialog = false;
  205. if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
  206. {
  207. //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
  208. if (appData.AppConfig.MarginHide)
  209. {
  210. if (!MarginHide.IsMargin())
  211. {
  212. MainWindow.HideApp();
  213. }
  214. }
  215. else
  216. {
  217. MainWindow.HideApp();
  218. }
  219. }
  220. break;// c#好像不能case穿透
  221. case IconStartType.DEFAULT_STARTUP:
  222. if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
  223. {
  224. //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
  225. if (appData.AppConfig.MarginHide)
  226. {
  227. if (!MarginHide.IsMargin())
  228. {
  229. MainWindow.HideApp();
  230. }
  231. }
  232. else
  233. {
  234. MainWindow.HideApp();
  235. }
  236. }
  237. break;
  238. case IconStartType.SHOW_IN_EXPLORE:
  239. p.StartInfo.FileName = "Explorer.exe";
  240. p.StartInfo.Arguments = "/e,/select," + icon.Path;
  241. break;
  242. }
  243. }
  244. else
  245. {
  246. if (appData.AppConfig.AppHideType == AppHideType.START_EXE && !RunTimeStatus.LOCK_APP_PANEL)
  247. {
  248. //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
  249. if (appData.AppConfig.MarginHide)
  250. {
  251. if (!MarginHide.IS_HIDE)
  252. {
  253. MainWindow.HideApp();
  254. }
  255. }
  256. else
  257. {
  258. MainWindow.HideApp();
  259. }
  260. }
  261. }
  262. p.Start();
  263. if (useRelativePath)
  264. {
  265. //如果使用相对路径启动成功 那么重新设置程序绝对路径
  266. icon.Path = path;
  267. }
  268. }
  269. }
  270. icon.Count++;
  271. //隐藏搜索框
  272. if (RunTimeStatus.SEARCH_BOX_SHOW)
  273. {
  274. MainWindow.mainWindow.HidedSearchBox();
  275. }
  276. }
  277. catch (Exception e)
  278. {
  279. if (!useRelativePath)
  280. {
  281. StartIconApp(icon, type, true);
  282. }
  283. else
  284. {
  285. HandyControl.Controls.Growl.WarningGlobal("程序启动失败(可能为不支持的启动方式)!");
  286. LogUtil.WriteErrorLog(e, "程序启动失败:path=" + icon.Path + ",type=" + type);
  287. }
  288. }
  289. }
  290. private void StartSystemApp(string startArg, IconStartType type)
  291. {
  292. if (type == IconStartType.SHOW_IN_EXPLORE)
  293. {
  294. Growl.WarningGlobal("系统项目不支持打开文件位置操作!");
  295. return;
  296. }
  297. switch (startArg)
  298. {
  299. case "Calculator":
  300. Process.Start("calc.exe");
  301. break;
  302. case "Computer":
  303. Process.Start("explorer.exe");
  304. break;
  305. case "GroupPolicy":
  306. Process.Start("gpedit.msc");
  307. break;
  308. case "Notepad":
  309. Process.Start("notepad");
  310. break;
  311. case "Network":
  312. Process.Start("ncpa.cpl");
  313. break;
  314. case "RecycleBin":
  315. Process.Start("shell:RecycleBinFolder");
  316. break;
  317. case "Registry":
  318. Process.Start("regedit.exe");
  319. break;
  320. case "Mstsc":
  321. if (type == IconStartType.ADMIN_STARTUP)
  322. {
  323. Process.Start("mstsc", "-admin");
  324. }
  325. else
  326. {
  327. Process.Start("mstsc");
  328. }
  329. break;
  330. case "Control":
  331. Process.Start("Control");
  332. break;
  333. case "CMD":
  334. if (type == IconStartType.ADMIN_STARTUP)
  335. {
  336. using (Process process = new Process())
  337. {
  338. process.StartInfo.FileName = "cmd.exe";
  339. process.StartInfo.Verb = "runas";
  340. process.Start();
  341. }
  342. }
  343. else
  344. {
  345. Process.Start("cmd");
  346. }
  347. break;
  348. case "Services":
  349. Process.Start("services.msc");
  350. break;
  351. }
  352. //如果开启了贴边隐藏 则窗体不贴边才隐藏窗口
  353. if (appData.AppConfig.MarginHide)
  354. {
  355. if (!MarginHide.IS_HIDE)
  356. {
  357. MainWindow.HideApp();
  358. }
  359. }
  360. else
  361. {
  362. MainWindow.HideApp();
  363. }
  364. }
  365. /// <summary>
  366. /// 拖动添加项目
  367. /// </summary>
  368. /// <param name="sender"></param>
  369. /// <param name="e"></param>
  370. private void Wrap_Drop(object sender, DragEventArgs e)
  371. {
  372. Array dropObject = (System.Array)e.Data.GetData(DataFormats.FileDrop);
  373. if (dropObject == null) return;
  374. foreach (object obj in dropObject)
  375. {
  376. string path = (string)obj;
  377. IconInfo iconInfo = CommonCode.GetIconInfoByPath(path);
  378. MainWindow.appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Add(iconInfo);
  379. }
  380. CommonCode.SortIconList();
  381. CommonCode.SaveAppData(MainWindow.appData, Constants.DATA_FILE_PATH);
  382. }
  383. /// <summary>
  384. /// 从列表删除图标
  385. /// </summary>
  386. /// <param name="sender"></param>
  387. /// <param name="e"></param>
  388. private void RemoveIcon(object sender, RoutedEventArgs e)
  389. {
  390. appData.MenuList[appData.AppConfig.SelectedMenuIndex].IconList.Remove((IconInfo)((MenuItem)sender).Tag);
  391. }
  392. private void SystemContextMenu(object sender, RoutedEventArgs e)
  393. {
  394. IconInfo icon = (IconInfo)((MenuItem)sender).Tag;
  395. DirectoryInfo[] folders = new DirectoryInfo[1];
  396. folders[0] = new DirectoryInfo(icon.Path);
  397. ShellContextMenu scm = new ShellContextMenu();
  398. System.Drawing.Point p = System.Windows.Forms.Cursor.Position;
  399. p.X -= 80;
  400. p.Y -= 80;
  401. scm.ShowContextMenu(folders, p);
  402. }
  403. /// <summary>
  404. /// 弹出Icon属性修改面板
  405. /// </summary>
  406. /// <param name="sender"></param>
  407. /// <param name="e"></param>
  408. private void PropertyConfig(object sender, RoutedEventArgs e)
  409. {
  410. IconInfo info = (IconInfo)((MenuItem)sender).Tag;
  411. switch (info.IconType)
  412. {
  413. case IconType.URL:
  414. IconInfoUrlDialog urlDialog = new IconInfoUrlDialog(info);
  415. urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
  416. break;
  417. default:
  418. IconInfoDialog dialog = new IconInfoDialog(info);
  419. dialog.dialog = HandyControl.Controls.Dialog.Show(dialog, "MainWindowDialog");
  420. break;
  421. }
  422. }
  423. private void StackPanel_MouseEnter(object sender, MouseEventArgs e)
  424. {
  425. double width = appData.AppConfig.ImageWidth;
  426. double height = appData.AppConfig.ImageHeight;
  427. width += width * 0.15;
  428. height += height * 0.15;
  429. Thread t = new Thread(() =>
  430. {
  431. this.Dispatcher.BeginInvoke(new Action(() =>
  432. {
  433. ImgStoryBoard(sender, (int)width, (int)height, 1, true);
  434. }));
  435. });
  436. t.IsBackground = true;
  437. t.Start();
  438. }
  439. private void StackPanel_MouseLeave(object sender, MouseEventArgs e)
  440. {
  441. Thread t = new Thread(() =>
  442. {
  443. this.Dispatcher.BeginInvoke(new Action(() =>
  444. {
  445. ImgStoryBoard(sender, appData.AppConfig.ImageWidth, appData.AppConfig.ImageHeight, 260);
  446. }));
  447. });
  448. t.IsBackground = true;
  449. t.Start();
  450. }
  451. private void ImgStoryBoard(object sender, int height, int width, int milliseconds, bool checkRmStoryboard = false)
  452. {
  453. if (appData.AppConfig.PMModel) return;
  454. //int count = 0;
  455. //Panel sp = sender as Panel;
  456. //Image img = sp.Children[0] as Image;
  457. //int nowH = (int)img.Height;
  458. //bool isSmall = nowH > height;
  459. //if (!isSmall)
  460. //{
  461. // img.Height = height;
  462. // img.Width = width;
  463. // return;
  464. //}
  465. //double subLen = (double)Math.Abs(nowH - height) / (double)milliseconds;
  466. //new Thread(() =>
  467. //{
  468. // this.Dispatcher.Invoke(() =>
  469. // {
  470. // while (count < milliseconds)
  471. // {
  472. // if (!isSmall)
  473. // {
  474. // img.Height += subLen;
  475. // img.Width += subLen;
  476. // } else
  477. // {
  478. // //if (img.Height > 1)
  479. // //{
  480. // // img.Height -= 1;
  481. // // img.Width -= 1;
  482. // //}
  483. // Application.Current.Dispatcher.Invoke(DispatcherPriority.Background,
  484. // new Action(delegate {
  485. // img.Height -= subLen;
  486. // img.Width -= subLen;
  487. // }));
  488. // //img.Height -= subLen;
  489. // //img.Width -= subLen;
  490. // }
  491. // count++;
  492. // Thread.Sleep(1);
  493. // }
  494. // img.Height = height;
  495. // img.Width = width;
  496. // });
  497. //}).Start();
  498. Panel sp = sender as Panel;
  499. DependencyObject dos = sp.Parent;
  500. Image img = sp.Children[0] as Image;
  501. double afterHeight = img.Height;
  502. double afterWidth = img.Width;
  503. //动画定义
  504. Storyboard myStoryboard = new Storyboard();
  505. DoubleAnimation heightAnimation = new DoubleAnimation
  506. {
  507. From = afterHeight,
  508. To = height,
  509. Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
  510. };
  511. DoubleAnimation widthAnimation = new DoubleAnimation
  512. {
  513. From = afterWidth,
  514. To = width,
  515. Duration = new Duration(TimeSpan.FromMilliseconds(milliseconds))
  516. };
  517. Timeline.SetDesiredFrameRate(heightAnimation, 60);
  518. Timeline.SetDesiredFrameRate(widthAnimation, 60);
  519. Storyboard.SetTarget(widthAnimation, img);
  520. Storyboard.SetTargetProperty(widthAnimation, new PropertyPath("Width"));
  521. Storyboard.SetTarget(heightAnimation, img);
  522. Storyboard.SetTargetProperty(heightAnimation, new PropertyPath("Height"));
  523. myStoryboard.Children.Add(heightAnimation);
  524. myStoryboard.Children.Add(widthAnimation);
  525. CheckRemoveStoryboard crs = new CheckRemoveStoryboard
  526. {
  527. sb = myStoryboard,
  528. sp = sp,
  529. heightAnimation = heightAnimation,
  530. widthAnimation = widthAnimation,
  531. img = img,
  532. isMouseOver = !checkRmStoryboard
  533. };
  534. heightAnimation.Completed += (s, e) =>
  535. {
  536. if (checkRmStoryboard)
  537. {
  538. ThreadStart ts = new ThreadStart(crs.Remove);
  539. System.Threading.Thread t = new System.Threading.Thread(ts);
  540. t.IsBackground = true;
  541. t.Start();
  542. }
  543. else
  544. {
  545. img.BeginAnimation(WidthProperty, null);
  546. img.BeginAnimation(HeightProperty, null);
  547. }
  548. };
  549. img.BeginAnimation(WidthProperty, widthAnimation);
  550. img.BeginAnimation(HeightProperty, heightAnimation);
  551. //###################################################################
  552. //myStoryboard.Completed += (s, e) =>
  553. //{
  554. // if (checkRmStoryboard)
  555. // {
  556. // ThreadStart ts = new ThreadStart(crs.Remove);
  557. // System.Threading.Thread t = new System.Threading.Thread(ts);
  558. // t.Start();
  559. // }
  560. // else
  561. // {
  562. // myStoryboard.Remove();
  563. // }
  564. //};
  565. //myStoryboard.Begin();
  566. }
  567. private class CheckRemoveStoryboard
  568. {
  569. public Storyboard sb;
  570. public Panel sp;
  571. public Image img;
  572. public DoubleAnimation heightAnimation;
  573. public DoubleAnimation widthAnimation;
  574. public bool isMouseOver;
  575. public void Remove()
  576. {
  577. while (true)
  578. {
  579. if (sp.IsMouseOver == isMouseOver)
  580. {
  581. App.Current.Dispatcher.Invoke((Action)(() =>
  582. {
  583. img.BeginAnimation(WidthProperty, null);
  584. img.BeginAnimation(HeightProperty, null);
  585. //heightAnimation.FillBehavior = FillBehavior.Stop;
  586. //widthAnimation.FillBehavior = FillBehavior.Stop;
  587. }));
  588. return;
  589. }
  590. else
  591. {
  592. System.Threading.Thread.Sleep(500);
  593. }
  594. }
  595. }
  596. }
  597. public void RemoveSB(Object sb)
  598. {
  599. Storyboard sb2 = sb as Storyboard;
  600. System.Threading.Thread.Sleep(500);
  601. sb2.Remove();
  602. }
  603. /// <summary>
  604. /// 添加URL项目
  605. /// </summary>
  606. /// <param name="sender"></param>
  607. /// <param name="e"></param>
  608. private void AddUrlIcon(object sender, RoutedEventArgs e)
  609. {
  610. IconInfoUrlDialog urlDialog = new IconInfoUrlDialog();
  611. urlDialog.dialog = HandyControl.Controls.Dialog.Show(urlDialog, "MainWindowDialog");
  612. }
  613. /// <summary>
  614. /// 添加系统项目
  615. /// </summary>
  616. /// <param name="sender"></param>
  617. /// <param name="e"></param>
  618. private void AddSystemIcon(object sender, RoutedEventArgs e)
  619. {
  620. SystemItemWindow.Show();
  621. }
  622. public void VisibilitySearchCard(Visibility vb)
  623. {
  624. VerticalCard.Visibility = vb;
  625. if (vb == Visibility.Visible)
  626. {
  627. WrapCard.Visibility = Visibility.Collapsed;
  628. }
  629. else
  630. {
  631. WrapCard.Visibility = Visibility.Visible;
  632. }
  633. }
  634. /// <summary>
  635. /// 搜索Card点击事件
  636. /// </summary>
  637. /// <param name="sender"></param>
  638. /// <param name="e"></param>
  639. private void VerticalCard_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  640. {
  641. //隐藏搜索框
  642. if (RunTimeStatus.SEARCH_BOX_SHOW)
  643. {
  644. MainWindow.mainWindow.HidedSearchBox();
  645. }
  646. }
  647. /// <summary>
  648. /// 设置光标
  649. /// </summary>
  650. /// <param name="sender"></param>
  651. /// <param name="e"></param>
  652. private void CursorPanel_MouseEnter(object sender, MouseEventArgs e)
  653. {
  654. this.Cursor = Cursors.Hand;
  655. }
  656. /// <summary>
  657. /// 设置光标
  658. /// </summary>
  659. /// <param name="sender"></param>
  660. /// <param name="e"></param>
  661. private void CursorPanel_MouseLeave(object sender, MouseEventArgs e)
  662. {
  663. this.Cursor = Cursors.Arrow;
  664. }
  665. /// <summary>
  666. /// 锁定/解锁主面板
  667. /// </summary>
  668. /// <param name="sender"></param>
  669. /// <param name="e"></param>
  670. private void LockAppPanel(object sender, RoutedEventArgs e)
  671. {
  672. RunTimeStatus.LOCK_APP_PANEL = !RunTimeStatus.LOCK_APP_PANEL;
  673. }
  674. private void WrapCard_PreviewMouseRightButtonDown(object sender, MouseButtonEventArgs e)
  675. {
  676. if (RunTimeStatus.LOCK_APP_PANEL)
  677. {
  678. CardLockCM.Header = "解锁主面板";
  679. } else
  680. {
  681. CardLockCM.Header = "锁定主面板";
  682. }
  683. }
  684. public void SearchListBoxIndexAdd()
  685. {
  686. if (SearchListBox.Items.Count > 0)
  687. {
  688. if (SearchListBox.SelectedIndex < SearchListBox.Items.Count - 1)
  689. {
  690. SearchListBox.SelectedIndex += 1;
  691. }
  692. }
  693. }
  694. public void SearchListBoxIndexSub()
  695. {
  696. if (SearchListBox.Items.Count > 0)
  697. {
  698. if (SearchListBox.SelectedIndex > 0)
  699. {
  700. SearchListBox.SelectedIndex -= 1;
  701. }
  702. }
  703. }
  704. public void StartupSelectionItem()
  705. {
  706. if (SearchListBox.SelectedItem != null)
  707. {
  708. IconInfo icon = SearchListBox.SelectedItem as IconInfo;
  709. if (icon.AdminStartUp)
  710. {
  711. StartIconApp(icon, IconStartType.ADMIN_STARTUP);
  712. }
  713. else
  714. {
  715. StartIconApp(icon, IconStartType.DEFAULT_STARTUP);
  716. }
  717. }
  718. }
  719. private void SearchListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
  720. {
  721. SearchListBox.ScrollIntoView(SearchListBox.SelectedItem);
  722. }
  723. private void PDDialog_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
  724. {
  725. if (PDDialog.Visibility == Visibility.Visible)
  726. {
  727. RunTimeStatus.SHOW_MENU_PASSWORDBOX = true;
  728. PDDialog.ClearVal();
  729. PDDialog.ErrorMsg.Visibility = Visibility.Collapsed;
  730. PDDialog.PasswordGrid.Visibility = Visibility.Visible;
  731. PDDialog.HintGrid.Visibility = Visibility.Collapsed;
  732. PDDialog.count = 0;
  733. PDDialog.SetFocus();
  734. }
  735. else
  736. {
  737. RunTimeStatus.SHOW_MENU_PASSWORDBOX = false;
  738. PDDialog.ClearVal();
  739. MainWindow.mainWindow.Focus();
  740. }
  741. }
  742. }
  743. }