mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 10:47:02 -07:00
Small cleanups [skip ci]
This commit is contained in:
parent
02a06a12b0
commit
98e6be5eb6
171 changed files with 1607 additions and 1769 deletions
|
@ -34,7 +34,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public abstract class AbstractDestination : IDestination {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(AbstractDestination));
|
||||
private static CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly CoreConfiguration configuration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
|
||||
public virtual int CompareTo(object obj) {
|
||||
IDestination other = obj as IDestination;
|
||||
|
@ -312,7 +312,8 @@ namespace GreenshotPlugin.Core {
|
|||
basisMenuItem.Click += destinationClickHandler;
|
||||
|
||||
if (isDynamic && addDynamics) {
|
||||
basisMenuItem.DropDownOpening += delegate(object source, EventArgs eventArgs) {
|
||||
basisMenuItem.DropDownOpening += delegate
|
||||
{
|
||||
if (basisMenuItem.DropDownItems.Count == 0) {
|
||||
List<IDestination> subDestinations = new List<IDestination>();
|
||||
// Fixing Bug #3536968 by catching the COMException (every exception) and not displaying the "subDestinations"
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
private const int IE_ACTIVE_TAB = 2097154;
|
||||
private const int CHILDID_SELF = 0;
|
||||
private IAccessible accessible;
|
||||
private readonly IAccessible accessible;
|
||||
private Accessible[] Children {
|
||||
get {
|
||||
int num = 0;
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Collections.Generic;
|
||||
using log4net;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
|
||||
|
@ -33,7 +31,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// Is there a next frame?
|
||||
/// </summary>
|
||||
bool hasNext {
|
||||
bool HasNext {
|
||||
get;
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -81,12 +79,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
/// <typeparam name="T">Type for the animation, like Point/Rectangle/Size</typeparam>
|
||||
public abstract class AnimatorBase<T> : IAnimator {
|
||||
protected T first;
|
||||
protected T last;
|
||||
protected T current;
|
||||
private Queue<AnimationLeg<T>> queue = new Queue<AnimationLeg<T>>();
|
||||
protected int frames;
|
||||
protected int currentFrameNr = 0;
|
||||
private readonly Queue<AnimationLeg<T>> _queue = new Queue<AnimationLeg<T>>();
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
|
@ -97,10 +90,10 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="easingType"></param>
|
||||
/// <param name="easingMode"></param>
|
||||
public AnimatorBase(T first, T last, int frames, EasingType easingType, EasingMode easingMode) {
|
||||
this.first = first;
|
||||
this.last = last;
|
||||
this.frames = frames;
|
||||
current = first;
|
||||
First = first;
|
||||
Last = last;
|
||||
Frames = frames;
|
||||
Current = first;
|
||||
EasingType = easingType;
|
||||
EasingMode = easingMode;
|
||||
}
|
||||
|
@ -109,39 +102,34 @@ namespace GreenshotPlugin.Core {
|
|||
/// The amount of frames
|
||||
/// </summary>
|
||||
public int Frames {
|
||||
get { return frames; }
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Current frame number
|
||||
/// </summary>
|
||||
public int CurrentFrameNr {
|
||||
get { return currentFrameNr; }
|
||||
}
|
||||
public int CurrentFrameNr { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// First animation value
|
||||
/// </summary>
|
||||
public T First {
|
||||
get { return first; }
|
||||
}
|
||||
public T First { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Last animation value, of this "leg"
|
||||
/// </summary>
|
||||
public T Last {
|
||||
get { return last; }
|
||||
}
|
||||
public T Last { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Final animation value, this is including the legs
|
||||
/// </summary>
|
||||
public T Final {
|
||||
get {
|
||||
if (queue.Count == 0) {
|
||||
return last;
|
||||
if (_queue.Count == 0) {
|
||||
return Last;
|
||||
}
|
||||
return queue.ToArray()[queue.Count - 1].Destination;
|
||||
return _queue.ToArray()[_queue.Count - 1].Destination;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,7 +138,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
/// <param name="newDestination"></param>
|
||||
public void ChangeDestination(T newDestination) {
|
||||
ChangeDestination(newDestination, frames);
|
||||
ChangeDestination(newDestination, Frames);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -159,11 +147,11 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="newDestination"></param>
|
||||
/// <param name="frames"></param>
|
||||
public void ChangeDestination(T newDestination, int frames) {
|
||||
queue.Clear();
|
||||
first = current;
|
||||
currentFrameNr = 0;
|
||||
this.frames = frames;
|
||||
last = newDestination;
|
||||
_queue.Clear();
|
||||
First = Current;
|
||||
CurrentFrameNr = 0;
|
||||
Frames = frames;
|
||||
Last = newDestination;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -202,12 +190,14 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="easingType"></param>
|
||||
/// <param name="easingMode"></param>
|
||||
public void QueueDestinationLeg(T queuedDestination, int frames, EasingType easingType, EasingMode easingMode) {
|
||||
AnimationLeg<T> leg = new AnimationLeg<T>();
|
||||
leg.Destination = queuedDestination;
|
||||
leg.Frames = frames;
|
||||
leg.EasingType = easingType;
|
||||
leg.EasingMode = easingMode;
|
||||
queue.Enqueue(leg);
|
||||
AnimationLeg<T> leg = new AnimationLeg<T>
|
||||
{
|
||||
Destination = queuedDestination,
|
||||
Frames = frames,
|
||||
EasingType = easingType,
|
||||
EasingMode = easingMode
|
||||
};
|
||||
_queue.Enqueue(leg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -233,12 +223,12 @@ namespace GreenshotPlugin.Core {
|
|||
get {
|
||||
switch (EasingMode) {
|
||||
case EasingMode.EaseOut:
|
||||
return Easing.EaseOut((double)currentFrameNr / (double)frames, EasingType);
|
||||
return Easing.EaseOut(CurrentFrameNr / (double)Frames, EasingType);
|
||||
case EasingMode.EaseInOut:
|
||||
return Easing.EaseInOut((double)currentFrameNr / (double)frames, EasingType);
|
||||
return Easing.EaseInOut(CurrentFrameNr / (double)Frames, EasingType);
|
||||
case EasingMode.EaseIn:
|
||||
default:
|
||||
return Easing.EaseIn((double)currentFrameNr / (double)frames, EasingType);
|
||||
return Easing.EaseIn(CurrentFrameNr / (double)Frames, EasingType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -246,27 +236,23 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// Get the current (previous) frame object
|
||||
/// </summary>
|
||||
public virtual T Current {
|
||||
get {
|
||||
return current;
|
||||
}
|
||||
}
|
||||
public virtual T Current { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns if there are any frame left, and if this is the case than the frame is increased.
|
||||
/// </summary>
|
||||
public virtual bool NextFrame {
|
||||
get {
|
||||
if (currentFrameNr < frames) {
|
||||
currentFrameNr++;
|
||||
if (CurrentFrameNr < Frames) {
|
||||
CurrentFrameNr++;
|
||||
return true;
|
||||
}
|
||||
if (queue.Count > 0) {
|
||||
first = current;
|
||||
currentFrameNr = 0;
|
||||
AnimationLeg<T> nextLeg = queue.Dequeue();
|
||||
last = nextLeg.Destination;
|
||||
frames = nextLeg.Frames;
|
||||
if (_queue.Count > 0) {
|
||||
First = Current;
|
||||
CurrentFrameNr = 0;
|
||||
AnimationLeg<T> nextLeg = _queue.Dequeue();
|
||||
Last = nextLeg.Destination;
|
||||
Frames = nextLeg.Frames;
|
||||
EasingType = nextLeg.EasingType;
|
||||
EasingMode = nextLeg.EasingMode;
|
||||
return true;
|
||||
|
@ -278,12 +264,12 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// Are there more frames to animate?
|
||||
/// </summary>
|
||||
public virtual bool hasNext {
|
||||
public virtual bool HasNext {
|
||||
get {
|
||||
if (currentFrameNr < frames) {
|
||||
if (CurrentFrameNr < Frames) {
|
||||
return true;
|
||||
}
|
||||
return queue.Count > 0;
|
||||
return _queue.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,8 +284,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// Implementation of the RectangleAnimator
|
||||
/// </summary>
|
||||
public class RectangleAnimator : AnimatorBase<Rectangle> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(RectangleAnimator));
|
||||
|
||||
public RectangleAnimator(Rectangle first, Rectangle last, int frames)
|
||||
: base(first, last, frames, EasingType.Linear, EasingMode.EaseIn) {
|
||||
}
|
||||
|
@ -318,18 +302,18 @@ namespace GreenshotPlugin.Core {
|
|||
public override Rectangle Next() {
|
||||
if (NextFrame) {
|
||||
double easingValue = EasingValue;
|
||||
double dx = last.X - first.X;
|
||||
double dy = last.Y - first.Y;
|
||||
double dx = Last.X - First.X;
|
||||
double dy = Last.Y - First.Y;
|
||||
|
||||
int x = first.X + (int)(easingValue * dx);
|
||||
int y = first.Y + (int)(easingValue * dy);
|
||||
double dw = last.Width - first.Width;
|
||||
double dh = last.Height - first.Height;
|
||||
int width = first.Width + (int)(easingValue * dw);
|
||||
int height = first.Height + (int)(easingValue * dh);
|
||||
current = new Rectangle(x, y, width, height);
|
||||
int x = First.X + (int)(easingValue * dx);
|
||||
int y = First.Y + (int)(easingValue * dy);
|
||||
double dw = Last.Width - First.Width;
|
||||
double dh = Last.Height - First.Height;
|
||||
int width = First.Width + (int)(easingValue * dw);
|
||||
int height = First.Height + (int)(easingValue * dh);
|
||||
Current = new Rectangle(x, y, width, height);
|
||||
}
|
||||
return current;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +321,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// Implementation of the PointAnimator
|
||||
/// </summary>
|
||||
public class PointAnimator : AnimatorBase<Point> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(PointAnimator));
|
||||
public PointAnimator(Point first, Point last, int frames)
|
||||
: base(first, last, frames, EasingType.Linear, EasingMode.EaseIn) {
|
||||
}
|
||||
|
@ -355,14 +338,14 @@ namespace GreenshotPlugin.Core {
|
|||
public override Point Next() {
|
||||
if (NextFrame) {
|
||||
double easingValue = EasingValue;
|
||||
double dx = last.X - first.X;
|
||||
double dy = last.Y - first.Y;
|
||||
double dx = Last.X - First.X;
|
||||
double dy = Last.Y - First.Y;
|
||||
|
||||
int x = first.X + (int)(easingValue * dx);
|
||||
int y = first.Y + (int)(easingValue * dy);
|
||||
current = new Point(x, y);
|
||||
int x = First.X + (int)(easingValue * dx);
|
||||
int y = First.Y + (int)(easingValue * dy);
|
||||
Current = new Point(x, y);
|
||||
}
|
||||
return current;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,7 +353,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// Implementation of the SizeAnimator
|
||||
/// </summary>
|
||||
public class SizeAnimator : AnimatorBase<Size> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(SizeAnimator));
|
||||
public SizeAnimator(Size first, Size last, int frames)
|
||||
: base(first, last, frames, EasingType.Linear, EasingMode.EaseIn) {
|
||||
}
|
||||
|
@ -388,13 +370,13 @@ namespace GreenshotPlugin.Core {
|
|||
public override Size Next() {
|
||||
if (NextFrame) {
|
||||
double easingValue = EasingValue;
|
||||
double dw = last.Width - first.Width;
|
||||
double dh = last.Height - first.Height;
|
||||
int width = first.Width + (int)(easingValue * dw);
|
||||
int height = first.Height + (int)(easingValue * dh);
|
||||
current = new Size(width, height);
|
||||
double dw = Last.Width - First.Width;
|
||||
double dh = Last.Height - First.Height;
|
||||
int width = First.Width + (int)(easingValue * dw);
|
||||
int height = First.Height + (int)(easingValue * dh);
|
||||
Current = new Size(width, height);
|
||||
}
|
||||
return current;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +384,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// Implementation of the ColorAnimator
|
||||
/// </summary>
|
||||
public class ColorAnimator : AnimatorBase<Color> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(ColorAnimator));
|
||||
public ColorAnimator(Color first, Color last, int frames)
|
||||
: base(first, last, frames, EasingType.Linear, EasingMode.EaseIn) {
|
||||
}
|
||||
|
@ -420,17 +401,17 @@ namespace GreenshotPlugin.Core {
|
|||
public override Color Next() {
|
||||
if (NextFrame) {
|
||||
double easingValue = EasingValue;
|
||||
double da = last.A - first.A;
|
||||
double dr = last.R - first.R;
|
||||
double dg = last.G - first.G;
|
||||
double db = last.B - first.B;
|
||||
int a = first.A + (int)(easingValue * da);
|
||||
int r = first.R + (int)(easingValue * dr);
|
||||
int g = first.G + (int)(easingValue * dg);
|
||||
int b = first.B + (int)(easingValue * db);
|
||||
current = Color.FromArgb(a,r,g,b);
|
||||
double da = Last.A - First.A;
|
||||
double dr = Last.R - First.R;
|
||||
double dg = Last.G - First.G;
|
||||
double db = Last.B - First.B;
|
||||
int a = First.A + (int)(easingValue * da);
|
||||
int r = First.R + (int)(easingValue * dr);
|
||||
int g = First.G + (int)(easingValue * dg);
|
||||
int b = First.B + (int)(easingValue * db);
|
||||
Current = Color.FromArgb(a,r,g,b);
|
||||
}
|
||||
return current;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,7 +419,6 @@ namespace GreenshotPlugin.Core {
|
|||
/// Implementation of the IntAnimator
|
||||
/// </summary>
|
||||
public class IntAnimator : AnimatorBase<int> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(IntAnimator));
|
||||
public IntAnimator(int first, int last, int frames)
|
||||
: base(first, last, frames, EasingType.Linear, EasingMode.EaseIn) {
|
||||
}
|
||||
|
@ -456,10 +436,10 @@ namespace GreenshotPlugin.Core {
|
|||
public override int Next() {
|
||||
if (NextFrame) {
|
||||
double easingValue = EasingValue;
|
||||
double delta = last - first;
|
||||
current = first + (int)(easingValue * delta);
|
||||
double delta = Last - First;
|
||||
Current = First + (int)(easingValue * delta);
|
||||
}
|
||||
return current;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +450,7 @@ namespace GreenshotPlugin.Core {
|
|||
// Adapted from http://www.robertpenner.com/easing/penner_chapter7_tweening.pdf
|
||||
|
||||
public static double Ease(double linearStep, double acceleration, EasingType type) {
|
||||
double easedStep = acceleration > 0 ? EaseIn(linearStep, type) : acceleration < 0 ? EaseOut(linearStep, type) : (double)linearStep;
|
||||
double easedStep = acceleration > 0 ? EaseIn(linearStep, type) : acceleration < 0 ? EaseOut(linearStep, type) : linearStep;
|
||||
// Lerp:
|
||||
return ((easedStep - linearStep) * Math.Abs(acceleration) + linearStep);
|
||||
}
|
||||
|
|
|
@ -31,10 +31,10 @@ namespace GreenshotPlugin.Core {
|
|||
/// <typeparam name="TV">Type of value</typeparam>
|
||||
public class Cache<TK, TV> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(Cache<TK, TV>));
|
||||
private IDictionary<TK, TV> internalCache = new Dictionary<TK, TV>();
|
||||
private object lockObject = new object();
|
||||
private int secondsToExpire = 10;
|
||||
private CacheObjectExpired expiredCallback = null;
|
||||
private readonly IDictionary<TK, TV> internalCache = new Dictionary<TK, TV>();
|
||||
private readonly object lockObject = new object();
|
||||
private readonly int secondsToExpire = 10;
|
||||
private readonly CacheObjectExpired expiredCallback;
|
||||
public delegate void CacheObjectExpired(TK key, TV cacheValue);
|
||||
|
||||
/// <summary>
|
||||
|
@ -168,7 +168,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
private class CachedItem {
|
||||
public event CacheObjectExpired Expired;
|
||||
private int secondsToExpire;
|
||||
private readonly int secondsToExpire;
|
||||
private readonly Timer _timerEvent;
|
||||
|
||||
public CachedItem(TK key, TV item, int secondsToExpire) {
|
||||
|
|
|
@ -327,9 +327,9 @@ EndSelection:<<<<<<<4
|
|||
if (formats != null && formats.Contains(FORMAT_PNG_OFFICEART) && formats.Contains(DataFormats.Dib)) {
|
||||
// Outlook ??
|
||||
LOG.Info("Most likely the current clipboard contents come from Outlook, as this has a problem with PNG and others we place the DIB format to the front...");
|
||||
retrieveFormats = new string[] { DataFormats.Dib, FORMAT_BITMAP, FORMAT_FILECONTENTS, FORMAT_PNG_OFFICEART, FORMAT_PNG, FORMAT_JFIF_OFFICEART, FORMAT_JPG, FORMAT_JFIF, DataFormats.Tiff, FORMAT_GIF };
|
||||
retrieveFormats = new[] { DataFormats.Dib, FORMAT_BITMAP, FORMAT_FILECONTENTS, FORMAT_PNG_OFFICEART, FORMAT_PNG, FORMAT_JFIF_OFFICEART, FORMAT_JPG, FORMAT_JFIF, DataFormats.Tiff, FORMAT_GIF };
|
||||
} else {
|
||||
retrieveFormats = new string[] { FORMAT_PNG_OFFICEART, FORMAT_PNG, FORMAT_17, FORMAT_JFIF_OFFICEART, FORMAT_JPG, FORMAT_JFIF, DataFormats.Tiff, DataFormats.Dib, FORMAT_BITMAP, FORMAT_FILECONTENTS, FORMAT_GIF };
|
||||
retrieveFormats = new[] { FORMAT_PNG_OFFICEART, FORMAT_PNG, FORMAT_17, FORMAT_JFIF_OFFICEART, FORMAT_JPG, FORMAT_JFIF, DataFormats.Tiff, DataFormats.Dib, FORMAT_BITMAP, FORMAT_FILECONTENTS, FORMAT_GIF };
|
||||
}
|
||||
foreach (string currentFormat in retrieveFormats) {
|
||||
if (formats.Contains(currentFormat)) {
|
||||
|
@ -717,7 +717,7 @@ EndSelection:<<<<<<<4
|
|||
/// <param name="format">string with format</param>
|
||||
/// <returns>true if one the format is found</returns>
|
||||
public static bool ContainsFormat(string format) {
|
||||
return ContainsFormat(GetDataObject(), new string[]{format});
|
||||
return ContainsFormat(GetDataObject(), new[]{format});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -726,7 +726,7 @@ EndSelection:<<<<<<<4
|
|||
/// <param name="format">string with format</param>
|
||||
/// <returns>true if one the format is found</returns>
|
||||
public static bool ContainsFormat(IDataObject dataObject, string format) {
|
||||
return ContainsFormat(dataObject, new string[] { format });
|
||||
return ContainsFormat(dataObject, new[] { format });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -198,6 +198,9 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
[IniProperty("OptimizeForRDP", Description="Make some optimizations for usage with remote desktop", DefaultValue="False")]
|
||||
public bool OptimizeForRDP;
|
||||
[IniProperty("DisableRDPOptimizing", Description = "Disable all optimizations for usage with remote desktop", DefaultValue = "False")]
|
||||
public bool DisableRDPOptimizing;
|
||||
|
||||
[IniProperty("MinimizeWorkingSetSize", Description="Optimize memory footprint, but with a performance penalty!", DefaultValue="False")]
|
||||
public bool MinimizeWorkingSetSize;
|
||||
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace GreenshotPlugin.Core {
|
|||
Banner = banner;
|
||||
}
|
||||
|
||||
private bool _alwaysDisplay = false;
|
||||
private bool _alwaysDisplay;
|
||||
/// <summary>
|
||||
/// Gets or sets if the dialog will be shown even if the credentials
|
||||
/// can be returned from an existing credential in the credential manager.
|
||||
|
@ -138,7 +138,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private bool _incorrectPassword = false;
|
||||
private bool _incorrectPassword;
|
||||
/// <summary>Gets or sets if the incorrect password balloontip needs to be shown. Introduced AFTER Windows XP</summary>Gets></summary>
|
||||
public bool IncorrectPassword {
|
||||
get {
|
||||
|
@ -149,7 +149,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private bool _keepName = false;
|
||||
private bool _keepName;
|
||||
/// <summary>Gets or sets if the name is read-only.</summary>
|
||||
public bool KeepName {
|
||||
get {
|
||||
|
@ -200,7 +200,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private bool _saveChecked = false;
|
||||
private bool _saveChecked;
|
||||
/// <summary>Gets or sets if the save checkbox status.</summary>
|
||||
public bool SaveChecked {
|
||||
get {
|
||||
|
@ -285,7 +285,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private Image _banner = null;
|
||||
private Image _banner;
|
||||
/// <summary>Gets or sets the image to display on the dialog.</summary>
|
||||
/// <remarks>A null value will cause a system default image to be used.</remarks>
|
||||
public Image Banner {
|
||||
|
|
|
@ -86,7 +86,8 @@ namespace Greenshot.Core {
|
|||
/// </summary>
|
||||
[TypeConverter(typeof(EffectConverter))]
|
||||
public class TornEdgeEffect : DropShadowEffect {
|
||||
public TornEdgeEffect() : base() {
|
||||
public TornEdgeEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public int ToothHeight {
|
||||
|
@ -116,7 +117,7 @@ namespace Greenshot.Core {
|
|||
ToothHeight = 12;
|
||||
HorizontalToothRange = 20;
|
||||
VerticalToothRange = 20;
|
||||
Edges = new bool[] { true, true, true, true };
|
||||
Edges = new[] { true, true, true, true };
|
||||
GenerateShadow = true;
|
||||
}
|
||||
public override Image Apply(Image sourceImage, Matrix matrix) {
|
||||
|
@ -146,16 +147,16 @@ namespace Greenshot.Core {
|
|||
/// MonochromeEffect
|
||||
/// </summary>
|
||||
public class MonochromeEffect : IEffect {
|
||||
private byte threshold;
|
||||
private readonly byte _threshold;
|
||||
/// <param name="threshold">Threshold for monochrome filter (0 - 255), lower value means less black</param>
|
||||
public MonochromeEffect(byte threshold) {
|
||||
this.threshold = threshold;
|
||||
_threshold = threshold;
|
||||
}
|
||||
public void Reset() {
|
||||
// TODO: Modify the threshold to have a default, which is reset here
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateMonochrome(sourceImage, threshold);
|
||||
return ImageHelper.CreateMonochrome(sourceImage, _threshold);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,7 +164,8 @@ namespace Greenshot.Core {
|
|||
/// AdjustEffect
|
||||
/// </summary>
|
||||
public class AdjustEffect : IEffect {
|
||||
public AdjustEffect() : base() {
|
||||
public AdjustEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public float Contrast {
|
||||
|
@ -192,8 +194,9 @@ namespace Greenshot.Core {
|
|||
/// ReduceColorsEffect
|
||||
/// </summary>
|
||||
public class ReduceColorsEffect : IEffect {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(ReduceColorsEffect));
|
||||
public ReduceColorsEffect() : base() {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(ReduceColorsEffect));
|
||||
public ReduceColorsEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public int Colors {
|
||||
|
@ -355,9 +358,10 @@ namespace Greenshot.Core {
|
|||
|
||||
public class EffectConverter : TypeConverter {
|
||||
// Fix to prevent BUG-1753
|
||||
private NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
|
||||
private readonly NumberFormatInfo numberFormatInfo = new NumberFormatInfo();
|
||||
|
||||
public EffectConverter() : base() {
|
||||
public EffectConverter()
|
||||
{
|
||||
numberFormatInfo.NumberDecimalSeparator = ".";
|
||||
numberFormatInfo.NumberGroupSeparator = ",";
|
||||
}
|
||||
|
@ -382,7 +386,7 @@ namespace Greenshot.Core {
|
|||
return base.CanConvertTo(context, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) {
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
|
||||
// to string
|
||||
if (destinationType == typeof(string)) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -400,7 +404,7 @@ namespace Greenshot.Core {
|
|||
}
|
||||
}
|
||||
// from string
|
||||
if (value.GetType() == typeof(string)) {
|
||||
if (value is string) {
|
||||
string settings = value as string;
|
||||
if (destinationType == typeof(DropShadowEffect)) {
|
||||
DropShadowEffect effect = new DropShadowEffect();
|
||||
|
@ -417,14 +421,13 @@ namespace Greenshot.Core {
|
|||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) {
|
||||
if (value != null && value.GetType() == typeof(string)) {
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) {
|
||||
if (value != null && value is string) {
|
||||
string settings = value as string;
|
||||
if (settings.Contains("ToothHeight")) {
|
||||
return ConvertTo(context, culture, value, typeof(TornEdgeEffect));
|
||||
} else {
|
||||
return ConvertTo(context, culture, value, typeof(DropShadowEffect));
|
||||
}
|
||||
return ConvertTo(context, culture, value, typeof(DropShadowEffect));
|
||||
}
|
||||
return base.ConvertFrom(context, culture, value);
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ using System;
|
|||
|
||||
namespace GreenshotPlugin.Core {
|
||||
public class EventDelay {
|
||||
private long lastCheck = 0;
|
||||
private long waitTime;
|
||||
private long lastCheck;
|
||||
private readonly long waitTime;
|
||||
public EventDelay(long ticks) {
|
||||
this.waitTime = ticks;
|
||||
}
|
||||
|
|
|
@ -322,7 +322,7 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
protected BitmapData bmData;
|
||||
protected int stride; /* bytes per pixel row */
|
||||
protected bool bitsLocked = false;
|
||||
protected bool bitsLocked;
|
||||
protected byte* pointer;
|
||||
|
||||
public static IFastBitmap Create(Bitmap source) {
|
||||
|
@ -726,8 +726,8 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public unsafe class FastChunkyBitmap : FastBitmap {
|
||||
// Used for indexed images
|
||||
private Color[] colorEntries;
|
||||
private Dictionary<Color, byte> colorCache = new Dictionary<Color, byte>();
|
||||
private readonly Color[] colorEntries;
|
||||
private readonly Dictionary<Color, byte> colorCache = new Dictionary<Color, byte>();
|
||||
|
||||
public FastChunkyBitmap(Bitmap source, Rectangle area) : base(source, area) {
|
||||
colorEntries = bitmap.Palette.Entries;
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
private static readonly Regex SPLIT_REGEXP = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
|
||||
private const int MAX_TITLE_LENGTH = 80;
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private const string UNSAFE_REPLACEMENT = "_";
|
||||
|
||||
/// <summary>
|
||||
|
@ -159,7 +159,7 @@ namespace GreenshotPlugin.Core {
|
|||
switch (parameter.Substring(0, 1)) {
|
||||
// Padding p<width>[,pad-character]
|
||||
case "p":
|
||||
string[] padParams = parameter.Substring(1).Split(new char[] { ',' });
|
||||
string[] padParams = parameter.Substring(1).Split(new[] { ',' });
|
||||
try {
|
||||
padWidth = int.Parse(padParams[0]);
|
||||
} catch {
|
||||
|
@ -171,7 +171,7 @@ namespace GreenshotPlugin.Core {
|
|||
// replace
|
||||
// r<old string>,<new string>
|
||||
case "r":
|
||||
string[] replaceParameters = parameter.Substring(1).Split(new char[] { ',' });
|
||||
string[] replaceParameters = parameter.Substring(1).Split(new[] { ',' });
|
||||
if (replaceParameters != null && replaceParameters.Length == 2) {
|
||||
replacements.Add(replaceParameters[0], replaceParameters[1]);
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ namespace GreenshotPlugin.Core {
|
|||
// s<start>[,length]
|
||||
case "s":
|
||||
string range = parameter.Substring(1);
|
||||
string[] rangelist = range.Split(new char[] { ',' });
|
||||
string[] rangelist = range.Split(new[] { ',' });
|
||||
if (rangelist.Length > 0) {
|
||||
try {
|
||||
startIndex = int.Parse(rangelist[0]);
|
||||
|
@ -418,9 +418,9 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
|
||||
return VAR_REGEXP.Replace(pattern,
|
||||
new MatchEvaluator(delegate(Match m) {
|
||||
return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
|
||||
})
|
||||
delegate(Match m) {
|
||||
return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -455,9 +455,9 @@ namespace GreenshotPlugin.Core {
|
|||
|
||||
try {
|
||||
return VAR_REGEXP.Replace(pattern,
|
||||
new MatchEvaluator(delegate(Match m) {
|
||||
return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, filenameSafeMode);
|
||||
})
|
||||
delegate(Match m) {
|
||||
return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, filenameSafeMode);
|
||||
}
|
||||
);
|
||||
} catch (Exception e) {
|
||||
// adding additional data for bug tracking
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// Centralized storage of the icons & bitmaps
|
||||
/// </summary>
|
||||
public static class GreenshotResources {
|
||||
private static ComponentResourceManager greenshotResources = new ComponentResourceManager(typeof(GreenshotResources));
|
||||
private static readonly ComponentResourceManager greenshotResources = new ComponentResourceManager(typeof(GreenshotResources));
|
||||
|
||||
public static Image getImage(string imageName) {
|
||||
return (Image)greenshotResources.GetObject(imageName);
|
||||
|
|
|
@ -24,10 +24,8 @@ using System.Drawing;
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Core;
|
||||
using log4net;
|
||||
|
||||
|
@ -48,8 +46,8 @@ namespace GreenshotPlugin.Core {
|
|||
/// Description of ImageHelper.
|
||||
/// </summary>
|
||||
public static class ImageHelper {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(ImageHelper));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(ImageHelper));
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private const int EXIF_ORIENTATION_ID = 0x0112;
|
||||
|
||||
/// <summary>
|
||||
|
@ -827,7 +825,7 @@ namespace GreenshotPlugin.Core {
|
|||
if ((shadowSize & 1) == 0) {
|
||||
shadowSize++;
|
||||
}
|
||||
bool useGDIBlur = GDIplus.isBlurPossible(shadowSize);
|
||||
bool useGDIBlur = GDIplus.IsBlurPossible(shadowSize);
|
||||
// Create "mask" for the shadow
|
||||
ColorMatrix maskMatrix = new ColorMatrix();
|
||||
maskMatrix.Matrix00 = 0;
|
||||
|
@ -1021,12 +1019,13 @@ namespace GreenshotPlugin.Core {
|
|||
public static ImageAttributes CreateAdjustAttributes(float brightness, float contrast, float gamma) {
|
||||
float adjustedBrightness = brightness - 1.0f;
|
||||
ColorMatrix applyColorMatrix = new ColorMatrix(
|
||||
new float[][] {
|
||||
new float[] {contrast, 0, 0, 0, 0}, // scale red
|
||||
new float[] {0, contrast, 0, 0, 0}, // scale green
|
||||
new float[] {0, 0, contrast, 0, 0}, // scale blue
|
||||
new float[] {0, 0, 0, 1.0f, 0}, // don't scale alpha
|
||||
new float[] {adjustedBrightness, adjustedBrightness, adjustedBrightness, 0, 1}
|
||||
new[]
|
||||
{
|
||||
new[] {contrast, 0, 0, 0, 0}, // scale red
|
||||
new[] {0, contrast, 0, 0, 0}, // scale green
|
||||
new[] {0, 0, contrast, 0, 0}, // scale blue
|
||||
new[] {0, 0, 0, 1.0f, 0}, // don't scale alpha
|
||||
new[] {adjustedBrightness, adjustedBrightness, adjustedBrightness, 0, 1}
|
||||
});
|
||||
|
||||
//create some image attributes
|
||||
|
@ -1063,10 +1062,11 @@ namespace GreenshotPlugin.Core {
|
|||
/// <returns>Bitmap with grayscale</returns>
|
||||
public static Image CreateGrayscale(Image sourceImage) {
|
||||
Bitmap clone = (Bitmap)Clone(sourceImage);
|
||||
ColorMatrix grayscaleMatrix = new ColorMatrix( new float[][] {
|
||||
new float[] {.3f, .3f, .3f, 0, 0},
|
||||
new float[] {.59f, .59f, .59f, 0, 0},
|
||||
new float[] {.11f, .11f, .11f, 0, 0},
|
||||
ColorMatrix grayscaleMatrix = new ColorMatrix( new[]
|
||||
{
|
||||
new[] {.3f, .3f, .3f, 0, 0},
|
||||
new[] {.59f, .59f, .59f, 0, 0},
|
||||
new[] {.11f, .11f, .11f, 0, 0},
|
||||
new float[] {0, 0, 0, 1, 0},
|
||||
new float[] {0, 0, 0, 0, 1}
|
||||
});
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace GreenshotPlugin.Core {
|
|||
private static readonly ILog LOG = LogManager.GetLogger(typeof(ImageOutput));
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
|
||||
private static Cache<string, string> tmpFileCache = new Cache<string, string>(10 * 60 * 60, RemoveExpiredTmpFile);
|
||||
private static readonly Cache<string, string> tmpFileCache = new Cache<string, string>(10 * 60 * 60, RemoveExpiredTmpFile);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a PropertyItem (Metadata) to store with the image.
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// Description of InterfaceUtils.
|
||||
/// </summary>
|
||||
public static class InterfaceUtils {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(InterfaceUtils));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(InterfaceUtils));
|
||||
|
||||
public static List<Type> GetSubclassesOf(Type type, bool excludeSystemTypes) {
|
||||
List<Type> list = new List<Type>();
|
||||
|
|
|
@ -8,7 +8,6 @@ The above copyright notice and this permission notice shall be included in all c
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
|
|
|
@ -35,21 +35,21 @@ namespace GreenshotPlugin.Core {
|
|||
/// The language resources are loaded from the language files found on fixed or supplied paths
|
||||
/// </summary>
|
||||
public class Language {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(Language));
|
||||
private static List<string> languagePaths = new List<string>();
|
||||
private static IDictionary<string, List<LanguageFile>> languageFiles = new Dictionary<string, List<LanguageFile>>();
|
||||
private static IDictionary<string, string> helpFiles = new Dictionary<string, string>();
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(Language));
|
||||
private static readonly List<string> languagePaths = new List<string>();
|
||||
private static readonly IDictionary<string, List<LanguageFile>> languageFiles = new Dictionary<string, List<LanguageFile>>();
|
||||
private static readonly IDictionary<string, string> helpFiles = new Dictionary<string, string>();
|
||||
private const string DEFAULT_LANGUAGE = "en-US";
|
||||
private const string HELP_FILENAME_PATTERN = @"help-*.html";
|
||||
private const string LANGUAGE_FILENAME_PATTERN = @"language*.xml";
|
||||
private static Regex PREFIX_REGEXP = new Regex(@"language_([a-zA-Z0-9]+).*");
|
||||
private static Regex IETF_CLEAN_REGEXP = new Regex(@"[^a-zA-Z]+");
|
||||
private static Regex IETF_REGEXP = new Regex(@"^.*([a-zA-Z]{2}-[a-zA-Z]{2})\.xml$");
|
||||
private static readonly Regex PREFIX_REGEXP = new Regex(@"language_([a-zA-Z0-9]+).*");
|
||||
private static readonly Regex IETF_CLEAN_REGEXP = new Regex(@"[^a-zA-Z]+");
|
||||
private static readonly Regex IETF_REGEXP = new Regex(@"^.*([a-zA-Z]{2}-[a-zA-Z]{2})\.xml$");
|
||||
private const string LANGUAGE_GROUPS_KEY = @"SYSTEM\CurrentControlSet\Control\Nls\Language Groups";
|
||||
private static List<string> unsupportedLanguageGroups = new List<string>();
|
||||
private static IDictionary<string, string> resources = new Dictionary<string, string>();
|
||||
private static string currentLanguage = null;
|
||||
private static CoreConfiguration coreConfig = null;
|
||||
private static readonly List<string> unsupportedLanguageGroups = new List<string>();
|
||||
private static readonly IDictionary<string, string> resources = new Dictionary<string, string>();
|
||||
private static string currentLanguage;
|
||||
private static readonly CoreConfiguration coreConfig;
|
||||
|
||||
public static event LanguageChangedHandler LanguageChanged;
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ namespace GreenshotPlugin.Core {
|
|||
public class LogHelper {
|
||||
private const string LOG4NET_FILE = "log4net.xml";
|
||||
private const string LOG4NET_PORTABLE_FILE = "log4net-portable.xml";
|
||||
private static bool isLog4NetConfigured = false;
|
||||
private static bool isLog4NetConfigured;
|
||||
private const string INIT_MESSAGE = "Greenshot initialization of log system failed";
|
||||
public static bool isInitialized {
|
||||
get {
|
||||
|
|
|
@ -552,10 +552,10 @@ namespace GreenshotPlugin.Core {
|
|||
/// A container to supply files to a Multi-part form data upload
|
||||
/// </summary>
|
||||
public class ByteContainer : IBinaryContainer {
|
||||
private byte[] file;
|
||||
private string fileName;
|
||||
private string contentType;
|
||||
private int fileSize;
|
||||
private readonly byte[] file;
|
||||
private readonly string fileName;
|
||||
private readonly string contentType;
|
||||
private readonly int fileSize;
|
||||
public ByteContainer(byte[] file) : this(file, null) {
|
||||
}
|
||||
public ByteContainer(byte[] file, string filename) : this(file, filename, null) {
|
||||
|
@ -635,9 +635,9 @@ namespace GreenshotPlugin.Core {
|
|||
/// A container to supply images to a Multi-part form data upload
|
||||
/// </summary>
|
||||
public class BitmapContainer : IBinaryContainer {
|
||||
private Bitmap bitmap;
|
||||
private SurfaceOutputSettings outputSettings;
|
||||
private string fileName;
|
||||
private readonly Bitmap bitmap;
|
||||
private readonly SurfaceOutputSettings outputSettings;
|
||||
private readonly string fileName;
|
||||
|
||||
public BitmapContainer(Bitmap bitmap, SurfaceOutputSettings outputSettings, string filename) {
|
||||
this.bitmap = bitmap;
|
||||
|
@ -712,9 +712,9 @@ namespace GreenshotPlugin.Core {
|
|||
/// A container to supply surfaces to a Multi-part form data upload
|
||||
/// </summary>
|
||||
public class SurfaceContainer : IBinaryContainer {
|
||||
private ISurface surface;
|
||||
private SurfaceOutputSettings outputSettings;
|
||||
private string fileName;
|
||||
private readonly ISurface surface;
|
||||
private readonly SurfaceOutputSettings outputSettings;
|
||||
private readonly string fileName;
|
||||
|
||||
public SurfaceContainer(ISurface surface, SurfaceOutputSettings outputSettings, string filename) {
|
||||
this.surface = surface;
|
||||
|
|
|
@ -27,7 +27,6 @@ using System.Collections.Specialized;
|
|||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Security.Cryptography;
|
||||
|
@ -968,7 +967,7 @@ Greenshot received information from CloudServiceName. You can close this browser
|
|||
|
||||
private string _cloudServiceName;
|
||||
|
||||
private IDictionary<string, string> _returnValues = new Dictionary<string, string>();
|
||||
private readonly IDictionary<string, string> _returnValues = new Dictionary<string, string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -991,7 +990,7 @@ Greenshot received information from CloudServiceName. You can close this browser
|
|||
Process.Start(authorizationUrl);
|
||||
|
||||
// Wait to get the authorization code response.
|
||||
var context = listener.BeginGetContext(new AsyncCallback(ListenerCallback), listener);
|
||||
var context = listener.BeginGetContext(ListenerCallback, listener);
|
||||
_ready.Reset();
|
||||
|
||||
while (!context.AsyncWaitHandle.WaitOne(1000, true)) {
|
||||
|
|
|
@ -37,9 +37,9 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public static class PluginUtils {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(PluginUtils));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private const string PATH_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
||||
private static IDictionary<string, Image> exeIconCache = new Dictionary<string, Image>();
|
||||
private static readonly IDictionary<string, Image> exeIconCache = new Dictionary<string, Image>();
|
||||
|
||||
static PluginUtils() {
|
||||
conf.PropertyChanged += OnIconSizeChanged;
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
|
||||
public class WuQuantizer : IDisposable {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(WuQuantizer));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(WuQuantizer));
|
||||
|
||||
private const Int32 MAXCOLOR = 512;
|
||||
private const Int32 RED = 2;
|
||||
|
@ -82,23 +82,23 @@ namespace GreenshotPlugin.Core {
|
|||
private const Int32 MAXVOLUME = SIDESIZE * SIDESIZE * SIDESIZE;
|
||||
|
||||
// To count the colors
|
||||
private int colorCount = 0;
|
||||
private readonly int colorCount;
|
||||
|
||||
private Int32[] reds;
|
||||
private Int32[] greens;
|
||||
private Int32[] blues;
|
||||
private Int32[] sums;
|
||||
|
||||
private Int64[, ,] weights;
|
||||
private Int64[, ,] momentsRed;
|
||||
private Int64[, ,] momentsGreen;
|
||||
private Int64[, ,] momentsBlue;
|
||||
private Single[, ,] moments;
|
||||
private readonly Int64[, ,] weights;
|
||||
private readonly Int64[, ,] momentsRed;
|
||||
private readonly Int64[, ,] momentsGreen;
|
||||
private readonly Int64[, ,] momentsBlue;
|
||||
private readonly Single[, ,] moments;
|
||||
|
||||
private byte[] tag;
|
||||
|
||||
private WuColorCube[] cubes;
|
||||
private Bitmap sourceBitmap;
|
||||
private readonly WuColorCube[] cubes;
|
||||
private readonly Bitmap sourceBitmap;
|
||||
private Bitmap resultBitmap;
|
||||
|
||||
public void Dispose() {
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Xml;
|
||||
|
@ -96,7 +95,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// Description of SourceForgeHelper.
|
||||
/// </summary>
|
||||
public class SourceForgeHelper {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(SourceForgeHelper));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(SourceForgeHelper));
|
||||
private const string RSSFEED = "http://getgreenshot.org/project-feed/";
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -26,7 +26,6 @@ using System.Text;
|
|||
using log4net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
public static class StringExtensions {
|
||||
|
|
|
@ -62,7 +62,7 @@ namespace GreenshotPlugin.Core {
|
|||
set;
|
||||
}
|
||||
|
||||
private Dictionary<string, string> metaData = new Dictionary<string, string>();
|
||||
private readonly Dictionary<string, string> metaData = new Dictionary<string, string>();
|
||||
public Dictionary<string, string> MetaData {
|
||||
get {return metaData;}
|
||||
}
|
||||
|
@ -644,7 +644,7 @@ namespace GreenshotPlugin.Core {
|
|||
// capture.Image = capturedBitmap;
|
||||
// capture.Location = captureBounds.Location;
|
||||
|
||||
using (SafeWindowDCHandle desktopDCHandle = SafeWindowDCHandle.fromDesktop()) {
|
||||
using (SafeWindowDCHandle desktopDCHandle = SafeWindowDCHandle.FromDesktop()) {
|
||||
if (desktopDCHandle.IsInvalid) {
|
||||
// Get Exception before the error is lost
|
||||
Exception exceptionToThrow = CreateCaptureException("desktopDCHandle", captureBounds);
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public class WindowsEnumerator {
|
||||
#region Member Variables
|
||||
private List<WindowDetails> items = null;
|
||||
private List<WindowDetails> items;
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
|
@ -89,7 +89,7 @@ namespace GreenshotPlugin.Core {
|
|||
public WindowsEnumerator GetWindows(IntPtr hWndParent, string classname) {
|
||||
items = new List<WindowDetails>();
|
||||
List<WindowDetails> windows = new List<WindowDetails>();
|
||||
User32.EnumChildWindows(hWndParent, new EnumWindowsProc(WindowEnum), IntPtr.Zero);
|
||||
User32.EnumChildWindows(hWndParent, WindowEnum, IntPtr.Zero);
|
||||
|
||||
bool hasParent = !IntPtr.Zero.Equals(hWndParent);
|
||||
string parentText = null;
|
||||
|
@ -164,11 +164,11 @@ namespace GreenshotPlugin.Core {
|
|||
private const string METRO_APPLAUNCHER_CLASS = "ImmersiveLauncher";
|
||||
private const string METRO_GUTTER_CLASS = "ImmersiveGutter";
|
||||
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(WindowDetails));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static List<IntPtr> ignoreHandles = new List<IntPtr>();
|
||||
private static List<string> excludeProcessesFromFreeze = new List<string>();
|
||||
private static IAppVisibility appVisibility = null;
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(WindowDetails));
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly List<IntPtr> ignoreHandles = new List<IntPtr>();
|
||||
private static readonly List<string> excludeProcessesFromFreeze = new List<string>();
|
||||
private static readonly IAppVisibility appVisibility;
|
||||
|
||||
static WindowDetails() {
|
||||
try {
|
||||
|
@ -189,10 +189,10 @@ namespace GreenshotPlugin.Core {
|
|||
return ignoreHandles.Contains(handle);
|
||||
}
|
||||
|
||||
private List<WindowDetails> childWindows = null;
|
||||
private List<WindowDetails> childWindows;
|
||||
private IntPtr parentHandle = IntPtr.Zero;
|
||||
private WindowDetails parent = null;
|
||||
private bool frozen = false;
|
||||
private WindowDetails parent;
|
||||
private bool frozen;
|
||||
|
||||
public bool isApp {
|
||||
get {
|
||||
|
@ -224,7 +224,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <summary>
|
||||
/// The window handle.
|
||||
/// </summary>
|
||||
private IntPtr hWnd = IntPtr.Zero;
|
||||
private readonly IntPtr hWnd = IntPtr.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// To allow items to be compared, the hash code
|
||||
|
@ -588,7 +588,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private string text = null;
|
||||
private string text;
|
||||
/// <summary>
|
||||
/// Gets the window's title (caption)
|
||||
/// </summary>
|
||||
|
@ -606,7 +606,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
}
|
||||
|
||||
private string className = null;
|
||||
private string className;
|
||||
/// <summary>
|
||||
/// Gets the window's class name.
|
||||
/// </summary>
|
||||
|
@ -755,7 +755,7 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
|
||||
private Rectangle previousWindowRectangle = Rectangle.Empty;
|
||||
private long lastWindowRectangleRetrieveTime = 0;
|
||||
private long lastWindowRectangleRetrieveTime;
|
||||
private const long CACHE_TIME = TimeSpan.TicksPerSecond * 2;
|
||||
/// <summary>
|
||||
/// Gets the bounding rectangle of the window
|
||||
|
@ -1515,7 +1515,7 @@ namespace GreenshotPlugin.Core {
|
|||
continue;
|
||||
}
|
||||
// Ignore some classes
|
||||
List<string> ignoreClasses = new List<string>(new string[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
|
||||
List<string> ignoreClasses = new List<string>(new[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
|
||||
if (ignoreClasses.Contains(window.ClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -1585,7 +1585,7 @@ namespace GreenshotPlugin.Core {
|
|||
continue;
|
||||
}
|
||||
// Ignore some classes
|
||||
List<string> ignoreClasses = new List<string>(new string[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
|
||||
List<string> ignoreClasses = new List<string>(new[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
|
||||
if (ignoreClasses.Contains(window.ClassName)) {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue