diff --git a/Control/Windows/SystemItemWindow.xaml b/Control/Windows/SystemItemWindow.xaml
new file mode 100644
index 0000000..4cf58b4
--- /dev/null
+++ b/Control/Windows/SystemItemWindow.xaml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Control/Windows/SystemItemWindow.xaml.cs b/Control/Windows/SystemItemWindow.xaml.cs
new file mode 100644
index 0000000..4312a43
--- /dev/null
+++ b/Control/Windows/SystemItemWindow.xaml.cs
@@ -0,0 +1,227 @@
+using GeekDesk.Control.Other;
+using GeekDesk.Interface;
+using GeekDesk.Util;
+using GeekDesk.ViewModel;
+
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+
+using System.Windows;
+using System.Windows.Controls;
+
+using System.Windows.Input;
+using static GeekDesk.Util.ShowWindowFollowMouse;
+
+namespace GeekDesk.Control.Windows
+{
+ ///
+ /// SystemItemWindow.xaml 的交互逻辑
+ /// 添加系统项目到对应菜单
+ ///
+ public partial class SystemItemWindow : Window, IWindowCommon
+ {
+ private static AppConfig appConfig = MainWindow.appData.AppConfig;
+ private static MenuInfo menuInfo;
+ private static List systemIcons;
+ private static List customIcons;
+ public static IconfontViewModel vm;
+ private SystemItemWindow(List icons, MenuInfo menuInfo)
+ {
+
+ InitializeComponent();
+
+ systemIcons = icons;
+ this.Topmost = true;
+ SystemItemWindow.menuInfo = menuInfo;
+ vm = new IconfontViewModel
+ {
+ Iconfonts = systemIcons
+ };
+ this.DataContext = vm;
+ }
+
+
+
+ ///
+ /// 移动窗口
+ ///
+ ///
+ ///
+ private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (e.LeftButton == MouseButtonState.Pressed)
+ {
+ DragMove();
+ }
+ }
+
+ private void Close_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+
+ private void TabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
+ {
+ TabItem ti = this.MyTabControl.SelectedItem as TabItem;
+
+ switch (ti.Tag.ToString())
+ {
+ case "Custom":
+ CustomButton.IsEnabled = true;
+ if (StringUtil.IsEmpty(appConfig.CustomIconUrl) || StringUtil.IsEmpty(appConfig.CustomIconJsonUrl))
+ {
+ LoadingEle.Visibility = Visibility.Visible;
+ CustomIcon.Visibility = Visibility.Collapsed;
+ HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig), "IconUrlDialog");
+ } else
+ {
+ if (customIcons == null)
+ {
+ vm.Iconfonts = null;
+ LoadingOnlineIcon();
+ } else
+ {
+ vm.Iconfonts = customIcons;
+ LoadingEle.Visibility = Visibility.Collapsed;
+ CustomIcon.Visibility = Visibility.Visible;
+ }
+ }
+ break;
+ default:
+ if (CustomButton != null)
+ {
+ CustomButton.IsEnabled = false;
+ }
+ if (vm != null)
+ {
+ vm.Iconfonts = systemIcons;
+ }
+ break;
+ }
+ }
+
+ private void Confirm_Click(object sender, RoutedEventArgs e)
+ {
+ TabItem ti = this.MyTabControl.SelectedItem as TabItem;
+ int index;
+ switch (ti.Tag.ToString())
+ {
+ case "Custom":
+ index = this.CustomIcon.IconListBox.SelectedIndex;
+ if (index != -1)
+ {
+ menuInfo.MenuGeometry = customIcons[index].Text;
+ }
+ break;
+ default:
+ index = this.CustomIcon.IconListBox.SelectedIndex;
+ if (index != -1)
+ {
+ menuInfo.MenuGeometry = systemIcons[index].Text;
+ }
+ break;
+ }
+ this.Close();
+ }
+
+
+ private static System.Windows.Window window = null;
+ public static void Show(List listInfo, MenuInfo menuInfo)
+ {
+ if (window == null || !window.Activate())
+ {
+ window = new SystemItemWindow(listInfo, menuInfo);
+ }
+ window.Show();
+ Keyboard.Focus(window);
+ ShowWindowFollowMouse.Show(window, MousePosition.LEFT_CENTER, 0, 0, false);
+ }
+
+ private void CustomButton_Click(object sender, RoutedEventArgs e)
+ {
+ HandyControl.Controls.Dialog.Show(new CustomIconUrlDialog(appConfig));
+ }
+
+
+ private void CheckSettingUrl_TextChanged(object sender, TextChangedEventArgs e)
+ {
+ if (CheckSettingUrl.Text == "true")
+ {
+ LoadingOnlineIcon();
+ } else
+ {
+ LoadingEle.IsRunning = true;
+ CustomIcon.Visibility = Visibility.Collapsed;
+ }
+ }
+
+
+ private void LoadingOnlineIcon()
+ {
+ try
+ {
+ string svgJsStr = HttpUtil.Get(appConfig.CustomIconUrl);
+ string jsonStr = HttpUtil.Get(appConfig.CustomIconJsonUrl);
+ List icons = SvgToGeometry.GetIconfonts(svgJsStr, jsonStr);
+ customIcons = icons;
+ vm.Iconfonts = customIcons;
+ LoadingEle.Visibility = Visibility.Collapsed;
+ CustomIcon.Visibility = Visibility.Visible;
+ }
+ catch (Exception e)
+ {
+ HandyControl.Controls.Growl.WarningGlobal("加载远程图标异常!");
+ LogUtil.WriteErrorLog(e, "加载远程图标异常!");
+ }
+ }
+
+ public void OnKeyDown(object sender, KeyEventArgs e)
+ {
+ if (e.Key == Key.Escape)
+ {
+ this.Close();
+ }
+ }
+
+ public class IconfontViewModel : INotifyPropertyChanged
+ {
+ private List iconfonts;
+ private string isSettingUrl;
+
+ public List Iconfonts
+ {
+ get
+ {
+ return iconfonts;
+ }
+ set
+ {
+ iconfonts = value;
+ OnPropertyChanged("Iconfonts");
+ }
+ }
+
+ public string IsSettingUrl
+ {
+ get
+ {
+ return isSettingUrl;
+ }
+ set
+ {
+ isSettingUrl = value;
+ OnPropertyChanged("IsSettingUrl");
+ }
+ }
+
+
+ public event PropertyChangedEventHandler PropertyChanged;
+ private void OnPropertyChanged(string propertyName)
+ {
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/GeekDesk.csproj b/GeekDesk.csproj
index 653c091..eeaee7c 100644
--- a/GeekDesk.csproj
+++ b/GeekDesk.csproj
@@ -149,6 +149,9 @@
IconPannel.xaml
+
+ SystemItemWindow.xaml
+
ToDoInfoWindow.xaml
@@ -215,6 +218,7 @@
+
@@ -245,6 +249,10 @@
Designer
MSBuild:Compile
+
+ MSBuild:Compile
+ Designer
+
Designer
MSBuild:Compile
diff --git a/Util/FileIcon.cs b/Util/FileIcon.cs
index 9f0460c..9ac7906 100644
--- a/Util/FileIcon.cs
+++ b/Util/FileIcon.cs
@@ -72,6 +72,22 @@ namespace GeekDesk.Util
ico = Icon.FromHandle(ip);
}
+ IntPtr hIcon2 = IntPtr.Zero;
+ //TODO
+ for (int i=0; i<=1000; i++)
+ {
+ try
+ {
+ ico = SystemIcon.MyExtractIcon("%SystemRoot%\\system32\\shell32.dll", i, hIcon2);
+ Bitmap bmp2 = ico.ToBitmap();
+ bmp2.Save("d:\\test\\" + i + ".png");
+ } catch
+ {
+
+ }
+ }
+ ico = SystemIcon.MyExtractIcon("%SystemRoot%\\system32\\shell32.dll", 16, hIcon2);
+
Bitmap bmp = ico.ToBitmap();
MemoryStream strm = new MemoryStream();
@@ -80,7 +96,7 @@ namespace GeekDesk.Util
EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, 75L);
EncoderParameters myEncoderParameters = new EncoderParameters(1);
myEncoderParameters.Param[0] = myEncoderParameter;
-
+ bmp.Save("d:\\test.png");
bmp.Save(strm, myImageCodecInfo, myEncoderParameters);
BitmapImage bmpImage = new BitmapImage();
bmpImage.BeginInit();
diff --git a/Util/SystemIcon.cs b/Util/SystemIcon.cs
new file mode 100644
index 0000000..10f7412
--- /dev/null
+++ b/Util/SystemIcon.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GeekDesk.Util
+{
+ public class SystemIcon
+ {
+ [DllImport("Shell32.dll")]
+ public static extern int ExtractIcon(IntPtr h, string strx, int ii);
+
+ public static Icon MyExtractIcon(string FileName, int iIndex, IntPtr h)
+ {
+ try
+ {
+ IntPtr hIcon = (IntPtr)ExtractIcon(h, FileName, iIndex);
+ if (!hIcon.Equals(null))
+ {
+ Icon icon = Icon.FromHandle(hIcon);
+ return icon;
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+ return null;
+ }
+
+}
+}