又是大佬拿来的代码,修修改改就能用了。单纯记录
using System;
using System.Drawing;
using System.Windows.Forms;
using DSAPI.神扩展;
using static DSAPI.神扩展.神扩展;
using System.Threading.Tasks;
using System.Threading;
using System.Drawing.Text;
namespace CustomHexagonProgressBar
{
public partial class HexagonProgressBarEx : Form
{
private Form OverlayForm = new Form();
public HexagonProgressBarEx()
{
InitializeComponent();
}
public delegate void del(string str);
private void HexagonProgressBarEx_Load(object sender, EventArgs e)
{
this.设置鼠标拖动();
var _with1 = OverlayForm;
_with1.FormBorderStyle = FormBorderStyle.None;
_with1.Size = new Size(40, 40);
_with1.Owner = this;
_with1.Show();
_with1.BringToFront();
_with1.居中();
_with1.Location = new Point(932, 500);
_with1.TopMost = false;
_with1.跟随宿主窗体移动(this);
_with1.ShowInTaskbar = false;
Task.Factory.StartNew(() =>
{
for (int i = 1; i <= 99; i++)
{
this.委托执行(() =>
{
this.ShowDigit($"{i}/99");
});
Thread.Sleep(1000);
}
});
}
public void ShowDigit(string digit)
{
using (Bitmap bit = new Bitmap(54, 54))
{
using (Graphics graphics = Graphics.FromImage(bit))
{
using (StringFormat sf = new StringFormat())
{
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
graphics.TextRenderingHint = TextRenderingHint.AntiAlias;
graphics.DrawString(digit, new Font("微软雅黑", 10), Brushes.White, new Rectangle(0, 0, 54, 54), sf);
}
}
OverlayForm.透明窗体样式显示图像(bit);
}
}
}
}
还需要调用大佬的dll。但是这里要咋放放上去不懂。。。