1
0

IconfontWindow.xaml.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. using GeekDesk.Control.Other;
  2. using GeekDesk.Util;
  3. using GeekDesk.ViewModel;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows;
  10. using System.Windows.Controls;
  11. using System.Windows.Data;
  12. using System.Windows.Documents;
  13. using System.Windows.Input;
  14. using System.Windows.Media;
  15. using System.Windows.Media.Imaging;
  16. using System.Windows.Shapes;
  17. namespace GeekDesk.Control.Windows
  18. {
  19. /// <summary>
  20. /// IconfontWindow.xaml 的交互逻辑
  21. /// </summary>
  22. public partial class IconfontWindow : Window
  23. {
  24. private static MenuInfo menuInfo;
  25. private static List<IconfontInfo> systemIcons;
  26. private static List<IconfontInfo> customIcons;
  27. private IconfontWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
  28. {
  29. systemIcons = icons;
  30. this.DataContext = systemIcons;
  31. this.Topmost = true;
  32. IconfontWindow.menuInfo = menuInfo;
  33. InitializeComponent();
  34. }
  35. /// <summary>
  36. /// 移动窗口
  37. /// </summary>
  38. /// <param name="sender"></param>
  39. /// <param name="e"></param>
  40. private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
  41. {
  42. if (e.LeftButton == MouseButtonState.Pressed)
  43. {
  44. DragMove();
  45. }
  46. }
  47. private void Close_Click(object sender, RoutedEventArgs e)
  48. {
  49. this.Close();
  50. }
  51. private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
  52. {
  53. TabItem ti = this.MyTabControl.SelectedItem as TabItem;
  54. switch (ti.Tag.ToString())
  55. {
  56. case "Custom":
  57. CustomButton.IsEnabled = true;
  58. this.DataContext = customIcons;
  59. break;
  60. default:
  61. if (CustomButton != null)
  62. {
  63. CustomButton.IsEnabled = false;
  64. }
  65. this.DataContext = systemIcons;
  66. break;
  67. }
  68. }
  69. private void Confirm_Click(object sender, RoutedEventArgs e)
  70. {
  71. TabItem ti = this.MyTabControl.SelectedItem as TabItem;
  72. int index;
  73. switch (ti.Tag.ToString())
  74. {
  75. case "Custom":
  76. index = this.CustomIcon.IconListBox.SelectedIndex;
  77. if (index != -1)
  78. {
  79. menuInfo.MenuGeometry = customIcons[index].Text;
  80. }
  81. break;
  82. default:
  83. index = this.SystemIcon.IconListBox.SelectedIndex;
  84. if (index != -1)
  85. {
  86. menuInfo.MenuGeometry = systemIcons[index].Text;
  87. }
  88. break;
  89. }
  90. this.Close();
  91. }
  92. private static System.Windows.Window window = null;
  93. public static void Show(List<IconfontInfo> listInfo, MenuInfo menuInfo)
  94. {
  95. if (window == null || !window.Activate())
  96. {
  97. window = new IconfontWindow(listInfo, menuInfo);
  98. }
  99. window.Show();
  100. }
  101. private void CustomButton_Click(object sender, RoutedEventArgs e)
  102. {
  103. }
  104. }
  105. }