using HMI.Core.Annotation;
|
using HMI.Core.Util;
|
using HMI.MenuManage.Entity;
|
using HMI.UI.DpUtil;
|
using Microsoft.Win32;
|
using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using Panuon.WPF.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Collections.ObjectModel;
|
using System.ComponentModel;
|
using System.Data;
|
using System.IO;
|
using System.Linq;
|
using System.Reflection;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Xml.Linq;
|
|
namespace HMI.MenuManage
|
{
|
/// <summary>
|
/// ModalWindow.xaml 的交互逻辑
|
/// </summary>
|
public partial class IconSelector : WindowX
|
{
|
|
private static readonly List<IconMeta> icons;
|
|
private string data;
|
public string Data
|
{
|
get => data;
|
set { Set(ref data, value); }
|
}
|
|
static IconSelector()
|
{
|
try
|
{
|
Assembly assembly = Assembly.Load("HMI.UI");
|
var serializer = new JsonSerializer();
|
var sb = assembly.GetManifestResourceNames();
|
using (Stream stream = assembly.GetManifestResourceStream("HMI.UI.Resources.Font.iconfont.json"))
|
using (StreamReader streamReader = new StreamReader(stream))
|
using (JsonTextReader jsonTextReader = new JsonTextReader(streamReader))
|
{
|
IconHolder holder = serializer.Deserialize<IconHolder>(jsonTextReader);
|
icons = holder?.glyphs;
|
}
|
}
|
catch (Exception ex)
|
{
|
|
}
|
}
|
|
public IconSelector()
|
{
|
DataContext = this;
|
InitializeComponent();
|
}
|
private bool _isProcessing;
|
|
|
protected override void OnClosing(CancelEventArgs e)
|
{
|
base.OnClosing(e);
|
}
|
|
public bool? Open(string currentValue)
|
{
|
list.ItemsSource = icons.Select(i => i.Code).ToList();
|
Data = currentValue;
|
return this.ShowDialog();
|
}
|
|
|
}
|
}
|