diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Adorners/TargetAdorner.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Adorners/TargetAdorner.cs index 5147c2a9d..2940899e9 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/Adorners/TargetAdorner.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Adorners/TargetAdorner.cs @@ -31,10 +31,13 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Adorners /// 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; + } /// /// Handle the mouse down @@ -96,8 +99,12 @@ 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); + + } + } /// /// Made sure this adorner is transformed diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs index 203351bef..35ec6f29a 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs @@ -110,26 +110,41 @@ namespace Greenshot.Addon.LegacyEditor.Drawing } } + /// + /// The adorner for the target + /// public TargetAdorner TargetAdorner { get { return _targetAdorner; } } + /// + /// Specifies if this contain has a context menu + /// public virtual bool HasContextMenu { get { return true; } } + /// + /// Specifies if this container has a default size + /// public virtual bool HasDefaultSize { get { return false; } } + /// + /// The default size + /// public virtual Size DefaultSize { get { throw new NotSupportedException("Object doesn't have a default size"); } } + /// + /// This specifies the edit status + /// public EditStatus DefaultEditMode { get { return _defaultEditMode; } @@ -145,18 +160,27 @@ namespace Greenshot.Addon.LegacyEditor.Drawing GC.SuppressFinalize(this); } + /// + /// The property change event is triggered when a property is changed + /// public event PropertyChangedEventHandler PropertyChanged { add { _propertyChanged += value; } remove { _propertyChanged -= value; } } + /// + /// The surface this container belongs to + /// public ISurface Parent { get { return _parent; } set { SwitchParent((Surface) value); } } + /// + /// Is this container selected? + /// public bool Selected { get { return _selected; } @@ -493,6 +517,9 @@ namespace Greenshot.Addon.LegacyEditor.Drawing return (int) Math.Round(f); } + /// + /// This is called when the container is double clicked + /// public virtual void OnDoubleClick() { } @@ -502,7 +529,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing /// 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; } diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs index ef0cc38ca..5b019d54f 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs @@ -36,11 +36,17 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10; + /// + /// Constructor taking all dependencies + /// + /// parent + /// IEditorConfiguration public LineContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration) { Init(); } + /// protected override void InitializeFields() { AddField(GetType(), FieldTypes.LINE_THICKNESS, 2); @@ -48,17 +54,22 @@ namespace Greenshot.Addon.LegacyEditor.Drawing AddField(GetType(), FieldTypes.SHADOW, true); } + /// protected override void OnDeserialized(StreamingContext context) { Init(); } + /// + /// Initialize this container + /// protected void Init() { Adorners.Add(new MoveAdorner(this, Positions.TopLeft)); Adorners.Add(new MoveAdorner(this, Positions.BottomRight)); } + /// public override void Draw(Graphics graphics, RenderMode rm) { graphics.SmoothingMode = SmoothingMode.HighQuality; @@ -90,8 +101,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing Top + currentStep + Height); currentStep++; - alpha = alpha - basealpha / steps; - } +#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 } } + /// 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() + /// + protected override IDoubleProcessor GetAngleRoundProcessor() { - return ScaleHelper.LineAngleRoundBehavior.Instance; + return LineAngleRoundBehavior.Instance; } } } \ No newline at end of file diff --git a/src/Greenshot.Addons/AddonsModule.cs b/src/Greenshot.Addons/AddonsModule.cs index 4fc288325..d0249db4f 100644 --- a/src/Greenshot.Addons/AddonsModule.cs +++ b/src/Greenshot.Addons/AddonsModule.cs @@ -34,6 +34,7 @@ namespace Greenshot.Addons /// public class AddonsModule : AddonModule { + /// protected override void Load(ContainerBuilder builder) { builder diff --git a/src/Greenshot.Addons/Animation/AnimatorBase.cs b/src/Greenshot.Addons/Animation/AnimatorBase.cs index 187477fad..ca721ccdd 100644 --- a/src/Greenshot.Addons/Animation/AnimatorBase.cs +++ b/src/Greenshot.Addons/Animation/AnimatorBase.cs @@ -185,7 +185,7 @@ namespace Greenshot.Addons.Animation /// /// Get the next animation frame value object /// - /// + /// T public abstract T Next(); /// diff --git a/src/Greenshot.Addons/Animation/ColorAnimator.cs b/src/Greenshot.Addons/Animation/ColorAnimator.cs index 1b458e431..943a34c81 100644 --- a/src/Greenshot.Addons/Animation/ColorAnimator.cs +++ b/src/Greenshot.Addons/Animation/ColorAnimator.cs @@ -26,16 +26,21 @@ namespace Greenshot.Addons.Animation /// public class ColorAnimator : AnimatorBase { + /// + /// Create a color animator + /// + /// Color to start with + /// Color to end with + /// int amount of frames to animate + /// EasingTypes, the easing type to use + /// EasingModes, the easing mode to use public ColorAnimator(Color first, Color last, int frames, EasingTypes easingType = EasingTypes.Linear, EasingModes easingMode = EasingModes.EaseIn) : base(first, last, frames, easingType, easingMode) { } - /// - /// Calculate the next frame values - /// - /// Color - public override Color Next() + /// + public override Color Next() { if (!NextFrame) { diff --git a/src/Greenshot.Addons/Animation/EaseSine.cs b/src/Greenshot.Addons/Animation/EaseSine.cs index 3d8ff7964..cb78ec6d1 100644 --- a/src/Greenshot.Addons/Animation/EaseSine.cs +++ b/src/Greenshot.Addons/Animation/EaseSine.cs @@ -26,16 +26,31 @@ namespace Greenshot.Addons.Animation /// public static class EaseSine { + /// + /// Calculate the ease in + /// + /// double + /// double public static double EaseIn(double s) { return Math.Sin(s * (Math.PI / 2) - Math.PI / 2) + 1; } + /// + /// Calculate the ease in out + /// + /// double + /// double public static double EaseInOut(double s) { return Math.Sin(s * Math.PI - Math.PI / 2 + 1) / 2; } + /// + /// Calculate the ease out + /// + /// double + /// double public static double EaseOut(double s) { return Math.Sin(s * (Math.PI / 2)); diff --git a/src/Greenshot.Addons/Animation/EasingModes.cs b/src/Greenshot.Addons/Animation/EasingModes.cs index b90095936..4bece4de3 100644 --- a/src/Greenshot.Addons/Animation/EasingModes.cs +++ b/src/Greenshot.Addons/Animation/EasingModes.cs @@ -24,8 +24,17 @@ namespace Greenshot.Addons.Animation /// public enum EasingModes { + /// + /// Use ease in + /// EaseIn, + /// + /// Use ease out + /// EaseOut, + /// + /// Use ease in and out + /// EaseInOut } } \ No newline at end of file diff --git a/src/Greenshot.Addons/Animation/EasingTypes.cs b/src/Greenshot.Addons/Animation/EasingTypes.cs index 4a1e243fe..e5b9f96be 100644 --- a/src/Greenshot.Addons/Animation/EasingTypes.cs +++ b/src/Greenshot.Addons/Animation/EasingTypes.cs @@ -24,12 +24,33 @@ namespace Greenshot.Addons.Animation /// public enum EasingTypes { + /// + /// Use easing with steps + /// Step, + /// + /// Use linear easing + /// Linear, + /// + /// Use sine easing + /// Sine, + /// + /// Use quadratic easing + /// Quadratic, + /// + /// Use cubic easing + /// Cubic, + /// + /// Use quartic easing + /// Quartic, + /// + /// Use quintic easing + /// Quintic } } \ No newline at end of file diff --git a/src/Greenshot.Addons/Animation/IntAnimator.cs b/src/Greenshot.Addons/Animation/IntAnimator.cs index f906d3374..304459542 100644 --- a/src/Greenshot.Addons/Animation/IntAnimator.cs +++ b/src/Greenshot.Addons/Animation/IntAnimator.cs @@ -24,16 +24,21 @@ namespace Greenshot.Addons.Animation /// public class IntAnimator : AnimatorBase { + /// + /// Create an int animator + /// + /// int to start with + /// int to end with + /// int with the number of frames + /// EasingTypes + /// EasingModes public IntAnimator(int first, int last, int frames, EasingTypes easingType = EasingTypes.Linear, EasingModes easingMode = EasingModes.EaseIn) : base(first, last, frames, easingType, easingMode) { } - /// - /// Calculate the next frame values - /// - /// int - public override int Next() + /// + public override int Next() { if (!NextFrame) { diff --git a/src/Greenshot.Addons/Animation/PointAnimator.cs b/src/Greenshot.Addons/Animation/PointAnimator.cs index 215de02d7..888ccb215 100644 --- a/src/Greenshot.Addons/Animation/PointAnimator.cs +++ b/src/Greenshot.Addons/Animation/PointAnimator.cs @@ -31,11 +31,8 @@ namespace Greenshot.Addons.Animation { } - /// - /// Calculate the next frame value - /// - /// NativePoint - public override NativePoint Next() + /// + public override NativePoint Next() { if (!NextFrame) { diff --git a/src/Greenshot.Addons/Animation/RectangleAnimator.cs b/src/Greenshot.Addons/Animation/RectangleAnimator.cs index 0034e7508..2d919bc66 100644 --- a/src/Greenshot.Addons/Animation/RectangleAnimator.cs +++ b/src/Greenshot.Addons/Animation/RectangleAnimator.cs @@ -31,11 +31,8 @@ namespace Greenshot.Addons.Animation { } - /// - /// Calculate the next frame object - /// - /// NativeRect - public override NativeRect Next() + /// + public override NativeRect Next() { if (!NextFrame) { diff --git a/src/Greenshot.Addons/Animation/SizeAnimator.cs b/src/Greenshot.Addons/Animation/SizeAnimator.cs index 043c78fd2..334b5c80a 100644 --- a/src/Greenshot.Addons/Animation/SizeAnimator.cs +++ b/src/Greenshot.Addons/Animation/SizeAnimator.cs @@ -31,10 +31,7 @@ namespace Greenshot.Addons.Animation { } - /// - /// Calculate the next frame values - /// - /// NativeSize + /// public override NativeSize Next() { if (!NextFrame) diff --git a/src/Greenshot.Addons/Components/DestinationAttribute.cs b/src/Greenshot.Addons/Components/DestinationAttribute.cs index eeae98311..a1847fb6d 100644 --- a/src/Greenshot.Addons/Components/DestinationAttribute.cs +++ b/src/Greenshot.Addons/Components/DestinationAttribute.cs @@ -22,10 +22,16 @@ using System.ComponentModel.Composition; namespace Greenshot.Addons.Components { + /// + /// This attribute is used on a destination + /// [MetadataAttribute] [AttributeUsage(AttributeTargets.Class, Inherited = false)] public class DestinationAttribute : Attribute { + /// + /// This is needed to make sure the values do not need to be specified + /// public DestinationAttribute() { @@ -55,7 +61,10 @@ namespace Greenshot.Addons.Components } } + /// public string Designation { get; set; } + + /// public int Priority { get; set; } = 10; } } diff --git a/src/Greenshot.Addons/Components/DestinationOrder.cs b/src/Greenshot.Addons/Components/DestinationOrder.cs index 8192882d0..a60714929 100644 --- a/src/Greenshot.Addons/Components/DestinationOrder.cs +++ b/src/Greenshot.Addons/Components/DestinationOrder.cs @@ -19,18 +19,54 @@ namespace Greenshot.Addons.Components { + /// + /// This is used to order the destinations + /// public enum DestinationOrder { + /// + /// Order for the File without a dialog destination + /// FileNoDialog = 0, + /// + /// Order for the file with dialog destination + /// FileDialog = 0, + /// + /// Order for the picker destination + /// Picker = 1, + /// + /// Order for the Printer destination + /// Printer = 2, + /// + /// Order for the Clipboard destination + /// Clipboard = 2, + /// + /// Order for the Email destination + /// Email = 3, + /// + /// Order for the Outlook destination + /// Outlook = 3, + /// + /// Order for the Word destination + /// Word = 4, + /// + /// Order for the PowerPoint destination + /// Powerpoint = 4, + /// + /// Order for the OneNote destination + /// OneNote = 4, + /// + /// Order for the Excel destination + /// Excel = 5, } diff --git a/src/Greenshot.Addons/Components/ExportNotification.cs b/src/Greenshot.Addons/Components/ExportNotification.cs index fd9a8f60a..31f34b359 100644 --- a/src/Greenshot.Addons/Components/ExportNotification.cs +++ b/src/Greenshot.Addons/Components/ExportNotification.cs @@ -38,6 +38,12 @@ namespace Greenshot.Addons.Components private readonly IEventAggregator _eventAggregator; private readonly Func> _toastFactory; + /// + /// DI Constructor + /// + /// ICoreConfiguration + /// IEventAggregator + /// Func to create toasts public ExportNotification( ICoreConfiguration coreConfiguration, IEventAggregator eventAggregator, diff --git a/src/Greenshot.Addons/Components/IDestinationProvider.cs b/src/Greenshot.Addons/Components/IDestinationProvider.cs index 398f833ff..0d4162663 100644 --- a/src/Greenshot.Addons/Components/IDestinationProvider.cs +++ b/src/Greenshot.Addons/Components/IDestinationProvider.cs @@ -27,6 +27,10 @@ namespace Greenshot.Addons.Components /// public interface IDestinationProvider { + /// + /// Provide destinations + /// + /// IEnumerable with lazy IDestinations IEnumerable> Provide(); } } diff --git a/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs b/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs index d062ce4df..79efa5d69 100644 --- a/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs +++ b/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs @@ -30,111 +30,303 @@ using Greenshot.Core.Enums; namespace Greenshot.Addons.Config.Impl { + /// + /// Implementation of the ICoreConfiguration + /// public class CoreConfigurationImpl : IniSectionBase, ICoreConfiguration { + /// public override void AfterLoad() { CoreConfigurationExtensions.AfterLoad(this); } + /// public string OutputFilePath { get; set; } + + /// public bool OutputFileAllowOverwrite { get; set; } + + /// public string OutputFileFilenamePattern { get; set; } + + /// public OutputFormats OutputFileFormat { get; set; } + + /// public bool OutputFileReduceColors { get; set; } + + /// public bool OutputFileAutoReduceColors { get; set; } + + /// public int OutputFileReduceColorsTo { get; set; } + + /// public int OutputFileJpegQuality { get; set; } + + /// public bool OutputFilePromptQuality { get; set; } + + /// public uint OutputFileIncrementingNumber { get; set; } + + /// public string OptimizePNGCommand { get; set; } + + /// public string OptimizePNGCommandArguments { get; set; } + /// public NativeSize Win10BorderCrop { get; set; } + + /// public bool CaptureMousepointer { get; set; } + + /// public bool CaptureWindowsInteractive { get; set; } + + /// public int CaptureDelay { get; set; } + + /// public ScreenCaptureMode ScreenCaptureMode { get; set; } + + /// public int ScreenToCapture { get; set; } + + /// public WindowCaptureModes WindowCaptureMode { get; set; } + + /// public Color DWMBackgroundColor { get; set; } + + /// public IList NoGDICaptureForProduct { get; set; } + + /// public IList NoDWMCaptureForProduct { get; set; } + + /// public bool WindowCaptureRemoveCorners { get; set; } + + /// public IList WindowCornerCutShape { get; set; } + /// public string Language { get; set; } + + /// public string RegionHotkey { get; set; } + + /// public string WindowHotkey { get; set; } + + /// public string FullscreenHotkey { get; set; } + + /// public string LastregionHotkey { get; set; } + + /// public string IEHotkey { get; set; } + + /// public bool IsFirstLaunch { get; set; } + + /// public IList OutputDestinations { get; set; } + + /// public IList PickerDestinations { get; set; } + + /// public IList ClipboardFormats { get; set; } + + /// public bool WindowCaptureAllChildLocations { get; set; } + + /// public bool PlayCameraSound { get; set; } + + /// public bool ShowTrayNotification { get; set; } + + /// public bool OutputFileCopyPathToClipboard { get; set; } + + /// public string OutputFileAsFullpath { get; set; } + + /// public bool OutputPrintPromptOptions { get; set; } + + /// public bool OutputPrintAllowRotate { get; set; } + + /// public bool OutputPrintAllowEnlarge { get; set; } + + /// public bool OutputPrintAllowShrink { get; set; } + + /// public bool OutputPrintCenter { get; set; } + + /// public bool OutputPrintInverted { get; set; } + + /// public bool OutputPrintGrayscale { get; set; } + + /// public bool OutputPrintMonochrome { get; set; } + + /// public byte OutputPrintMonochromeThreshold { get; set; } + + /// public bool OutputPrintFooter { get; set; } + + /// public string OutputPrintFooterPattern { get; set; } + + /// public string NotificationSound { get; set; } + + /// public bool UseProxy { get; set; } + + /// public bool IECapture { get; set; } + + /// public bool IEFieldCapture { get; set; } + + /// public IList WindowClassesToCheckForIE { get; set; } + + /// public int AutoCropDifference { get; set; } + + /// public IList IncludePlugins { get; set; } + + /// public IList ExcludePlugins { get; set; } + + /// public IList ExcludeDestinations { get; set; } + + /// public bool CheckForUpdates { get; set; } + + /// public int UpdateCheckInterval { get; set; } + + /// public DateTime LastUpdateCheck { get; set; } + + /// public bool DisableSettings { get; set; } + + /// public bool DisableQuickSettings { get; set; } + + /// public bool HideTrayicon { get; set; } + + /// public bool HideExpertSettings { get; set; } + + /// public bool ThumnailPreview { get; set; } + + /// public bool OptimizeForRDP { get; set; } + + /// public bool DisableRDPOptimizing { get; set; } + + /// public bool MinimizeWorkingSetSize { get; set; } + + /// public bool CheckForUnstable { get; set; } + + /// public IList ActiveTitleFixes { get; set; } + + /// public IDictionary TitleFixMatcher { get; set; } + + /// public IDictionary TitleFixReplacer { get; set; } + + /// public IList ExperimentalFeatures { get; set; } + + /// public bool EnableSpecialDIBClipboardReader { get; set; } + + /// public ClickActions LeftClickAction { get; set; } + + /// public ClickActions DoubleClickAction { get; set; } + + /// public bool ZoomerEnabled { get; set; } + + /// public float ZoomerOpacity { get; set; } + + /// public int MaxMenuItemLength { get; set; } + + /// public string MailApiTo { get; set; } + + /// public string MailApiCC { get; set; } + + /// public string MailApiBCC { get; set; } + + /// public string LastSaveWithVersion { get; set; } + + /// public bool ProcessEXIFOrientation { get; set; } + + /// public NativeRect LastCapturedRegion { get; set; } + + /// public NativeSize IconSize { get; set; } + + /// public int WebRequestTimeout { get; set; } + + /// public int WebRequestReadWriteTimeout { get; set; } + + /// public bool IsScrollingCaptureEnabled { get; set; } + + /// public bool IsPortable { get; set; } + + /// public ISet Permissions { get; set; } + /// public WindowStartupLocation DefaultWindowStartupLocation { get; set; } + + /// public bool AreWindowLocationsStored { get; set; } + + /// public IDictionary WindowLocations { get; set; } } } diff --git a/src/Greenshot.Addons/Controls/AnimatingForm.cs b/src/Greenshot.Addons/Controls/AnimatingForm.cs index cdad5ef8a..33547c621 100644 --- a/src/Greenshot.Addons/Controls/AnimatingForm.cs +++ b/src/Greenshot.Addons/Controls/AnimatingForm.cs @@ -33,6 +33,9 @@ namespace Greenshot.Addons.Controls /// public class AnimatingForm : GreenshotForm { + /// + /// The ICoreConfiguration which can be used in all derived forms + /// protected readonly ICoreConfiguration _coreConfiguration; private const int DefaultVerticalRefresh = 60; private static readonly LogSource Log = new LogSource(); diff --git a/src/Greenshot.Addons/Controls/BackgroundForm.cs b/src/Greenshot.Addons/Controls/BackgroundForm.cs index 68d432407..6a80b6ee0 100644 --- a/src/Greenshot.Addons/Controls/BackgroundForm.cs +++ b/src/Greenshot.Addons/Controls/BackgroundForm.cs @@ -26,12 +26,17 @@ using Greenshot.Addons.Resources; namespace Greenshot.Addons.Controls { /// - /// Description of PleaseWaitForm. + /// This form is used to show in the background /// public sealed partial class BackgroundForm : Form { private volatile bool _shouldClose; + /// + /// Constructor for the form + /// + /// string + /// string public BackgroundForm(string title, string text) { // @@ -51,6 +56,12 @@ namespace Greenshot.Addons.Controls ShowDialog(); } + /// + /// Show this form an wait + /// + /// string + /// string + /// BackgroundForm public static BackgroundForm ShowAndWait(string title, string text) { var backgroundForm = new BackgroundForm(title, text); @@ -63,8 +74,10 @@ namespace Greenshot.Addons.Controls return backgroundForm; } - // Can be used instead of ShowDialog - public new void Show() + /// + /// Can be used instead of ShowDialog + /// + public new void Show() { base.Show(); var positioned = false; @@ -100,6 +113,9 @@ namespace Greenshot.Addons.Controls } } + /// + /// Close the form + /// public void CloseDialog() { _shouldClose = true; diff --git a/src/Greenshot.Addons/Controls/FormWithoutActivation.cs b/src/Greenshot.Addons/Controls/FormWithoutActivation.cs index 2daa58c50..f12d29216 100644 --- a/src/Greenshot.Addons/Controls/FormWithoutActivation.cs +++ b/src/Greenshot.Addons/Controls/FormWithoutActivation.cs @@ -26,6 +26,7 @@ namespace Greenshot.Addons.Controls /// public class FormWithoutActivation : Form { + /// protected override bool ShowWithoutActivation { get { return true; } diff --git a/src/Greenshot.Addons/Controls/GreenshotButton.cs b/src/Greenshot.Addons/Controls/GreenshotButton.cs index 18489ba99..0053ae75e 100644 --- a/src/Greenshot.Addons/Controls/GreenshotButton.cs +++ b/src/Greenshot.Addons/Controls/GreenshotButton.cs @@ -22,8 +22,14 @@ using System.Windows.Forms; namespace Greenshot.Addons.Controls { + /// + /// This is a button which takes it translation via the set language key + /// public class GreenshotButton : Button, IGreenshotLanguageBindable { + /// + /// The key for the translation to use + /// [Category("Greenshot")] [DefaultValue(null)] [Description("Specifies key of the language file to use when displaying the text.")] diff --git a/src/Greenshot.Addons/Controls/GreenshotCheckBox.cs b/src/Greenshot.Addons/Controls/GreenshotCheckBox.cs index d08876fa4..3a75508f5 100644 --- a/src/Greenshot.Addons/Controls/GreenshotCheckBox.cs +++ b/src/Greenshot.Addons/Controls/GreenshotCheckBox.cs @@ -27,16 +27,25 @@ namespace Greenshot.Addons.Controls /// public class GreenshotCheckBox : CheckBox, IGreenshotLanguageBindable, IGreenshotConfigBindable { + /// + /// Name of the section to use for the checkbox value + /// [Category("Greenshot")] [DefaultValue("Core")] [Description("Specifies the Ini-Section to map this control with.")] public string SectionName { get; set; } = "Core"; + /// + /// Name of the propety to use for the checkbox value + /// [Category("Greenshot")] [DefaultValue(null)] [Description("Specifies the property name to map the configuration.")] public string PropertyName { get; set; } + /// + /// Key for the translation of the label belonging to the checkbox + /// [Category("Greenshot")] [DefaultValue(null)] [Description("Specifies key of the language file to use when displaying the text.")] diff --git a/src/Greenshot.Addons/Controls/GreenshotComboBox.cs b/src/Greenshot.Addons/Controls/GreenshotComboBox.cs index dd5bb30cf..ad907300f 100644 --- a/src/Greenshot.Addons/Controls/GreenshotComboBox.cs +++ b/src/Greenshot.Addons/Controls/GreenshotComboBox.cs @@ -25,6 +25,9 @@ using Dapplo.Config.Language; namespace Greenshot.Addons.Controls { + /// + /// A special combox box which can show a list of translated enum values + /// public class GreenshotComboBox : ComboBox, IGreenshotConfigBindable { private readonly ILanguage _language; @@ -104,7 +107,6 @@ namespace Greenshot.Addons.Controls /// private void StoreSelectedEnum() { - var enumTypeName = _enumType.Name; var selectedValue = SelectedItem as string; var availableValues = Enum.GetValues(_enumType); object returnValue = null; diff --git a/src/Greenshot.Addons/Controls/GreenshotForm.cs b/src/Greenshot.Addons/Controls/GreenshotForm.cs index e3fc29a11..4a35f86c7 100644 --- a/src/Greenshot.Addons/Controls/GreenshotForm.cs +++ b/src/Greenshot.Addons/Controls/GreenshotForm.cs @@ -45,6 +45,9 @@ namespace Greenshot.Addons.Controls private static readonly IDictionary ReflectionCache = new Dictionary(); private readonly ILanguage _language; + /// + /// This is the bitmap scale handler + /// protected readonly BitmapScaleHandler ScaleHandler; #if DEBUG @@ -63,8 +66,14 @@ namespace Greenshot.Addons.Controls ScaleHandler = BitmapScaleHandler.Create(FormDpiHandler, (imageName, dpi) => GreenshotResources.Instance.GetBitmap(imageName, GetType()), (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi)); } + /// + /// manually apply the language + /// protected bool ManualLanguageApply { get; set; } + /// + /// Manually apply the field values + /// protected bool ManualStoreFields { get; set; } /// @@ -72,11 +81,15 @@ namespace Greenshot.Addons.Controls /// protected bool ToFront { get; set; } + /// + /// The kex for the translation + /// [Category("Greenshot")] [DefaultValue(null)] [Description("Specifies key of the language file to use when displaying the text.")] public string LanguageKey { get; set; } + /// protected override void OnLoad(EventArgs e) { // Every GreenshotForm should have it's default icon @@ -383,6 +396,9 @@ namespace Greenshot.Addons.Controls OnFieldsFilled(); } + /// + /// This is called when the fields are filled + /// protected virtual void OnFieldsFilled() { } diff --git a/src/Greenshot.Addons/Controls/GreenshotGroupBox.cs b/src/Greenshot.Addons/Controls/GreenshotGroupBox.cs index 899f49c8a..1121bb515 100644 --- a/src/Greenshot.Addons/Controls/GreenshotGroupBox.cs +++ b/src/Greenshot.Addons/Controls/GreenshotGroupBox.cs @@ -22,8 +22,14 @@ using System.Windows.Forms; namespace Greenshot.Addons.Controls { + /// + /// This is a group box where you can specify the key for the translation + /// public class GreenshotGroupBox : GroupBox, IGreenshotLanguageBindable { + /// + /// Key for the translation + /// [Category("Greenshot")] [DefaultValue(null)] [Description("Specifies key of the language file to use when displaying the text.")] diff --git a/src/Greenshot.Addons/Controls/PleaseWaitForm.cs b/src/Greenshot.Addons/Controls/PleaseWaitForm.cs index 7e50ddf3c..14f5f141c 100644 --- a/src/Greenshot.Addons/Controls/PleaseWaitForm.cs +++ b/src/Greenshot.Addons/Controls/PleaseWaitForm.cs @@ -42,6 +42,10 @@ namespace Greenshot.Addons.Controls private readonly CancellationTokenSource _cancellationTokenSource; private Thread _waitFor; + /// + /// DI Constructor + /// + /// IGreenshotLanguage public PleaseWaitForm(IGreenshotLanguage greenshotLanguage) { _greenshotLanguage = greenshotLanguage; @@ -52,11 +56,17 @@ namespace Greenshot.Addons.Controls Icon = GreenshotResources.Instance.GetGreenshotIcon(); } + /// + /// DI Constructor + /// + /// IGreenshotLanguage + /// CancellationTokenSource public PleaseWaitForm(IGreenshotLanguage greenshotLanguage, CancellationTokenSource cancellationTokenSource = default) : this(greenshotLanguage) { _cancellationTokenSource = cancellationTokenSource; } + /// protected override CreateParams CreateParams { get diff --git a/src/Greenshot.Addons/Controls/ResourceImageManager.cs b/src/Greenshot.Addons/Controls/ResourceImageManager.cs index a1658e860..360e33c05 100644 --- a/src/Greenshot.Addons/Controls/ResourceImageManager.cs +++ b/src/Greenshot.Addons/Controls/ResourceImageManager.cs @@ -32,6 +32,11 @@ namespace Greenshot.Addons.Controls { private readonly Type _resourceType; private readonly List _images = new List(); + + /// + /// A constructor where one specifies the type which contains the resources + /// + /// Type public ResourceImageManager(Type resourceType) { _resourceType = resourceType; @@ -63,11 +68,15 @@ namespace Greenshot.Addons.Controls } } + /// public void Dispose() { ReleaseUnmanagedResources(); } + /// + /// Destructor + /// ~ResourceImageManager() { ReleaseUnmanagedResources(); diff --git a/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs b/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs index e01af7576..1315ac11a 100644 --- a/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs +++ b/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs @@ -38,8 +38,13 @@ namespace Greenshot.Addons.Controls private readonly ICaptureDetails _captureDetails; private DirectoryInfo _eagerlyCreatedDirectory; private FilterOption[] _filterOptions; - protected SaveFileDialog SaveFileDialog; + private SaveFileDialog SaveFileDialog; + /// + /// DI Constructor + /// + /// ICoreConfiguration + /// ICaptureDetails public SaveImageFileDialog(ICoreConfiguration coreConfiguration, ICaptureDetails captureDetails = null) { _coreConfiguration = coreConfiguration; @@ -108,11 +113,13 @@ namespace Greenshot.Addons.Controls } } + /// public void Dispose() { Dispose(true); } + /// protected virtual void Dispose(bool disposing) { if (disposing) @@ -196,6 +203,10 @@ namespace Greenshot.Addons.Controls } } + /// + /// Show the save file dialog + /// + /// public DialogResult ShowDialog() { var ret = SaveFileDialog.ShowDialog(); diff --git a/src/Greenshot.Addons/Core/Credentials/CredFlags.cs b/src/Greenshot.Addons/Core/Credentials/CredFlags.cs index cf5372491..a53f5ed64 100644 --- a/src/Greenshot.Addons/Core/Credentials/CredFlags.cs +++ b/src/Greenshot.Addons/Core/Credentials/CredFlags.cs @@ -21,16 +21,17 @@ using System; namespace Greenshot.Addons.Core.Credentials { - /// - /// http://www.pinvoke.net/default.aspx/Enums.CREDUI_FLAGS - /// 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 - /// - [Flags] + /// + /// http://www.pinvoke.net/default.aspx/Enums.CREDUI_FLAGS + /// 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 + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + [Flags] public enum CredFlags { - IncorrectPassword = 0x1, - DoNotPersist = 0x2, + IncorrectPassword = 0x1, + DoNotPersist = 0x2, RequestAdministrator = 0x4, ExcludeCertificates = 0x8, RequireCertificate = 0x10, diff --git a/src/Greenshot.Addons/Core/Enums/ClickActions.cs b/src/Greenshot.Addons/Core/Enums/ClickActions.cs index a7bb5f003..68f05b83a 100644 --- a/src/Greenshot.Addons/Core/Enums/ClickActions.cs +++ b/src/Greenshot.Addons/Core/Enums/ClickActions.cs @@ -19,7 +19,11 @@ namespace Greenshot.Addons.Core.Enums { - public enum ClickActions + /// + /// Specify what action a click resolves to + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + public enum ClickActions { DO_NOTHING, OPEN_LAST_IN_EXPLORER, diff --git a/src/Greenshot.Addons/Core/Enums/ClipboardFormats.cs b/src/Greenshot.Addons/Core/Enums/ClipboardFormats.cs index 86c1f6980..e0eefa72c 100644 --- a/src/Greenshot.Addons/Core/Enums/ClipboardFormats.cs +++ b/src/Greenshot.Addons/Core/Enums/ClipboardFormats.cs @@ -19,7 +19,11 @@ namespace Greenshot.Addons.Core.Enums { - public enum ClipboardFormats + /// + /// Specify the formats of the clipboard + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + public enum ClipboardFormats { NONE, PNG, diff --git a/src/Greenshot.Addons/Core/Enums/ConfigIds.cs b/src/Greenshot.Addons/Core/Enums/ConfigIds.cs index a1aa20c2e..af7b27c7f 100644 --- a/src/Greenshot.Addons/Core/Enums/ConfigIds.cs +++ b/src/Greenshot.Addons/Core/Enums/ConfigIds.cs @@ -19,6 +19,10 @@ namespace Greenshot.Addons.Core.Enums { + /// + /// This is used to specify where configuration viewmodels are located + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public enum ConfigIds { Ui, diff --git a/src/Greenshot.Addons/Core/ICoreConfiguration.cs b/src/Greenshot.Addons/Core/ICoreConfiguration.cs index ab33a289d..ed297097f 100644 --- a/src/Greenshot.Addons/Core/ICoreConfiguration.cs +++ b/src/Greenshot.Addons/Core/ICoreConfiguration.cs @@ -34,6 +34,7 @@ namespace Greenshot.Addons.Core /// [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)")] diff --git a/src/Greenshot.Addons/Core/IFileConfiguration.cs b/src/Greenshot.Addons/Core/IFileConfiguration.cs index 42c1cf8f8..226e4c490 100644 --- a/src/Greenshot.Addons/Core/IFileConfiguration.cs +++ b/src/Greenshot.Addons/Core/IFileConfiguration.cs @@ -25,6 +25,7 @@ namespace Greenshot.Addons.Core /// /// File configuration. /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public interface IFileConfiguration { [Description("Output file path.")] diff --git a/src/Greenshot.Addons/IGreenshotLanguage.cs b/src/Greenshot.Addons/IGreenshotLanguage.cs index f08ee6b64..6a42013b7 100644 --- a/src/Greenshot.Addons/IGreenshotLanguage.cs +++ b/src/Greenshot.Addons/IGreenshotLanguage.cs @@ -22,9 +22,13 @@ using Dapplo.Config.Language; namespace Greenshot.Addons { + /// + /// This specifies many translations + /// [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; } diff --git a/src/Greenshot.Addons/Interfaces/CaptureMode.cs b/src/Greenshot.Addons/Interfaces/CaptureMode.cs index a011d2a59..76bcc66c5 100644 --- a/src/Greenshot.Addons/Interfaces/CaptureMode.cs +++ b/src/Greenshot.Addons/Interfaces/CaptureMode.cs @@ -19,10 +19,11 @@ namespace Greenshot.Addons.Interfaces { - /// - /// The capture mode for Greenshot - /// - public enum CaptureMode + /// + /// The capture mode for Greenshot + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + public enum CaptureMode { None, Region, diff --git a/src/Greenshot.Addons/Interfaces/DrawingModes.cs b/src/Greenshot.Addons/Interfaces/DrawingModes.cs index 1abe651bd..0aac5b686 100644 --- a/src/Greenshot.Addons/Interfaces/DrawingModes.cs +++ b/src/Greenshot.Addons/Interfaces/DrawingModes.cs @@ -19,7 +19,11 @@ namespace Greenshot.Addons.Interfaces { - public enum DrawingModes + /// + /// What are we drawing? + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + public enum DrawingModes { None, Rect, diff --git a/src/Greenshot.Core/Configuration/ICaptureConfiguration.cs b/src/Greenshot.Core/Configuration/ICaptureConfiguration.cs index 50f65ebf0..9ab4e24ad 100644 --- a/src/Greenshot.Core/Configuration/ICaptureConfiguration.cs +++ b/src/Greenshot.Core/Configuration/ICaptureConfiguration.cs @@ -6,6 +6,10 @@ using Greenshot.Core.Enums; namespace Greenshot.Core.Configuration { + /// + /// The configuration for capturing + /// +#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")] diff --git a/src/Greenshot.Core/Enums/CaptureElementType.cs b/src/Greenshot.Core/Enums/CaptureElementType.cs index 8da1ee1d2..5074d29c5 100644 --- a/src/Greenshot.Core/Enums/CaptureElementType.cs +++ b/src/Greenshot.Core/Enums/CaptureElementType.cs @@ -20,17 +20,41 @@ namespace Greenshot.Core.Enums { /// - /// This is used to specified what type of capture + /// This is used to specified what type elements in an capture are /// public enum CaptureElementType { + /// + /// Not specified + /// Unknown, + /// + /// Screen + /// Screen, + /// + /// Mouse + /// Mouse, + /// + /// Cursor + /// Cursor, + /// + /// Icon + /// Icon, + /// + /// Popup + /// Popup, + /// + /// Window + /// Window, + /// + /// File + /// File } } diff --git a/src/Greenshot.Core/Enums/OutputFormats.cs b/src/Greenshot.Core/Enums/OutputFormats.cs index 731618f2f..fc94ca9da 100644 --- a/src/Greenshot.Core/Enums/OutputFormats.cs +++ b/src/Greenshot.Core/Enums/OutputFormats.cs @@ -19,14 +19,38 @@ namespace Greenshot.Core.Enums { + /// + /// The output formats we support + /// public enum OutputFormats { + /// + /// Specify bmp to write bitmap files + /// bmp, - gif, - jpg, - png, - tiff, - greenshot, - ico - } + /// + /// Specify gif to write gif files + /// + gif, + /// + /// Specify jpg to write bitjpgmap files + /// + jpg, + /// + /// Specify png to write png files + /// + png, + /// + /// Specify tiff to write tiff files + /// + tiff, + /// + /// Specify greenshot to write greenshot files with annotations and a PNG bitmap + /// + greenshot, + /// + /// Specify ico to write icon files + /// + ico + } } \ No newline at end of file diff --git a/src/Greenshot.Core/Enums/ScreenCaptureMode.cs b/src/Greenshot.Core/Enums/ScreenCaptureMode.cs index f8fee651d..d49386f06 100644 --- a/src/Greenshot.Core/Enums/ScreenCaptureMode.cs +++ b/src/Greenshot.Core/Enums/ScreenCaptureMode.cs @@ -19,10 +19,22 @@ namespace Greenshot.Core.Enums { + /// + /// These are the different screen capture modus + /// public enum ScreenCaptureMode { + /// + /// Automatically select the mode + /// Auto, + /// + /// Capture the whole screen + /// FullScreen, + /// + /// Specify the screen to capture + /// Fixed } } \ No newline at end of file diff --git a/src/Greenshot.Core/Enums/WindowCaptureModes.cs b/src/Greenshot.Core/Enums/WindowCaptureModes.cs index fef1ddcfb..79c8b54d5 100644 --- a/src/Greenshot.Core/Enums/WindowCaptureModes.cs +++ b/src/Greenshot.Core/Enums/WindowCaptureModes.cs @@ -19,12 +19,32 @@ namespace Greenshot.Core.Enums { + /// + /// These are the possible ways to capture a window + /// public enum WindowCaptureModes { + /// + /// USe the screen + /// Screen, + /// + /// Use GDI "print" + /// Gdi, + /// + /// Use Aero to clone the window and the screen to capture. + /// This mode will remove transparency + /// Aero, + /// + /// Use Aero to clone the window and the screen to capture. + /// This mode will maintain transparency + /// AeroTransparent, + /// + /// Automatically select the modus + /// Auto } } \ No newline at end of file diff --git a/src/Greenshot.Core/Sources/DwmWindowSource.cs b/src/Greenshot.Core/Sources/DwmWindowSource.cs index 2ccce83c3..5c7a8b363 100644 --- a/src/Greenshot.Core/Sources/DwmWindowSource.cs +++ b/src/Greenshot.Core/Sources/DwmWindowSource.cs @@ -36,12 +36,18 @@ namespace Greenshot.Core.Sources private readonly ICaptureConfiguration _captureConfiguration; private readonly Func _retrieveWindowFunc; + /// + /// Constructor + /// + /// ICaptureConfiguration + /// Func to select the window public DwmWindowSource(ICaptureConfiguration captureConfiguration, Func retrieveWindowFunc = null) { _captureConfiguration = captureConfiguration; _retrieveWindowFunc = retrieveWindowFunc ?? InteropWindowQuery.GetForegroundWindow; } + /// public ValueTask> Import(CancellationToken cancellationToken = default) { var window = _retrieveWindowFunc(); diff --git a/src/Greenshot.Core/Templates/CroppedTemplate.cs b/src/Greenshot.Core/Templates/CroppedTemplate.cs index 4c1a424f6..988f2a347 100644 --- a/src/Greenshot.Core/Templates/CroppedTemplate.cs +++ b/src/Greenshot.Core/Templates/CroppedTemplate.cs @@ -32,7 +32,12 @@ namespace Greenshot.Core.Templates /// public class CroppedTemplate : ITemplate { + /// + /// Specify if the mouse cursor should be displayed + /// public bool DisplayMouse { get; set; } = true; + + /// public FrameworkElement Apply(ICapture 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; } diff --git a/src/Greenshot.Core/Templates/SimpleTemplate.cs b/src/Greenshot.Core/Templates/SimpleTemplate.cs index 78f58f00d..a2af2ce50 100644 --- a/src/Greenshot.Core/Templates/SimpleTemplate.cs +++ b/src/Greenshot.Core/Templates/SimpleTemplate.cs @@ -31,7 +31,12 @@ namespace Greenshot.Core.Templates /// public class SimpleTemplate : ITemplate { + /// + /// Specify if the mouse should be shown + /// public bool DisplayMouse { get; set; } = true; + + /// public FrameworkElement Apply(ICapture 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; } diff --git a/src/Greenshot.Gfx/BitmapHelper.cs b/src/Greenshot.Gfx/BitmapHelper.cs index c0558941f..0ec362e6f 100644 --- a/src/Greenshot.Gfx/BitmapHelper.cs +++ b/src/Greenshot.Gfx/BitmapHelper.cs @@ -125,6 +125,9 @@ namespace Greenshot.Gfx }; } + /// + /// This defines all available bitmap reader functions, registered to an "extension" is called with a stream to a IBitmap. + /// public static IDictionary> StreamConverters { get; } = new Dictionary>(StringComparer.OrdinalIgnoreCase); /// diff --git a/src/Greenshot.Gfx/BitmapWrapper.cs b/src/Greenshot.Gfx/BitmapWrapper.cs index 65df1b2c6..538a944a0 100644 --- a/src/Greenshot.Gfx/BitmapWrapper.cs +++ b/src/Greenshot.Gfx/BitmapWrapper.cs @@ -32,6 +32,10 @@ namespace Greenshot.Gfx // Underlying image private readonly Bitmap _bitmap; + /// + /// Constructor taking a Bitmap + /// + /// 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; } + /// public void Dispose() { _bitmap.Dispose(); diff --git a/src/Greenshot.Gfx/Effects/AdjustEffect.cs b/src/Greenshot.Gfx/Effects/AdjustEffect.cs index 7e34d86ab..35802f41a 100644 --- a/src/Greenshot.Gfx/Effects/AdjustEffect.cs +++ b/src/Greenshot.Gfx/Effects/AdjustEffect.cs @@ -29,12 +29,22 @@ namespace Greenshot.Gfx.Effects /// public class AdjustEffect : IEffect { + /// + /// The contrast for the effect + /// public float Contrast { get; set; } = 1f; + /// + /// The brightness for the effect + /// public float Brightness { get; set; } = 1f; + /// + /// The gamma for the effect + /// public float Gamma { get; set; } = 1f; + /// public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return Adjust(sourceBitmap, Brightness, Contrast, Gamma); diff --git a/src/Greenshot.Gfx/Effects/BlurEffect.cs b/src/Greenshot.Gfx/Effects/BlurEffect.cs index dfebeca53..140e8b4c4 100644 --- a/src/Greenshot.Gfx/Effects/BlurEffect.cs +++ b/src/Greenshot.Gfx/Effects/BlurEffect.cs @@ -29,9 +29,13 @@ namespace Greenshot.Gfx.Effects [TypeConverter(typeof(EffectConverter))] public class BlurEffect : IEffect { + /// + /// The range for the blur + /// public int Range { get; set; } = 3; - public virtual IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) + /// + public virtual IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { var result = FastBitmapFactory.CreateCloneOf(sourceBitmap); result.ApplyBoxBlur(Range); diff --git a/src/Greenshot.Gfx/Effects/BorderEffect.cs b/src/Greenshot.Gfx/Effects/BorderEffect.cs index d710bd391..e880844b3 100644 --- a/src/Greenshot.Gfx/Effects/BorderEffect.cs +++ b/src/Greenshot.Gfx/Effects/BorderEffect.cs @@ -29,11 +29,18 @@ namespace Greenshot.Gfx.Effects /// public class BorderEffect : IEffect { + /// + /// The color of the border + /// public Color Color { get; set; } = Color.Black; + /// + /// The width of the border + /// public int Width { get; set; } = 2; - - public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) + + /// + public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return CreateBorder(sourceBitmap, Width, Color, sourceBitmap.PixelFormat, matrix); } diff --git a/src/Greenshot.Gfx/Effects/EffectConverter.cs b/src/Greenshot.Gfx/Effects/EffectConverter.cs index 6f4b7bc47..fbc6c3c32 100644 --- a/src/Greenshot.Gfx/Effects/EffectConverter.cs +++ b/src/Greenshot.Gfx/Effects/EffectConverter.cs @@ -34,13 +34,17 @@ namespace Greenshot.Gfx.Effects // Fix to prevent BUG-1753 private readonly NumberFormatInfo _numberFormatInfo = new NumberFormatInfo(); + /// + /// Default constructor + /// public EffectConverter() { _numberFormatInfo.NumberDecimalSeparator = "."; _numberFormatInfo.NumberGroupSeparator = ","; } - public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + /// + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { if (sourceType == typeof(string)) { @@ -49,12 +53,14 @@ namespace Greenshot.Gfx.Effects return base.CanConvertFrom(context, sourceType); } - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) + /// + public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) { return destinationType == typeof(string) || destinationType == typeof(DropShadowEffect) || destinationType == typeof(TornEdgeEffect) || base.CanConvertTo(context, destinationType); } - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + /// + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { // to string if (destinationType == typeof(string)) @@ -93,7 +99,8 @@ namespace Greenshot.Gfx.Effects return base.ConvertTo(context, culture, value, destinationType); } - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + /// + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (!(value is string settings)) { @@ -102,7 +109,8 @@ namespace Greenshot.Gfx.Effects return ConvertTo(context, culture, settings, settings.Contains("ToothHeight") ? typeof(TornEdgeEffect) : typeof(DropShadowEffect)); } - private void ApplyDropShadowEffectValues(string valuesString, DropShadowEffect effect) + /// + private void ApplyDropShadowEffectValues(string valuesString, DropShadowEffect effect) { var values = valuesString.Split('|'); foreach (var nameValuePair in values) diff --git a/src/Greenshot.Gfx/Effects/InvertEffect.cs b/src/Greenshot.Gfx/Effects/InvertEffect.cs index f5ea5b82d..778415121 100644 --- a/src/Greenshot.Gfx/Effects/InvertEffect.cs +++ b/src/Greenshot.Gfx/Effects/InvertEffect.cs @@ -27,7 +27,9 @@ namespace Greenshot.Gfx.Effects /// public class InvertEffect : IEffect { - public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) + + /// + public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return CreateNegative(sourceBitmap); } diff --git a/src/Greenshot.Gfx/Effects/MonochromeEffect.cs b/src/Greenshot.Gfx/Effects/MonochromeEffect.cs index 0e0b26001..451cc9dd7 100644 --- a/src/Greenshot.Gfx/Effects/MonochromeEffect.cs +++ b/src/Greenshot.Gfx/Effects/MonochromeEffect.cs @@ -37,7 +37,8 @@ namespace Greenshot.Gfx.Effects _threshold = threshold; } - public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) + /// + public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return CreateMonochrome(sourceBitmap, _threshold); } diff --git a/src/Greenshot.Gfx/Effects/ReduceColorsEffect.cs b/src/Greenshot.Gfx/Effects/ReduceColorsEffect.cs index c58652b35..6feba3306 100644 --- a/src/Greenshot.Gfx/Effects/ReduceColorsEffect.cs +++ b/src/Greenshot.Gfx/Effects/ReduceColorsEffect.cs @@ -31,9 +31,13 @@ namespace Greenshot.Gfx.Effects { private static readonly LogSource Log = new LogSource(); + /// + /// The amount of colors the bitmap is allowed to have + /// public int Colors { get; set; } = 256; - public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) + /// + public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { using (var quantizer = new WuQuantizer(sourceBitmap)) { diff --git a/src/Greenshot.Gfx/Effects/ResizeCanvasEffect.cs b/src/Greenshot.Gfx/Effects/ResizeCanvasEffect.cs index 8799e992e..a42038122 100644 --- a/src/Greenshot.Gfx/Effects/ResizeCanvasEffect.cs +++ b/src/Greenshot.Gfx/Effects/ResizeCanvasEffect.cs @@ -23,10 +23,17 @@ using System.Drawing.Drawing2D; namespace Greenshot.Gfx.Effects { /// - /// ResizeCanvasEffect + /// This effect will enlange the bitmap with the specified pixels to the left, right, top, bottom /// public class ResizeCanvasEffect : IEffect { + /// + /// The constructor which takes the sizes to grow the canvas + /// + /// int + /// int + /// int + /// int 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 } + /// + /// The pixels which need to be added left + /// public int Left { get; set; } + /// + /// The pixels which need to be added right + /// public int Right { get; set; } - public int Top { get; set; } + /// + /// The pixels which need to be added top + /// + public int Top { get; set; } + /// + /// The pixels which need to be added bottom + /// public int Bottom { get; set; } + /// + /// The color of the new pixels + /// public Color BackgroundColor { get; set; } + /// public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return BitmapHelper.ResizeCanvas(sourceBitmap, BackgroundColor, Left, Right, Top, Bottom, matrix); diff --git a/src/Greenshot.Gfx/Effects/ResizeEffect.cs b/src/Greenshot.Gfx/Effects/ResizeEffect.cs index ed378a18e..0f5a2f0dc 100644 --- a/src/Greenshot.Gfx/Effects/ResizeEffect.cs +++ b/src/Greenshot.Gfx/Effects/ResizeEffect.cs @@ -22,10 +22,16 @@ using System.Drawing.Drawing2D; namespace Greenshot.Gfx.Effects { /// - /// ResizeEffect + /// This effect resizes the bitmap /// public class ResizeEffect : IEffect { + /// + /// The constructor which takes the new width and height and if the aspect ratio should be maintained + /// + /// int + /// int + /// bool public ResizeEffect(int width, int height, bool maintainAspectRatio) { Width = width; @@ -33,12 +39,22 @@ namespace Greenshot.Gfx.Effects MaintainAspectRatio = maintainAspectRatio; } + /// + /// The new width + /// public int Width { get; set; } + /// + /// The new height + /// public int Height { get; set; } + /// + /// Do we need to maintain the aspect ration + /// public bool MaintainAspectRatio { get; set; } + /// public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { return sourceBitmap.Resize(MaintainAspectRatio, Width, Height, matrix); diff --git a/src/Greenshot.Gfx/Effects/RotateEffect.cs b/src/Greenshot.Gfx/Effects/RotateEffect.cs index 5e07af68b..edae02e81 100644 --- a/src/Greenshot.Gfx/Effects/RotateEffect.cs +++ b/src/Greenshot.Gfx/Effects/RotateEffect.cs @@ -24,17 +24,25 @@ using System.Drawing.Drawing2D; namespace Greenshot.Gfx.Effects { /// - /// RotateEffect + /// This effect rotates the bitmap, this will also resize the bitmap /// public class RotateEffect : IEffect { + /// + /// The constructor which takes the angle + /// + /// int with the angle public RotateEffect(int angle) { Angle = angle; } + /// + /// The angle + /// public int Angle { get; set; } + /// public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { RotateFlipType flipType; diff --git a/src/Greenshot.Gfx/Effects/Scale2xEffect.cs b/src/Greenshot.Gfx/Effects/Scale2xEffect.cs index 2bfe9a807..ec7c2b7e4 100644 --- a/src/Greenshot.Gfx/Effects/Scale2xEffect.cs +++ b/src/Greenshot.Gfx/Effects/Scale2xEffect.cs @@ -24,11 +24,12 @@ using Greenshot.Gfx.Extensions; namespace Greenshot.Gfx.Effects { /// - /// Scale2x Effect + /// This effect scales the bitmap to 2x its size /// [TypeConverter(typeof(EffectConverter))] public sealed class Scale2xEffect : IEffect { + /// public IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { matrix?.Scale(2, 2, MatrixOrder.Append); diff --git a/src/Greenshot.Gfx/Effects/TornEdgeEffect.cs b/src/Greenshot.Gfx/Effects/TornEdgeEffect.cs index 56e260499..bb0b4d676 100644 --- a/src/Greenshot.Gfx/Effects/TornEdgeEffect.cs +++ b/src/Greenshot.Gfx/Effects/TornEdgeEffect.cs @@ -33,16 +33,32 @@ namespace Greenshot.Gfx.Effects [TypeConverter(typeof(EffectConverter))] public sealed class TornEdgeEffect : DropShadowEffect { + /// + /// Height of the teeth + /// public int ToothHeight { get; set; } = 12; + /// + /// How many teeth are horizontally displayed + /// public int HorizontalToothRange { get; set; } = 20; + /// + /// How many teeth are vertically displayed + /// public int VerticalToothRange { get; set; } = 20; + /// + /// Specify which edges should get teeth + /// public bool[] Edges { get; set; } = { true, true, true, true }; + /// + /// Generate a shadow? + /// public bool GenerateShadow { get; set; } = true; + /// public override IBitmapWithNativeSupport Apply(IBitmapWithNativeSupport sourceBitmap, Matrix matrix) { var tmpTornImage = CreateTornEdge(sourceBitmap, ToothHeight, HorizontalToothRange, VerticalToothRange, Edges); @@ -56,7 +72,6 @@ namespace Greenshot.Gfx.Effects } } - /// /// Helper method for the tornedge /// diff --git a/src/Greenshot.Gfx/Extensions/WriteableBitmapExtensions.cs b/src/Greenshot.Gfx/Extensions/WriteableBitmapExtensions.cs index 64f596ab9..a0cd3daad 100644 --- a/src/Greenshot.Gfx/Extensions/WriteableBitmapExtensions.cs +++ b/src/Greenshot.Gfx/Extensions/WriteableBitmapExtensions.cs @@ -23,14 +23,17 @@ using Dapplo.Windows.Common.Structs; namespace Greenshot.Gfx.Extensions { + /// + /// These extensions are for the writable bitmap + /// public static class WriteableBitmapExtensions { /// /// Copy the rect from source to target /// - /// - /// - /// + /// WriteableBitmap + /// BitmapSource + /// BitmapSource public static void CopyPixels(this WriteableBitmap target, BitmapSource source, NativeRect rect) { // Calculate stride of source diff --git a/src/Greenshot.Gfx/FastBitmap/Fast24RgbBitmap.cs b/src/Greenshot.Gfx/FastBitmap/Fast24RgbBitmap.cs index c890a90f2..24928434a 100644 --- a/src/Greenshot.Gfx/FastBitmap/Fast24RgbBitmap.cs +++ b/src/Greenshot.Gfx/FastBitmap/Fast24RgbBitmap.cs @@ -27,6 +27,11 @@ namespace Greenshot.Gfx.FastBitmap /// public unsafe class Fast24RgbBitmap : FastBitmapBase { + /// + /// Constructor which takes an IBitmap to wrap the fastbitmap logic around it + /// + /// IBitmapWithNativeSupport + /// NativeRect optional public Fast24RgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) { } diff --git a/src/Greenshot.Gfx/FastBitmap/Fast32ArgbBitmap.cs b/src/Greenshot.Gfx/FastBitmap/Fast32ArgbBitmap.cs index 927715843..6ddb81ab3 100644 --- a/src/Greenshot.Gfx/FastBitmap/Fast32ArgbBitmap.cs +++ b/src/Greenshot.Gfx/FastBitmap/Fast32ArgbBitmap.cs @@ -27,16 +27,24 @@ namespace Greenshot.Gfx.FastBitmap /// public unsafe class Fast32ArgbBitmap : FastBitmapBase, IFastBitmapWithBlend { - public Fast32ArgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) + /// + /// Constructor which takes an IBitmap to wrap the fastbitmap logic around it + /// + /// IBitmapWithNativeSupport + /// NativeRect optional + public Fast32ArgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) { BackgroundBlendColor = Color.White; } - public override int BytesPerPixel { get; } = 4; + /// + public override int BytesPerPixel { get; } = 4; + /// public override bool HasAlphaChannel => true; - public Color BackgroundBlendColor { get; set; } + /// + public Color BackgroundBlendColor { get; set; } /// public override Color GetColorAt(int x, int y) diff --git a/src/Greenshot.Gfx/FastBitmap/Fast32RgbBitmap.cs b/src/Greenshot.Gfx/FastBitmap/Fast32RgbBitmap.cs index 1dad2c929..13c98d3aa 100644 --- a/src/Greenshot.Gfx/FastBitmap/Fast32RgbBitmap.cs +++ b/src/Greenshot.Gfx/FastBitmap/Fast32RgbBitmap.cs @@ -27,7 +27,12 @@ namespace Greenshot.Gfx.FastBitmap /// public unsafe class Fast32RgbBitmap : FastBitmapBase { - public Fast32RgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) + /// + /// Constructor which takes an IBitmap to wrap the fastbitmap logic around it + /// + /// IBitmapWithNativeSupport + /// NativeRect optional + public Fast32RgbBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) { } diff --git a/src/Greenshot.Gfx/FastBitmap/FastBitmapBase.cs b/src/Greenshot.Gfx/FastBitmap/FastBitmapBase.cs index 96106c323..594ac56ea 100644 --- a/src/Greenshot.Gfx/FastBitmap/FastBitmapBase.cs +++ b/src/Greenshot.Gfx/FastBitmap/FastBitmapBase.cs @@ -476,11 +476,11 @@ namespace Greenshot.Gfx.FastBitmap } /// - /// returns true if x & y are inside the FastBitmap + /// returns true if x and y are inside the FastBitmap /// /// /// - /// true if x & y are inside the FastBitmap + /// true if x and y are inside the FastBitmap bool IFastBitmapWithOffset.Contains(int x, int y) { return Area.Contains(x - Left, y - Top); diff --git a/src/Greenshot.Gfx/FastBitmap/FastChunkyBitmap.cs b/src/Greenshot.Gfx/FastBitmap/FastChunkyBitmap.cs index 8f3aa6f80..0282edf0e 100644 --- a/src/Greenshot.Gfx/FastBitmap/FastChunkyBitmap.cs +++ b/src/Greenshot.Gfx/FastBitmap/FastChunkyBitmap.cs @@ -33,6 +33,11 @@ namespace Greenshot.Gfx.FastBitmap // Used for indexed images private readonly Color[] _colorEntries; + /// + /// This contructor creates a FastBitmap for the specified source + /// + /// IBitmapWithNativeSupport + /// NativeRect public FastChunkyBitmap(IBitmapWithNativeSupport source, NativeRect? area = null) : base(source, area) { _colorEntries = Bitmap.NativeBitmap.Palette.Entries; diff --git a/src/Greenshot.Gfx/FastBitmap/IFastBitmapWithOffset.cs b/src/Greenshot.Gfx/FastBitmap/IFastBitmapWithOffset.cs index f02a839f6..1e6a98bac 100644 --- a/src/Greenshot.Gfx/FastBitmap/IFastBitmapWithOffset.cs +++ b/src/Greenshot.Gfx/FastBitmap/IFastBitmapWithOffset.cs @@ -26,9 +26,15 @@ namespace Greenshot.Gfx.FastBitmap /// public unsafe interface IFastBitmapWithOffset : IFastBitmap { + /// + /// Specify the x offset for the IFastBitmap + /// new int Left { get; set; } - new int Top { get; set; } + /// + /// Specify the y offset for the IFastBitmap + /// + new int Top { get; set; } /// /// Return true if the coordinates are inside the FastBitmap diff --git a/src/Greenshot.Gfx/Legacy/FixedAngleRoundBehavior.cs b/src/Greenshot.Gfx/Legacy/FixedAngleRoundBehavior.cs new file mode 100644 index 000000000..d7fc6be38 --- /dev/null +++ b/src/Greenshot.Gfx/Legacy/FixedAngleRoundBehavior.cs @@ -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 . + +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; + } + } +} \ No newline at end of file diff --git a/src/Greenshot.Addons/Core/Enums/BuildStates.cs b/src/Greenshot.Gfx/Legacy/IDoubleProcessor.cs similarity index 68% rename from src/Greenshot.Addons/Core/Enums/BuildStates.cs rename to src/Greenshot.Gfx/Legacy/IDoubleProcessor.cs index 9779068d1..50142f6a6 100644 --- a/src/Greenshot.Addons/Core/Enums/BuildStates.cs +++ b/src/Greenshot.Gfx/Legacy/IDoubleProcessor.cs @@ -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 . -namespace Greenshot.Addons.Core.Enums +namespace Greenshot.Gfx.Legacy { - public enum BuildStates + /// + /// Every + /// + public interface IDoubleProcessor { - ALPHA, - BETA, - RELEASE_CANDIDATE, - RELEASE + /// + /// Do the processing + /// + /// double + /// double + double Process(double d); } } \ No newline at end of file diff --git a/src/Greenshot.Gfx/Legacy/LineAngleRoundBehavior.cs b/src/Greenshot.Gfx/Legacy/LineAngleRoundBehavior.cs new file mode 100644 index 000000000..ee7a4e16d --- /dev/null +++ b/src/Greenshot.Gfx/Legacy/LineAngleRoundBehavior.cs @@ -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 . + +using System; + +namespace Greenshot.Gfx.Legacy +{ + /// + /// TODO: Describe + /// + public class LineAngleRoundBehavior : IDoubleProcessor + { + public static LineAngleRoundBehavior Instance = new LineAngleRoundBehavior(); + + private LineAngleRoundBehavior() + { + } + + /// + public double Process(double angle) + { + return Math.Round(angle / 15) * 15; + } + } + +} \ No newline at end of file diff --git a/src/Greenshot.Gfx/Legacy/Positions.cs b/src/Greenshot.Gfx/Legacy/Positions.cs index 638ce19e7..c2d0517b6 100644 --- a/src/Greenshot.Gfx/Legacy/Positions.cs +++ b/src/Greenshot.Gfx/Legacy/Positions.cs @@ -20,17 +20,41 @@ namespace Greenshot.Gfx.Legacy { /// - /// Position + /// This specifies the position of something /// public enum Positions { + /// + /// Position top left + /// TopLeft = 0, - TopCenter = 1, - TopRight = 2, - MiddleRight = 3, - BottomRight = 4, - BottomCenter = 5, - BottomLeft = 6, - MiddleLeft = 7 + /// + /// Position top center + /// + TopCenter = 1, + /// + /// Position top right + /// + TopRight = 2, + /// + /// Position middle right + /// + MiddleRight = 3, + /// + /// Position bottom right + /// + BottomRight = 4, + /// + /// Position bottom center + /// + BottomCenter = 5, + /// + /// Position bottom left + /// + BottomLeft = 6, + /// + /// Position middle left + /// + MiddleLeft = 7 } } \ No newline at end of file diff --git a/src/Greenshot.Gfx/Legacy/RoundedRectangle.cs b/src/Greenshot.Gfx/Legacy/RoundedRectangle.cs index 4c4340412..e67d5d7fc 100644 --- a/src/Greenshot.Gfx/Legacy/RoundedRectangle.cs +++ b/src/Greenshot.Gfx/Legacy/RoundedRectangle.cs @@ -23,10 +23,11 @@ using Dapplo.Windows.Common.Structs; namespace Greenshot.Gfx.Legacy { - /// - /// TODO: currently this is only used in the capture form, we might move this code directly to there! - /// - public abstract class RoundedRectangle + /// + /// TODO: currently this is only used in the capture form, we might move this code directly to there! + /// +#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member + public abstract class RoundedRectangle { [Flags] public enum RectangleCorners @@ -55,8 +56,8 @@ namespace Greenshot.Gfx.Legacy return gp; } - public static GraphicsPath Create(int x, int y, int width, int height, int radius, RectangleCorners corners) - { + public static GraphicsPath Create(int x, int y, int width, int height, int radius, RectangleCorners corners) + { var xw = x + width; var yh = y + height; var xwr = xw - radius; diff --git a/src/Greenshot.Gfx/Legacy/ScaleHelper.cs b/src/Greenshot.Gfx/Legacy/ScaleHelper.cs index 1ea6c98d8..7be09e7c1 100644 --- a/src/Greenshot.Gfx/Legacy/ScaleHelper.cs +++ b/src/Greenshot.Gfx/Legacy/ScaleHelper.cs @@ -25,29 +25,11 @@ using Dapplo.Windows.Common.Structs; namespace Greenshot.Gfx.Legacy { - /// - /// Offers a few helper functions for scaling/aligning an element with another element - /// - public static class ScaleHelper + /// + /// Offers a few helper functions for scaling/aligning an element with another element + /// + public static partial class ScaleHelper { - [Flags] - public enum ScaleOptions - { - /// - /// Default scale behavior. - /// - Default = 0x00, - - /// - /// Scale a rectangle in two our four directions, mirrored at it's center coordinates - /// - Centered = 0x01, - - /// - /// Scale a rectangle maintaining it's aspect ratio - /// - Rational = 0x02 - } /// /// 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 /// a new NativeRectFloat object with Location aligned aligned to targetRect 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 /// coordinates of the used handle/gripper 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) { diff --git a/src/Greenshot.Gfx/Legacy/ScaleOptions.cs b/src/Greenshot.Gfx/Legacy/ScaleOptions.cs new file mode 100644 index 000000000..553b2531d --- /dev/null +++ b/src/Greenshot.Gfx/Legacy/ScaleOptions.cs @@ -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 . + +using System; + +namespace Greenshot.Gfx.Legacy +{ + + /// + /// Specify options for scaling + /// + [Flags] + public enum ScaleOptions + { + /// + /// Default scale behavior. + /// + Default = 0x00, + + /// + /// Scale a rectangle in two our four directions, mirrored at it's center coordinates + /// + Centered = 0x01, + + /// + /// Scale a rectangle maintaining it's aspect ratio + /// + Rational = 0x02 + } +} \ No newline at end of file diff --git a/src/Greenshot.Gfx/Legacy/ShapeAngleRoundBehavior.cs b/src/Greenshot.Gfx/Legacy/ShapeAngleRoundBehavior.cs new file mode 100644 index 000000000..45f6bf7dc --- /dev/null +++ b/src/Greenshot.Gfx/Legacy/ShapeAngleRoundBehavior.cs @@ -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 . + +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; + } + }*/ + } +} \ No newline at end of file diff --git a/src/Greenshot.Gfx/Murmur3.cs b/src/Greenshot.Gfx/Murmur3.cs index c2029a25c..cc1120b8d 100644 --- a/src/Greenshot.Gfx/Murmur3.cs +++ b/src/Greenshot.Gfx/Murmur3.cs @@ -41,8 +41,14 @@ namespace Greenshot.Gfx private uint _hash; private uint _length; + /// public override int HashSize => 32; + /// + /// Constructor for the Murmur3 algorythm + /// + /// + /// public Murmur3(uint seed, uint length = 0) { _seed = seed; diff --git a/src/Greenshot.Gfx/Quantizer/WuQuantizer.cs b/src/Greenshot.Gfx/Quantizer/WuQuantizer.cs index 03120764f..896f70467 100644 --- a/src/Greenshot.Gfx/Quantizer/WuQuantizer.cs +++ b/src/Greenshot.Gfx/Quantizer/WuQuantizer.cs @@ -61,6 +61,10 @@ namespace Greenshot.Gfx.Quantizer private byte[] _tag; + /// + /// The constructor for the WuQauntizer + /// + /// public WuQuantizer(IBitmapWithNativeSupport sourceBitmap) { _sourceBitmap = sourceBitmap; @@ -103,16 +107,15 @@ 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) + sourceFastBitmap.Lock(); + using (var destinationFastBitmap = FastBitmapFactory.CreateEmpty(sourceBitmap.Size, PixelFormat.Format8bppIndexed, Color.White) as FastChunkyBitmap) { for (var y = 0; y < sourceFastBitmap.Height; y++) { 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 } } } + /// public void Dispose() { @@ -176,6 +180,10 @@ namespace Greenshot.Gfx.Quantizer _resultBitmap = null; } + /// + /// Returns the number of colors + /// + /// int 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++) + 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(); - for (var y = 0; y < src.Height; y++) + var lookup = new Dictionary(); + 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); diff --git a/src/Greenshot.Gfx/ScaleX.cs b/src/Greenshot.Gfx/ScaleX.cs index c35b85237..6ab7c7137 100644 --- a/src/Greenshot.Gfx/ScaleX.cs +++ b/src/Greenshot.Gfx/ScaleX.cs @@ -25,6 +25,9 @@ using Greenshot.Gfx.FastBitmap; namespace Greenshot.Gfx { + /// + /// This is the scale X implementation using IFastBitmap + /// public static class ScaleX { /// diff --git a/src/Greenshot.Gfx/Structs/PixelExtensions.cs b/src/Greenshot.Gfx/Structs/PixelExtensions.cs index 21c0ba2a7..447adedf2 100644 --- a/src/Greenshot.Gfx/Structs/PixelExtensions.cs +++ b/src/Greenshot.Gfx/Structs/PixelExtensions.cs @@ -24,8 +24,16 @@ using System.Drawing; namespace Greenshot.Gfx.Structs { + /// + /// These are extensions to help with pixels + /// public static class PixelExtensions { + /// + /// Make a Brga32 from the specified color + /// + /// Color + /// Bgr32 public static Bgra32 FromColorWithAlpha(this Color color) { return new Bgra32 @@ -36,6 +44,12 @@ namespace Greenshot.Gfx.Structs B = color.B, }; } + + /// + /// Make a Brg32 from the specified color + /// + /// Color + /// Bgr32 public static Bgr32 FromColor(this Color color) { return new Bgr32 diff --git a/src/Greenshot.Gfx/SvgBitmap.cs b/src/Greenshot.Gfx/SvgBitmap.cs index 3019b4b3d..ed315868d 100644 --- a/src/Greenshot.Gfx/SvgBitmap.cs +++ b/src/Greenshot.Gfx/SvgBitmap.cs @@ -148,6 +148,7 @@ namespace Greenshot.Gfx return _imageClone; } + /// public Size Size => new Size(Width, Height); /// diff --git a/src/Greenshot.Gfx/UnmanagedBitmap.cs b/src/Greenshot.Gfx/UnmanagedBitmap.cs index a31e7b7f1..c068ae590 100644 --- a/src/Greenshot.Gfx/UnmanagedBitmap.cs +++ b/src/Greenshot.Gfx/UnmanagedBitmap.cs @@ -154,6 +154,9 @@ namespace Greenshot.Gfx } } + /// + /// Returns the pixel format for this Unmanaged bitmap + /// public System.Windows.Media.PixelFormat WpfPixelFormat { get @@ -203,6 +206,7 @@ namespace Greenshot.Gfx } } + /// public Size Size => new Size(Width, Height); ///