mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-03 02:36:50 +13:00
Fixed tray progress indicator to be DPI-aware
This commit is contained in:
parent
d8008f993c
commit
dbba4fbb1a
1 changed files with 7 additions and 6 deletions
|
@ -574,24 +574,25 @@ public static Icon GetProgressIcon(int percentage)
|
||||||
{
|
{
|
||||||
percentage = percentage.Between(0, 99);
|
percentage = percentage.Between(0, 99);
|
||||||
|
|
||||||
using (Bitmap bmp = new Bitmap(16, 16))
|
Size size = SystemInformation.SmallIconSize;
|
||||||
|
using (Bitmap bmp = new Bitmap(size.Width, size.Height))
|
||||||
using (Graphics g = Graphics.FromImage(bmp))
|
using (Graphics g = Graphics.FromImage(bmp))
|
||||||
{
|
{
|
||||||
int y = (int)(16 * (percentage / 100f));
|
int y = (int)(size.Height * (percentage / 100f));
|
||||||
|
|
||||||
if (y > 0)
|
if (y > 0)
|
||||||
{
|
{
|
||||||
using (Brush brush = new SolidBrush(Color.FromArgb(16, 116, 193)))
|
using (Brush brush = new SolidBrush(Color.FromArgb(16, 116, 193)))
|
||||||
{
|
{
|
||||||
g.FillRectangle(brush, 0, 15 - y, 16, y);
|
g.FillRectangle(brush, 0, size.Height - 1 - y, size.Width, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
using (Font font = new Font("Arial", 12, GraphicsUnit.Pixel))
|
using (Font font = new Font("Arial", 10))
|
||||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||||
{
|
{
|
||||||
g.DrawString(percentage.ToString(), font, Brushes.Black, 8, 8, sf);
|
g.DrawString(percentage.ToString(), font, Brushes.Black, size.Width / 2, size.Height / 2, sf);
|
||||||
g.DrawString(percentage.ToString(), font, Brushes.White, 8, 7, sf);
|
g.DrawString(percentage.ToString(), font, Brushes.White, size.Width / 2, size.Height / 2 - 1, sf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Icon.FromHandle(bmp.GetHicon());
|
return Icon.FromHandle(bmp.GetHicon());
|
||||||
|
|
Loading…
Reference in a new issue