mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Show task status with subtle glow top of task panels
This commit is contained in:
parent
4aacfec76a
commit
716a005220
7 changed files with 120 additions and 7 deletions
|
@ -132,16 +132,16 @@ public static int Random(int min, int max)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int RandomPick(params int[] nums)
|
|
||||||
{
|
|
||||||
return nums[Random(nums.Length - 1)];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int RandomAdd(int num, int min, int max)
|
public static int RandomAdd(int num, int min, int max)
|
||||||
{
|
{
|
||||||
return num + Random(min, max);
|
return num + Random(min, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T RandomPick<T>(params T[] nums)
|
||||||
|
{
|
||||||
|
return nums[Random(nums.Length - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a random number between 0 and <c>max</c> (inclusive) generated with a cryptographic PRNG.
|
/// Returns a random number between 0 and <c>max</c> (inclusive) generated with a cryptographic PRNG.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
4
ShareX/Controls/TaskPanel.Designer.cs
generated
4
ShareX/Controls/TaskPanel.Designer.cs
generated
|
@ -31,7 +31,7 @@ protected override void Dispose(bool disposing)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.pThumbnail = new ShareX.HelpersLib.RoundedCornerPanel();
|
this.pThumbnail = new ShareX.TaskRoundedCornerPanel();
|
||||||
this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar();
|
this.pbProgress = new ShareX.HelpersLib.BlackStyleProgressBar();
|
||||||
this.pbThumbnail = new System.Windows.Forms.PictureBox();
|
this.pbThumbnail = new System.Windows.Forms.PictureBox();
|
||||||
this.lblFilename = new ShareX.HelpersLib.BlackStyleLabel();
|
this.lblFilename = new ShareX.HelpersLib.BlackStyleLabel();
|
||||||
|
@ -115,7 +115,7 @@ private void InitializeComponent()
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private HelpersLib.RoundedCornerPanel pThumbnail;
|
private ShareX.TaskRoundedCornerPanel pThumbnail;
|
||||||
private HelpersLib.BlackStyleLabel lblFilename;
|
private HelpersLib.BlackStyleLabel lblFilename;
|
||||||
private HelpersLib.BlackStyleProgressBar pbProgress;
|
private HelpersLib.BlackStyleProgressBar pbProgress;
|
||||||
private System.Windows.Forms.PictureBox pbThumbnail;
|
private System.Windows.Forms.PictureBox pbThumbnail;
|
||||||
|
|
|
@ -225,6 +225,14 @@ public void UpdateProgress()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateStatus()
|
||||||
|
{
|
||||||
|
if (Task.Info != null)
|
||||||
|
{
|
||||||
|
pThumbnail.UpdateStatusColor(Task.Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ClearThumbnail()
|
public void ClearThumbnail()
|
||||||
{
|
{
|
||||||
Image temp = pbThumbnail.Image;
|
Image temp = pbThumbnail.Image;
|
||||||
|
|
95
ShareX/Controls/TaskRoundedCornerPanel.cs
Normal file
95
ShareX/Controls/TaskRoundedCornerPanel.cs
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
#region License Information (GPL v3)
|
||||||
|
|
||||||
|
/*
|
||||||
|
ShareX - A program that allows you to take screenshots and share any file type
|
||||||
|
Copyright (c) 2007-2019 ShareX Team
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
|
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endregion License Information (GPL v3)
|
||||||
|
|
||||||
|
using ShareX.HelpersLib;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Drawing2D;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace ShareX
|
||||||
|
{
|
||||||
|
public class TaskRoundedCornerPanel : RoundedCornerPanel
|
||||||
|
{
|
||||||
|
public Color StatusColor { get; private set; } = Color.Transparent;
|
||||||
|
|
||||||
|
public void UpdateStatusColor(TaskStatus status)
|
||||||
|
{
|
||||||
|
Color previousStatusColor = StatusColor;
|
||||||
|
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case TaskStatus.Completed:
|
||||||
|
case TaskStatus.Stopped:
|
||||||
|
StatusColor = Color.CornflowerBlue;
|
||||||
|
break;
|
||||||
|
case TaskStatus.Failed:
|
||||||
|
StatusColor = Color.IndianRed;
|
||||||
|
break;
|
||||||
|
case TaskStatus.History:
|
||||||
|
StatusColor = Color.Transparent;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
StatusColor = Color.PaleGreen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousStatusColor != StatusColor)
|
||||||
|
{
|
||||||
|
Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
|
||||||
|
if (StatusColor.A > 0)
|
||||||
|
{
|
||||||
|
Graphics g = e.Graphics;
|
||||||
|
|
||||||
|
g.PixelOffsetMode = PixelOffsetMode.Half;
|
||||||
|
|
||||||
|
using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, ClientRectangle.Width, 1), Color.Black, Color.Black,
|
||||||
|
LinearGradientMode.Horizontal))
|
||||||
|
{
|
||||||
|
ColorBlend cb = new ColorBlend();
|
||||||
|
cb.Positions = new float[] { 0, 0.3f, 0.7f, 1 };
|
||||||
|
cb.Colors = new Color[] { Color.Transparent, StatusColor, StatusColor, Color.Transparent };
|
||||||
|
brush.InterpolationColors = cb;
|
||||||
|
|
||||||
|
using (Pen pen = new Pen(brush))
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, new Point(0, 0), new Point(ClientRectangle.Width - 1, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -143,5 +143,10 @@ public void UpdateProgressVisible(WorkerTask task, bool visible)
|
||||||
panel.ProgressVisible = visible;
|
panel.ProgressVisible = visible;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateStatus(WorkerTask task)
|
||||||
|
{
|
||||||
|
FindPanel(task)?.UpdateStatus();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -167,6 +167,9 @@
|
||||||
<Compile Include="Controls\TaskPanel.Designer.cs">
|
<Compile Include="Controls\TaskPanel.Designer.cs">
|
||||||
<DependentUpon>TaskPanel.cs</DependentUpon>
|
<DependentUpon>TaskPanel.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Controls\TaskRoundedCornerPanel.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Controls\TaskView.cs">
|
<Compile Include="Controls\TaskView.cs">
|
||||||
<SubType>UserControl</SubType>
|
<SubType>UserControl</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -265,6 +265,7 @@ private static void task_UploadStarted(WorkerTask task)
|
||||||
TaskView.UpdateFilename(task);
|
TaskView.UpdateFilename(task);
|
||||||
TaskView.UpdateThumbnail(task);
|
TaskView.UpdateThumbnail(task);
|
||||||
TaskView.UpdateProgressVisible(task, true);
|
TaskView.UpdateProgressVisible(task, true);
|
||||||
|
TaskView.UpdateStatus(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +361,7 @@ private static void task_TaskCompleted(WorkerTask task)
|
||||||
TaskView.UpdateFilename(task);
|
TaskView.UpdateFilename(task);
|
||||||
TaskView.UpdateThumbnail(task);
|
TaskView.UpdateThumbnail(task);
|
||||||
TaskView.UpdateProgressVisible(task, false);
|
TaskView.UpdateProgressVisible(task, false);
|
||||||
|
TaskView.UpdateStatus(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListViewItem lvi = FindListViewItem(task);
|
ListViewItem lvi = FindListViewItem(task);
|
||||||
|
|
Loading…
Reference in a new issue