using HMI.MenuManage.Entity;
using Newtonsoft.Json;
using Panuon.WPF.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
namespace HMI.MenuManage
{
///
/// ModalWindow.xaml 的交互逻辑
///
public partial class IconSelector : WindowX
{
private static readonly List 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(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();
}
}
}