alielie
2026-03-02 12e606635c42ea20f4b7c2bdda5204237a4b4c96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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
{
    /// <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();
        }
 
 
    }
}