字体图标选择界面,增加搜索框,搜索结果标红显示

This commit is contained in:
Sunny 2022-01-28 17:30:04 +08:00
parent cd829332de
commit 0874f1f657
8 changed files with 216 additions and 59 deletions

Binary file not shown.

Binary file not shown.

View File

@ -204,7 +204,7 @@ namespace Sunny.UI.Demo
this.uiDoubleUpDown1.TabIndex = 8;
this.uiDoubleUpDown1.Text = "uiDoubleUpDown1";
this.uiDoubleUpDown1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiDoubleUpDown1.Value = 0D;
this.uiDoubleUpDown1.Value = 10D;
//
// uiLabel3
//
@ -298,6 +298,7 @@ namespace Sunny.UI.Demo
this.uiIntegerUpDown1.TabIndex = 7;
this.uiIntegerUpDown1.Text = "_uiIntegerUpDown1";
this.uiIntegerUpDown1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
this.uiIntegerUpDown1.Value = 10;
//
// uiToolTip1
//

View File

@ -279,8 +279,8 @@ namespace Sunny.UI
pnlColor = pnlValue.FillColor;
pnlValue.FillColor = Color.White;
edit.TextAlign = HorizontalAlignment.Center;
edit.Text = pnlValue.Text;
edit.DecLength = Decimal;
edit.DoubleValue = Value;
edit.BringToFront();
edit.Visible = true;
edit.Focus();

View File

@ -272,7 +272,7 @@ namespace Sunny.UI
if (_uiEditType == UITextBox.UIEditType.Double)
{
mask = DecimalToMask(decLength);
Text = mask;
Text = DoubleValue.ToString(mask);
Invalidate();
}
}

View File

@ -276,7 +276,7 @@ namespace Sunny.UI
pnlColor = pnlValue.FillColor;
pnlValue.FillColor = Color.White;
edit.TextAlign = HorizontalAlignment.Center;
edit.Text = pnlValue.Text;
edit.IntValue = Value;
edit.BringToFront();
edit.Visible = true;
edit.Focus();

View File

