Just a bunch of code quality changes, still need to reduce another ~2000 warnings.

This commit is contained in:
Robin 2018-11-15 14:11:21 +01:00
commit 56c46e6800
68 changed files with 429 additions and 203 deletions

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Box.Configuration.Impl namespace Greenshot.Addon.Box.Configuration.Impl
{ {
/// <summary>
/// This implements IBoxLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class BoxLanguageImpl : LanguageBase<IBoxLanguage>, IBoxLanguage public class BoxLanguageImpl : LanguageBase<IBoxLanguage>, IBoxLanguage
{ {
#region Implementation of IBoxLanguage #region Implementation of IBoxLanguage

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Confluence.Configuration.Impl namespace Greenshot.Addon.Confluence.Configuration.Impl
{ {
/// <summary>
/// This implements IConfluenceLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class ConfluenceLanguageImpl : LanguageBase<IConfluenceLanguage>, IConfluenceLanguage public class ConfluenceLanguageImpl : LanguageBase<IConfluenceLanguage>, IConfluenceLanguage
{ {
#region Implementation of IConfluenceLanguage #region Implementation of IConfluenceLanguage

View file

@ -22,6 +22,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Dropbox.Configuration.Impl namespace Greenshot.Addon.Dropbox.Configuration.Impl
{ {
/// <summary>
/// This implements IDropboxLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class DropboxLanguageImpl: LanguageBase<IDropboxLanguage>, IDropboxLanguage public class DropboxLanguageImpl: LanguageBase<IDropboxLanguage>, IDropboxLanguage
{ {

View file

@ -198,7 +198,7 @@ namespace Greenshot.Addon.Dropbox
/// <param name="progress">IProgress</param> /// <param name="progress">IProgress</param>
/// <param name="cancellationToken">CancellationToken</param> /// <param name="cancellationToken">CancellationToken</param>
/// <returns>Url as string</returns> /// <returns>Url as string</returns>
private async Task<string> UploadAsync(string filename, HttpContent content, IProgress<int> progress = null, CancellationToken cancellationToken = default(CancellationToken)) private async Task<string> UploadAsync(string filename, HttpContent content, IProgress<int> progress = null, CancellationToken cancellationToken = default)
{ {
var oAuthHttpBehaviour = _oAuthHttpBehaviour.ShallowClone(); var oAuthHttpBehaviour = _oAuthHttpBehaviour.ShallowClone();
// Use UploadProgress // Use UploadProgress

View file

@ -25,6 +25,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Dapplo.Config.Ini; using Dapplo.Config.Ini;
using Greenshot.Addon.ExternalCommand.Entities; using Greenshot.Addon.ExternalCommand.Entities;
using Greenshot.Addons.Core; using Greenshot.Addons.Core;
@ -38,6 +39,7 @@ namespace Greenshot.Addon.ExternalCommand.Configuration
/// </summary> /// </summary>
[IniSection("ExternalCommand")] [IniSection("ExternalCommand")]
[Description("Greenshot ExternalCommand Plugin configuration")] [Description("Greenshot ExternalCommand Plugin configuration")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public interface IExternalCommandConfiguration : IIniSection, IDestinationFileConfiguration public interface IExternalCommandConfiguration : IIniSection, IDestinationFileConfiguration
{ {
[Description("The commands that are available.")] [Description("The commands that are available.")]

View file

@ -21,11 +21,13 @@
#endregion #endregion
using System.Diagnostics.CodeAnalysis;
using Dapplo.Config.Language; using Dapplo.Config.Language;
namespace Greenshot.Addon.ExternalCommand.Configuration namespace Greenshot.Addon.ExternalCommand.Configuration
{ {
[Language("ExternalCommand")] [Language("ExternalCommand")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public interface IExternalCommandLanguage : ILanguage public interface IExternalCommandLanguage : ILanguage
{ {
string ContextmenuConfigure { get; } string ContextmenuConfigure { get; }

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.ExternalCommand.Configuration.Impl namespace Greenshot.Addon.ExternalCommand.Configuration.Impl
{ {
/// <summary>
/// This implements IExternalCommandLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class ExternalCommandLanguageImpl : LanguageBase<IExternalCommandLanguage>, IExternalCommandLanguage public class ExternalCommandLanguageImpl : LanguageBase<IExternalCommandLanguage>, IExternalCommandLanguage
{ {
#region Implementation of IExternalCommandLanguage #region Implementation of IExternalCommandLanguage

View file

@ -24,6 +24,7 @@
#region Usings #region Usings
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Dapplo.Config.Ini; using Dapplo.Config.Ini;
using Dapplo.HttpExtensions.OAuth; using Dapplo.HttpExtensions.OAuth;
@ -33,18 +34,12 @@ using Greenshot.Addons.Core;
namespace Greenshot.Addon.Flickr.Configuration namespace Greenshot.Addon.Flickr.Configuration
{ {
public enum SafetyLevel
{
Safe = 1,
Moderate = 2,
Restricted = 3
}
/// <summary> /// <summary>
/// Description of FlickrConfiguration. /// This defines the configuration for the Flickr addon
/// </summary> /// </summary>
[IniSection("Flickr")] [IniSection("Flickr")]
[Description("Greenshot Flickr Plugin configuration")] [Description("Greenshot Flickr Plugin configuration")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public interface IFlickrConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth1Token public interface IFlickrConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth1Token
{ {
[Description("IsPublic.")] [Description("IsPublic.")]
@ -59,18 +54,30 @@ namespace Greenshot.Addon.Flickr.Configuration
[DefaultValue(true)] [DefaultValue(true)]
bool IsFriend { get; set; } bool IsFriend { get; set; }
/// <summary>
///
/// </summary>
[Description("Safety level")] [Description("Safety level")]
[DefaultValue(SafetyLevel.Safe)] [DefaultValue(SafetyLevel.Safe)]
SafetyLevel SafetyLevel { get; set; } SafetyLevel SafetyLevel { get; set; }
/// <summary>
/// Hide the image from the search results in Flickr
/// </summary>
[Description("Hidden from search")] [Description("Hidden from search")]
[DefaultValue(false)] [DefaultValue(false)]
bool HiddenFromSearch { get; set; } bool HiddenFromSearch { get; set; }
/// <summary>
/// Place the link to Flickr onto the clipboard after it's uploaded
/// </summary>
[Description("After upload send flickr link to clipboard.")] [Description("After upload send flickr link to clipboard.")]
[DefaultValue(true)] [DefaultValue(true)]
bool AfterUploadLinkToClipBoard { get; set; } bool AfterUploadLinkToClipBoard { get; set; }
/// <summary>
/// Defines if we use the pagelink or direct link on the clipboard
/// </summary>
[Description("Use pagelink instead of direct link on the clipboard")] [Description("Use pagelink instead of direct link on the clipboard")]
[DefaultValue(false)] [DefaultValue(false)]
bool UsePageLink { get; set; } bool UsePageLink { get; set; }

View file

@ -19,6 +19,7 @@
#region Usings #region Usings
using System.Diagnostics.CodeAnalysis;
using Dapplo.Config.Language; using Dapplo.Config.Language;
#endregion #endregion
@ -26,6 +27,7 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Flickr.Configuration namespace Greenshot.Addon.Flickr.Configuration
{ {
[Language("Flickr")] [Language("Flickr")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public interface IFlickrLanguage : ILanguage public interface IFlickrLanguage : ILanguage
{ {
string CommunicationWait { get; } string CommunicationWait { get; }

View file

@ -26,6 +26,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Flickr.Configuration.Impl namespace Greenshot.Addon.Flickr.Configuration.Impl
{ {
/// <summary>
/// This implements IFlickrLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class FlickrLanguageImpl : LanguageBase<IFlickrLanguage>, IFlickrLanguage public class FlickrLanguageImpl : LanguageBase<IFlickrLanguage>, IFlickrLanguage
{ {

View file

@ -0,0 +1,35 @@
#region Greenshot GNU General Public License
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2018 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/>.
#endregion
namespace Greenshot.Addon.Flickr.Configuration
{
/// <summary>
/// The Flickr SafetyLevel
/// </summary>
public enum SafetyLevel
{
Safe = 1,
Moderate = 2,
Restricted = 3
}
}

View file

@ -32,6 +32,9 @@ using Greenshot.Addons.ViewModels;
namespace Greenshot.Addon.Flickr.ViewModels namespace Greenshot.Addon.Flickr.ViewModels
{ {
/// <summary>
/// This is the ViewModel for the configuration of the Flickr addon
/// </summary>
public sealed class FlickrConfigViewModel : SimpleConfigScreen public sealed class FlickrConfigViewModel : SimpleConfigScreen
{ {
/// <summary> /// <summary>
@ -39,10 +42,20 @@ namespace Greenshot.Addon.Flickr.ViewModels
/// </summary> /// </summary>
private CompositeDisposable _disposables; private CompositeDisposable _disposables;
/// <summary>
/// Configuration for the view
/// </summary>
public IFlickrConfiguration FlickrConfiguration { get; } public IFlickrConfiguration FlickrConfiguration { get; }
/// <summary>
/// Translations for the view
/// </summary>
public IFlickrLanguage FlickrLanguage { get; } public IFlickrLanguage FlickrLanguage { get; }
/// <summary>
/// FileConfigPartViewModel is used from the view
/// TODO: Check if this is really true and needed
/// </summary>
public FileConfigPartViewModel FileConfigPartViewModel { get; } public FileConfigPartViewModel FileConfigPartViewModel { get; }
public FlickrConfigViewModel( public FlickrConfigViewModel(
@ -55,6 +68,7 @@ namespace Greenshot.Addon.Flickr.ViewModels
FileConfigPartViewModel = fileConfigPartViewModel; FileConfigPartViewModel = fileConfigPartViewModel;
} }
/// <inheritdoc />
public override void Initialize(IConfig config) public override void Initialize(IConfig config)
{ {
FileConfigPartViewModel.DestinationFileConfiguration = FlickrConfiguration; FileConfigPartViewModel.DestinationFileConfiguration = FlickrConfiguration;
@ -76,12 +90,16 @@ namespace Greenshot.Addon.Flickr.ViewModels
base.Initialize(config); base.Initialize(config);
} }
/// <inheritdoc />
protected override void OnDeactivate(bool close) protected override void OnDeactivate(bool close)
{ {
_disposables.Dispose(); _disposables.Dispose();
base.OnDeactivate(close); base.OnDeactivate(close);
} }
/// <summary>
/// Used in the view for the dropdown
/// </summary>
public SafetyLevel SelectedSafetyLevel public SafetyLevel SelectedSafetyLevel
{ {
get => FlickrConfiguration.SafetyLevel; get => FlickrConfiguration.SafetyLevel;
@ -92,6 +110,9 @@ namespace Greenshot.Addon.Flickr.ViewModels
} }
} }
/// <summary>
/// Used for a dropdown in the view
/// </summary>
public IDictionary<SafetyLevel, string> SafetyLevels => FlickrLanguage.TranslationValuesForEnum<SafetyLevel>(); public IDictionary<SafetyLevel, string> SafetyLevels => FlickrLanguage.TranslationValuesForEnum<SafetyLevel>();
} }
} }

View file

@ -24,6 +24,7 @@
#region Usings #region Usings
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using Dapplo.Config.Ini; using Dapplo.Config.Ini;
using Dapplo.HttpExtensions.OAuth; using Dapplo.HttpExtensions.OAuth;
@ -38,6 +39,7 @@ namespace Greenshot.Addon.GooglePhotos.Configuration
/// </summary> /// </summary>
[IniSection("GooglePhotos")] [IniSection("GooglePhotos")]
[Description("Greenshot Google Photos Plugin configuration")] [Description("Greenshot Google Photos Plugin configuration")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
public interface IGooglePhotosConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth2Token public interface IGooglePhotosConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth2Token
{ {
[Description("After upload send Google Photos link to clipboard.")] [Description("After upload send Google Photos link to clipboard.")]

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.GooglePhotos.Configuration.Impl namespace Greenshot.Addon.GooglePhotos.Configuration.Impl
{ {
/// <summary>
/// This implements IGooglePhotosLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class GooglePhotosLanguageImpl : LanguageBase<IGooglePhotosLanguage>, IGooglePhotosLanguage public class GooglePhotosLanguageImpl : LanguageBase<IGooglePhotosLanguage>, IGooglePhotosLanguage
{ {
#region Implementation of IGooglePhotosLanguage #region Implementation of IGooglePhotosLanguage

View file

@ -37,8 +37,20 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
/// </summary> /// </summary>
private CompositeDisposable _disposables; private CompositeDisposable _disposables;
/// <summary>
/// Configuration for the view
/// </summary>
public IGooglePhotosConfiguration GooglePhotosConfiguration { get; } public IGooglePhotosConfiguration GooglePhotosConfiguration { get; }
/// <summary>
/// Translations for the view
/// </summary>
public IGooglePhotosLanguage GooglePhotosLanguage { get; } public IGooglePhotosLanguage GooglePhotosLanguage { get; }
/// <summary>
/// FileConfigPartViewModel is used from the view
/// TODO: Check if this is really true and needed
/// </summary>
public FileConfigPartViewModel FileConfigPartViewModel { get; } public FileConfigPartViewModel FileConfigPartViewModel { get; }
public GooglePhotosConfigViewModel( public GooglePhotosConfigViewModel(
@ -51,6 +63,7 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
FileConfigPartViewModel = fileConfigPartViewModel; FileConfigPartViewModel = fileConfigPartViewModel;
} }
/// <inheritdoc />
public override void Initialize(IConfig config) public override void Initialize(IConfig config)
{ {
FileConfigPartViewModel.DestinationFileConfiguration = GooglePhotosConfiguration; FileConfigPartViewModel.DestinationFileConfiguration = GooglePhotosConfiguration;
@ -72,6 +85,7 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
base.Initialize(config); base.Initialize(config);
} }
/// <inheritdoc />
protected override void OnDeactivate(bool close) protected override void OnDeactivate(bool close)
{ {
_disposables.Dispose(); _disposables.Dispose();

View file

@ -26,6 +26,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Imgur.Configuration.Impl namespace Greenshot.Addon.Imgur.Configuration.Impl
{ {
/// <summary>
/// This implements IImgurLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class ImgurLanguageImpl : LanguageBase<IImgurLanguage>, IImgurLanguage public class ImgurLanguageImpl : LanguageBase<IImgurLanguage>, IImgurLanguage
{ {

View file

@ -45,16 +45,22 @@ namespace Greenshot.Addon.Imgur.ViewModels
public sealed class ImgurHistoryViewModel : Screen public sealed class ImgurHistoryViewModel : Screen
{ {
private static readonly LogSource Log = new LogSource(); private static readonly LogSource Log = new LogSource();
private readonly ImgurApi _imgurApi;
/// <summary> /// <summary>
/// Here all disposables are registered, so we can clean the up /// Here all disposables are registered, so we can clean the up
/// </summary> /// </summary>
private CompositeDisposable _disposables; private CompositeDisposable _disposables;
/// <summary>
/// The configuration used in the view
/// </summary>
public IImgurConfiguration ImgurConfiguration { get; } public IImgurConfiguration ImgurConfiguration { get; }
public ImgurApi ImgurApi { get; }
/// <summary>
/// The translations used in the view
/// </summary>
public IImgurLanguage ImgurLanguage { get; } public IImgurLanguage ImgurLanguage { get; }
/// <summary> /// <summary>
@ -62,6 +68,13 @@ namespace Greenshot.Addon.Imgur.ViewModels
/// </summary> /// </summary>
public IGreenshotLanguage GreenshotLanguage { get; } public IGreenshotLanguage GreenshotLanguage { get; }
/// <summary>
/// Constructor which accepts the dependencies for this class
/// </summary>
/// <param name="imgurConfiguration">IImgurConfiguration</param>
/// <param name="imgurApi">ImgurApi</param>
/// <param name="imgurLanguage">IImgurLanguage</param>
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
public ImgurHistoryViewModel( public ImgurHistoryViewModel(
IImgurConfiguration imgurConfiguration, IImgurConfiguration imgurConfiguration,
ImgurApi imgurApi, ImgurApi imgurApi,
@ -70,7 +83,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
) )
{ {
ImgurConfiguration = imgurConfiguration; ImgurConfiguration = imgurConfiguration;
ImgurApi = imgurApi; _imgurApi = imgurApi;
ImgurLanguage = imgurLanguage; ImgurLanguage = imgurLanguage;
GreenshotLanguage = greenshotLanguage; GreenshotLanguage = greenshotLanguage;
} }
@ -79,6 +92,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
/// </summary> /// </summary>
public ObservableCollection<ImgurImage> ImgurHistory { get; } = new BindableCollection<ImgurImage>(); public ObservableCollection<ImgurImage> ImgurHistory { get; } = new BindableCollection<ImgurImage>();
/// <inheritdoc />
protected override void OnActivate() protected override void OnActivate()
{ {
// Prepare disposables // Prepare disposables
@ -91,6 +105,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
_ = LoadHistory(); _ = LoadHistory();
} }
/// <inheritdoc />
protected override void OnDeactivate(bool close) protected override void OnDeactivate(bool close)
{ {
_disposables.Dispose(); _disposables.Dispose();
@ -117,10 +132,10 @@ namespace Greenshot.Addon.Imgur.ViewModels
} }
try try
{ {
var imgurInfo = await ImgurApi.RetrieveImgurInfoAsync(hash, ImgurConfiguration.ImgurUploadHistory[hash], cancellationToken).ConfigureAwait(true); var imgurInfo = await _imgurApi.RetrieveImgurInfoAsync(hash, ImgurConfiguration.ImgurUploadHistory[hash], cancellationToken).ConfigureAwait(true);
if (imgurInfo != null) if (imgurInfo != null)
{ {
await ImgurApi.RetrieveImgurThumbnailAsync(imgurInfo, cancellationToken).ConfigureAwait(true); await _imgurApi.RetrieveImgurThumbnailAsync(imgurInfo, cancellationToken).ConfigureAwait(true);
ImgurConfiguration.RuntimeImgurHistory.Add(hash, imgurInfo); ImgurConfiguration.RuntimeImgurHistory.Add(hash, imgurInfo);
// Already loaded, only add it to the view // Already loaded, only add it to the view
ImgurHistory.Add(imgurInfo); ImgurHistory.Add(imgurInfo);
@ -138,6 +153,9 @@ namespace Greenshot.Addon.Imgur.ViewModels
} }
} }
/// <summary>
/// The selected Imgur entry
/// </summary>
public ImgurImage SelectedImgur { get; private set; } public ImgurImage SelectedImgur { get; private set; }
/// <summary> /// <summary>
@ -150,7 +168,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
/// </summary> /// </summary>
public async Task Delete() public async Task Delete()
{ {
await ImgurApi.DeleteImgurImageAsync(SelectedImgur).ConfigureAwait(true); await _imgurApi.DeleteImgurImageAsync(SelectedImgur).ConfigureAwait(true);
} }
/// <summary> /// <summary>

View file

@ -72,8 +72,7 @@ namespace Greenshot.Addon.InternetExplorer
var list = new List<Accessible>(res.Length); var list = new List<Accessible>(res.Length);
foreach (var obj in res) foreach (var obj in res)
{ {
var accessible = obj as IAccessible; if (obj is IAccessible accessible)
if (accessible != null)
{ {
list.Add(new Accessible(accessible)); list.Add(new Accessible(accessible));
} }
@ -92,6 +91,9 @@ namespace Greenshot.Addon.InternetExplorer
get { return accessible.accChildCount; } get { return accessible.accChildCount; }
} }
/// <summary>
/// Returns the URL for the active tab
/// </summary>
public string IEActiveTabUrl public string IEActiveTabUrl
{ {
get get
@ -124,6 +126,9 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Get the index of the active tab
/// </summary>
public int IEActiveTabIndex public int IEActiveTabIndex
{ {
get get
@ -149,6 +154,9 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Get the caption of the active tab
/// </summary>
public string IEActiveTabCaption public string IEActiveTabCaption
{ {
get get
@ -172,6 +180,9 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Get the captions of all tabs
/// </summary>
public List<string> IETabCaptions public List<string> IETabCaptions
{ {
get get
@ -199,7 +210,9 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Get the urls of all tabs
/// </summary>
public IEnumerable<string> IETabUrls public IEnumerable<string> IETabUrls
{ {
get get
@ -226,6 +239,9 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Count the tabs
/// </summary>
public int IETabCount public int IETabCount
{ {
get get
@ -244,6 +260,10 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Activate the specified tab
/// </summary>
/// <param name="tabCaptionToActivate">string</param>
public void ActivateIETab(string tabCaptionToActivate) public void ActivateIETab(string tabCaptionToActivate)
{ {
foreach (var accessor in Children) foreach (var accessor in Children)
@ -262,6 +282,10 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Close the specified tabs
/// </summary>
/// <param name="tabCaptionToClose">string</param>
public void CloseIETab(string tabCaptionToClose) public void CloseIETab(string tabCaptionToClose)
{ {
foreach (var accessor in Children) foreach (var accessor in Children)
@ -283,6 +307,10 @@ namespace Greenshot.Addon.InternetExplorer
} }
} }
/// <summary>
/// Active the IE tab
/// </summary>
/// <param name="tabIndexToActivate">int</param>
public void ActivateIETab(int tabIndexToActivate) public void ActivateIETab(int tabIndexToActivate)
{ {
var index = 0; var index = 0;

View file

@ -60,12 +60,19 @@ namespace Greenshot.Addon.InternetExplorer
// TODO: Solve, was static reference! // TODO: Solve, was static reference!
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl(); private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
// Helper method to activate a certain IE Tab /// <summary>
/// Helper method to activate a certain IE Tab
/// </summary>
/// <param name="nativeIeWindow">IInteropWindow</param>
/// <param name="tabIndex">int</param>
public static void ActivateIeTab(IInteropWindow nativeIeWindow, int tabIndex) public static void ActivateIeTab(IInteropWindow nativeIeWindow, int tabIndex)
{ {
var directUiInteropWindow = IEHelper.GetDirectUi(nativeIeWindow); var directUiInteropWindow = IEHelper.GetDirectUi(nativeIeWindow);
if (directUiInteropWindow != null) if (directUiInteropWindow == null)
{ {
return;
}
// Bring window to the front // Bring window to the front
nativeIeWindow.Restore(); nativeIeWindow.Restore();
// Get accessible // Get accessible
@ -73,7 +80,6 @@ namespace Greenshot.Addon.InternetExplorer
// Activate Tab // Activate Tab
ieAccessible.ActivateIETab(tabIndex); ieAccessible.ActivateIETab(tabIndex);
} }
}
/// <summary> /// <summary>
/// Return true if the supplied window has a sub-window which covers more than the supplied percentage /// Return true if the supplied window has a sub-window which covers more than the supplied percentage

View file

@ -26,6 +26,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Jira.Configuration.Impl namespace Greenshot.Addon.Jira.Configuration.Impl
{ {
/// <summary>
/// This implements IJiraLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class JiraLanguageImpl : LanguageBase<IJiraLanguage>, IJiraLanguage public class JiraLanguageImpl : LanguageBase<IJiraLanguage>, IJiraLanguage
{ {

View file

@ -30,13 +30,27 @@ using System.Drawing;
namespace Greenshot.Addon.LegacyEditor namespace Greenshot.Addon.LegacyEditor
{ {
/// <summary>
/// Utility class to work with System.Drawing.Colors
/// TODO: should be done differently
/// </summary>
public static class Colors public static class Colors
{ {
/// <summary>
/// Is the specified color visible?
/// </summary>
/// <param name="c">Color</param>
/// <returns>bool true if visible</returns>
public static bool IsVisible(Color c) public static bool IsVisible(Color c)
{ {
return !c.Equals(Color.Empty) && !c.Equals(Color.Transparent) && c.A > 0; return !c.Equals(Color.Empty) && !c.Equals(Color.Transparent) && c.A > 0;
} }
/// <summary>
/// Mix all specified colors into one
/// </summary>
/// <param name="colors">IEnumerable with Color</param>
/// <returns>Color</returns>
public static Color Mix(IEnumerable<Color> colors) public static Color Mix(IEnumerable<Color> colors)
{ {
var a = 0; var a = 0;

View file

@ -3,7 +3,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.LegacyEditor.Configuration.Impl namespace Greenshot.Addon.LegacyEditor.Configuration.Impl
{ {
/// <summary>
/// This implements IEditorLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class EditorLanguageImpl : LanguageBase<IEditorLanguage>, IEditorLanguage public class EditorLanguageImpl : LanguageBase<IEditorLanguage>, IEditorLanguage
{ {
#region Implementation of IEditorLanguage #region Implementation of IEditorLanguage

View file

@ -63,7 +63,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls
{ {
int halfHeight = e.ArrowRectangle.Height / 2; int halfHeight = e.ArrowRectangle.Height / 2;
int halfWidth = e.ArrowRectangle.Width / 2; int halfWidth = e.ArrowRectangle.Width / 2;
Point middle = new Point(dropDownRect.Left + halfWidth, dropDownRect.Top + halfHeight); var middle = new Point(dropDownRect.Left + halfWidth, dropDownRect.Top + halfHeight);
Point[] arrow; Point[] arrow;

View file

@ -92,7 +92,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls
public event EventHandler<PipetteUsedArgs> PipetteUsed; public event EventHandler<PipetteUsedArgs> PipetteUsed;
/// <summary> /// <summary>
/// Create a cursor from the supplied bitmap & hotspot coordinates /// Create a cursor from the supplied bitmap and hotspot coordinates
/// </summary> /// </summary>
/// <param name="bitmap">Bitmap to create an icon from</param> /// <param name="bitmap">Bitmap to create an icon from</param>
/// <param name="hotspotX">Hotspot X coordinate</param> /// <param name="hotspotX">Hotspot X coordinate</param>

View file

@ -521,7 +521,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
continue; continue;
} }
Size defaultSize = container.DefaultSize; var defaultSize = container.DefaultSize;
container.MakeBoundsChangeUndoable(false); container.MakeBoundsChangeUndoable(false);
container.Width = defaultSize.Width; container.Width = defaultSize.Width;
container.Height = defaultSize.Height; container.Height = defaultSize.Height;

View file

@ -119,8 +119,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
public override bool Equals(object obj) public override bool Equals(object obj)
{ {
var other = obj as Field; if (!(obj is Field other))
if (other == null)
{ {
return false; return false;
} }

View file

@ -75,11 +75,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
set { parent = value; } set { parent = value; }
} }
public DrawableContainer GetParent()
{
return parent;
}
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode); public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode);
protected void OnPropertyChanged(string propertyName) protected void OnPropertyChanged(string propertyName)

View file

@ -32,11 +32,28 @@ using Greenshot.Addons.Interfaces.Drawing;
namespace Greenshot.Addon.LegacyEditor.Drawing.Filters namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
{ {
/// <summary>
/// This defines the interface for all filters
/// </summary>
public interface IFilter : INotifyPropertyChanged, IFieldHolder public interface IFilter : INotifyPropertyChanged, IFieldHolder
{ {
/// <summary>
/// Filters are childen of DrawableContainers, this is the parent
/// </summary>
DrawableContainer Parent { get; set; } DrawableContainer Parent { get; set; }
/// <summary>
/// is the filtered area inverted?
/// </summary>
bool Invert { get; set; } bool Invert { get; set; }
/// <summary>
/// Apply this filter
/// </summary>
/// <param name="graphics">Graphics to use</param>
/// <param name="bmp">Bitmap to apply to</param>
/// <param name="rect">NativeRect with the area</param>
/// <param name="renderMode">RenderMode to use</param>
void Apply(Graphics graphics, Bitmap bmp, NativeRect rect, RenderMode renderMode); void Apply(Graphics graphics, Bitmap bmp, NativeRect rect, RenderMode renderMode);
DrawableContainer GetParent();
} }
} }

View file

@ -184,7 +184,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS); int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR); var lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
using (var pen = new Pen(lineColor)) { using (var pen = new Pen(lineColor)) {
pen.Width = lineThickness; pen.Width = lineThickness;
if (!(pen.Width > 0)) if (!(pen.Width > 0))
@ -199,7 +199,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
graphics.TranslateTransform(Left, Top); graphics.TranslateTransform(Left, Top);
lock (_freehandPathLock) lock (_freehandPathLock)
{ {
if (isRecalculated && Selected && renderMode == RenderMode.EDIT) if (isRecalculated && Selected && renderMode == RenderMode.Edit)
{ {
DrawSelectionBorder(graphics, pen, freehandPath); DrawSelectionBorder(graphics, pen, freehandPath);
} }
@ -257,8 +257,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
{ {
return false; return false;
} }
var other = obj as FreehandContainer;
if (other != null && Equals(freehandPath, other.freehandPath)) { if (obj is FreehandContainer other && Equals(freehandPath, other.freehandPath)) {
ret = true; ret = true;
} }
return ret; return ret;

View file

@ -63,8 +63,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
public override void Draw(Graphics graphics, RenderMode rm) { public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS); int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR, Color.Red); var lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR, Color.Red);
Color fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR, Color.Transparent); var fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR, Color.Transparent);
bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW); bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW);
var rect = new NativeRect(Left, Top, Width, Height).Normalize(); var rect = new NativeRect(Left, Top, Width, Height).Normalize();
@ -95,7 +95,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
int steps = 5; int steps = 5;
int currentStep = lineVisible ? 1 : 0; int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) { while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) { using (var shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1; shadowPen.Width = lineVisible ? lineThickness : 1;
var shadowRect = new NativeRect( var shadowRect = new NativeRect(
rect.Left + currentStep, rect.Left + currentStep,
@ -118,7 +118,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
graphics.SmoothingMode = SmoothingMode.HighSpeed; graphics.SmoothingMode = SmoothingMode.HighSpeed;
if (lineVisible) { if (lineVisible) {
using (Pen pen = new Pen(lineColor, lineThickness)) { using (var pen = new Pen(lineColor, lineThickness)) {
graphics.DrawRectangle(pen, rect); graphics.DrawRectangle(pen, rect);
} }
} }
@ -127,7 +127,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
public override bool ClickableAt(int x, int y) { public override bool ClickableAt(int x, int y) {
var rect = new NativeRect(Left, Top, Width, Height).Normalize(); var rect = new NativeRect(Left, Top, Width, Height).Normalize();
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS) + 10; int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS) + 10;
Color fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR); var fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR);
return RectangleClickableAt(rect, lineThickness, fillColor, x, y); return RectangleClickableAt(rect, lineThickness, fillColor, x, y);
} }
@ -144,8 +144,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
// check the rest of the lines // check the rest of the lines
if (lineThickness > 0) { if (lineThickness > 0) {
using (Pen pen = new Pen(Color.White, lineThickness)) { using (var pen = new Pen(Color.White, lineThickness)) {
using (GraphicsPath path = new GraphicsPath()) { using (var path = new GraphicsPath()) {
path.AddRectangle(rect); path.AddRectangle(rect);
return path.IsOutlineVisible(x, y, pen); return path.IsOutlineVisible(x, y, pen);
} }

View file

@ -229,7 +229,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
var lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor); var lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
var rect = new NativeRect(Left, Top, Width, Height).Normalize(); var rect = new NativeRect(Left, Top, Width, Height).Normalize();
if (Selected && renderMode == RenderMode.EDIT) if (Selected && renderMode == RenderMode.Edit)
{ {
DrawSelectionBorder(graphics, rect); DrawSelectionBorder(graphics, rect);
} }

View file

@ -597,7 +597,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
/// <returns></returns> /// <returns></returns>
public Bitmap GetBitmapForExport() public Bitmap GetBitmapForExport()
{ {
return GetBitmap(RenderMode.EXPORT); return GetBitmap(RenderMode.Export);
} }
/// <summary> /// <summary>
@ -1646,7 +1646,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
DrawBackground(graphics, clipRectangle); DrawBackground(graphics, clipRectangle);
graphics.DrawImage(Screenshot, clipRectangle, clipRectangle, GraphicsUnit.Pixel); graphics.DrawImage(Screenshot, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
graphics.SetClip(targetGraphics); graphics.SetClip(targetGraphics);
_elements.Draw(graphics, _buffer, RenderMode.EDIT, clipRectangle); _elements.Draw(graphics, _buffer, RenderMode.Edit, clipRectangle);
} }
targetGraphics.DrawImage(_buffer, clipRectangle, clipRectangle, GraphicsUnit.Pixel); targetGraphics.DrawImage(_buffer, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
} }
@ -1654,7 +1654,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
{ {
DrawBackground(targetGraphics, clipRectangle); DrawBackground(targetGraphics, clipRectangle);
targetGraphics.DrawImage(Screenshot, clipRectangle, clipRectangle, GraphicsUnit.Pixel); targetGraphics.DrawImage(Screenshot, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
_elements.Draw(targetGraphics, null, RenderMode.EDIT, clipRectangle); _elements.Draw(targetGraphics, null, RenderMode.Edit, clipRectangle);
} }
// No clipping for the adorners // No clipping for the adorners

View file

@ -168,7 +168,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public void FitToText() public void FitToText()
{ {
Size textSize = TextRenderer.MeasureText(text, _font); var textSize = TextRenderer.MeasureText(text, _font);
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS); int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
Width = textSize.Width + lineThickness; Width = textSize.Width + lineThickness;
Height = textSize.Height + lineThickness; Height = textSize.Height + lineThickness;
@ -288,7 +288,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
{ {
return; return;
} }
Color lc = GetFieldValueAsColor(FieldTypes.LINE_COLOR); var lc = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
if (lc.R > 203 && lc.G > 203 && lc.B > 203) if (lc.R > 203 && lc.G > 203 && lc.B > 203)
{ {
_textBox.BackColor = Color.FromArgb(51, 51, 51); _textBox.BackColor = Color.FromArgb(51, 51, 51);
@ -331,7 +331,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
private Font CreateFont(string fontFamilyName, bool fontBold, bool fontItalic, float fontSize) private Font CreateFont(string fontFamilyName, bool fontBold, bool fontItalic, float fontSize)
{ {
FontStyle fontStyle = FontStyle.Regular; var fontStyle = FontStyle.Regular;
bool hasStyle = false; bool hasStyle = false;
using (var fontFamily = new FontFamily(fontFamilyName)) using (var fontFamily = new FontFamily(fontFamilyName))
@ -444,7 +444,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
lineWidth = 1; lineWidth = 1;
correction = -1; correction = -1;
} }
NativeRect absRectangle = new NativeRect(Left, Top, Width, Height).Normalize(); var absRectangle = new NativeRect(Left, Top, Width, Height).Normalize();
_textBox.Left = absRectangle.Left + lineWidth; _textBox.Left = absRectangle.Left + lineWidth;
_textBox.Top = absRectangle.Top + lineWidth; _textBox.Top = absRectangle.Top + lineWidth;
if (lineThickness <= 1) if (lineThickness <= 1)
@ -534,8 +534,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
graphics.PixelOffsetMode = PixelOffsetMode.None; graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault; graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
NativeRect rect = new NativeRect(Left, Top, Width, Height).Normalize(); var rect = new NativeRect(Left, Top, Width, Height).Normalize();
if (Selected && rm == RenderMode.EDIT) if (Selected && rm == RenderMode.Edit)
{ {
DrawSelectionBorder(graphics, rect); DrawSelectionBorder(graphics, rect);
} }
@ -547,9 +547,9 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
// we only draw the shadow if there is no background // we only draw the shadow if there is no background
bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW); bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW);
Color fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR); var fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR);
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS); int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR); var lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
bool drawShadow = shadow && (fillColor == Color.Transparent || fillColor == Color.Empty); bool drawShadow = shadow && (fillColor == Color.Transparent || fillColor == Color.Empty);
DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font); DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font);

View file

@ -34,10 +34,14 @@ using Greenshot.Gfx.Effects;
namespace Greenshot.Addon.LegacyEditor.Forms namespace Greenshot.Addon.LegacyEditor.Forms
{ {
/// <summary>
/// This form makes it possible to change the settings for a DropShadow effect
/// </summary>
public partial class DropShadowSettingsForm : GreenshotForm public partial class DropShadowSettingsForm : GreenshotForm
{ {
private readonly DropShadowEffect _effect; private readonly DropShadowEffect _effect;
/// <inheritdoc />
public DropShadowSettingsForm(DropShadowEffect effect, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage) public DropShadowSettingsForm(DropShadowEffect effect, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
{ {
_effect = effect; _effect = effect;

View file

@ -1703,6 +1703,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
#region key handling #region key handling
/// <inheritdoc />
protected override bool ProcessKeyPreview(ref Message msg) protected override bool ProcessKeyPreview(ref Message msg)
{ {
// disable default key handling if surface has requested a lock // disable default key handling if surface has requested a lock
@ -1714,6 +1715,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
return base.ProcessKeyPreview(ref msg); return base.ProcessKeyPreview(ref msg);
} }
/// <inheritdoc />
protected override bool ProcessCmdKey(ref Message msg, Keys keys) protected override bool ProcessCmdKey(ref Message msg, Keys keys)
{ {
// disable default key handling if surface has requested a lock // disable default key handling if surface has requested a lock

View file

@ -35,7 +35,7 @@ using Greenshot.Addons.Interfaces.Drawing;
namespace Greenshot.Addon.LegacyEditor.Memento namespace Greenshot.Addon.LegacyEditor.Memento
{ {
/// <summary> /// <summary>
/// The DrawableContainerBoundsChangeMemento makes it possible to undo-redo an IDrawableContainer resize & move /// The DrawableContainerBoundsChangeMemento makes it possible to undo-redo an IDrawableContainer resize and move
/// </summary> /// </summary>
public class DrawableContainerBoundsChangeMemento : IMemento public class DrawableContainerBoundsChangeMemento : IMemento
{ {

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Lutim.Configuration.Impl namespace Greenshot.Addon.Lutim.Configuration.Impl
{ {
/// <summary>
/// This implements ILutimLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class LutimLanguageImpl : LanguageBase<ILutimLanguage>, ILutimLanguage public class LutimLanguageImpl : LanguageBase<ILutimLanguage>, ILutimLanguage
{ {
#region Implementation of ILutimLanguage #region Implementation of ILutimLanguage

View file

@ -24,17 +24,20 @@
#region Usings #region Usings
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using Dapplo.Config.Ini; using Dapplo.Config.Ini;
#endregion #endregion
namespace Greenshot.Addon.OCR namespace Greenshot.Addon.OCR.Configuration
{ {
/// <summary> /// <summary>
/// OCR Configuration. /// OCR Configuration.
/// </summary> /// </summary>
[IniSection("OCR")] [IniSection("OCR")]
[Description("Greenshot OCR Plugin configuration")] [Description("Greenshot OCR Plugin configuration")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
#pragma warning disable CS1591
public interface IOcrConfiguration : IIniSection public interface IOcrConfiguration : IIniSection
{ {
[Description("Language for OCR")] [Description("Language for OCR")]

View file

@ -17,13 +17,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.ComponentModel; using System.Diagnostics.CodeAnalysis;
using Dapplo.Config.Language; using Dapplo.Config.Language;
namespace Greenshot.Addon.OCR namespace Greenshot.Addon.OCR.Configuration
{ {
[Language("Ocr")] [Language("Ocr")]
public interface IOcrLanguage : ILanguage, INotifyPropertyChanged [SuppressMessage("ReSharper", "UnusedMember.Global")]
#pragma warning disable CS1591
public interface IOcrLanguage : ILanguage
{ {
string Language { get; } string Language { get; }
string OrientImage { get; } string OrientImage { get; }

View file

@ -26,6 +26,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.OCR.Configuration.Impl namespace Greenshot.Addon.OCR.Configuration.Impl
{ {
/// <summary>
/// This implements IOcrLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class OcrLanguageImpl : LanguageBase<IOcrLanguage>, IOcrLanguage public class OcrLanguageImpl : LanguageBase<IOcrLanguage>, IOcrLanguage
{ {

View file

@ -30,6 +30,7 @@ using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
using Dapplo.Log; using Dapplo.Log;
using Greenshot.Addon.OCR.Configuration;
using Greenshot.Addons; using Greenshot.Addons;
using Greenshot.Addons.Components; using Greenshot.Addons.Components;
using Greenshot.Addons.Core; using Greenshot.Addons.Core;

View file

@ -28,6 +28,7 @@ using Dapplo.Addons;
using Dapplo.Addons.Bootstrapper.Resolving; using Dapplo.Addons.Bootstrapper.Resolving;
using Dapplo.Config.Ini; using Dapplo.Config.Ini;
using Dapplo.Config.Language; using Dapplo.Config.Language;
using Greenshot.Addon.OCR.Configuration;
using Greenshot.Addon.OCR.Configuration.Impl; using Greenshot.Addon.OCR.Configuration.Impl;
using Greenshot.Addons.Components; using Greenshot.Addons.Components;

View file

@ -24,6 +24,7 @@
#region Usings #region Usings
using System; using System;
using Greenshot.Addon.OCR.Configuration;
using Greenshot.Addons.Controls; using Greenshot.Addons.Controls;
#endregion #endregion

View file

@ -22,6 +22,9 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Office.Configuration namespace Greenshot.Addon.Office.Configuration
{ {
/// <summary>
/// This implements IOfficeLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591 #pragma warning disable CS1591
[Language("Office")] [Language("Office")]
public interface IOfficeLanguage : ILanguage, INotifyPropertyChanged public interface IOfficeLanguage : ILanguage, INotifyPropertyChanged

View file

@ -1,9 +1,35 @@
using Dapplo.Config.Ini; #region Greenshot GNU General License
// Greenshot - a free and open source screenshot tool
// Copyright (C) 2007-2018 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 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 License for more details.
//
// You should have received a copy of the GNU General License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#endregion
using Dapplo.Config.Ini;
using Greenshot.Addon.Office.OfficeInterop; using Greenshot.Addon.Office.OfficeInterop;
using Microsoft.Office.Interop.PowerPoint; using Microsoft.Office.Interop.PowerPoint;
namespace Greenshot.Addon.Office.Configuration.Impl namespace Greenshot.Addon.Office.Configuration.Impl
{ {
/// <summary>
/// This implements IOfficeConfiguration and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591 #pragma warning disable CS1591
public class OfficeConfigurationImpl : IniSectionBase<IOfficeConfiguration>, IOfficeConfiguration public class OfficeConfigurationImpl : IniSectionBase<IOfficeConfiguration>, IOfficeConfiguration
{ {

View file

@ -26,6 +26,9 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Office.Configuration.Impl namespace Greenshot.Addon.Office.Configuration.Impl
{ {
/// <summary>
/// This implements IOfficeLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591 #pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class OfficeLanguageImpl : LanguageBase<IOfficeLanguage>, IOfficeLanguage public class OfficeLanguageImpl : LanguageBase<IOfficeLanguage>, IOfficeLanguage

View file

@ -38,7 +38,7 @@ namespace Greenshot.Addon.Office.OfficeExport.Entities
{ {
get get
{ {
OneNoteNotebook notebook = Parent.Parent; var notebook = Parent.Parent;
if (string.IsNullOrEmpty(notebook.Name)) if (string.IsNullOrEmpty(notebook.Name))
{ {
return string.Format("{0} / {1}", Parent.Name, Name); return string.Format("{0} / {1}", Parent.Name, Name);

View file

@ -76,7 +76,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// <returns>ComDisposable for Excel.Application</returns> /// <returns>ComDisposable for Excel.Application</returns>
private static IDisposableCom<Application> GetOrCreateExcelApplication() private static IDisposableCom<Application> GetOrCreateExcelApplication()
{ {
IDisposableCom<Application> excelApplication = GetExcelApplication(); var excelApplication = GetExcelApplication();
if (excelApplication == null) if (excelApplication == null)
{ {
excelApplication = DisposableCom.Create(new Application()); excelApplication = DisposableCom.Create(new Application());

View file

@ -582,7 +582,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// <returns>IDisposableCom for Outlook.Application</returns> /// <returns>IDisposableCom for Outlook.Application</returns>
private IDisposableCom<Application> GetOrCreateOutlookApplication() private IDisposableCom<Application> GetOrCreateOutlookApplication()
{ {
IDisposableCom<Application> outlookApplication = GetOutlookApplication(); var outlookApplication = GetOutlookApplication();
if (outlookApplication == null) if (outlookApplication == null)
{ {
outlookApplication = DisposableCom.Create(new Application()); outlookApplication = DisposableCom.Create(new Application());
@ -620,7 +620,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// <returns></returns> /// <returns></returns>
private string GetOutlookSignature(EmailFormat format) private string GetOutlookSignature(EmailFormat format)
{ {
using (RegistryKey profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false)) using (var profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false))
{ {
if (profilesKey == null) if (profilesKey == null)
{ {
@ -628,7 +628,7 @@ namespace Greenshot.Addon.Office.OfficeExport
} }
string defaultProfile = (string)profilesKey.GetValue(DefaultProfileValue); string defaultProfile = (string)profilesKey.GetValue(DefaultProfileValue);
Log.Debug().WriteLine("defaultProfile={0}", defaultProfile); Log.Debug().WriteLine("defaultProfile={0}", defaultProfile);
using (RegistryKey profileKey = profilesKey.OpenSubKey(defaultProfile + @"\" + AccountKey, false)) using (var profileKey = profilesKey.OpenSubKey(defaultProfile + @"\" + AccountKey, false))
{ {
if (profileKey != null) if (profileKey != null)
{ {
@ -636,7 +636,7 @@ namespace Greenshot.Addon.Office.OfficeExport
foreach (string number in numbers) foreach (string number in numbers)
{ {
Log.Debug().WriteLine("Found subkey {0}", number); Log.Debug().WriteLine("Found subkey {0}", number);
using (RegistryKey numberKey = profileKey.OpenSubKey(number, false)) using (var numberKey = profileKey.OpenSubKey(number, false))
{ {
if (numberKey != null) if (numberKey != null)
{ {

View file

@ -257,7 +257,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// <returns>ComDisposable for PowerPoint.Application</returns> /// <returns>ComDisposable for PowerPoint.Application</returns>
private IDisposableCom<Application> GetOrCreatePowerPointApplication() private IDisposableCom<Application> GetOrCreatePowerPointApplication()
{ {
IDisposableCom<Application> powerPointApplication = GetPowerPointApplication(); var powerPointApplication = GetPowerPointApplication();
if (powerPointApplication == null) if (powerPointApplication == null)
{ {
powerPointApplication = DisposableCom.Create(new Application()); powerPointApplication = DisposableCom.Create(new Application());

View file

@ -79,7 +79,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// <returns>ComDisposable for Word.Application</returns> /// <returns>ComDisposable for Word.Application</returns>
private IDisposableCom<Application> GetOrCreateWordApplication() private IDisposableCom<Application> GetOrCreateWordApplication()
{ {
IDisposableCom<Application> wordApplication = GetWordApplication(); var wordApplication = GetWordApplication();
if (wordApplication == null) if (wordApplication == null)
{ {
wordApplication = DisposableCom.Create(new Application()); wordApplication = DisposableCom.Create(new Application());

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.OneDrive.Configuration.Impl namespace Greenshot.Addon.OneDrive.Configuration.Impl
{ {
/// <summary>
/// This implements IOneDriveLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class OneDriveLanguageImpl : LanguageBase<IOneDriveLanguage>, IOneDriveLanguage public class OneDriveLanguageImpl : LanguageBase<IOneDriveLanguage>, IOneDriveLanguage
{ {
#region Implementation of IOneDriveLanguage #region Implementation of IOneDriveLanguage

View file

@ -26,6 +26,10 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Photobucket.Configuration.Impl namespace Greenshot.Addon.Photobucket.Configuration.Impl
{ {
/// <summary>
/// This implements IPhotobucketLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
#pragma warning disable CS1591
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
public class PhotobucketLanguageImpl : LanguageBase<IPhotobucketLanguage>, IPhotobucketLanguage public class PhotobucketLanguageImpl : LanguageBase<IPhotobucketLanguage>, IPhotobucketLanguage
{ {

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addon.Tfs.Configuration.Impl namespace Greenshot.Addon.Tfs.Configuration.Impl
{ {
/// <summary>
/// This implements ITfsLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
public class TfsLanguageImpl : LanguageBase<ITfsLanguage>, ITfsLanguage public class TfsLanguageImpl : LanguageBase<ITfsLanguage>, ITfsLanguage
{ {
#region Implementation of ITfsLanguage #region Implementation of ITfsLanguage

View file

@ -94,7 +94,7 @@ namespace Greenshot.Addon.Tfs
public async Task<WorkItemList> GetOwnWorkitems() public async Task<WorkItemList> GetOwnWorkitems()
{ {
_tfsHttpBehaviour.MakeCurrent(); _tfsHttpBehaviour.MakeCurrent();
Uri apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0"); var apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0");
var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey); var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey);
var workitemsQueryUri = apiUri.AppendSegments("wit", "wiql"); var workitemsQueryUri = apiUri.AppendSegments("wit", "wiql");
@ -127,7 +127,7 @@ namespace Greenshot.Addon.Tfs
_tfsHttpBehaviour.MakeCurrent(); _tfsHttpBehaviour.MakeCurrent();
var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey); var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey);
Uri apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0"); var apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0");
var filename = surface.GenerateFilename(_coreConfiguration, _tfsConfiguration); var filename = surface.GenerateFilename(_coreConfiguration, _tfsConfiguration);
var attachmentUri = apiUri.AppendSegments("wit", "attachments").ExtendQuery("fileName", filename); var attachmentUri = apiUri.AppendSegments("wit", "attachments").ExtendQuery("fileName", filename);
@ -159,7 +159,7 @@ namespace Greenshot.Addon.Tfs
_tfsHttpBehaviour.MakeCurrent(); _tfsHttpBehaviour.MakeCurrent();
var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey); var client = HttpClientFactory.Create(_tfsConfiguration.TfsUri).SetBasicAuthorization("", _tfsConfiguration.ApiKey);
Uri apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0"); var apiUri = _tfsConfiguration.TfsUri.AppendSegments("_apis").ExtendQuery("api-version", "3.0");
// https://docs.microsoft.com/en-us/rest/api/vsts/wit/work%20items/update#add_an_attachment // https://docs.microsoft.com/en-us/rest/api/vsts/wit/work%20items/update#add_an_attachment
var linkAttachmentUri = apiUri.AppendSegments("wit", "workItems", workItem.Id); var linkAttachmentUri = apiUri.AppendSegments("wit", "workItems", workItem.Id);
var linkAttachmentRequest = new List<Operation> var linkAttachmentRequest = new List<Operation>

View file

@ -34,11 +34,23 @@ namespace Greenshot.Addons.Animation
/// </summary> /// </summary>
public static class EasePower public static class EasePower
{ {
/// <summary>
/// Calculate EaseIn
/// </summary>
/// <param name="s">double</param>
/// <param name="power">int</param>
/// <returns>double</returns>
public static double EaseIn(double s, int power) public static double EaseIn(double s, int power)
{ {
return Math.Pow(s, power); return Math.Pow(s, power);
} }
/// <summary>
/// Calculate EaseInOut
/// </summary>
/// <param name="s">double</param>
/// <param name="power">int</param>
/// <returns>double</returns>
public static double EaseInOut(double s, int power) public static double EaseInOut(double s, int power)
{ {
s *= 2; s *= 2;
@ -50,6 +62,12 @@ namespace Greenshot.Addons.Animation
return sign / 2.0 * (Math.Pow(s - 2, power) + sign * 2); return sign / 2.0 * (Math.Pow(s - 2, power) + sign * 2);
} }
/// <summary>
/// Calculate EaseOut
/// </summary>
/// <param name="s">double</param>
/// <param name="power">int</param>
/// <returns>double</returns>
public static double EaseOut(double s, int power) public static double EaseOut(double s, int power)
{ {
var sign = power % 2 == 0 ? -1 : 1; var sign = power % 2 == 0 ? -1 : 1;

View file

@ -3,7 +3,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Addons.Config.Impl namespace Greenshot.Addons.Config.Impl
{ {
/// <summary>
/// This implements IGreenshotLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
internal class GreenshotLanguageImpl : LanguageBase<IGreenshotLanguage>, IGreenshotLanguage internal class GreenshotLanguageImpl : LanguageBase<IGreenshotLanguage>, IGreenshotLanguage
{ {
#region Implementation of ICoreTranslations #region Implementation of ICoreTranslations

View file

@ -36,8 +36,7 @@ namespace Greenshot.Addons.Core
{ {
public virtual int CompareTo(object obj) public virtual int CompareTo(object obj)
{ {
var other = obj as IProcessor; if (!(obj is IProcessor other))
if (other == null)
{ {
return 1; return 1;
} }
@ -52,20 +51,14 @@ namespace Greenshot.Addons.Core
public abstract string Description { get; } public abstract string Description { get; }
public virtual int Priority public virtual int Priority => 10;
{
get { return 10; }
}
public void Dispose() public void Dispose()
{ {
Dispose(true); Dispose(true);
} }
public virtual bool IsActive public virtual bool IsActive => true;
{
get { return true; }
}
public abstract bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails); public abstract bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails);

View file

@ -38,23 +38,31 @@ namespace Greenshot.Addons.Core
/// </summary> /// </summary>
public class CaptureDetails : ICaptureDetails public class CaptureDetails : ICaptureDetails
{ {
/// <inheritdoc />
public CaptureDetails() public CaptureDetails()
{ {
DateTime = DateTime.Now; DateTime = DateTime.Now;
} }
/// <inheritdoc />
public string Title { get; set; } public string Title { get; set; }
/// <inheritdoc />
public string Filename { get; set; } public string Filename { get; set; }
/// <inheritdoc />
public DateTime DateTime { get; set; } public DateTime DateTime { get; set; }
/// <inheritdoc />
public float DpiX { get; set; } public float DpiX { get; set; }
/// <inheritdoc />
public float DpiY { get; set; } public float DpiY { get; set; }
/// <inheritdoc />
public Dictionary<string, string> MetaData { get; } = new Dictionary<string, string>(); public Dictionary<string, string> MetaData { get; } = new Dictionary<string, string>();
/// <inheritdoc />
public void AddMetaData(string key, string value) public void AddMetaData(string key, string value)
{ {
if (MetaData.ContainsKey(key)) if (MetaData.ContainsKey(key))
@ -67,15 +75,19 @@ namespace Greenshot.Addons.Core
} }
} }
/// <inheritdoc />
public CaptureMode CaptureMode { get; set; } public CaptureMode CaptureMode { get; set; }
/// <inheritdoc />
public List<IDestination> CaptureDestinations { get; set; } = new List<IDestination>(); public List<IDestination> CaptureDestinations { get; set; } = new List<IDestination>();
/// <inheritdoc />
public void ClearDestinations() public void ClearDestinations()
{ {
CaptureDestinations.Clear(); CaptureDestinations.Clear();
} }
/// <inheritdoc />
public void RemoveDestination(IDestination destination) public void RemoveDestination(IDestination destination)
{ {
if (CaptureDestinations.Contains(destination)) if (CaptureDestinations.Contains(destination))
@ -84,6 +96,7 @@ namespace Greenshot.Addons.Core
} }
} }
/// <inheritdoc />
public void AddDestination(IDestination captureDestination) public void AddDestination(IDestination captureDestination)
{ {
if (!CaptureDestinations.Contains(captureDestination)) if (!CaptureDestinations.Contains(captureDestination))
@ -92,6 +105,7 @@ namespace Greenshot.Addons.Core
} }
} }
/// <inheritdoc />
public bool HasDestination(string designation) public bool HasDestination(string designation)
{ {
foreach (var destination in CaptureDestinations) foreach (var destination in CaptureDestinations)

View file

@ -131,7 +131,7 @@ namespace Greenshot.Addons.Core
// Make sure we have clipboard formats, otherwise a paste doesn't make sense! // Make sure we have clipboard formats, otherwise a paste doesn't make sense!
if (coreConfiguration.ClipboardFormats == null || coreConfiguration.ClipboardFormats.Count == 0) if (coreConfiguration.ClipboardFormats == null || coreConfiguration.ClipboardFormats.Count == 0)
{ {
coreConfiguration.ClipboardFormats = new List<ClipboardFormats> { Enums.ClipboardFormats.PNG, Enums.ClipboardFormats.HTML, Enums.ClipboardFormats.DIB }; coreConfiguration.ClipboardFormats = new List<ClipboardFormats> { ClipboardFormats.PNG, ClipboardFormats.HTML, ClipboardFormats.DIB };
} }
// Make sure the lists are lowercase, to speedup the check // Make sure the lists are lowercase, to speedup the check

View file

@ -546,8 +546,10 @@ namespace Greenshot.Addons.Core
else if (Equals(imageFormat, ImageFormat.Icon)) else if (Equals(imageFormat, ImageFormat.Icon))
{ {
// FEATURE-916: Added Icon support // FEATURE-916: Added Icon support
IList<Bitmap> bitmaps = new List<Bitmap>(); IList<Bitmap> bitmaps = new List<Bitmap>
bitmaps.Add(bitmapToSave); {
bitmapToSave
};
WriteIcon(stream, bitmaps); WriteIcon(stream, bitmaps);
} }
else else

View file

@ -23,9 +23,18 @@
namespace Greenshot.Addons.Interfaces.Drawing namespace Greenshot.Addons.Interfaces.Drawing
{ {
/// <summary>
/// Specifies how something needs to be rendered, the idea was that export needs more details and no "edit" adorners.
/// </summary>
public enum RenderMode public enum RenderMode
{ {
EDIT, /// <summary>
EXPORT /// Render for editing
/// </summary>
Edit,
/// <summary>
/// Render for exporting
/// </summary>
Export
} }
} }

View file

@ -75,7 +75,7 @@ namespace Greenshot.Core.Extensions
public static ICaptureElement<BitmapSource> CaptureFromScreen(this IInteropWindow interopWindow, bool clientBounds = false) public static ICaptureElement<BitmapSource> CaptureFromScreen(this IInteropWindow interopWindow, bool clientBounds = false)
{ {
var bounds = clientBounds ? interopWindow.GetInfo().ClientBounds: interopWindow.GetInfo().Bounds; var bounds = clientBounds ? interopWindow.GetInfo().ClientBounds: interopWindow.GetInfo().Bounds;
ICaptureElement<BitmapSource> result = ScreenSource.CaptureRectangle(bounds); var result = ScreenSource.CaptureRectangle(bounds);
return result; return result;
} }

View file

@ -57,8 +57,7 @@ namespace Greenshot.Gfx
{ {
using (var tmpImage = Image.FromStream(stream, true, true)) using (var tmpImage = Image.FromStream(stream, true, true))
{ {
var bitmap = tmpImage as Bitmap; if (!(tmpImage is Bitmap bitmap))
if (bitmap == null)
{ {
return null; return null;
} }
@ -69,8 +68,6 @@ namespace Greenshot.Gfx
static BitmapHelper() static BitmapHelper()
{ {
// Fallback // Fallback
StreamConverters[""] = FromStreamReader; StreamConverters[""] = FromStreamReader;

View file

@ -26,7 +26,11 @@ using Dapplo.Config.Language;
namespace Greenshot.Configuration.Impl namespace Greenshot.Configuration.Impl
{ {
/// <summary>
/// This implements IConfigTranslations and takes care of storing, all setters are replaced via AutoProperties.Fody
/// </summary>
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")] [SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
#pragma warning disable CS1591
internal class ConfigTranslationsImpl : LanguageBase<IConfigTranslations>, IConfigTranslations internal class ConfigTranslationsImpl : LanguageBase<IConfigTranslations>, IConfigTranslations
{ {
public string Filter { get; } public string Filter { get; }

View file

@ -1,79 +0,0 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Diagnostics;
using Greenshot.Addon.LegacyEditor.Controls;
namespace GreenShot
{
public delegate void ColorPickerEventHandler(object o, ColorPickerEventArgs e);
public class ColorPickerToolStripButton : System.Windows.Forms.ToolStripButton
{
private Color color;
public Point Offset = new Point(0,0);
public event ColorPickerEventHandler ColorPicked;
private Greenshot.Addon.LegacyEditor.Controls.ColorDialog cd;
public ColorPickerToolStripButton()
{
cd = null;// Greenshot.Addon.LegacyEditor.Controls.ColorDialog.GetInstance();
this.Click += new System.EventHandler(this.ToolStripButton1Click);
}
public Color Color {
set {color = value;this.Invalidate();}
get {return color;}
}
protected override void OnPaint (PaintEventArgs e) {
base.OnPaint(e);
if(color != null) {
// replace transparent color with selected color
Graphics g = e.Graphics;
//Graphics g = Graphics.FromImage(Image);
ColorMap[] colorMap = new ColorMap[1];
colorMap[0] = new ColorMap();
colorMap[0].OldColor = Color.Magenta;//this.ImageTransparentColor;
colorMap[0].NewColor = color;
var attr = new ImageAttributes();
attr.SetRemapTable(colorMap);
Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
// todo find a way to retrieve transparency offset automatically
// for now, we use the public variable Offset to define this manually
rect.Offset(Offset.X,Offset.Y);
//Image.
Debug.WriteLine("paint!"+this.Text+": "+color);
//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
//this.Image.In
}
}
void ToolStripButton1Click(object sender, System.EventArgs e)
{
cd.ShowDialog(this.Owner);
Color = cd.Color;
if(ColorPicked != null) {
//ColorPicked(this, new ColorPickerEventArgs(Color, cd.RecentColors));
}
}
}
public class ColorPickerEventArgs : System.EventArgs {
public Color Color;
public Color[] RecentColors;
public ColorPickerEventArgs(Color color, Color[] recentColors) {
Color = color;
RecentColors = recentColors;
}
}
}

View file

@ -723,7 +723,7 @@ namespace Greenshot.Helpers
/// <returns>WindowDetails with the target Window OR a replacement</returns> /// <returns>WindowDetails with the target Window OR a replacement</returns>
public static IInteropWindow SelectCaptureWindow(IInteropWindow windowToCapture) public static IInteropWindow SelectCaptureWindow(IInteropWindow windowToCapture)
{ {
NativeRect windowRectangle = windowToCapture.GetInfo().Bounds; var windowRectangle = windowToCapture.GetInfo().Bounds;
if (windowRectangle.Width == 0 || windowRectangle.Height == 0) if (windowRectangle.Width == 0 || windowRectangle.Height == 0)
{ {
Log.Warn().WriteLine("Window {0} has nothing to capture, using workaround to find other window of same process.", windowToCapture.Text); Log.Warn().WriteLine("Window {0} has nothing to capture, using workaround to find other window of same process.", windowToCapture.Text);
@ -784,7 +784,7 @@ namespace Greenshot.Helpers
{ {
captureForWindow = new Capture(); captureForWindow = new Capture();
} }
NativeRect windowRectangle = windowToCapture.GetInfo().Bounds; var windowRectangle = windowToCapture.GetInfo().Bounds;
// When Vista & DWM (Aero) enabled // When Vista & DWM (Aero) enabled
var dwmEnabled = Dwm.IsDwmEnabled; var dwmEnabled = Dwm.IsDwmEnabled;