Reduced warnings by >500

This commit is contained in:
Robin Krom 2019-04-28 22:54:53 +02:00
commit 6bdcf35ce2
81 changed files with 1071 additions and 203 deletions

View file

@ -31,9 +31,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
/// </summary>
public class TargetAdorner : AbstractAdorner
{
public TargetAdorner(IDrawableContainer owner, NativePoint location) : base(owner)
private readonly Color _color;
public TargetAdorner(IDrawableContainer owner, NativePoint location, Color color) : base(owner)
{
Location = location;
_color = color;
}
/// <summary>
@ -96,7 +99,11 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners
var targetGraphics = paintEventArgs.Graphics;
var bounds = Bounds;
targetGraphics.FillRectangle(Brushes.Green, bounds.X, bounds.Y, bounds.Width, bounds.Height);
using (var brush = new SolidBrush(_color))
{
targetGraphics.FillRectangle(brush, bounds.X, bounds.Y, bounds.Width, bounds.Height);
}
}
/// <summary>

View file

@ -110,26 +110,41 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
}
}
/// <summary>
/// The adorner for the target
/// </summary>
public TargetAdorner TargetAdorner
{
get { return _targetAdorner; }
}
/// <summary>
/// Specifies if this contain has a context menu
/// </summary>
public virtual bool HasContextMenu
{
get { return true; }
}
/// <summary>
/// Specifies if this container has a default size
/// </summary>
public virtual bool HasDefaultSize
{
get { return false; }
}
/// <summary>
/// The default size
/// </summary>
public virtual Size DefaultSize
{
get { throw new NotSupportedException("Object doesn't have a default size"); }
}
/// <summary>
/// This specifies the edit status
/// </summary>
public EditStatus DefaultEditMode
{
get { return _defaultEditMode; }
@ -145,18 +160,27 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
GC.SuppressFinalize(this);
}
/// <summary>
/// The property change event is triggered when a property is changed
/// </summary>
public event PropertyChangedEventHandler PropertyChanged
{
add { _propertyChanged += value; }
remove { _propertyChanged -= value; }
}
/// <summary>
/// The surface this container belongs to
/// </summary>
public ISurface Parent
{
get { return _parent; }
set { SwitchParent((Surface) value); }
}
/// <summary>
/// Is this container selected?
/// </summary>
public bool Selected
{
get { return _selected; }
@ -493,6 +517,9 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
return (int) Math.Round(f);
}
/// <summary>
/// This is called when the container is double clicked
/// </summary>
public virtual void OnDoubleClick()
{
}
@ -502,7 +529,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
/// </summary>
protected void InitAdorner(Color gripperColor, NativePoint location)
{
_targetAdorner = new TargetAdorner(this, location);
// TODO: Pass the gripperColor to the target adorner
_targetAdorner = new TargetAdorner(this, location, gripperColor);
Adorners.Add(_targetAdorner);
}
@ -584,7 +612,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
}
public void ResizeTo(int width, int height, int anchorPosition)
public void ResizeTo(int width, int height)
{
Width = width;
Height = height;
@ -674,7 +702,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
return (int) -Math.Round(radians * 180 / Math.PI);
}
protected virtual ScaleHelper.IDoubleProcessor GetAngleRoundProcessor()
protected virtual IDoubleProcessor GetAngleRoundProcessor()
{
return ScaleHelper.ShapeAngleRoundBehavior.Instance;
}

View file

@ -36,11 +36,17 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
{
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
/// <summary>
/// Constructor taking all dependencies
/// </summary>
/// <param name="parent">parent</param>
/// <param name="editorConfiguration">IEditorConfiguration</param>
public LineContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
/// <inheritdoc />
protected override void InitializeFields()
{
AddField(GetType(), FieldTypes.LINE_THICKNESS, 2);
@ -48,17 +54,22 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
AddField(GetType(), FieldTypes.SHADOW, true);
}
/// <inheritdoc />
protected override void OnDeserialized(StreamingContext context)
{
Init();
}
/// <summary>
/// Initialize this container
/// </summary>
protected void Init()
{
Adorners.Add(new MoveAdorner(this, Positions.TopLeft));
Adorners.Add(new MoveAdorner(this, Positions.BottomRight));
}
/// <inheritdoc />
public override void Draw(Graphics graphics, RenderMode rm)
{
graphics.SmoothingMode = SmoothingMode.HighQuality;
@ -90,7 +101,9 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
Top + currentStep + Height);
currentStep++;
#pragma warning disable IDE0054 // Use compound assignment
alpha = alpha - basealpha / steps;
#pragma warning restore IDE0054 // Use compound assignment
}
}
}
@ -102,6 +115,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
}
}
/// <inheritdoc />
public override bool ClickableAt(int x, int y)
{
var lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS) + 5;
@ -120,9 +134,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
return false;
}
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor()
/// <inheritdoc />
protected override IDoubleProcessor GetAngleRoundProcessor()
{
return ScaleHelper.LineAngleRoundBehavior.Instance;
return LineAngleRoundBehavior.Instance;
}
}
}

View file