@ -17,6 +17,7 @@
* : 2020-01-01
*
* 2020-01-01: V2.2.0
* 2022-01-28: V3.1.0
******************************************************************************/
using System;
@ -31,7 +32,7 @@ namespace Sunny.UI
/// <summary>
/// 字体图标编辑器
/// </summary>
public partial class UIFontImages : Form, ISymbol
internal partial class UIFontImages : Form, ISymbol
{
private readonly ConcurrentQueue<Label> FontAwesomeV4Labels = new ConcurrentQueue<Label>();
private readonly ConcurrentQueue<Label> ElegantIconsLabels = new ConcurrentQueue<Label>();
@ -220,15 +221,22 @@ namespace Sunny.UI
toolTip.SetToolTip(lbl, symbol.ToString());
}
public struct SymbolValue
public class SymbolValue
{
public int Symbol { get; set; }
public UISymbolType SymbolType { get; set; }
public string Name { get; set; }
public bool IsRed { get; set; }
public override string ToString()
{
return Symbol.ToString();
if (Name.IsValid())
return Name + Environment.NewLine + (((int)SymbolType) * 100000 + Symbol).ToString();
else
return (((int)SymbolType) * 100000 + Symbol).ToString();
}
}
@ -252,10 +260,31 @@ namespace Sunny.UI
return lbl;
}
private Label CreateLabel(string name, int icon, UISymbolType symbolType)
{
Label lbl = new Label
{
AutoSize = false,
Size = new Size(32, 32),
ForeColor = UIColor.Blue,
Image = FontImageHelper.CreateImage(icon + (int)symbolType * 100000, 28, UIFontColor.Primary),
ImageAlign = ContentAlignment.MiddleCenter,
TextAlign = ContentAlignment.MiddleLeft,
Margin = new Padding(2)
};
lbl.Click += lbl_DoubleClick;
lbl.MouseEnter += Lbl_MouseEnter;
lbl.MouseLeave += Lbl_MouseLeave;
lbl.Tag = new SymbolValue() { Name = name.Replace("fa_", ""), Symbol = icon, SymbolType = symbolType };
return lbl;
}
private void Lbl_MouseLeave(object sender, EventArgs e)
{
Label lbl = (Label)sender;
SymbolValue symbol = (SymbolValue)lbl.Tag;
if (symbol.IsRed) return;
lbl.Image = FontImageHelper.CreateImage(symbol.Symbol + (int)symbol.SymbolType * 100000, 28, UIFontColor.Primary);
}
@ -263,6 +292,7 @@ namespace Sunny.UI
{
Label lbl = (Label)sender;
SymbolValue symbol = (SymbolValue)lbl.Tag;
if (symbol.IsRed) return;
lbl.Image = FontImageHelper.CreateImage(symbol.Symbol + (int)symbol.SymbolType * 100000, 28, UIColor.Blue);
}
@ -291,11 +321,11 @@ namespace Sunny.UI
var t = typeof(FontAwesomeIcons);
foreach (var fieldInfo in t.GetFields())
{
object obj = fieldInfo.GetRawConstantValue();
var obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV4Labels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4));
FontAwesomeV4Labels.Enqueue(CreateLabel(fieldInfo.Name, value, UISymbolType.FontAwesomeV4));
}
}
}
@ -305,11 +335,11 @@ namespace Sunny.UI
var t = typeof(FontElegantIcons);
foreach (var fieldInfo in t.GetFields())
{
object obj = fieldInfo.GetRawConstantValue();
var obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
ElegantIconsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV4));
ElegantIconsLabels.Enqueue(CreateLabel(fieldInfo.Name, value, UISymbolType.FontAwesomeV4));
}
}
}
@ -319,11 +349,11 @@ namespace Sunny.UI
var t = typeof(FontAweSomeV5Brands);
foreach (var fieldInfo in t.GetFields())
{
object obj = fieldInfo.GetRawConstantValue();
var obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5BrandsLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Brands));
FontAwesomeV5BrandsLabels.Enqueue(CreateLabel(fieldInfo.Name, value, UISymbolType.FontAwesomeV5Brands));
}
}
}
@ -333,11 +363,11 @@ namespace Sunny.UI
var t = typeof(FontAweSomeV5Regular);
foreach (var fieldInfo in t.GetFields())
{
object obj = fieldInfo.GetRawConstantValue();
var obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5RegularLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Regular));
FontAwesomeV5RegularLabels.Enqueue(CreateLabel(fieldInfo.Name, value, UISymbolType.FontAwesomeV5Regular));
}
}
}
@ -347,14 +377,88 @@ namespace Sunny.UI
var t = typeof(FontAweSomeV5Solid);
foreach (var fieldInfo in t.GetFields())
{
object obj = fieldInfo.GetRawConstantValue();
var obj = fieldInfo.GetRawConstantValue();
if (obj != null)
{
int value = obj.ToString().ToInt();
FontAwesomeV5SolidLabels.Enqueue(CreateLabel(value, UISymbolType.FontAwesomeV5Solid));
FontAwesomeV5SolidLabels.Enqueue(CreateLabel(fieldInfo.Name, value, UISymbolType.FontAwesomeV5Solid));
}
}
}
int findCount = 0;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text.IsNullOrEmpty()) return;
findCount = 0;
foreach (var item in lpV5Brands.Controls)
{
if (item is Label lbl)
{
SetLabelFilter(lbl);
}
}
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 lpV5Regular.Controls)
{
if (item is Label lbl)
{
SetLabelFilter(lbl);
}
}
foreach (var item in lpV5Solid.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)
{
textBox1.Focus();
}
}
/// <summary>

View File

