* UIFontImages: 增加搜索结果显示页面

This commit is contained in:
Sunny 2023-04-23 14:56:35 +08:00
parent 94ff3f35b3
commit 4a16603367
2 changed files with 85 additions and 97 deletions

View File

@ -18,6 +18,7 @@
* *
* 2020-01-01: V2.2.0 * 2020-01-01: V2.2.0
* 2022-01-28: V3.1.0 * 2022-01-28: V3.1.0
* 2023-04-23: V3.3.5
******************************************************************************/ ******************************************************************************/
using System; using System;
@ -42,6 +43,7 @@ namespace Sunny.UI
private readonly ConcurrentQueue<Label> FontAwesomeV6SolidLabels = new ConcurrentQueue<Label>(); private readonly ConcurrentQueue<Label> FontAwesomeV6SolidLabels = new ConcurrentQueue<Label>();
private readonly ConcurrentQueue<Label> FontAwesomeV6BrandsLabels = new ConcurrentQueue<Label>(); private readonly ConcurrentQueue<Label> FontAwesomeV6BrandsLabels = new ConcurrentQueue<Label>();
private readonly ConcurrentQueue<Label> FontAwesomeV6RegularLabels = new ConcurrentQueue<Label>(); private readonly ConcurrentQueue<Label> FontAwesomeV6RegularLabels = new ConcurrentQueue<Label>();
private readonly ConcurrentQueue<Label> SearchLabels = new ConcurrentQueue<Label>();
/// <summary> /// <summary>
/// 构造函数 /// 构造函数
@ -49,6 +51,12 @@ namespace Sunny.UI
public UIFontImages() public UIFontImages()
{ {
InitializeComponent(); InitializeComponent();
lblResult.DoubleBuffered();
lpAwesome.DoubleBuffered();
lpElegant.DoubleBuffered();
lpV6Brands.DoubleBuffered();
lpV6Regular.DoubleBuffered();
lpV6Solid.DoubleBuffered();
} }
private void UIFontImages_Load(object sender, EventArgs e) private void UIFontImages_Load(object sender, EventArgs e)
@ -259,6 +267,7 @@ namespace Sunny.UI
Margin = new Padding(2) Margin = new Padding(2)
}; };
lbl.DoubleBuffered();
lbl.Click += lbl_DoubleClick; lbl.Click += lbl_DoubleClick;
lbl.MouseEnter += Lbl_MouseEnter; lbl.MouseEnter += Lbl_MouseEnter;
lbl.MouseLeave += Lbl_MouseLeave; 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>(); ConcurrentDictionary<int, FieldInfo> dic = new ConcurrentDictionary<int, FieldInfo>();
foreach (var fieldInfo in type.GetFields()) foreach (var fieldInfo in type.GetFields())
@ -348,7 +357,10 @@ namespace Sunny.UI
foreach (var value in list) 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(); dic.Clear();
@ -368,89 +380,43 @@ namespace Sunny.UI
private void bg3_DoWork(object sender, DoWorkEventArgs e) private void bg3_DoWork(object sender, DoWorkEventArgs e)
{ {
//public const int FontAwesomeV6BrandsCount = 457;
LoadLabels(typeof(FontAweSomeV6Brands), FontAwesomeV6BrandsLabels, UISymbolType.FontAwesomeV6Brands); LoadLabels(typeof(FontAweSomeV6Brands), FontAwesomeV6BrandsLabels, UISymbolType.FontAwesomeV6Brands);
} }
private void bg4_DoWork(object sender, DoWorkEventArgs e) private void bg4_DoWork(object sender, DoWorkEventArgs e)
{ {
//public const int FontAwesomeV6RegularCount = 151;
LoadLabels(typeof(FontAweSomeV6Regular), FontAwesomeV6RegularLabels, UISymbolType.FontAwesomeV6Regular); LoadLabels(typeof(FontAweSomeV6Regular), FontAwesomeV6RegularLabels, UISymbolType.FontAwesomeV6Regular);
} }
private void bg5_DoWork(object sender, DoWorkEventArgs e) private void bg5_DoWork(object sender, DoWorkEventArgs e)
{ {
//public const int FontAwesomeV6SolidCount = 1001;
LoadLabels(typeof(FontAweSomeV6Solid), FontAwesomeV6SolidLabels, UISymbolType.FontAwesomeV6Solid); LoadLabels(typeof(FontAweSomeV6Solid), FontAwesomeV6SolidLabels, UISymbolType.FontAwesomeV6Solid);
} }
int findCount = 0;
private void button1_Click(object sender, EventArgs e) private void button1_Click(object sender, EventArgs e)
{ {
if (textBox1.Text.IsNullOrEmpty()) return; if (textBox1.Text.IsNullOrEmpty()) return;
findCount = 0; lblResult.Controls.Clear();
foreach (var item in lpV6Brands.Controls) 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) tabControl1.SelectedTab = tabPage7;
{
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++;
}
} }
private void UIFontImages_Shown(object sender, EventArgs e) private void UIFontImages_Shown(object sender, EventArgs e)
@ -458,11 +424,6 @@ namespace Sunny.UI
textBox1.Focus(); textBox1.Focus();
} }
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void textBox1_KeyDown(object sender, KeyEventArgs e) private void textBox1_KeyDown(object sender, KeyEventArgs e)
{ {
if (e.KeyCode == Keys.Enter) if (e.KeyCode == Keys.Enter)

View File

@ -34,14 +34,16 @@
lpCustom = new System.Windows.Forms.FlowLayoutPanel(); lpCustom = new System.Windows.Forms.FlowLayoutPanel();
tabPage5 = new System.Windows.Forms.TabPage(); tabPage5 = new System.Windows.Forms.TabPage();
lpV6Solid = new System.Windows.Forms.FlowLayoutPanel(); lpV6Solid = new System.Windows.Forms.FlowLayoutPanel();
tabPage4 = new System.Windows.Forms.TabPage();
lpV6Brands = new System.Windows.Forms.FlowLayoutPanel();
tabPage6 = new System.Windows.Forms.TabPage(); tabPage6 = new System.Windows.Forms.TabPage();
lpV6Regular = new System.Windows.Forms.FlowLayoutPanel(); lpV6Regular = new System.Windows.Forms.FlowLayoutPanel();
tabPage4 = new System.Windows.Forms.TabPage();
lpV6Brands = new System.Windows.Forms.FlowLayoutPanel();
tabPage2 = new System.Windows.Forms.TabPage(); tabPage2 = new System.Windows.Forms.TabPage();
lpAwesome = new System.Windows.Forms.FlowLayoutPanel(); lpAwesome = new System.Windows.Forms.FlowLayoutPanel();
tabPage3 = new System.Windows.Forms.TabPage(); tabPage3 = new System.Windows.Forms.TabPage();
lpElegant = new System.Windows.Forms.FlowLayoutPanel(); lpElegant = new System.Windows.Forms.FlowLayoutPanel();
tabPage7 = new System.Windows.Forms.TabPage();
lblResult = new System.Windows.Forms.FlowLayoutPanel();
bg1 = new System.ComponentModel.BackgroundWorker(); bg1 = new System.ComponentModel.BackgroundWorker();
timer = new System.Windows.Forms.Timer(components); timer = new System.Windows.Forms.Timer(components);
toolTip = new System.Windows.Forms.ToolTip(components); toolTip = new System.Windows.Forms.ToolTip(components);
@ -57,10 +59,11 @@
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
tabPage1.SuspendLayout(); tabPage1.SuspendLayout();
tabPage5.SuspendLayout(); tabPage5.SuspendLayout();
tabPage4.SuspendLayout();
tabPage6.SuspendLayout(); tabPage6.SuspendLayout();
tabPage4.SuspendLayout();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
tabPage3.SuspendLayout(); tabPage3.SuspendLayout();
tabPage7.SuspendLayout();
panel1.SuspendLayout(); panel1.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -72,6 +75,7 @@
tabControl1.Controls.Add(tabPage4); tabControl1.Controls.Add(tabPage4);
tabControl1.Controls.Add(tabPage2); tabControl1.Controls.Add(tabPage2);
tabControl1.Controls.Add(tabPage3); tabControl1.Controls.Add(tabPage3);
tabControl1.Controls.Add(tabPage7);
tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
tabControl1.ItemSize = new System.Drawing.Size(48, 24); tabControl1.ItemSize = new System.Drawing.Size(48, 24);
tabControl1.Location = new System.Drawing.Point(0, 81); tabControl1.Location = new System.Drawing.Point(0, 81);
@ -121,27 +125,6 @@
lpV6Solid.Size = new System.Drawing.Size(886, 572); lpV6Solid.Size = new System.Drawing.Size(886, 572);
lpV6Solid.TabIndex = 3; 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
// //
tabPage6.Controls.Add(lpV6Regular); tabPage6.Controls.Add(lpV6Regular);
@ -163,6 +146,27 @@
lpV6Regular.Size = new System.Drawing.Size(886, 572); lpV6Regular.Size = new System.Drawing.Size(886, 572);
lpV6Regular.TabIndex = 3; 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
// //
tabPage2.Controls.Add(lpAwesome); tabPage2.Controls.Add(lpAwesome);
@ -205,6 +209,27 @@
lpElegant.Size = new System.Drawing.Size(886, 572); lpElegant.Size = new System.Drawing.Size(886, 572);
lpElegant.TabIndex = 2; 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
// //
bg1.DoWork += bg_DoWork; bg1.DoWork += bg_DoWork;
@ -245,7 +270,7 @@
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); 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.Location = new System.Drawing.Point(12, 14);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new System.Drawing.Size(631, 16); label2.Size = new System.Drawing.Size(631, 16);
@ -256,7 +281,7 @@
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); 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.Location = new System.Drawing.Point(441, 48);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new System.Drawing.Size(87, 16); label1.Size = new System.Drawing.Size(87, 16);
@ -282,7 +307,6 @@
textBox1.Size = new System.Drawing.Size(317, 26); textBox1.Size = new System.Drawing.Size(317, 26);
textBox1.TabIndex = 0; textBox1.TabIndex = 0;
textBox1.KeyDown += textBox1_KeyDown; textBox1.KeyDown += textBox1_KeyDown;
textBox1.KeyPress += textBox1_KeyPress;
// //
// UIFontImages // UIFontImages
// //
@ -299,10 +323,11 @@
tabControl1.ResumeLayout(false); tabControl1.ResumeLayout(false);
tabPage1.ResumeLayout(false); tabPage1.ResumeLayout(false);
tabPage5.ResumeLayout(false); tabPage5.ResumeLayout(false);
tabPage4.ResumeLayout(false);
tabPage6.ResumeLayout(false); tabPage6.ResumeLayout(false);
tabPage4.ResumeLayout(false);
tabPage2.ResumeLayout(false); tabPage2.ResumeLayout(false);
tabPage3.ResumeLayout(false); tabPage3.ResumeLayout(false);
tabPage7.ResumeLayout(false);
panel1.ResumeLayout(false); panel1.ResumeLayout(false);
panel1.PerformLayout(); panel1.PerformLayout();
ResumeLayout(false); ResumeLayout(false);
@ -335,5 +360,7 @@
private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1; private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label2;
private System.Windows.Forms.TabPage tabPage7;
private System.Windows.Forms.FlowLayoutPanel lblResult;
} }
} }