* UIFontImages: 增加搜索结果显示页面
This commit is contained in:
parent
94ff3f35b3
commit
4a16603367
@ -18,6 +18,7 @@
|
||||
*
|
||||
* 2020-01-01: V2.2.0 增加文件说明
|
||||
* 2022-01-28: V3.1.0 增加搜索框,搜索结果标红显示
|
||||
* 2023-04-23: V3.3.5 增加搜索结果显示页面
|
||||
******************************************************************************/
|
||||
|
||||
using System;
|
||||
@ -42,6 +43,7 @@ namespace Sunny.UI
|
||||
private readonly ConcurrentQueue<Label> FontAwesomeV6SolidLabels = new ConcurrentQueue<Label>();
|
||||
private readonly ConcurrentQueue<Label> FontAwesomeV6BrandsLabels = new ConcurrentQueue<Label>();
|
||||
private readonly ConcurrentQueue<Label> FontAwesomeV6RegularLabels = new ConcurrentQueue<Label>();
|
||||
private readonly ConcurrentQueue<Label> SearchLabels = new ConcurrentQueue<Label>();
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
@ -49,6 +51,12 @@ namespace Sunny.UI
|
||||
public UIFontImages()
|
||||
{
|
||||
InitializeComponent();
|
||||
lblResult.DoubleBuffered();
|
||||
lpAwesome.DoubleBuffered();
|
||||
lpElegant.DoubleBuffered();
|
||||
lpV6Brands.DoubleBuffered();
|
||||
lpV6Regular.DoubleBuffered();
|
||||
lpV6Solid.DoubleBuffered();
|
||||
}
|
||||
|
||||
private void UIFontImages_Load(object sender, EventArgs e)
|
||||
@ -259,6 +267,7 @@ namespace Sunny.UI
|
||||
Margin = new Padding(2)
|
||||
};
|
||||
|
||||
lbl.DoubleBuffered();
|
||||
lbl.Click += lbl_DoubleClick;
|
||||
lbl.MouseEnter += Lbl_MouseEnter;
|
||||
lbl.MouseLeave += Lbl_MouseLeave;
|
||||
@ -331,7 +340,7 @@ namespace Sunny.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadLabels(Type type, ConcurrentQueue<Label> labels, UISymbolType symbolType)
|
||||
private void LoadLabels(Type type, ConcurrentQueue<Label> labels, UISymbolType symbolType, string filter = "")
|
||||
{
|
||||
ConcurrentDictionary<int, FieldInfo> dic = new ConcurrentDictionary<int, FieldInfo>();
|
||||
foreach (var fieldInfo in type.GetFields())
|
||||
@ -348,7 +357,10 @@ namespace Sunny.UI
|
||||
|
||||
foreach (var value in list)
|
||||
{
|
||||
labels.Enqueue(CreateLabel(dic[value].Name, value, symbolType));
|
||||
if (filter == "")
|
||||
labels.Enqueue(CreateLabel(dic[value].Name, value, symbolType));
|
||||
else if (dic[value].Name.ToUpper().Contains(filter.ToUpper()))
|
||||
labels.Enqueue(CreateLabel(dic[value].Name, value, symbolType));
|
||||
}
|
||||
|
||||
dic.Clear();
|
||||
@ -368,89 +380,43 @@ namespace Sunny.UI
|
||||
|
||||
private void bg3_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
//public const int FontAwesomeV6BrandsCount = 457;
|
||||
LoadLabels(typeof(FontAweSomeV6Brands), FontAwesomeV6BrandsLabels, UISymbolType.FontAwesomeV6Brands);
|
||||
}
|
||||
|
||||
private void bg4_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
//public const int FontAwesomeV6RegularCount = 151;
|
||||
LoadLabels(typeof(FontAweSomeV6Regular), FontAwesomeV6RegularLabels, UISymbolType.FontAwesomeV6Regular);
|
||||
}
|
||||
|
||||
private void bg5_DoWork(object sender, DoWorkEventArgs e)
|
||||
{
|
||||
//public const int FontAwesomeV6SolidCount = 1001;
|
||||
LoadLabels(typeof(FontAweSomeV6Solid), FontAwesomeV6SolidLabels, UISymbolType.FontAwesomeV6Solid);
|
||||
}
|
||||
|
||||
int findCount = 0;
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (textBox1.Text.IsNullOrEmpty()) return;
|
||||
findCount = 0;
|
||||
foreach (var item in lpV6Brands.Controls)
|
||||
lblResult.Controls.Clear();
|
||||
SearchLabels.Clear();
|
||||
|
||||
LoadLabels(typeof(FontAwesomeIcons), SearchLabels, UISymbolType.FontAwesomeV4, textBox1.Text);
|
||||
LoadLabels(typeof(FontElegantIcons), SearchLabels, UISymbolType.FontAwesomeV4, textBox1.Text);
|
||||
LoadLabels(typeof(FontAweSomeV6Brands), SearchLabels, UISymbolType.FontAwesomeV6Brands, textBox1.Text);
|
||||
LoadLabels(typeof(FontAweSomeV6Regular), SearchLabels, UISymbolType.FontAwesomeV6Regular, textBox1.Text);
|
||||
LoadLabels(typeof(FontAweSomeV6Solid), SearchLabels, UISymbolType.FontAwesomeV6Solid, textBox1.Text);
|
||||
|
||||
label1.Text = SearchLabels.Count + " results.";
|
||||
while (!SearchLabels.IsEmpty)
|
||||
{
|
||||
if (item is Label lbl)
|
||||
if (SearchLabels.TryDequeue(out Label lbl))
|
||||
{
|
||||
SetLabelFilter(lbl);
|
||||
lblResult.Controls.Add(lbl);
|
||||
SymbolValue symbol = (SymbolValue)lbl.Tag;
|
||||
toolTip.SetToolTip(lbl, symbol.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in lpAwesome.Controls)
|
||||
{
|
||||
if (item is Label lbl)
|
||||
{
|
||||
SetLabelFilter(lbl);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in lpElegant.Controls)
|
||||
{
|
||||
if (item is Label lbl)
|
||||
{
|
||||
SetLabelFilter(lbl);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in lpV6Regular.Controls)
|
||||
{
|
||||
if (item is Label lbl)
|
||||
{
|
||||
SetLabelFilter(lbl);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var item in lpV6Solid.Controls)
|
||||
{
|
||||
if (item is Label lbl)
|
||||
{
|
||||
SetLabelFilter(lbl);
|
||||
}
|
||||
}
|
||||
|
||||
label1.Text = findCount + " results.";
|
||||
}
|
||||
|
||||
private void SetLabelFilter(Label lbl)
|
||||
{
|
||||
SymbolValue symbol = (SymbolValue)lbl.Tag;
|
||||
if (textBox1.Text.IsNullOrEmpty() || !symbol.Name.Contains(textBox1.Text))
|
||||
{
|
||||
if (symbol.IsRed)
|
||||
lbl.Image = FontImageHelper.CreateImage(symbol.Symbol + (int)symbol.SymbolType * 100000, 28, UIFontColor.Primary);
|
||||
|
||||
symbol.IsRed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!symbol.IsRed)
|
||||
lbl.Image = FontImageHelper.CreateImage(symbol.Symbol + (int)symbol.SymbolType * 100000, 28, UIColor.Red);
|
||||
|
||||
symbol.IsRed = true;
|
||||
findCount++;
|
||||
}
|
||||
tabControl1.SelectedTab = tabPage7;
|
||||
}
|
||||
|
||||
private void UIFontImages_Shown(object sender, EventArgs e)
|
||||
@ -458,11 +424,6 @@ namespace Sunny.UI
|
||||
textBox1.Focus();
|
||||
}
|
||||
|
||||
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void textBox1_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
|
83
SunnyUI/Font/UIFontImages.designer.cs
generated
83
SunnyUI/Font/UIFontImages.designer.cs
generated
@ -34,14 +34,16 @@
|
||||
lpCustom = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage5 = new System.Windows.Forms.TabPage();
|
||||
lpV6Solid = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage4 = new System.Windows.Forms.TabPage();
|
||||
lpV6Brands = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage6 = new System.Windows.Forms.TabPage();
|
||||
lpV6Regular = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage4 = new System.Windows.Forms.TabPage();
|
||||
lpV6Brands = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage2 = new System.Windows.Forms.TabPage();
|
||||
lpAwesome = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage3 = new System.Windows.Forms.TabPage();
|
||||
lpElegant = new System.Windows.Forms.FlowLayoutPanel();
|
||||
tabPage7 = new System.Windows.Forms.TabPage();
|
||||
lblResult = new System.Windows.Forms.FlowLayoutPanel();
|
||||
bg1 = new System.ComponentModel.BackgroundWorker();
|
||||
timer = new System.Windows.Forms.Timer(components);
|
||||
toolTip = new System.Windows.Forms.ToolTip(components);
|
||||
@ -57,10 +59,11 @@
|
||||
tabControl1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
tabPage5.SuspendLayout();
|
||||
tabPage4.SuspendLayout();
|
||||
tabPage6.SuspendLayout();
|
||||
tabPage4.SuspendLayout();
|
||||
tabPage2.SuspendLayout();
|
||||
tabPage3.SuspendLayout();
|
||||
tabPage7.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -72,6 +75,7 @@
|
||||
tabControl1.Controls.Add(tabPage4);
|
||||
tabControl1.Controls.Add(tabPage2);
|
||||
tabControl1.Controls.Add(tabPage3);
|
||||
tabControl1.Controls.Add(tabPage7);
|
||||
tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
tabControl1.ItemSize = new System.Drawing.Size(48, 24);
|
||||
tabControl1.Location = new System.Drawing.Point(0, 81);
|
||||
@ -121,27 +125,6 @@
|
||||
lpV6Solid.Size = new System.Drawing.Size(886, 572);
|
||||
lpV6Solid.TabIndex = 3;
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
tabPage4.Controls.Add(lpV6Brands);
|
||||
tabPage4.Location = new System.Drawing.Point(4, 28);
|
||||
tabPage4.Name = "tabPage4";
|
||||
tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage4.Size = new System.Drawing.Size(892, 578);
|
||||
tabPage4.TabIndex = 3;
|
||||
tabPage4.Text = "V6 Brands";
|
||||
tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lpV6Brands
|
||||
//
|
||||
lpV6Brands.AutoScroll = true;
|
||||
lpV6Brands.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
lpV6Brands.ForeColor = System.Drawing.Color.FromArgb(64, 158, 255);
|
||||
lpV6Brands.Location = new System.Drawing.Point(3, 3);
|
||||
lpV6Brands.Name = "lpV6Brands";
|
||||
lpV6Brands.Size = new System.Drawing.Size(886, 572);
|
||||
lpV6Brands.TabIndex = 3;
|
||||
//
|
||||
// tabPage6
|
||||
//
|
||||
tabPage6.Controls.Add(lpV6Regular);
|
||||
@ -163,6 +146,27 @@
|
||||
lpV6Regular.Size = new System.Drawing.Size(886, 572);
|
||||
lpV6Regular.TabIndex = 3;
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
tabPage4.Controls.Add(lpV6Brands);
|
||||
tabPage4.Location = new System.Drawing.Point(4, 28);
|
||||
tabPage4.Name = "tabPage4";
|
||||
tabPage4.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage4.Size = new System.Drawing.Size(892, 578);
|
||||
tabPage4.TabIndex = 3;
|
||||
tabPage4.Text = "V6 Brands";
|
||||
tabPage4.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lpV6Brands
|
||||
//
|
||||
lpV6Brands.AutoScroll = true;
|
||||
lpV6Brands.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
lpV6Brands.ForeColor = System.Drawing.Color.FromArgb(64, 158, 255);
|
||||
lpV6Brands.Location = new System.Drawing.Point(3, 3);
|
||||
lpV6Brands.Name = "lpV6Brands";
|
||||
lpV6Brands.Size = new System.Drawing.Size(886, 572);
|
||||
lpV6Brands.TabIndex = 3;
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
tabPage2.Controls.Add(lpAwesome);
|
||||
@ -205,6 +209,27 @@
|
||||
lpElegant.Size = new System.Drawing.Size(886, 572);
|
||||
lpElegant.TabIndex = 2;
|
||||
//
|
||||
// tabPage7
|
||||
//
|
||||
tabPage7.Controls.Add(lblResult);
|
||||
tabPage7.Location = new System.Drawing.Point(4, 28);
|
||||
tabPage7.Name = "tabPage7";
|
||||
tabPage7.Padding = new System.Windows.Forms.Padding(3);
|
||||
tabPage7.Size = new System.Drawing.Size(892, 578);
|
||||
tabPage7.TabIndex = 6;
|
||||
tabPage7.Text = "Search result";
|
||||
tabPage7.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// lblResult
|
||||
//
|
||||
lblResult.AutoScroll = true;
|
||||
lblResult.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
lblResult.ForeColor = System.Drawing.Color.FromArgb(64, 158, 255);
|
||||
lblResult.Location = new System.Drawing.Point(3, 3);
|
||||
lblResult.Name = "lblResult";
|
||||
lblResult.Size = new System.Drawing.Size(886, 572);
|
||||
lblResult.TabIndex = 3;
|
||||
//
|
||||
// bg1
|
||||
//
|
||||
bg1.DoWork += bg_DoWork;
|
||||
@ -245,7 +270,7 @@
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
label2.ForeColor = System.Drawing.Color.FromArgb(230, 80, 80);
|
||||
label2.ForeColor = System.Drawing.Color.Blue;
|
||||
label2.Location = new System.Drawing.Point(12, 14);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new System.Drawing.Size(631, 16);
|
||||
@ -256,7 +281,7 @@
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||
label1.ForeColor = System.Drawing.Color.FromArgb(230, 80, 80);
|
||||
label1.ForeColor = System.Drawing.Color.Blue;
|
||||
label1.Location = new System.Drawing.Point(441, 48);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(87, 16);
|
||||
@ -282,7 +307,6 @@
|
||||
textBox1.Size = new System.Drawing.Size(317, 26);
|
||||
textBox1.TabIndex = 0;
|
||||
textBox1.KeyDown += textBox1_KeyDown;
|
||||
textBox1.KeyPress += textBox1_KeyPress;
|
||||
//
|
||||
// UIFontImages
|
||||
//
|
||||
@ -299,10 +323,11 @@
|
||||
tabControl1.ResumeLayout(false);
|
||||
tabPage1.ResumeLayout(false);
|
||||
tabPage5.ResumeLayout(false);
|
||||
tabPage4.ResumeLayout(false);
|
||||
tabPage6.ResumeLayout(false);
|
||||
tabPage4.ResumeLayout(false);
|
||||
tabPage2.ResumeLayout(false);
|
||||
tabPage3.ResumeLayout(false);
|
||||
tabPage7.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
panel1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
@ -335,5 +360,7 @@
|
||||
private System.Windows.Forms.TextBox textBox1;
|
||||
private System.Windows.Forms.Label label1;
|
||||
private System.Windows.Forms.Label label2;
|
||||
private System.Windows.Forms.TabPage tabPage7;
|
||||
private System.Windows.Forms.FlowLayoutPanel lblResult;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user