mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Changes to tray upload animation
This commit is contained in:
parent
83645f5445
commit
04b925a8bd
2 changed files with 30 additions and 11 deletions
|
@ -511,29 +511,28 @@ private static void AddExternalProgramFromRegistry(TaskSettings taskSettings, st
|
|||
|
||||
public static Icon GetProgressIcon(int percentage)
|
||||
{
|
||||
percentage = percentage.Between(0, 99);
|
||||
|
||||
using (Bitmap bmp = new Bitmap(16, 16))
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.Clear(Color.Black);
|
||||
int y = (int)(16 * (percentage / 100f));
|
||||
|
||||
int width = (int)(16 * (percentage / 100f));
|
||||
|
||||
if (width > 0)
|
||||
if (y > 0)
|
||||
{
|
||||
using (Brush brush = new LinearGradientBrush(new Rectangle(0, 0, width, 16), Color.DarkBlue, Color.DodgerBlue, LinearGradientMode.Vertical))
|
||||
using (Brush brush = new SolidBrush(Color.FromArgb(16, 116, 193)))
|
||||
{
|
||||
g.FillRectangle(brush, 0, 0, width, 16);
|
||||
g.FillRectangle(brush, 0, 15 - y, 16, y);
|
||||
}
|
||||
}
|
||||
|
||||
using (Font font = new Font("Arial", 11, GraphicsUnit.Pixel))
|
||||
using (Font font = new Font("Arial", 12, GraphicsUnit.Pixel))
|
||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||
{
|
||||
g.DrawString(percentage.ToString(), font, Brushes.White, 8, 8, sf);
|
||||
g.DrawString(percentage.ToString(), font, Brushes.Black, 8, 8, sf);
|
||||
g.DrawString(percentage.ToString(), font, Brushes.White, 8, 7, sf);
|
||||
}
|
||||
|
||||
g.DrawRectangleProper(Pens.WhiteSmoke, 0, 0, 16, 16);
|
||||
|
||||
return Icon.FromHandle(bmp.GetHicon());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -471,7 +471,7 @@ public static void UpdateProgressUI()
|
|||
}
|
||||
}
|
||||
|
||||
int progress = isWorkingTasks ? ((int)averageProgress).Between(0, 99) : -1;
|
||||
int progress = isWorkingTasks ? (int)averageProgress : -1;
|
||||
UpdateTrayIcon(progress);
|
||||
|
||||
string title;
|
||||
|
@ -529,6 +529,26 @@ public static void UpdateTrayIcon(int progress = -1)
|
|||
}
|
||||
}
|
||||
|
||||
public static void TestTrayIcon()
|
||||
{
|
||||
Timer timer = new Timer();
|
||||
timer.Interval = 50;
|
||||
int i = 0;
|
||||
timer.Tick += (sender, e) =>
|
||||
{
|
||||
if (i > 99)
|
||||
{
|
||||
timer.Stop();
|
||||
UpdateTrayIcon();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateTrayIcon(i++);
|
||||
}
|
||||
};
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public static void AddRecentTasksToMainWindow()
|
||||
{
|
||||
if (ListViewControl.Items.Count == 0)
|
||||
|
|
Loading…
Reference in a new issue