Added region capture border glowing for non active regions

This commit is contained in:
Jaex 2015-08-09 02:15:46 +03:00
parent 7444eac51b
commit dafcce6568
3 changed files with 85 additions and 1 deletions

View file

@ -68,6 +68,8 @@ public Color CurrentColor
#endregion Screen ruler
private GlowTimer glowTimer = new GlowTimer();
public RectangleRegion()
{
AreaManager = new AreaManager(this);
@ -183,6 +185,7 @@ public override void Prepare()
protected override void Update()
{
base.Update();
glowTimer.Update();
AreaManager.Update();
}
@ -206,7 +209,10 @@ protected override void Draw(Graphics g)
}
}
g.DrawPath(borderPen, regionDrawPath);
using (Pen glowingBorderPen = new Pen(glowTimer.GetColor()))
{
g.DrawPath(glowingBorderPen, regionDrawPath);
}
/*
if (areas.Count > 1)

View file

@ -0,0 +1,77 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright © 2007-2015 ShareX Developers
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.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
namespace ShareX.ScreenCaptureLib
{
public class GlowTimer
{
public float Max = 1;
public float Min = 0;
public float Current = 0;
private Stopwatch timer;
private TimeSpan previousTime;
private int direction = 1;
private float increase = 0.75f;
public GlowTimer()
{
timer = Stopwatch.StartNew();
}
public void Update()
{
TimeSpan totalElapsed = timer.Elapsed;
TimeSpan elapsed = totalElapsed - previousTime;
previousTime = totalElapsed;
Current += (float)elapsed.TotalSeconds * increase * direction;
if (Current > Max)
{
Current = Max - (Current - Max);
direction = -1;
}
else if (Current < Min)
{
Current = Min + (Min - Current);
direction = 1;
}
}
public Color GetColor()
{
return ColorHelpers.Lerp(Color.FromArgb(30, 30, 30), Color.FromArgb(100, 100, 100), Current);
}
}
}

View file

@ -60,6 +60,7 @@
<Compile Include="MonitorRegion.cs" />
<Compile Include="MonitorRegionDefaultCreator.cs" />
<Compile Include="RectangleAnnotateOptions.cs" />
<Compile Include="RegionHelpers\GlowColorTimer.cs" />
<Compile Include="RegionHelpers\RegionInfo.cs" />
<Compile Include="Screencast\FFmpegOptions.cs" />
<Compile Include="Screencast\FFmpegHelper.cs" />