Files
GeekDesk/Control/Windows/IconfontWindow.xaml.cs

120 lines
3.4 KiB
C#
Raw Normal View History

2021-07-12 17:28:57 +08:00
using GeekDesk.Control.Other;
using GeekDesk.Util;
2021-07-07 17:28:29 +08:00
using GeekDesk.ViewModel;
2021-07-12 17:28:57 +08:00
2021-07-07 17:28:29 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace GeekDesk.Control.Windows
{
/// <summary>
/// IconfontWindow.xaml 的交互逻辑
/// </summary>
public partial class IconfontWindow : Window
{
private static MenuInfo menuInfo;
2021-07-12 17:28:57 +08:00
private static List<IconfontInfo> systemIcons;
private static List<IconfontInfo> customIcons;
private IconfontWindow(List<IconfontInfo> icons, MenuInfo menuInfo)
2021-07-07 17:28:29 +08:00
{
2021-07-12 17:28:57 +08:00
systemIcons = icons;
this.DataContext = systemIcons;
this.Topmost = true;
2021-07-07 17:28:29 +08:00
IconfontWindow.menuInfo = menuInfo;
2021-07-12 17:28:57 +08:00
InitializeComponent();
2021-07-07 17:28:29 +08:00
}
2021-07-09 17:31:44 +08:00
2021-07-07 17:28:29 +08:00
/// <summary>
/// 移动窗口
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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)
{
2021-07-12 17:28:57 +08:00
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
switch (ti.Tag.ToString())
{
case "Custom":
CustomButton.IsEnabled = true;
this.DataContext = customIcons;
break;
default:
if (CustomButton != null)
{
CustomButton.IsEnabled = false;
}
this.DataContext = systemIcons;
break;
}
2021-07-07 17:28:29 +08:00
}
private void Confirm_Click(object sender, RoutedEventArgs e)
{
2021-07-12 17:28:57 +08:00
TabItem ti = this.MyTabControl.SelectedItem as TabItem;
int index;
switch (ti.Tag.ToString())
2021-07-07 17:28:29 +08:00
{
case "Custom":
2021-07-12 17:28:57 +08:00
index = this.CustomIcon.IconListBox.SelectedIndex;
if (index != -1)
2021-07-07 17:28:29 +08:00
{
2021-07-12 17:28:57 +08:00
menuInfo.MenuGeometry = customIcons[index].Text;
2021-07-07 17:28:29 +08:00
}
break;
default:
2021-07-12 17:28:57 +08:00
index = this.SystemIcon.IconListBox.SelectedIndex;
if (index != -1)
2021-07-07 17:28:29 +08:00
{
2021-07-12 17:28:57 +08:00
menuInfo.MenuGeometry = systemIcons[index].Text;
2021-07-07 17:28:29 +08:00
}
break;
}
this.Close();
}
private static System.Windows.Window window = null;
public static void Show(List<IconfontInfo> listInfo, MenuInfo menuInfo)
{
if (window == null || !window.Activate())
{
window = new IconfontWindow(listInfo, menuInfo);
}
window.Show();
}
2021-07-09 17:31:44 +08:00
2021-07-12 17:28:57 +08:00
private void CustomButton_Click(object sender, RoutedEventArgs e)
2021-07-09 17:31:44 +08:00
{
2021-07-12 17:28:57 +08:00
2021-07-09 17:31:44 +08:00
}
2021-07-07 17:28:29 +08:00
}
}