@ -34,6 +34,7 @@ namespace Greenshot.Addons
/// <inheritdoc />
public class AddonsModule : AddonModule
{
/// <inheritdoc/>
protected override void Load(ContainerBuilder builder)
{
builder

View file

@ -185,7 +185,7 @@ namespace Greenshot.Addons.Animation
/// <summary>
/// Get the next animation frame value object
/// </summary>
/// <returns></returns>
/// <returns>T</returns>
public abstract T Next();
/// <summary>

View file

@ -26,15 +26,20 @@ namespace Greenshot.Addons.Animation
/// </summary>
public class ColorAnimator : AnimatorBase<Color>
{
/// <summary>
/// Create a color animator
/// </summary>
/// <param name="first">Color to start with</param>
/// <param name="last">Color to end with</param>
/// <param name="frames">int amount of frames to animate</param>
/// <param name="easingType">EasingTypes, the easing type to use</param>
/// <param name="easingMode">EasingModes, the easing mode to use</param>
public ColorAnimator(Color first, Color last, int frames, EasingTypes easingType = EasingTypes.Linear, EasingModes easingMode = EasingModes.EaseIn)
: base(first, last, frames, easingType, easingMode)
{
}
/// <summary>
/// Calculate the next frame values
/// </summary>
/// <returns>Color</returns>
/// <inheritdoc />
public override Color Next()
{
if (!NextFrame)

View file

@ -26,16 +26,31 @@ namespace Greenshot.Addons.Animation
/// </summary>
public static class EaseSine
{
/// <summary>
/// Calculate the ease in
/// </summary>
/// <param name="s">double</param>
/// <returns>double</returns>
public static double EaseIn(double s)
{
return Math.Sin(s * (Math.PI / 2) - Math.PI / 2) + 1;
}
/// <summary>
/// Calculate the ease in out
/// </summary>
/// <param name="s">double</param>
/// <returns>double</returns>
public static double EaseInOut(double s)
{
return Math.Sin(s * Math.PI - Math.PI / 2 + 1) / 2;
}
/// <summary>
/// Calculate the ease out
/// </summary>
/// <param name="s">double</param>
/// <returns>double</returns>
public static double EaseOut(double s)
{
return Math.Sin(s * (Math.PI / 2));

View file

@ -24,8 +24,17 @@ namespace Greenshot.Addons.Animation
/// </summary>
public enum EasingModes
{
/// <summary>
/// Use ease in
/// </summary>
EaseIn,
/// <summary>
/// Use ease out
/// </summary>
EaseOut,
/// <summary>
/// Use ease in and out
/// </summary>
EaseInOut
}
}

View file

@ -24,12 +24,33 @@ namespace Greenshot.Addons.Animation
/// </summary>
public enum EasingTypes
{
/// <summary>
/// Use easing with steps
/// </summary>
Step,
/// <summary>
/// Use linear easing
/// </summary>
Linear,
/// <summary>
/// Use sine easing
/// </summary>
Sine,
/// <summary>
/// Use quadratic easing
/// </summary>
Quadratic,
/// <summary>
/// Use cubic easing
/// </summary>
Cubic,
/// <summary>
/// Use quartic easing
/// </summary>
Quartic,
/// <summary>
/// Use quintic easing
/// </summary>
Quintic
}
}

View file

@ -24,15 +24,20 @@ namespace Greenshot.Addons.Animation
/// </summary>
public class IntAnimator : AnimatorBase<int>
{
/// <summary>
/// Create an int animator
/// </summary>
/// <param name="first">int to start with</param>
/// <param name="last">int to end with</param>
/// <param name="frames">int with the number of frames</param>
/// <param name="easingType">EasingTypes</param>
/// <param name="easingMode">EasingModes</param>
public IntAnimator(int first, int last, int frames, EasingTypes easingType = EasingTypes.Linear, EasingModes easingMode = EasingModes.EaseIn)
: base(first, last, frames, easingType, easingMode)
{
}
/// <summary>
/// Calculate the next frame values
/// </summary>
/// <returns>int</returns>
/// <inheritdoc />
public override int Next()
{
if (!NextFrame)

View file

@ -31,10 +31,7 @@ namespace Greenshot.Addons.Animation
{
}
/// <summary>
/// Calculate the next frame value
/// </summary>
/// <returns>NativePoint</returns>
/// <inheritdoc />
public override NativePoint Next()
{
if (!NextFrame)

View file

@ -31,10 +31,7 @@ namespace Greenshot.Addons.Animation
{
}
/// <summary>
/// Calculate the next frame object
/// </summary>
/// <returns>NativeRect</returns>
/// <inheritdoc />
public override NativeRect Next()
{
if (!NextFrame)

View file

@ -31,10 +31,7 @@ namespace Greenshot.Addons.Animation
{
}
/// <summary>
/// Calculate the next frame values
/// </summary>
/// <returns>NativeSize</returns>
/// <inheritdoc />
public override NativeSize Next()
{
if (!NextFrame)

View file

@ -22,10 +22,16 @@ using System.ComponentModel.Composition;
namespace Greenshot.Addons.Components
{
/// <summary>
/// This attribute is used on a destination
/// </summary>
[MetadataAttribute]
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
public class DestinationAttribute : Attribute
{
/// <summary>
/// This is needed to make sure the values do not need to be specified
/// </summary>
public DestinationAttribute()
{
@ -55,7 +61,10 @@ namespace Greenshot.Addons.Components
}
}
/// <inheritdoc />
public string Designation { get; set; }
/// <inheritdoc />
public int Priority { get; set; } = 10;
}
}

View file

@ -19,18 +19,54 @@
namespace Greenshot.Addons.Components
{
/// <summary>
/// This is used to order the destinations
/// </summary>
public enum DestinationOrder
{
/// <summary>
/// Order for the File without a dialog destination
/// </summary>
FileNoDialog = 0,
/// <summary>
/// Order for the file with dialog destination
/// </summary>
FileDialog = 0,
/// <summary>
/// Order for the picker destination
/// </summary>
Picker = 1,
/// <summary>
/// Order for the Printer destination
/// </summary>
Printer = 2,
/// <summary>
/// Order for the Clipboard destination
/// </summary>
Clipboard = 2,
/// <summary>
/// Order for the Email destination
/// </summary>
Email = 3,
/// <summary>
/// Order for the Outlook destination
/// </summary>
Outlook = 3,
/// <summary>
/// Order for the Word destination
/// </summary>
Word = 4,
/// <summary>
/// Order for the PowerPoint destination
/// </summary>
Powerpoint = 4,
/// <summary>
/// Order for the OneNote destination
/// </summary>
OneNote = 4,
/// <summary>
/// Order for the Excel destination
/// </summary>
Excel = 5,
}

View file

@ -38,6 +38,12 @@ namespace Greenshot.Addons.Components
private readonly IEventAggregator _eventAggregator;
private readonly Func<IDestination, ExportInformation, ISurface, IConfigScreen, Owned<ExportNotificationViewModel>> _toastFactory;
/// <summary>
/// DI Constructor
/// </summary>
/// <param name="coreConfiguration">ICoreConfiguration</param>
/// <param name="eventAggregator">IEventAggregator</param>
/// <param name="toastFactory">Func to create toasts</param>
public ExportNotification(
ICoreConfiguration coreConfiguration,
IEventAggregator eventAggregator,

View file

@ -27,6 +27,10 @@ namespace Greenshot.Addons.Components
/// </summary>
public interface IDestinationProvider
{
/// <summary>
/// Provide destinations
/// </summary>
/// <returns>IEnumerable with lazy IDestinations</returns>
IEnumerable<Lazy<IDestination, DestinationAttribute>> Provide();
}
}

View file

@ -30,111 +30,303 @@ using Greenshot.Core.Enums;
namespace Greenshot.Addons.Config.Impl
{
/// <summary>
/// Implementation of the ICoreConfiguration
/// </summary>
public class CoreConfigurationImpl : IniSectionBase<ICoreConfiguration>, ICoreConfiguration
{
/// <inheritdoc />
public override void AfterLoad()
{
CoreConfigurationExtensions.AfterLoad(this);
}
/// <inheritdoc />
public string OutputFilePath { get; set; }
/// <inheritdoc />
public bool OutputFileAllowOverwrite { get; set; }
/// <inheritdoc />
public string OutputFileFilenamePattern { get; set; }
/// <inheritdoc />
public OutputFormats OutputFileFormat { get; set; }
/// <inheritdoc />
public bool OutputFileReduceColors { get; set; }
/// <inheritdoc />
public bool OutputFileAutoReduceColors { get; set; }
/// <inheritdoc />
public int OutputFileReduceColorsTo { get; set; }
/// <inheritdoc />
public int OutputFileJpegQuality { get; set; }
/// <inheritdoc />
public bool OutputFilePromptQuality { get; set; }
/// <inheritdoc />
public uint OutputFileIncrementingNumber { get; set; }
/// <inheritdoc />
public string OptimizePNGCommand { get; set; }
/// <inheritdoc />
public string OptimizePNGCommandArguments { get; set; }
/// <inheritdoc />
public NativeSize Win10BorderCrop { get; set; }
/// <inheritdoc />
public bool CaptureMousepointer { get; set; }
/// <inheritdoc />
public bool CaptureWindowsInteractive { get; set; }
/// <inheritdoc />
public int CaptureDelay { get; set; }
/// <inheritdoc />
public ScreenCaptureMode ScreenCaptureMode { get; set; }
/// <inheritdoc />
public int ScreenToCapture { get; set; }
/// <inheritdoc />
public WindowCaptureModes WindowCaptureMode { get; set; }
/// <inheritdoc />
public Color DWMBackgroundColor { get; set; }
/// <inheritdoc />
public IList<string> NoGDICaptureForProduct { get; set; }
/// <inheritdoc />
public IList<string> NoDWMCaptureForProduct { get; set; }
/// <inheritdoc />
public bool WindowCaptureRemoveCorners { get; set; }
/// <inheritdoc />
public IList<int> WindowCornerCutShape { get; set; }
/// <inheritdoc />
public string Language { get; set; }
/// <inheritdoc />
public string RegionHotkey { get; set; }
/// <inheritdoc />
public string WindowHotkey { get; set; }
/// <inheritdoc />
public string FullscreenHotkey { get; set; }
/// <inheritdoc />
public string LastregionHotkey { get; set; }
/// <inheritdoc />
public string IEHotkey { get; set; }
/// <inheritdoc />
public bool IsFirstLaunch { get; set; }
/// <inheritdoc />
public IList<string> OutputDestinations { get; set; }
/// <inheritdoc />
public IList<string> PickerDestinations { get; set; }
/// <inheritdoc />
public IList<ClipboardFormats> ClipboardFormats { get; set; }
/// <inheritdoc />
public bool WindowCaptureAllChildLocations { get; set; }
/// <inheritdoc />
public bool PlayCameraSound { get; set; }
/// <inheritdoc />
public bool ShowTrayNotification { get; set; }
/// <inheritdoc />
public bool OutputFileCopyPathToClipboard { get; set; }
/// <inheritdoc />
public string OutputFileAsFullpath { get; set; }
/// <inheritdoc />
public bool OutputPrintPromptOptions { get; set; }
/// <inheritdoc />
public bool OutputPrintAllowRotate { get; set; }
/// <inheritdoc />
public bool OutputPrintAllowEnlarge { get; set; }
/// <inheritdoc />
public bool OutputPrintAllowShrink { get; set; }
/// <inheritdoc />
public bool OutputPrintCenter { get; set; }
/// <inheritdoc />
public bool OutputPrintInverted { get; set; }
/// <inheritdoc />
public bool OutputPrintGrayscale { get; set; }
/// <inheritdoc />
public bool OutputPrintMonochrome { get; set; }
/// <inheritdoc />
public byte OutputPrintMonochromeThreshold { get; set; }
/// <inheritdoc />
public bool OutputPrintFooter { get; set; }
/// <inheritdoc />
public string OutputPrintFooterPattern { get; set; }
/// <inheritdoc />
public string NotificationSound { get; set; }
/// <inheritdoc />
public bool UseProxy { get; set; }
/// <inheritdoc />
public bool IECapture { get; set; }
/// <inheritdoc />
public bool IEFieldCapture { get; set; }
/// <inheritdoc />
public IList<string> WindowClassesToCheckForIE { get; set; }
/// <inheritdoc />
public int AutoCropDifference { get; set; }
/// <inheritdoc />
public IList<string> IncludePlugins { get; set; }
/// <inheritdoc />
public IList<string> ExcludePlugins { get; set; }
/// <inheritdoc />
public IList<string> ExcludeDestinations { get; set; }
/// <inheritdoc />
public bool CheckForUpdates { get; set; }
/// <inheritdoc />
public int UpdateCheckInterval { get; set; }
/// <inheritdoc />
public DateTime LastUpdateCheck { get; set; }
/// <inheritdoc />
public bool DisableSettings { get; set; }
/// <inheritdoc />
public bool DisableQuickSettings { get; set; }
/// <inheritdoc />
public bool HideTrayicon { get; set; }
/// <inheritdoc />
public bool HideExpertSettings { get; set; }
/// <inheritdoc />
public bool ThumnailPreview { get; set; }
/// <inheritdoc />
public bool OptimizeForRDP { get; set; }
/// <inheritdoc />
public bool DisableRDPOptimizing { get; set; }
/// <inheritdoc />
public bool MinimizeWorkingSetSize { get; set; }
/// <inheritdoc />
public bool CheckForUnstable { get; set; }
/// <inheritdoc />
public IList<string> ActiveTitleFixes { get; set; }
/// <inheritdoc />
public IDictionary<string, string> TitleFixMatcher { get; set; }
/// <inheritdoc />
public IDictionary<string, string> TitleFixReplacer { get; set; }
/// <inheritdoc />
public IList<string> ExperimentalFeatures { get; set; }
/// <inheritdoc />
public bool EnableSpecialDIBClipboardReader { get; set; }
/// <inheritdoc />
public ClickActions LeftClickAction { get; set; }
/// <inheritdoc />
public ClickActions DoubleClickAction { get; set; }
/// <inheritdoc />
public bool ZoomerEnabled { get; set; }
/// <inheritdoc />
public float ZoomerOpacity { get; set; }
/// <inheritdoc />
public int MaxMenuItemLength { get; set; }
/// <inheritdoc />
public string MailApiTo { get; set; }
/// <inheritdoc />
public string MailApiCC { get; set; }
/// <inheritdoc />
public string MailApiBCC { get; set; }
/// <inheritdoc />
public string LastSaveWithVersion { get; set; }
/// <inheritdoc />
public bool ProcessEXIFOrientation { get; set; }
/// <inheritdoc />
public NativeRect LastCapturedRegion { get; set; }
/// <inheritdoc />
public NativeSize IconSize { get; set; }
/// <inheritdoc />
public int WebRequestTimeout { get; set; }
/// <inheritdoc />
public int WebRequestReadWriteTimeout { get; set; }
/// <inheritdoc />
public bool IsScrollingCaptureEnabled { get; set; }
/// <inheritdoc />
public bool IsPortable { get; set; }
/// <inheritdoc />
public ISet<string> Permissions { get; set; }
/// <inheritdoc />
public WindowStartupLocation DefaultWindowStartupLocation { get; set; }
/// <inheritdoc />
public bool AreWindowLocationsStored { get; set; }
/// <inheritdoc />
public IDictionary<string, WindowPlacement> WindowLocations { get; set; }
}
}

View file

@ -33,6 +33,9 @@ namespace Greenshot.Addons.Controls
/// </summary>
public class AnimatingForm : GreenshotForm
{
/// <summary>
/// The ICoreConfiguration which can be used in all derived forms
/// </summary>
protected readonly ICoreConfiguration _coreConfiguration;
private const int DefaultVerticalRefresh = 60;
private static readonly LogSource Log = new LogSource();

View file

@ -26,12 +26,17 @@ using Greenshot.Addons.Resources;
namespace Greenshot.Addons.Controls
{
/// <summary>
/// Description of PleaseWaitForm.
/// This form is used to show in the background
/// </summary>
public sealed partial class BackgroundForm : Form
{
private volatile bool _shouldClose;
/// <summary>
/// Constructor for the form
/// </summary>
/// <param name="title">string</param>
/// <param name="text">string</param>
public BackgroundForm(string title, string text)
{
//
@ -51,6 +56,12 @@ namespace Greenshot.Addons.Controls
ShowDialog();
}
/// <summary>
/// Show this form an wait
/// </summary>
/// <param name="title">string</param>
/// <param name="text">string</param>
/// <returns>BackgroundForm</returns>
public static BackgroundForm ShowAndWait(string title, string text)
{
var backgroundForm = new BackgroundForm(title, text);
@ -63,7 +74,9 @@ namespace Greenshot.Addons.Controls
return backgroundForm;
}
// Can be used instead of ShowDialog
/// <summary>
/// Can be used instead of ShowDialog
/// </summary>
public new void Show()
{
base.Show();
@ -100,6 +113,9 @@ namespace Greenshot.Addons.Controls
}
}
/// <summary>
/// Close the form
/// </summary>
public void CloseDialog()
{
_shouldClose = true;

View file

@ -26,6 +26,7 @@ namespace Greenshot.Addons.Controls
/// </summary>
public class FormWithoutActivation : Form
{
/// <inheritdoc />
protected override bool ShowWithoutActivation
{
get { return true; }

View file

@ -22,8 +22,14 @@ using System.Windows.Forms;
namespace Greenshot.Addons.Controls
{
/// <summary>
/// This is a button which takes it translation via the set language key
/// </summary>
public class GreenshotButton : Button, IGreenshotLanguageBindable
{
/// <summary>
/// The key for the translation to use
/// </summary>
[Category("Greenshot")]
[DefaultValue(null)]
[Description("Specifies key of the language file to use when displaying the text.")]

View file

@ -27,16 +27,25 @@ namespace Greenshot.Addons.Controls
/// </summary>
public class GreenshotCheckBox : CheckBox, IGreenshotLanguageBindable, IGreenshotConfigBindable
{
/// <summary>
/// Name of the section to use for the checkbox value
/// </summary>
[Category("Greenshot")]
[DefaultValue("Core")]
[Description("Specifies the Ini-Section to map this control with.")]
public string SectionName { get; set; } = "Core";
/// <summary>
/// Name of the propety to use for the checkbox value
/// </summary>
[Category("Greenshot")]
[DefaultValue(null)]
[Description("Specifies the property name to map the configuration.")]
public string PropertyName { get; set; }
/// <summary>
/// Key for the translation of the label belonging to the checkbox
/// </summary>
[Category("Greenshot")]
[DefaultValue(null)]
[Description("Specifies key of the language file to use when displaying the text.")]

View file

@ -25,6 +25,9 @@ using Dapplo.Config.Language;
namespace Greenshot.Addons.Controls
{
/// <summary>
/// A special combox box which can show a list of translated enum values
/// </summary>
public class GreenshotComboBox : ComboBox, IGreenshotConfigBindable
{
private readonly ILanguage _language;
@ -104,7 +107,6 @@ namespace Greenshot.Addons.Controls
/// </summary>
private void StoreSelectedEnum()
{
var enumTypeName = _enumType.Name;
var selectedValue = SelectedItem as string;
var availableValues = Enum.GetValues(_enumType);
object returnValue = null;

View file

@ -45,6 +45,9 @@ namespace Greenshot.Addons.Controls
private static readonly IDictionary<Type, FieldInfo[]> ReflectionCache = new Dictionary<Type, FieldInfo[]>();
private readonly ILanguage _language;
/// <summary>
/// This is the bitmap scale handler
/// </summary>
protected readonly BitmapScaleHandler<string, IBitmapWithNativeSupport> ScaleHandler;
#if DEBUG
@ -63,8 +66,14 @@ namespace Greenshot.Addons.Controls
ScaleHandler = BitmapScaleHandler.Create<string, IBitmapWithNativeSupport>(FormDpiHandler, (imageName, dpi) => GreenshotResources.Instance.GetBitmap(imageName, GetType()), (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));
}
/// <summary>
/// manually apply the language
/// </summary>
protected bool ManualLanguageApply { get; set; }
/// <summary>
/// Manually apply the field values
/// </summary>
protected bool ManualStoreFields { get; set; }
/// <summary>
@ -72,11 +81,15 @@ namespace Greenshot.Addons.Controls
/// </summary>
protected bool ToFront { get; set; }
/// <summary>
/// The kex for the translation
/// </summary>
[Category("Greenshot")]
[DefaultValue(null)]
[Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey { get; set; }
/// <inheritdoc />
protected override void OnLoad(EventArgs e)
{
// Every GreenshotForm should have it's default icon
@ -383,6 +396,9 @@ namespace Greenshot.Addons.Controls
OnFieldsFilled();
}
/// <summary>
/// This is called when the fields are filled
/// </summary>
protected virtual void OnFieldsFilled()
{
}

View file

@ -22,8 +22,14 @@ using System.Windows.Forms;
namespace Greenshot.Addons.Controls
{
/// <summary>
/// This is a group box where you can specify the key for the translation
/// </summary>
public class GreenshotGroupBox : GroupBox, IGreenshotLanguageBindable
{
/// <summary>
/// Key for the translation
/// </summary>
[Category("Greenshot")]
[DefaultValue(null)]
[Description("Specifies key of the language file to use when displaying the text.")]

View file

@ -42,6 +42,10 @@ namespace Greenshot.Addons.Controls
private readonly CancellationTokenSource _cancellationTokenSource;
private Thread _waitFor;
/// <summary>
/// DI Constructor
/// </summary>
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
public PleaseWaitForm(IGreenshotLanguage greenshotLanguage)
{
_greenshotLanguage = greenshotLanguage;
@ -52,11 +56,17 @@ namespace Greenshot.Addons.Controls
Icon = GreenshotResources.Instance.GetGreenshotIcon();
}
/// <summary>
/// DI Constructor
/// </summary>
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
/// <param name="cancellationTokenSource">CancellationTokenSource</param>
public PleaseWaitForm(IGreenshotLanguage greenshotLanguage, CancellationTokenSource cancellationTokenSource = default) : this(greenshotLanguage)
{
_cancellationTokenSource = cancellationTokenSource;
}
/// <inheritdoc/>
protected override CreateParams CreateParams
{
get

View file

@ -32,6 +32,11 @@ namespace Greenshot.Addons.Controls
{
private readonly Type _resourceType;
private readonly List<IBitmapWithNativeSupport> _images = new List<IBitmapWithNativeSupport>();
/// <summary>
/// A constructor where one specifies the type which contains the resources
/// </summary>
/// <param name="resourceType">Type</param>
public ResourceImageManager(Type resourceType)
{
_resourceType = resourceType;
@ -63,11 +68,15 @@ namespace Greenshot.Addons.Controls
}
}
/// <inheritdoc />
public void Dispose()
{
ReleaseUnmanagedResources();
}
/// <summary>
/// Destructor
/// </summary>
~ResourceImageManager()
{
ReleaseUnmanagedResources();

View file

@ -38,8 +38,13 @@ namespace Greenshot.Addons.Controls
private readonly ICaptureDetails _captureDetails;
private DirectoryInfo _eagerlyCreatedDirectory;
private FilterOption[] _filterOptions;
protected SaveFileDialog SaveFileDialog;
private SaveFileDialog SaveFileDialog;
/// <summary>
/// DI Constructor
/// </summary>
/// <param name="coreConfiguration">ICoreConfiguration</param>
/// <param name="captureDetails">ICaptureDetails</param>
public SaveImageFileDialog(ICoreConfiguration coreConfiguration, ICaptureDetails captureDetails = null)
{
_coreConfiguration = coreConfiguration;
@ -108,11 +113,13 @@ namespace Greenshot.Addons.Controls
}
}
/// <inheritdoc />
public void Dispose()
{
Dispose(true);
}
/// <inheritdoc />
protected virtual void Dispose(bool disposing)
{
if (disposing)
@ -196,6 +203,10 @@ namespace Greenshot.Addons.Controls
}
}
/// <summary>
/// Show the save file dialog
/// </summary>
/// <returns></returns>
public DialogResult ShowDialog()
{
var ret = SaveFileDialog.ShowDialog();

View file

@ -26,6 +26,7 @@ namespace Greenshot.Addons.Core.Credentials
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/dpapiusercredentials.asp
/// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secauthn/security/creduipromptforcredentials.asp
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
[Flags]
public enum CredFlags
{

View file

@ -19,6 +19,10 @@
namespace Greenshot.Addons.Core.Enums
{
/// <summary>
/// Specify what action a click resolves to
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum ClickActions
{
DO_NOTHING,

View file

@ -19,6 +19,10 @@
namespace Greenshot.Addons.Core.Enums
{
/// <summary>
/// Specify the formats of the clipboard
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum ClipboardFormats
{
NONE,

View file

@ -19,6 +19,10 @@
namespace Greenshot.Addons.Core.Enums
{
/// <summary>
/// This is used to specify where configuration viewmodels are located
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum ConfigIds
{
Ui,

View file

@ -34,6 +34,7 @@ namespace Greenshot.Addons.Core
/// </summary>
[IniSection("Core")]
[Description("Greenshot core configuration")]
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface ICoreConfiguration : IIniSection, IFileConfiguration, ICaptureConfiguration, IUiConfiguration
{
[Description("The language in IETF format (e.g. en-US)")]

View file

@ -25,6 +25,7 @@ namespace Greenshot.Addons.Core
/// <summary>
/// File configuration.
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface IFileConfiguration
{
[Description("Output file path.")]

View file

@ -22,9 +22,13 @@ using Dapplo.Config.Language;
namespace Greenshot.Addons
{
/// <summary>
/// This specifies many translations
/// </summary>
[Language("Core")]
public interface IGreenshotLanguage : ILanguage, Dapplo.CaliburnMicro.Translations.ICoreTranslations
{
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
string None { get; }
string AboutBugs { get; }
string AboutDonations { get; }

View file

@ -22,6 +22,7 @@ namespace Greenshot.Addons.Interfaces
/// <summary>
/// The capture mode for Greenshot
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum CaptureMode
{
None,

View file

@ -19,6 +19,10 @@
namespace Greenshot.Addons.Interfaces
{
/// <summary>
/// What are we drawing?
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public enum DrawingModes
{
None,

View file

@ -6,6 +6,10 @@ using Greenshot.Core.Enums;
namespace Greenshot.Core.Configuration
{
/// <summary>
/// The configuration for capturing
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public interface ICaptureConfiguration
{
[Description("The capture is cropped with these settings, e.g. when you don't want to color around it -1,-1")]

View file

@ -20,17 +20,41 @@
namespace Greenshot.Core.Enums
{
/// <summary>
/// This is used to specified what type of capture
/// This is used to specified what type elements in an capture are
/// </summary>
public enum CaptureElementType
{
/// <summary>
/// Not specified
/// </summary>
Unknown,
/// <summary>
/// Screen
/// </summary>
Screen,
/// <summary>
/// Mouse
/// </summary>
Mouse,
/// <summary>
/// Cursor
/// </summary>
Cursor,
/// <summary>
/// Icon
/// </summary>
Icon,
/// <summary>
/// Popup
/// </summary>
Popup,
/// <summary>
/// Window
/// </summary>
Window,
/// <summary>
/// File
/// </summary>
File
}
}

View file

@ -19,14 +19,38 @@
namespace Greenshot.Core.Enums
{
/// <summary>
/// The output formats we support
/// </summary>
public enum OutputFormats
{
/// <summary>
/// Specify bmp to write bitmap files
/// </summary>
bmp,
/// <summary>
/// Specify gif to write gif files
/// </summary>
gif,
/// <summary>
/// Specify jpg to write bitjpgmap files
/// </summary>
jpg,
/// <summary>
/// Specify png to write png files
/// </summary>
png,
/// <summary>
/// Specify tiff to write tiff files
/// </summary>
tiff,
/// <summary>
/// Specify greenshot to write greenshot files with annotations and a PNG bitmap
/// </summary>
greenshot,
/// <summary>
/// Specify ico to write icon files
/// </summary>
ico
}
}

View file

@ -19,10 +19,22 @@
namespace Greenshot.Core.Enums
{
/// <summary>
/// These are the different screen capture modus
/// </summary>
public enum ScreenCaptureMode
{
/// <summary>
/// Automatically select the mode
/// </summary>
Auto,
/// <summary>
/// Capture the whole screen
/// </summary>
FullScreen,
/// <summary>
/// Specify the screen to capture
/// </summary>
Fixed
}
}

View file

@ -19,12 +19,32 @@
namespace Greenshot.Core.Enums
{
/// <summary>
/// These are the possible ways to capture a window
/// </summary>
public enum WindowCaptureModes
{
/// <summary>
/// USe the screen
/// </summary>
Screen,
/// <summary>
/// Use GDI "print"
/// </summary>
Gdi,
/// <summary>
/// Use Aero to clone the window and the screen to capture.
/// This mode will remove transparency
/// </summary>
Aero,
/// <summary>
/// Use Aero to clone the window and the screen to capture.
/// This mode will maintain transparency
/// </summary>
AeroTransparent,
/// <summary>
/// Automatically select the modus
/// </summary>
Auto
}
}

View file

@ -36,12 +36,18 @@ namespace Greenshot.Core.Sources
private readonly ICaptureConfiguration _captureConfiguration;
private readonly Func<IInteropWindow> _retrieveWindowFunc;
/// <summary>
/// Constructor
/// </summary>
/// <param name="captureConfiguration">ICaptureConfiguration</param>
/// <param name="retrieveWindowFunc">Func to select the window</param>
public DwmWindowSource(ICaptureConfiguration captureConfiguration, Func<IInteropWindow> retrieveWindowFunc = null)
{
_captureConfiguration = captureConfiguration;
_retrieveWindowFunc = retrieveWindowFunc ?? InteropWindowQuery.GetForegroundWindow;
}
/// <inheritdoc/>
public ValueTask<ICaptureElement<BitmapSource>> Import(CancellationToken cancellationToken = default)
{
var window = _retrieveWindowFunc();

View file

@ -32,7 +32,12 @@ namespace Greenshot.Core.Templates
/// </summary>
public class CroppedTemplate : ITemplate<BitmapSource>
{
/// <summary>
/// Specify if the mouse cursor should be displayed
/// </summary>
public bool DisplayMouse { get; set; } = true;
/// <inheritdoc/>
public FrameworkElement Apply(ICapture<BitmapSource> capture)
{
var width = (int)(capture.CropRect.Width + 0.5);
@ -62,7 +67,7 @@ namespace Greenshot.Core.Templates
foreach (var captureCaptureElement in capture.CaptureElements)
{
// Skip mouse cursor
if (captureCaptureElement.ElementType == CaptureElementType.Cursor && DisplayMouse)
if (captureCaptureElement.ElementType == CaptureElementType.Cursor && !DisplayMouse)
{
continue;
}

View file

@ -31,7 +31,12 @@ namespace Greenshot.Core.Templates
/// </summary>
public class SimpleTemplate : ITemplate<BitmapSource>
{
/// <summary>
/// Specify if the mouse should be shown
/// </summary>
public bool DisplayMouse { get; set; } = true;
/// <inheritdoc/>
public FrameworkElement Apply(ICapture<BitmapSource> capture)
{
var canvas = new Canvas
@ -43,7 +48,7 @@ namespace Greenshot.Core.Templates
foreach (var captureCaptureElement in capture.CaptureElements)
{
// Skip mouse cursor
if (captureCaptureElement.ElementType == CaptureElementType.Cursor && DisplayMouse)
if (captureCaptureElement.ElementType == CaptureElementType.Cursor && !DisplayMouse)
{
continue;
}

View file

@ -125,6 +125,9 @@ namespace Greenshot.Gfx
};
}
/// <summary>
/// This defines all available bitmap reader functions, registered to an "extension" is called with a stream to a IBitmap.
/// </summary>
public static IDictionary<string, Func<Stream, string, IBitmapWithNativeSupport>> StreamConverters { get; } = new Dictionary<string, Func<Stream, string, IBitmapWithNativeSupport>>(StringComparer.OrdinalIgnoreCase);
/// <summary>

View file

@ -32,6 +32,10 @@ namespace Greenshot.Gfx
// Underlying image
private readonly Bitmap _bitmap;
/// <summary>
/// Constructor taking a Bitmap
/// </summary>
/// <param name="bitmap"></param>
public BitmapWrapper(Bitmap bitmap)
{
// Make sure the orientation is set correctly so Greenshot can process the image correctly
@ -39,6 +43,7 @@ namespace Greenshot.Gfx
_bitmap = bitmap;
}
/// <inheritdoc/>
public void Dispose()
{
_bitmap.Dispose();

View file

@ -29,12 +29,22 @@ namespace Greenshot.Gfx.Effects
/// </summary>
public class AdjustEffect : IEffect
{
/// <summary>
/// The contrast for the effect
/// </summary>
public float Contrast { get; set; } = 1f;
/// <summary>
/// The brightness for the effect
/// </summary>
public float Brightness { get; set; } = 1f;
/// <summary>
/// The gamma for the effect
/// </summary>
public float Gamma { get; set; } = 1f;
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return Adjust(sourceBitmap, Brightness, Contrast, Gamma);

View file

@ -29,8 +29,12 @@ namespace Greenshot.Gfx.Effects
[TypeConverter(typeof(EffectConverter))]
public class BlurEffect : IEffect
{
/// <summary>
/// The range for the blur
/// </summary>
public int Range { get; set; } = 3;
/// <inheritdoc />
public virtual IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
var result = FastBitmapFactory.CreateCloneOf(sourceBitmap);

View file

@ -29,10 +29,17 @@ namespace Greenshot.Gfx.Effects
/// </summary>
public class BorderEffect : IEffect
{
/// <summary>
/// The color of the border
/// </summary>
public Color Color { get; set; } = Color.Black;
/// <summary>
/// The width of the border
/// </summary>
public int Width { get; set; } = 2;
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return CreateBorder(sourceBitmap, Width, Color, sourceBitmap.PixelFormat, matrix);

View file

@ -34,12 +34,16 @@ namespace Greenshot.Gfx.Effects
// Fix to prevent BUG-1753
private readonly NumberFormatInfo _numberFormatInfo = new NumberFormatInfo();
/// <summary>
/// Default constructor
/// </summary>
public EffectConverter()
{
_numberFormatInfo.NumberDecimalSeparator = ".";
_numberFormatInfo.NumberGroupSeparator = ",";
}
/// <inheritdoc />
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(string))
@ -49,11 +53,13 @@ namespace Greenshot.Gfx.Effects
return base.CanConvertFrom(context, sourceType);
}
/// <inheritdoc />
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(string) || destinationType == typeof(DropShadowEffect) || destinationType == typeof(TornEdgeEffect) || base.CanConvertTo(context, destinationType);
}
/// <inheritdoc />
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
// to string
@ -93,6 +99,7 @@ namespace Greenshot.Gfx.Effects
return base.ConvertTo(context, culture, value, destinationType);
}
/// <inheritdoc />
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (!(value is string settings))
@ -102,6 +109,7 @@ namespace Greenshot.Gfx.Effects
return ConvertTo(context, culture, settings, settings.Contains("ToothHeight") ? typeof(TornEdgeEffect) : typeof(DropShadowEffect));
}
/// <inheritdoc />
private void ApplyDropShadowEffectValues(string valuesString, DropShadowEffect effect)
{
var values = valuesString.Split('|');

View file

@ -27,6 +27,8 @@ namespace Greenshot.Gfx.Effects
/// </summary>
public class InvertEffect : IEffect
{
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return CreateNegative(sourceBitmap);

View file

@ -37,6 +37,7 @@ namespace Greenshot.Gfx.Effects
_threshold = threshold;
}
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return CreateMonochrome(sourceBitmap, _threshold);

View file

@ -31,8 +31,12 @@ namespace Greenshot.Gfx.Effects
{
private static readonly LogSource Log = new LogSource();
/// <summary>
/// The amount of colors the bitmap is allowed to have
/// </summary>
public int Colors { get; set; } = 256;
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
using (var quantizer = new WuQuantizer(sourceBitmap))

View file

@ -23,10 +23,17 @@ using System.Drawing.Drawing2D;
namespace Greenshot.Gfx.Effects
{
/// <summary>
/// ResizeCanvasEffect
/// This effect will enlange the bitmap with the specified pixels to the left, right, top, bottom
/// </summary>
public class ResizeCanvasEffect : IEffect
{
/// <summary>
/// The constructor which takes the sizes to grow the canvas
/// </summary>
/// <param name="left">int</param>
/// <param name="right">int</param>
/// <param name="top">int</param>
/// <param name="bottom">int</param>
public ResizeCanvasEffect(int left, int right, int top, int bottom)
{
Left = left;
@ -36,16 +43,32 @@ namespace Greenshot.Gfx.Effects
BackgroundColor = Color.Empty; // Uses the default background color depending on the format
}
/// <summary>
/// The pixels which need to be added left
/// </summary>
public int Left { get; set; }
/// <summary>
/// The pixels which need to be added right
/// </summary>
public int Right { get; set; }
/// <summary>
/// The pixels which need to be added top
/// </summary>
public int Top { get; set; }
/// <summary>
/// The pixels which need to be added bottom
/// </summary>
public int Bottom { get; set; }
/// <summary>
/// The color of the new pixels
/// </summary>
public Color BackgroundColor { get; set; }
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return BitmapHelper.ResizeCanvas(sourceBitmap, BackgroundColor, Left, Right, Top, Bottom, matrix);

View file

@ -22,10 +22,16 @@ using System.Drawing.Drawing2D;
namespace Greenshot.Gfx.Effects
{
/// <summary>
/// ResizeEffect
/// This effect resizes the bitmap
/// </summary>
public class ResizeEffect : IEffect
{
/// <summary>
/// The constructor which takes the new width and height and if the aspect ratio should be maintained
/// </summary>
/// <param name="width">int</param>
/// <param name="height">int</param>
/// <param name="maintainAspectRatio">bool</param>
public ResizeEffect(int width, int height, bool maintainAspectRatio)
{
Width = width;
@ -33,12 +39,22 @@ namespace Greenshot.Gfx.Effects
MaintainAspectRatio = maintainAspectRatio;
}
/// <summary>
/// The new width
/// </summary>
public int Width { get; set; }
/// <summary>
/// The new height
/// </summary>
public int Height { get; set; }
/// <summary>
/// Do we need to maintain the aspect ration
/// </summary>
public bool MaintainAspectRatio { get; set; }
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
return sourceBitmap.Resize(MaintainAspectRatio, Width, Height, matrix);

View file

@ -24,17 +24,25 @@ using System.Drawing.Drawing2D;
namespace Greenshot.Gfx.Effects
{
/// <summary>
/// RotateEffect
/// This effect rotates the bitmap, this will also resize the bitmap
/// </summary>
public class RotateEffect : IEffect
{
/// <summary>
/// The constructor which takes the angle
/// </summary>
/// <param name="angle">int with the angle</param>
public RotateEffect(int angle)
{
Angle = angle;
}
/// <summary>
/// The angle
/// </summary>
public int Angle { get; set; }
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
RotateFlipType flipType;

View file

@ -24,11 +24,12 @@ using Greenshot.Gfx.Extensions;
namespace Greenshot.Gfx.Effects
{
/// <summary>
/// Scale2x Effect
/// This effect scales the bitmap to 2x its size
/// </summary>
[TypeConverter(typeof(EffectConverter))]
public sealed class Scale2xEffect : IEffect
{
/// <inheritdoc />
public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
matrix?.Scale(2, 2, MatrixOrder.Append);

View file

@ -33,16 +33,32 @@ namespace Greenshot.Gfx.Effects
[TypeConverter(typeof(EffectConverter))]
public sealed class TornEdgeEffect : DropShadowEffect
{
/// <summary>
/// Height of the teeth
/// </summary>
public int ToothHeight { get; set; } = 12;
/// <summary>
/// How many teeth are horizontally displayed
/// </summary>
public int HorizontalToothRange { get; set; } = 20;
/// <summary>
/// How many teeth are vertically displayed
/// </summary>
public int VerticalToothRange { get; set; } = 20;
/// <summary>
/// Specify which edges should get teeth
/// </summary>
public bool[] Edges { get; set; } = { true, true, true, true };
/// <summary>
/// Generate a shadow?
/// </summary>
public bool GenerateShadow { get; set; } = true;
/// <inheritdoc/>
public override IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix)
{
var tmpTornImage = CreateTornEdge(sourceBitmap, ToothHeight, HorizontalToothRange, VerticalToothRange, Edges);
@ -56,7 +72,6 @@ namespace Greenshot.Gfx.Effects
}
}
/// <summary>
/// Helper method for the tornedge
/// </summary>

View file

@ -23,14 +23,17 @@ using Dapplo.Windows.Common.Structs;
namespace Greenshot.Gfx.Extensions
{
/// <summary>
/// These extensions are for the writable bitmap
/// </summary>
public static class WriteableBitmapExtensions
{
/// <summary>
/// Copy the rect from source to target
/// </summary>
/// <param name="target"></param>
/// <param name="source"></param>
/// <param name="rect"></param>
/// <param name="target">WriteableBitmap</param>
/// <param name="source">BitmapSource</param>
/// <param name="rect">BitmapSource</param>
public static void CopyPixels(this WriteableBitmap target, BitmapSource source, NativeRect rect)
{
// Calculate stride of source

View file

@ -27,6 +27,11 @@ namespace Greenshot.Gfx.FastBitmap
/// </summary>
public unsafe class Fast24RgbBitmap : FastBitmapBase
{
/// <summary>
/// Constructor which takes an IBitmap to wrap the fastbitmap logic around it
/// </summary>
/// <param name="source">IBitmapWithNativeSupport</param>
/// <param name="area">NativeRect optional</param>
public Fast24RgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area)
{
}

View file

@ -27,15 +27,23 @@ namespace Greenshot.Gfx.FastBitmap
/// </summary>
public unsafe class Fast32ArgbBitmap : FastBitmapBase, IFastBitmapWithBlend
{
/// <summary>
/// Constructor which takes an IBitmap to wrap the fastbitmap logic around it
/// </summary>
/// <param name="source">IBitmapWithNativeSupport</param>
/// <param name="area">NativeRect optional</param>
public Fast32ArgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area)
{
BackgroundBlendColor = Color.White;
}
/// <inheritdoc />
public override int BytesPerPixel { get; } = 4;
/// <inheritdoc />
public override bool HasAlphaChannel => true;
/// <inheritdoc />
public Color BackgroundBlendColor { get; set; }
/// <inheritdoc />

View file

@ -27,6 +27,11 @@ namespace Greenshot.Gfx.FastBitmap
/// </summary>
public unsafe class Fast32RgbBitmap : FastBitmapBase
{
/// <summary>
/// Constructor which takes an IBitmap to wrap the fastbitmap logic around it
/// </summary>
/// <param name="source">IBitmapWithNativeSupport</param>
/// <param name="area">NativeRect optional</param>
public Fast32RgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area)
{
}

View file

@ -476,11 +476,11 @@ namespace Greenshot.Gfx.FastBitmap
}
/// <summary>
/// returns true if x & y are inside the FastBitmap
/// returns true if x and y are inside the FastBitmap
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns>true if x & y are inside the FastBitmap</returns>
/// <returns>true if x and y are inside the FastBitmap</returns>
bool IFastBitmapWithOffset.Contains(int x, int y)
{
return Area.Contains(x - Left, y - Top);

View file

@ -33,6 +33,11 @@ namespace Greenshot.Gfx.FastBitmap
// Used for indexed images
private readonly Color[] _colorEntries;
/// <summary>
/// This contructor creates a FastBitmap for the specified source
/// </summary>
/// <param name="source">IBitmapWithNativeSupport</param>
/// <param name="area">NativeRect</param>
public FastChunkyBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area)
{
_colorEntries = Bitmap.NativeBitmap.Palette.Entries;

View file

@ -26,8 +26,14 @@ namespace Greenshot.Gfx.FastBitmap
/// </summary>
public unsafe interface IFastBitmapWithOffset : IFastBitmap
{
/// <summary>
/// Specify the x offset for the IFastBitmap
/// </summary>
new int Left { get; set; }
/// <summary>
/// Specify the y offset for the IFastBitmap
/// </summary>
new int Top { get; set; }
/// <summary>

View file

@ -0,0 +1,36 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// 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 1 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, see <http://www.gnu.org/licenses/>.
namespace Greenshot.Gfx.Legacy
{
public class FixedAngleRoundBehavior : IDoubleProcessor
{
private readonly double fixedAngle;
public FixedAngleRoundBehavior(double fixedAngle)
{
this.fixedAngle = fixedAngle;
}
public double Process(double angle)
{
return fixedAngle;
}
}
}

View file

@ -1,4 +1,4 @@
// Greenshot - a free and open source screenshot tool
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
@ -17,13 +17,18 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
namespace Greenshot.Addons.Core.Enums
namespace Greenshot.Gfx.Legacy
{
public enum BuildStates
/// <summary>
/// Every
/// </summary>
public interface IDoubleProcessor
{
ALPHA,
BETA,
RELEASE_CANDIDATE,
RELEASE
/// <summary>
/// Do the processing
/// </summary>
/// <param name="d">double</param>
/// <returns>double</returns>
double Process(double d);
}
}

View file

@ -0,0 +1,42 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// 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 1 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, see <http://www.gnu.org/licenses/>.
using System;
namespace Greenshot.Gfx.Legacy
{
/// <summary>
/// TODO: Describe
/// </summary>
public class LineAngleRoundBehavior : IDoubleProcessor
{
public static LineAngleRoundBehavior Instance = new LineAngleRoundBehavior();
private LineAngleRoundBehavior()
{
}
/// <inheritdoc/>
public double Process(double angle)
{
return Math.Round(angle / 15) * 15;
}
}
}

View file

@ -20,17 +20,41 @@
namespace Greenshot.Gfx.Legacy
{
/// <summary>
/// Position
/// This specifies the position of something
/// </summary>
public enum Positions
{
/// <summary>
/// Position top left
/// </summary>
TopLeft = 0,
/// <summary>
/// Position top center
/// </summary>
TopCenter = 1,
/// <summary>
/// Position top right
/// </summary>
TopRight = 2,
/// <summary>
/// Position middle right
/// </summary>
MiddleRight = 3,
/// <summary>
/// Position bottom right
/// </summary>
BottomRight = 4,
/// <summary>
/// Position bottom center
/// </summary>
BottomCenter = 5,
/// <summary>
/// Position bottom left
/// </summary>
BottomLeft = 6,
/// <summary>
/// Position middle left
/// </summary>
MiddleLeft = 7
}
}

View file

@ -26,6 +26,7 @@ namespace Greenshot.Gfx.Legacy
/// <summary>
/// TODO: currently this is only used in the capture form, we might move this code directly to there!
/// </summary>
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
public abstract class RoundedRectangle
{
[Flags]

View file

@ -28,26 +28,8 @@ namespace Greenshot.Gfx.Legacy
/// <summary>
/// Offers a few helper functions for scaling/aligning an element with another element
/// </summary>
public static class ScaleHelper
public static partial class ScaleHelper
{
[Flags]
public enum ScaleOptions
{
/// <summary>
/// Default scale behavior.
/// </summary>
Default = 0x00,
/// <summary>
/// Scale a rectangle in two our four directions, mirrored at it's center coordinates
/// </summary>
Centered = 0x01,
/// <summary>
/// Scale a rectangle maintaining it's aspect ratio
/// </summary>
Rational = 0x02
}
/// <summary>
/// calculates the Size an element must be resized to, in order to fit another element, keeping aspect ratio
@ -80,8 +62,8 @@ namespace Greenshot.Gfx.Legacy
/// <returns>a new NativeRectFloat object with Location aligned aligned to targetRect</returns>
public static NativeRectFloat GetAlignedRectangle(NativeRectFloat currentRect, NativeRectFloat targetRect, ContentAlignment alignment)
{
float x = targetRect.Location.X;
float y = targetRect.Location.Y;
var x = targetRect.Location.X;
var y = targetRect.Location.Y;
switch (alignment)
{
@ -210,10 +192,10 @@ namespace Greenshot.Gfx.Legacy
/// <param name="resizeHandleCoords">coordinates of the used handle/gripper</param>
private static void ScaleInternal(ref NativeRectFloat originalRectangle, Positions resizeHandlePosition, PointF resizeHandleCoords)
{
float x = originalRectangle.X;
float y = originalRectangle.Y;
float width = originalRectangle.Width;
float height = originalRectangle.Height;
var x = originalRectangle.X;
var y = originalRectangle.Y;
var width = originalRectangle.Width;
var height = originalRectangle.Height;
switch (resizeHandlePosition)
{
@ -421,54 +403,6 @@ namespace Greenshot.Gfx.Legacy
return opts;
}
public interface IDoubleProcessor
{
double Process(double d);
}
public class ShapeAngleRoundBehavior : IDoubleProcessor
{
public static ShapeAngleRoundBehavior Instance = new ShapeAngleRoundBehavior();
private ShapeAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round((angle + 45) / 90) * 90 - 45;
}
}
public class LineAngleRoundBehavior : IDoubleProcessor
{
public static LineAngleRoundBehavior Instance = new LineAngleRoundBehavior();
private LineAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round(angle / 15) * 15;
}
}
public class FixedAngleRoundBehavior : IDoubleProcessor
{
private readonly double fixedAngle;
public FixedAngleRoundBehavior(double fixedAngle)
{
this.fixedAngle = fixedAngle;
}
public double Process(double angle)
{
return fixedAngle;
}
}
/*public static int FindGripperPostition(float anchorX, float anchorY, float gripperX, float gripperY) {
if(gripperY > anchorY) {

View file

@ -0,0 +1,46 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// 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 1 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, see <http://www.gnu.org/licenses/>.
using System;
namespace Greenshot.Gfx.Legacy
{
/// <summary>
/// Specify options for scaling
/// </summary>
[Flags]
public enum ScaleOptions
{
/// <summary>
/// Default scale behavior.
/// </summary>
Default = 0x00,
/// <summary>
/// Scale a rectangle in two our four directions, mirrored at it's center coordinates
/// </summary>
Centered = 0x01,
/// <summary>
/// Scale a rectangle maintaining it's aspect ratio
/// </summary>
Rational = 0x02
}
}

View file

@ -0,0 +1,51 @@
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
//
// For more information see: http://getgreenshot.org/
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
//
// 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 1 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, see <http://www.gnu.org/licenses/>.
using System;
namespace Greenshot.Gfx.Legacy
{
public static partial class ScaleHelper
{
public class ShapeAngleRoundBehavior : IDoubleProcessor
{
public static ShapeAngleRoundBehavior Instance = new ShapeAngleRoundBehavior();
private ShapeAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round((angle + 45) / 90) * 90 - 45;
}
}
/*public static int FindGripperPostition(float anchorX, float anchorY, float gripperX, float gripperY) {
if(gripperY > anchorY) {
if(gripperX > anchorY) return Gripper.POSITION_BOTTOM_RIGHT;
else return Gripper.POSITION_BOTTOM_LEFT;
} else {
if(gripperX > anchorY) return Gripper.POSITION_TOP_RIGHT;
else return Gripper.POSITION_TOP_LEFT;
}
}*/
}
}

View file

@ -41,8 +41,14 @@ namespace Greenshot.Gfx
private uint _hash;
private uint _length;
/// <inheritdoc />
public override int HashSize => 32;
/// <summary>
/// Constructor for the Murmur3 algorythm
/// </summary>
/// <param name="seed"></param>
/// <param name="length"></param>
public Murmur3(uint seed, uint length = 0)
{
_seed = seed;

View file

@ -61,6 +61,10 @@ namespace Greenshot.Gfx.Quantizer
private byte[] _tag;
/// <summary>
/// The constructor for the WuQauntizer
/// </summary>
/// <param name="sourceBitmap"></param>
public WuQuantizer(IBitmapWithNativeSupport sourceBitmap)
{
_sourceBitmap = sourceBitmap;
@ -103,7 +107,6 @@ namespace Greenshot.Gfx.Quantizer
// Use a bitmap to store the initial match, which is just as good as an array and saves us 2x the storage
using (var sourceFastBitmap = FastBitmapFactory.Create(sourceBitmap))
{
var sourceFastBitmapWithBlend = sourceFastBitmap as IFastBitmapWithBlend;
sourceFastBitmap.Lock();
using (var destinationFastBitmap = FastBitmapFactory.CreateEmpty(sourceBitmap.Size, PixelFormat.Format8bppIndexed, Color.White) as FastChunkyBitmap)
{
@ -112,7 +115,7 @@ namespace Greenshot.Gfx.Quantizer
for (var x = 0; x < sourceFastBitmap.Width; x++)
{
Color color;
if (sourceFastBitmapWithBlend == null)
if (!(sourceFastBitmap is IFastBitmapWithBlend sourceFastBitmapWithBlend))
{
color = sourceFastBitmap.GetColorAt(x, y);
}
@ -149,6 +152,7 @@ namespace Greenshot.Gfx.Quantizer
}
}
}
/// <inheritdoc/>
public void Dispose()
{
@ -176,6 +180,10 @@ namespace Greenshot.Gfx.Quantizer
_resultBitmap = null;
}
/// <summary>
/// Returns the number of colors
/// </summary>
/// <returns>int</returns>
public int GetColorCount()
{
return _colorCount;
@ -194,15 +202,13 @@ namespace Greenshot.Gfx.Quantizer
bbbDest.Lock();
using (var bbbSrc = FastBitmapFactory.Create(_sourceBitmap))
{
var bbbSrcBlend = bbbSrc as IFastBitmapWithBlend;
bbbSrc.Lock();
for (var y = 0; y < bbbSrc.Height; y++)
{
for (var x = 0; x < bbbSrc.Width; x++)
{
Color color;
if (bbbSrcBlend != null)
if (bbbSrc is IFastBitmapWithBlend bbbSrcBlend)
{
color = bbbSrcBlend.GetBlendedColorAt(x, y);
}
@ -345,14 +351,13 @@ namespace Greenshot.Gfx.Quantizer
{
using (var src = FastBitmapFactory.Create(_sourceBitmap))
{
var srcBlend = src as IFastBitmapWithBlend;
var lookup = new Dictionary<Color, byte>();
for (var y = 0; y < src.Height; y++)
{
for (var x = 0; x < src.Width; x++)
{
Color color;
if (srcBlend != null)
if (src is IFastBitmapWithBlend srcBlend)
{
// WithoutAlpha, this makes it possible to ignore the alpha
color = srcBlend.GetBlendedColorAt(x, y);

View file

@ -25,6 +25,9 @@ using Greenshot.Gfx.FastBitmap;
namespace Greenshot.Gfx
{
/// <summary>
/// This is the scale X implementation using IFastBitmap
/// </summary>
public static class ScaleX
{
/// <summary>

View file

@ -24,8 +24,16 @@ using System.Drawing;
namespace Greenshot.Gfx.Structs
{
/// <summary>
/// These are extensions to help with pixels
/// </summary>
public static class PixelExtensions
{
/// <summary>
/// Make a Brga32 from the specified color
/// </summary>
/// <param name="color">Color</param>
/// <returns>Bgr32</returns>
public static Bgra32 FromColorWithAlpha(this Color color)
{
return new Bgra32
@ -36,6 +44,12 @@ namespace Greenshot.Gfx.Structs
B = color.B,
};
}
/// <summary>
/// Make a Brg32 from the specified color
/// </summary>
/// <param name="color">Color</param>
/// <returns>Bgr32</returns>
public static Bgr32 FromColor(this Color color)
{
return new Bgr32

View file

@ -148,6 +148,7 @@ namespace Greenshot.Gfx
return _imageClone;
}
/// <inheritdoc/>
public Size Size => new Size(Width, Height);
/// <summary>

View file

@ -154,6 +154,9 @@ namespace Greenshot.Gfx
}
}
/// <summary>
/// Returns the pixel format for this Unmanaged bitmap
/// </summary>
public System.Windows.Media.PixelFormat WpfPixelFormat
{
get
@ -203,6 +206,7 @@ namespace Greenshot.Gfx
}
}
/// <inheritdoc/>
public Size Size => new Size(Width, Height);
/// <summary>