同步操作将从 电脑程序爱好者/基于导航菜单的 WinForm 项目的基础框架 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;using System.Drawing;using System.Drawing.Drawing2D;using System.Drawing.Text;using System.IO;using System.Windows.Forms;using WinForm.NET4.Sample.CustomControl.Enum;namespace WinForm.NET4.Sample.CustomControl{public partial class AwesomeIcon : Control{public AwesomeIcon(){InitializeComponent();if (ImageFont.Families.Length == 0){var curNamespace = this.GetType().Namespace;Stream fontStream = this.GetType().Assembly.GetManifestResourceStream(curNamespace + ".Font.fontawesome.ttf");byte[] fontdata = new byte[fontStream.Length];fontStream.Read(fontdata, 0, (int)fontStream.Length);fontStream.Close();unsafe{fixed (byte* pFontData = fontdata){ImageFont.AddMemoryFont((System.IntPtr)pFontData, fontdata.Length);}}}if (ImageFont.Families.Length == 0){return;}else{iconfont = new Font(ImageFont.Families[0], Font.Size, FontStyle.Bold, Font.Unit);}}private PrivateFontCollection ImageFont = new PrivateFontCollection();private Font iconfont;private SizeF FontSize = new SizeF();private SolidBrush foreSolidBrush = new SolidBrush(DefaultForeColor);private string FontValue = "";private AwesomeValues _Value = AwesomeValues.None;public AwesomeValues Value{get => _Value;set{_Value = value;//if (value == AwesomeValues.None) return;FontValue = char.ConvertFromUtf32((int)_Value);Invalidate();}}~AwesomeIcon(){foreSolidBrush?.Dispose(); iconfont?.Dispose();}private void AwesomeIcon_Paint(object sender, PaintEventArgs e){if (ImageFont.Families.Length < 1) return;e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;e.Graphics.CompositingQuality = CompositingQuality.HighQuality;e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;foreSolidBrush.Color = ForeColor;iconfont = new Font(ImageFont.Families[0], Font.Size, FontStyle.Bold, Font.Unit);FontSize = e.Graphics.MeasureString(FontValue, iconfont);e.Graphics.DrawString(FontValue, iconfont, foreSolidBrush, (Width - FontSize.Width) / 2, (Height - FontSize.Height) / 2);}}}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。