@ -34,12 +34,12 @@
this.lpCustom = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.lpAwesome = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.lpV5Solid = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.lpElegant = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage4 = new System.Windows.Forms.TabPage();
this.lpV5Brands = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage5 = new System.Windows.Forms.TabPage();
this.lpV5Solid = new System.Windows.Forms.FlowLayoutPanel();
this.tabPage6 = new System.Windows.Forms.TabPage();
this.lpV5Regular = new System.Windows.Forms.FlowLayoutPanel();
this.bg1 = new System.ComponentModel.BackgroundWorker();
@ -49,39 +49,44 @@
this.bg3 = new System.ComponentModel.BackgroundWorker();
this.bg4 = new System.ComponentModel.BackgroundWorker();
this.bg5 = new System.ComponentModel.BackgroundWorker();
this.panel1 = new System.Windows.Forms.Panel();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.tabControl1.SuspendLayout();
this.tabPage1.SuspendLayout();
this.tabPage2.SuspendLayout();
this.tabPage5.SuspendLayout();
this.tabPage3.SuspendLayout();
this.tabPage4.SuspendLayout();
this.tabPage5.SuspendLayout();
this.tabPage6.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// tabControl1
//
this.tabControl1.Controls.Add(this.tabPage1);
this.tabControl1.Controls.Add(this.tabPage2);
this.tabControl1.Controls.Add(this.tabPage5);
this.tabControl1.Controls.Add(this.tabPage3);
this.tabControl1.Controls.Add(this.tabPage4);
this.tabControl1.Controls.Add(this.tabPage5);
this.tabControl1.Controls.Add(this.tabPage6);
this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControl1.Location = new System.Drawing.Point(0, 0);
this.tabControl1.Location = new System.Drawing.Point(0, 46);
this.tabControl1.Name = "tabControl1";
this.tabControl1.SelectedIndex = 0;
this.tabControl1.Size = new System.Drawing.Size(541, 502);
this.tabControl1.Size = new System.Drawing.Size(541, 456);
this.tabControl1.TabIndex = 0;
//
// tabPage1
//
this.tabPage1.Controls.Add(this.lpCustom);
this.tabPage1.Location = new System.Drawing.Point(4, 26);
this.tabPage1.Location = new System.Drawing.Point(4, 22);
this.tabPage1.Name = "tabPage1";
this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
this.tabPage1.Size = new System.Drawing.Size(533, 472);
this.tabPage1.Size = new System.Drawing.Size(533, 430);
this.tabPage1.TabIndex = 0;
this.tabPage1.Text = "常用";
this.tabPage1.Text = "Custom";
this.tabPage1.UseVisualStyleBackColor = true;
//
// lpCustom
@ -90,7 +95,7 @@
this.lpCustom.Dock = System.Windows.Forms.DockStyle.Fill;
this.lpCustom.Location = new System.Drawing.Point(3, 3);
this.lpCustom.Name = "lpCustom";
this.lpCustom.Size = new System.Drawing.Size(527, 466);
this.lpCustom.Size = new System.Drawing.Size(527, 424);
this.lpCustom.TabIndex = 1;
//
// tabPage2
@ -99,7 +104,7 @@
this.tabPage2.Location = new System.Drawing.Point(4, 26);
this.tabPage2.Name = "tabPage2";
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
this.tabPage2.Size = new System.Drawing.Size(756, 637);
this.tabPage2.Size = new System.Drawing.Size(533, 426);
this.tabPage2.TabIndex = 1;
this.tabPage2.Text = "FontAwesomeV4";
this.tabPage2.UseVisualStyleBackColor = true;
@ -111,16 +116,37 @@
this.lpAwesome.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpAwesome.Location = new System.Drawing.Point(3, 3);
this.lpAwesome.Name = "lpAwesome";
this.lpAwesome.Size = new System.Drawing.Size(750, 631);
this.lpAwesome.Size = new System.Drawing.Size(527, 420);
this.lpAwesome.TabIndex = 1;
//
// tabPage5
//
this.tabPage5.Controls.Add(this.lpV5Solid);
this.tabPage5.Location = new System.Drawing.Point(4, 26);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
this.tabPage5.Size = new System.Drawing.Size(533, 426);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "FontAwesomeV5";
this.tabPage5.UseVisualStyleBackColor = true;
//
// lpV5Solid
//
this.lpV5Solid.AutoScroll = true;
this.lpV5Solid.Dock = System.Windows.Forms.DockStyle.Fill;
this.lpV5Solid.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpV5Solid.Location = new System.Drawing.Point(3, 3);
this.lpV5Solid.Name = "lpV5Solid";
this.lpV5Solid.Size = new System.Drawing.Size(527, 420);
this.lpV5Solid.TabIndex = 3;
//
// tabPage3
//
this.tabPage3.Controls.Add(this.lpElegant);
this.tabPage3.Location = new System.Drawing.Point(4, 26);
this.tabPage3.Name = "tabPage3";
this.tabPage3.Padding = new System.Windows.Forms.Padding(3);
this.tabPage3.Size = new System.Drawing.Size(756, 637);
this.tabPage3.Size = new System.Drawing.Size(533, 426);
this.tabPage3.TabIndex = 2;
this.tabPage3.Text = "ElegantFont";
this.tabPage3.UseVisualStyleBackColor = true;
@ -132,7 +158,7 @@
this.lpElegant.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpElegant.Location = new System.Drawing.Point(3, 3);
this.lpElegant.Name = "lpElegant";
this.lpElegant.Size = new System.Drawing.Size(750, 631);
this.lpElegant.Size = new System.Drawing.Size(527, 420);
this.lpElegant.TabIndex = 2;
//
// tabPage4
@ -141,9 +167,9 @@
this.tabPage4.Location = new System.Drawing.Point(4, 26);
this.tabPage4.Name = "tabPage4";
this.tabPage4.Padding = new System.Windows.Forms.Padding(3);
this.tabPage4.Size = new System.Drawing.Size(756, 637);
this.tabPage4.Size = new System.Drawing.Size(533, 426);
this.tabPage4.TabIndex = 3;
this.tabPage4.Text = "FontAwesomeV5Brands";
this.tabPage4.Text = "V5Brands";
this.tabPage4.UseVisualStyleBackColor = true;
//
// lpV5Brands
@ -153,37 +179,16 @@
this.lpV5Brands.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpV5Brands.Location = new System.Drawing.Point(3, 3);
this.lpV5Brands.Name = "lpV5Brands";
this.lpV5Brands.Size = new System.Drawing.Size(750, 631);
this.lpV5Brands.Size = new System.Drawing.Size(527, 420);
this.lpV5Brands.TabIndex = 3;
//
// tabPage5
//
this.tabPage5.Controls.Add(this.lpV5Solid);
this.tabPage5.Location = new System.Drawing.Point(4, 26);
this.tabPage5.Name = "tabPage5";
this.tabPage5.Padding = new System.Windows.Forms.Padding(3);
this.tabPage5.Size = new System.Drawing.Size(756, 637);
this.tabPage5.TabIndex = 4;
this.tabPage5.Text = "V5Solid";
this.tabPage5.UseVisualStyleBackColor = true;
//
// lpV5Solid
//
this.lpV5Solid.AutoScroll = true;
this.lpV5Solid.Dock = System.Windows.Forms.DockStyle.Fill;
this.lpV5Solid.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpV5Solid.Location = new System.Drawing.Point(3, 3);
this.lpV5Solid.Name = "lpV5Solid";
this.lpV5Solid.Size = new System.Drawing.Size(750, 631);
this.lpV5Solid.TabIndex = 3;
//
// tabPage6
//
this.tabPage6.Controls.Add(this.lpV5Regular);
this.tabPage6.Location = new System.Drawing.Point(4, 26);
this.tabPage6.Name = "tabPage6";
this.tabPage6.Padding = new System.Windows.Forms.Padding(3);
this.tabPage6.Size = new System.Drawing.Size(756, 637);
this.tabPage6.Size = new System.Drawing.Size(533, 426);
this.tabPage6.TabIndex = 5;
this.tabPage6.Text = "V5Regular";
this.tabPage6.UseVisualStyleBackColor = true;
@ -195,7 +200,7 @@
this.lpV5Regular.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(158)))), ((int)(((byte)(255)))));
this.lpV5Regular.Location = new System.Drawing.Point(3, 3);
this.lpV5Regular.Name = "lpV5Regular";
this.lpV5Regular.Size = new System.Drawing.Size(750, 631);
this.lpV5Regular.Size = new System.Drawing.Size(527, 420);
this.lpV5Regular.TabIndex = 3;
//
// bg1
@ -222,22 +227,65 @@
//
this.bg5.DoWork += new System.ComponentModel.DoWorkEventHandler(this.bg5_DoWork);
//
// panel1
//
this.panel1.Controls.Add(this.label1);
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.textBox1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(541, 46);
this.panel1.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(80)))), ((int)(((byte)(80)))));
this.label1.Location = new System.Drawing.Point(422, 17);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(65, 12);
this.label1.TabIndex = 5;
this.label1.Text = "0 results.";
//
// button1
//
this.button1.Location = new System.Drawing.Point(336, 11);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Search";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(12, 12);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(317, 21);
this.textBox1.TabIndex = 0;
//
// UIFontImages
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(541, 502);
this.Controls.Add(this.tabControl1);
this.Controls.Add(this.panel1);
this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
this.Name = "UIFontImages";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "字体图标";
this.Text = "Symbols";
this.Load += new System.EventHandler(this.UIFontImages_Load);
this.Shown += new System.EventHandler(this.UIFontImages_Shown);
this.tabControl1.ResumeLayout(false);
this.tabPage1.ResumeLayout(false);
this.tabPage2.ResumeLayout(false);
this.tabPage5.ResumeLayout(false);
this.tabPage3.ResumeLayout(false);
this.tabPage4.ResumeLayout(false);
this.tabPage5.ResumeLayout(false);
this.tabPage6.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.ResumeLayout(false);
}
@ -264,5 +312,9 @@
private System.ComponentModel.BackgroundWorker bg3;
private System.ComponentModel.BackgroundWorker bg4;
private System.ComponentModel.BackgroundWorker bg5;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label1;
}
}