mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Just a bunch of code quality changes, still need to reduce another ~2000 warnings.
This commit is contained in:
parent
a2773088c7
commit
56c46e6800
68 changed files with 429 additions and 203 deletions
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class BoxLanguageImpl : LanguageBase<IBoxLanguage>, IBoxLanguage
|
||||
{
|
||||
#region Implementation of IBoxLanguage
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class ConfluenceLanguageImpl : LanguageBase<IConfluenceLanguage>, IConfluenceLanguage
|
||||
{
|
||||
#region Implementation of IConfluenceLanguage
|
||||
|
|
|
@ -22,6 +22,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class DropboxLanguageImpl: LanguageBase<IDropboxLanguage>, IDropboxLanguage
|
||||
{
|
||||
|
|
|
@ -198,7 +198,7 @@ namespace Greenshot.Addon.Dropbox
|
|||
/// <param name="progress">IProgress</param>
|
||||
/// <param name="cancellationToken">CancellationToken</param>
|
||||
/// <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();
|
||||
// Use UploadProgress
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dapplo.Config.Ini;
|
||||
using Greenshot.Addon.ExternalCommand.Entities;
|
||||
using Greenshot.Addons.Core;
|
||||
|
@ -38,6 +39,7 @@ namespace Greenshot.Addon.ExternalCommand.Configuration
|
|||
/// </summary>
|
||||
[IniSection("ExternalCommand")]
|
||||
[Description("Greenshot ExternalCommand Plugin configuration")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public interface IExternalCommandConfiguration : IIniSection, IDestinationFileConfiguration
|
||||
{
|
||||
[Description("The commands that are available.")]
|
||||
|
|
|
@ -21,11 +21,13 @@
|
|||
|
||||
#endregion
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dapplo.Config.Language;
|
||||
|
||||
namespace Greenshot.Addon.ExternalCommand.Configuration
|
||||
{
|
||||
[Language("ExternalCommand")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public interface IExternalCommandLanguage : ILanguage
|
||||
{
|
||||
string ContextmenuConfigure { get; }
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class ExternalCommandLanguageImpl : LanguageBase<IExternalCommandLanguage>, IExternalCommandLanguage
|
||||
{
|
||||
#region Implementation of IExternalCommandLanguage
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#region Usings
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using Dapplo.Config.Ini;
|
||||
using Dapplo.HttpExtensions.OAuth;
|
||||
|
@ -33,18 +34,12 @@ using Greenshot.Addons.Core;
|
|||
|
||||
namespace Greenshot.Addon.Flickr.Configuration
|
||||
{
|
||||
public enum SafetyLevel
|
||||
{
|
||||
Safe = 1,
|
||||
Moderate = 2,
|
||||
Restricted = 3
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Description of FlickrConfiguration.
|
||||
/// This defines the configuration for the Flickr addon
|
||||
/// </summary>
|
||||
[IniSection("Flickr")]
|
||||
[Description("Greenshot Flickr Plugin configuration")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public interface IFlickrConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth1Token
|
||||
{
|
||||
[Description("IsPublic.")]
|
||||
|
@ -59,18 +54,30 @@ namespace Greenshot.Addon.Flickr.Configuration
|
|||
[DefaultValue(true)]
|
||||
bool IsFriend { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[Description("Safety level")]
|
||||
[DefaultValue(SafetyLevel.Safe)]
|
||||
SafetyLevel SafetyLevel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Hide the image from the search results in Flickr
|
||||
/// </summary>
|
||||
[Description("Hidden from search")]
|
||||
[DefaultValue(false)]
|
||||
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.")]
|
||||
[DefaultValue(true)]
|
||||
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")]
|
||||
[DefaultValue(false)]
|
||||
bool UsePageLink { get; set; }
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#region Usings
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dapplo.Config.Language;
|
||||
|
||||
#endregion
|
||||
|
@ -26,6 +27,7 @@ using Dapplo.Config.Language;
|
|||
namespace Greenshot.Addon.Flickr.Configuration
|
||||
{
|
||||
[Language("Flickr")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public interface IFlickrLanguage : ILanguage
|
||||
{
|
||||
string CommunicationWait { get; }
|
||||
|
|
|
@ -26,6 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class FlickrLanguageImpl : LanguageBase<IFlickrLanguage>, IFlickrLanguage
|
||||
{
|
||||
|
|
35
src/Greenshot.Addon.Flickr/Configuration/SafetyLevel.cs
Normal file
35
src/Greenshot.Addon.Flickr/Configuration/SafetyLevel.cs
Normal 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
|
||||
}
|
||||
}
|
|
@ -32,6 +32,9 @@ using Greenshot.Addons.ViewModels;
|
|||
|
||||
namespace Greenshot.Addon.Flickr.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// This is the ViewModel for the configuration of the Flickr addon
|
||||
/// </summary>
|
||||
public sealed class FlickrConfigViewModel : SimpleConfigScreen
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -39,10 +42,20 @@ namespace Greenshot.Addon.Flickr.ViewModels
|
|||
/// </summary>
|
||||
private CompositeDisposable _disposables;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for the view
|
||||
/// </summary>
|
||||
public IFlickrConfiguration FlickrConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Translations for the view
|
||||
/// </summary>
|
||||
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 FlickrConfigViewModel(
|
||||
|
@ -55,6 +68,7 @@ namespace Greenshot.Addon.Flickr.ViewModels
|
|||
FileConfigPartViewModel = fileConfigPartViewModel;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(IConfig config)
|
||||
{
|
||||
FileConfigPartViewModel.DestinationFileConfiguration = FlickrConfiguration;
|
||||
|
@ -76,12 +90,16 @@ namespace Greenshot.Addon.Flickr.ViewModels
|
|||
base.Initialize(config);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_disposables.Dispose();
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used in the view for the dropdown
|
||||
/// </summary>
|
||||
public SafetyLevel SelectedSafetyLevel
|
||||
{
|
||||
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>();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#region Usings
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.Serialization;
|
||||
using Dapplo.Config.Ini;
|
||||
using Dapplo.HttpExtensions.OAuth;
|
||||
|
@ -38,6 +39,7 @@ namespace Greenshot.Addon.GooglePhotos.Configuration
|
|||
/// </summary>
|
||||
[IniSection("GooglePhotos")]
|
||||
[Description("Greenshot Google Photos Plugin configuration")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
public interface IGooglePhotosConfiguration : IIniSection, IDestinationFileConfiguration, IOAuth2Token
|
||||
{
|
||||
[Description("After upload send Google Photos link to clipboard.")]
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class GooglePhotosLanguageImpl : LanguageBase<IGooglePhotosLanguage>, IGooglePhotosLanguage
|
||||
{
|
||||
#region Implementation of IGooglePhotosLanguage
|
||||
|
|
|
@ -37,8 +37,20 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
|
|||
/// </summary>
|
||||
private CompositeDisposable _disposables;
|
||||
|
||||
/// <summary>
|
||||
/// Configuration for the view
|
||||
/// </summary>
|
||||
public IGooglePhotosConfiguration GooglePhotosConfiguration { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Translations for the view
|
||||
/// </summary>
|
||||
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 GooglePhotosConfigViewModel(
|
||||
|
@ -51,6 +63,7 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
|
|||
FileConfigPartViewModel = fileConfigPartViewModel;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Initialize(IConfig config)
|
||||
{
|
||||
FileConfigPartViewModel.DestinationFileConfiguration = GooglePhotosConfiguration;
|
||||
|
@ -72,6 +85,7 @@ namespace Greenshot.Addon.GooglePhotos.ViewModels
|
|||
base.Initialize(config);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_disposables.Dispose();
|
||||
|
|
|
@ -26,6 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class ImgurLanguageImpl : LanguageBase<IImgurLanguage>, IImgurLanguage
|
||||
{
|
||||
|
|
|
@ -45,16 +45,22 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
public sealed class ImgurHistoryViewModel : Screen
|
||||
{
|
||||
private static readonly LogSource Log = new LogSource();
|
||||
private readonly ImgurApi _imgurApi;
|
||||
|
||||
/// <summary>
|
||||
/// Here all disposables are registered, so we can clean the up
|
||||
/// </summary>
|
||||
private CompositeDisposable _disposables;
|
||||
|
||||
/// <summary>
|
||||
/// The configuration used in the view
|
||||
/// </summary>
|
||||
public IImgurConfiguration ImgurConfiguration { get; }
|
||||
|
||||
public ImgurApi ImgurApi { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The translations used in the view
|
||||
/// </summary>
|
||||
public IImgurLanguage ImgurLanguage { get; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -62,6 +68,13 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
/// </summary>
|
||||
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(
|
||||
IImgurConfiguration imgurConfiguration,
|
||||
ImgurApi imgurApi,
|
||||
|
@ -70,7 +83,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
)
|
||||
{
|
||||
ImgurConfiguration = imgurConfiguration;
|
||||
ImgurApi = imgurApi;
|
||||
_imgurApi = imgurApi;
|
||||
ImgurLanguage = imgurLanguage;
|
||||
GreenshotLanguage = greenshotLanguage;
|
||||
}
|
||||
|
@ -79,6 +92,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
/// </summary>
|
||||
public ObservableCollection<ImgurImage> ImgurHistory { get; } = new BindableCollection<ImgurImage>();
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnActivate()
|
||||
{
|
||||
// Prepare disposables
|
||||
|
@ -91,6 +105,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
_ = LoadHistory();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
_disposables.Dispose();
|
||||
|
@ -117,10 +132,10 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
}
|
||||
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)
|
||||
{
|
||||
await ImgurApi.RetrieveImgurThumbnailAsync(imgurInfo, cancellationToken).ConfigureAwait(true);
|
||||
await _imgurApi.RetrieveImgurThumbnailAsync(imgurInfo, cancellationToken).ConfigureAwait(true);
|
||||
ImgurConfiguration.RuntimeImgurHistory.Add(hash, imgurInfo);
|
||||
// Already loaded, only add it to the view
|
||||
ImgurHistory.Add(imgurInfo);
|
||||
|
@ -138,6 +153,9 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The selected Imgur entry
|
||||
/// </summary>
|
||||
public ImgurImage SelectedImgur { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
|
@ -150,7 +168,7 @@ namespace Greenshot.Addon.Imgur.ViewModels
|
|||
/// </summary>
|
||||
public async Task Delete()
|
||||
{
|
||||
await ImgurApi.DeleteImgurImageAsync(SelectedImgur).ConfigureAwait(true);
|
||||
await _imgurApi.DeleteImgurImageAsync(SelectedImgur).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -72,8 +72,7 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
var list = new List<Accessible>(res.Length);
|
||||
foreach (var obj in res)
|
||||
{
|
||||
var accessible = obj as IAccessible;
|
||||
if (accessible != null)
|
||||
if (obj is IAccessible accessible)
|
||||
{
|
||||
list.Add(new Accessible(accessible));
|
||||
}
|
||||
|
@ -92,6 +91,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
get { return accessible.accChildCount; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the URL for the active tab
|
||||
/// </summary>
|
||||
public string IEActiveTabUrl
|
||||
{
|
||||
get
|
||||
|
@ -124,6 +126,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the index of the active tab
|
||||
/// </summary>
|
||||
public int IEActiveTabIndex
|
||||
{
|
||||
get
|
||||
|
@ -149,6 +154,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the caption of the active tab
|
||||
/// </summary>
|
||||
public string IEActiveTabCaption
|
||||
{
|
||||
get
|
||||
|
@ -172,6 +180,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the captions of all tabs
|
||||
/// </summary>
|
||||
public List<string> IETabCaptions
|
||||
{
|
||||
get
|
||||
|
@ -199,7 +210,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get the urls of all tabs
|
||||
/// </summary>
|
||||
public IEnumerable<string> IETabUrls
|
||||
{
|
||||
get
|
||||
|
@ -226,6 +239,9 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Count the tabs
|
||||
/// </summary>
|
||||
public int IETabCount
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var index = 0;
|
||||
|
|
|
@ -60,12 +60,19 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
// TODO: Solve, was static reference!
|
||||
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)
|
||||
{
|
||||
var directUiInteropWindow = IEHelper.GetDirectUi(nativeIeWindow);
|
||||
if (directUiInteropWindow != null)
|
||||
if (directUiInteropWindow == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Bring window to the front
|
||||
nativeIeWindow.Restore();
|
||||
// Get accessible
|
||||
|
@ -73,7 +80,6 @@ namespace Greenshot.Addon.InternetExplorer
|
|||
// Activate Tab
|
||||
ieAccessible.ActivateIETab(tabIndex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Return true if the supplied window has a sub-window which covers more than the supplied percentage
|
||||
|
|
|
@ -26,6 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class JiraLanguageImpl : LanguageBase<IJiraLanguage>, IJiraLanguage
|
||||
{
|
||||
|
|
|
@ -30,13 +30,27 @@ using System.Drawing;
|
|||
|
||||
namespace Greenshot.Addon.LegacyEditor
|
||||
{
|
||||
/// <summary>
|
||||
/// Utility class to work with System.Drawing.Colors
|
||||
/// TODO: should be done differently
|
||||
/// </summary>
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
var a = 0;
|
||||
|
|
|
@ -3,7 +3,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class EditorLanguageImpl : LanguageBase<IEditorLanguage>, IEditorLanguage
|
||||
{
|
||||
#region Implementation of IEditorLanguage
|
||||
|
|
|
@ -63,7 +63,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
|||
{
|
||||
int halfHeight = e.ArrowRectangle.Height / 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;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace Greenshot.Addon.LegacyEditor.Controls
|
|||
public event EventHandler<PipetteUsedArgs> PipetteUsed;
|
||||
|
||||
/// <summary>
|
||||
/// Create a cursor from the supplied bitmap & hotspot coordinates
|
||||
/// Create a cursor from the supplied bitmap and hotspot coordinates
|
||||
/// </summary>
|
||||
/// <param name="bitmap">Bitmap to create an icon from</param>
|
||||
/// <param name="hotspotX">Hotspot X coordinate</param>
|
||||
|
|
|
@ -521,7 +521,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
continue;
|
||||
}
|
||||
|
||||
Size defaultSize = container.DefaultSize;
|
||||
var defaultSize = container.DefaultSize;
|
||||
container.MakeBoundsChangeUndoable(false);
|
||||
container.Width = defaultSize.Width;
|
||||
container.Height = defaultSize.Height;
|
||||
|
|
|
@ -119,8 +119,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
|||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as Field;
|
||||
if (other == null)
|
||||
if (!(obj is Field other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -75,11 +75,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
|||
set { parent = value; }
|
||||
}
|
||||
|
||||
public DrawableContainer GetParent()
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode);
|
||||
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
|
|
|
@ -32,11 +32,28 @@ using Greenshot.Addons.Interfaces.Drawing;
|
|||
|
||||
namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// This defines the interface for all filters
|
||||
/// </summary>
|
||||
public interface IFilter : INotifyPropertyChanged, IFieldHolder
|
||||
{
|
||||
/// <summary>
|
||||
/// Filters are childen of DrawableContainers, this is the parent
|
||||
/// </summary>
|
||||
DrawableContainer Parent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// is the filtered area inverted?
|
||||
/// </summary>
|
||||
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);
|
||||
DrawableContainer GetParent();
|
||||
}
|
||||
}
|
|
@ -184,7 +184,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
|
||||
|
||||
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
|
||||
Color lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
|
||||
var lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
|
||||
using (var pen = new Pen(lineColor)) {
|
||||
pen.Width = lineThickness;
|
||||
if (!(pen.Width > 0))
|
||||
|
@ -199,7 +199,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
graphics.TranslateTransform(Left, Top);
|
||||
lock (_freehandPathLock)
|
||||
{
|
||||
if (isRecalculated && Selected && renderMode == RenderMode.EDIT)
|
||||
if (isRecalculated && Selected && renderMode == RenderMode.Edit)
|
||||
{
|
||||
DrawSelectionBorder(graphics, pen, freehandPath);
|
||||
}
|
||||
|
@ -257,8 +257,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
{
|
||||
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;
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -63,8 +63,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
|
||||
public override void Draw(Graphics graphics, RenderMode rm) {
|
||||
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
|
||||
Color lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR, Color.Red);
|
||||
Color fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR, Color.Transparent);
|
||||
var lineColor = GetFieldValueAsColor(FieldTypes.LINE_COLOR, Color.Red);
|
||||
var fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR, Color.Transparent);
|
||||
bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW);
|
||||
var rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||
|
||||
|
@ -95,7 +95,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
int steps = 5;
|
||||
int currentStep = lineVisible ? 1 : 0;
|
||||
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;
|
||||
var shadowRect = new NativeRect(
|
||||
rect.Left + currentStep,
|
||||
|
@ -118,7 +118,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
|
||||
graphics.SmoothingMode = SmoothingMode.HighSpeed;
|
||||
if (lineVisible) {
|
||||
using (Pen pen = new Pen(lineColor, lineThickness)) {
|
||||
using (var pen = new Pen(lineColor, lineThickness)) {
|
||||
graphics.DrawRectangle(pen, rect);
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
public override bool ClickableAt(int x, int y) {
|
||||
var rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||
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);
|
||||
}
|
||||
|
@ -144,8 +144,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
|||
|
||||
// check the rest of the lines
|
||||
if (lineThickness > 0) {
|
||||
using (Pen pen = new Pen(Color.White, lineThickness)) {
|
||||
using (GraphicsPath path = new GraphicsPath()) {
|
||||
using (var pen = new Pen(Color.White, lineThickness)) {
|
||||
using (var path = new GraphicsPath()) {
|
||||
path.AddRectangle(rect);
|
||||
return path.IsOutlineVisible(x, y, pen);
|
||||
}
|
||||
|
|
|
@ -229,7 +229,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
var lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||
var rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||
|
||||
if (Selected && renderMode == RenderMode.EDIT)
|
||||
if (Selected && renderMode == RenderMode.Edit)
|
||||
{
|
||||
DrawSelectionBorder(graphics, rect);
|
||||
}
|
||||
|
|
|
@ -597,7 +597,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
/// <returns></returns>
|
||||
public Bitmap GetBitmapForExport()
|
||||
{
|
||||
return GetBitmap(RenderMode.EXPORT);
|
||||
return GetBitmap(RenderMode.Export);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1646,7 +1646,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
DrawBackground(graphics, clipRectangle);
|
||||
graphics.DrawImage(Screenshot, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
|
||||
graphics.SetClip(targetGraphics);
|
||||
_elements.Draw(graphics, _buffer, RenderMode.EDIT, clipRectangle);
|
||||
_elements.Draw(graphics, _buffer, RenderMode.Edit, clipRectangle);
|
||||
}
|
||||
targetGraphics.DrawImage(_buffer, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
|
||||
}
|
||||
|
@ -1654,7 +1654,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
{
|
||||
DrawBackground(targetGraphics, clipRectangle);
|
||||
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
|
||||
|
|
|
@ -168,7 +168,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
|
||||
public void FitToText()
|
||||
{
|
||||
Size textSize = TextRenderer.MeasureText(text, _font);
|
||||
var textSize = TextRenderer.MeasureText(text, _font);
|
||||
int lineThickness = GetFieldValueAsInt(FieldTypes.LINE_THICKNESS);
|
||||
Width = textSize.Width + lineThickness;
|
||||
Height = textSize.Height + lineThickness;
|
||||
|
@ -288,7 +288,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
{
|
||||
return;
|
||||
}
|
||||
Color lc = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
|
||||
var lc = GetFieldValueAsColor(FieldTypes.LINE_COLOR);
|
||||
if (lc.R > 203 && lc.G > 203 && lc.B > 203)
|
||||
{
|
||||
_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)
|
||||
{
|
||||
FontStyle fontStyle = FontStyle.Regular;
|
||||
var fontStyle = FontStyle.Regular;
|
||||
|
||||
bool hasStyle = false;
|
||||
using (var fontFamily = new FontFamily(fontFamilyName))
|
||||
|
@ -444,7 +444,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
lineWidth = 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.Top = absRectangle.Top + lineWidth;
|
||||
if (lineThickness <= 1)
|
||||
|
@ -534,8 +534,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||
|
||||
NativeRect rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||
if (Selected && rm == RenderMode.EDIT)
|
||||
var rect = new NativeRect(Left, Top, Width, Height).Normalize();
|
||||
if (Selected && rm == RenderMode.Edit)
|
||||
{
|
||||
DrawSelectionBorder(graphics, rect);
|
||||
}
|
||||
|
@ -547,9 +547,9 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
|||
|
||||
// we only draw the shadow if there is no background
|
||||
bool shadow = GetFieldValueAsBool(FieldTypes.SHADOW);
|
||||
Color fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR);
|
||||
var fillColor = GetFieldValueAsColor(FieldTypes.FILL_COLOR);
|
||||
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);
|
||||
|
||||
DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font);
|
||||
|
|
|
@ -34,10 +34,14 @@ using Greenshot.Gfx.Effects;
|
|||
|
||||
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
|
||||
{
|
||||
private readonly DropShadowEffect _effect;
|
||||
|
||||
/// <inheritdoc />
|
||||
public DropShadowSettingsForm(DropShadowEffect effect, IGreenshotLanguage greenshotLanguage) : base(greenshotLanguage)
|
||||
{
|
||||
_effect = effect;
|
||||
|
|
|
@ -1703,6 +1703,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
|
||||
#region key handling
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool ProcessKeyPreview(ref Message msg)
|
||||
{
|
||||
// disable default key handling if surface has requested a lock
|
||||
|
@ -1714,6 +1715,7 @@ namespace Greenshot.Addon.LegacyEditor.Forms
|
|||
return base.ProcessKeyPreview(ref msg);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keys)
|
||||
{
|
||||
// disable default key handling if surface has requested a lock
|
||||
|
|
|
@ -35,7 +35,7 @@ using Greenshot.Addons.Interfaces.Drawing;
|
|||
namespace Greenshot.Addon.LegacyEditor.Memento
|
||||
{
|
||||
/// <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>
|
||||
public class DrawableContainerBoundsChangeMemento : IMemento
|
||||
{
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class LutimLanguageImpl : LanguageBase<ILutimLanguage>, ILutimLanguage
|
||||
{
|
||||
#region Implementation of ILutimLanguage
|
||||
|
|
|
@ -24,17 +24,20 @@
|
|||
#region Usings
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dapplo.Config.Ini;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Greenshot.Addon.OCR
|
||||
namespace Greenshot.Addon.OCR.Configuration
|
||||
{
|
||||
/// <summary>
|
||||
/// OCR Configuration.
|
||||
/// </summary>
|
||||
[IniSection("OCR")]
|
||||
[Description("Greenshot OCR Plugin configuration")]
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
#pragma warning disable CS1591
|
||||
public interface IOcrConfiguration : IIniSection
|
||||
{
|
||||
[Description("Language for OCR")]
|
||||
|
|
|
@ -17,13 +17,15 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Dapplo.Config.Language;
|
||||
|
||||
namespace Greenshot.Addon.OCR
|
||||
namespace Greenshot.Addon.OCR.Configuration
|
||||
{
|
||||
[Language("Ocr")]
|
||||
public interface IOcrLanguage : ILanguage, INotifyPropertyChanged
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
#pragma warning disable CS1591
|
||||
public interface IOcrLanguage : ILanguage
|
||||
{
|
||||
string Language { get; }
|
||||
string OrientImage { get; }
|
||||
|
|
|
@ -26,6 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class OcrLanguageImpl : LanguageBase<IOcrLanguage>, IOcrLanguage
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using Dapplo.Log;
|
||||
using Greenshot.Addon.OCR.Configuration;
|
||||
using Greenshot.Addons;
|
||||
using Greenshot.Addons.Components;
|
||||
using Greenshot.Addons.Core;
|
||||
|
|
|
@ -28,6 +28,7 @@ using Dapplo.Addons;
|
|||
using Dapplo.Addons.Bootstrapper.Resolving;
|
||||
using Dapplo.Config.Ini;
|
||||
using Dapplo.Config.Language;
|
||||
using Greenshot.Addon.OCR.Configuration;
|
||||
using Greenshot.Addon.OCR.Configuration.Impl;
|
||||
using Greenshot.Addons.Components;
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#region Usings
|
||||
|
||||
using System;
|
||||
using Greenshot.Addon.OCR.Configuration;
|
||||
using Greenshot.Addons.Controls;
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace Greenshot.Addon.Office.Configuration
|
|||
/// <summary>
|
||||
/// Office configuration
|
||||
/// </summary>
|
||||
#pragma warning disable CS1591
|
||||
#pragma warning disable CS1591
|
||||
[IniSection("Office")]
|
||||
[Description("Greenshot Office configuration")]
|
||||
public interface IOfficeConfiguration : IIniSection
|
||||
|
|
|
@ -22,7 +22,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
namespace Greenshot.Addon.Office.Configuration
|
||||
{
|
||||
#pragma warning disable CS1591
|
||||
/// <summary>
|
||||
/// This implements IOfficeLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
|
||||
/// </summary>
|
||||
#pragma warning disable CS1591
|
||||
[Language("Office")]
|
||||
public interface IOfficeLanguage : ILanguage, INotifyPropertyChanged
|
||||
{
|
||||
|
|
|
@ -1,10 +1,36 @@
|
|||
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 Microsoft.Office.Interop.PowerPoint;
|
||||
|
||||
namespace Greenshot.Addon.Office.Configuration.Impl
|
||||
{
|
||||
#pragma warning disable CS1591
|
||||
/// <summary>
|
||||
/// This implements IOfficeConfiguration and takes care of storing, all setters are replaced via AutoProperties.Fody
|
||||
/// </summary>
|
||||
#pragma warning disable CS1591
|
||||
public class OfficeConfigurationImpl : IniSectionBase<IOfficeConfiguration>, IOfficeConfiguration
|
||||
{
|
||||
#region Implementation of IOfficeConfiguration
|
||||
|
|
|
@ -26,7 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
namespace Greenshot.Addon.Office.Configuration.Impl
|
||||
{
|
||||
#pragma warning disable CS1591
|
||||
/// <summary>
|
||||
/// This implements IOfficeLanguage and takes care of storing, all setters are replaced via AutoProperties.Fody
|
||||
/// </summary>
|
||||
#pragma warning disable CS1591
|
||||
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
|
||||
public class OfficeLanguageImpl : LanguageBase<IOfficeLanguage>, IOfficeLanguage
|
||||
{
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace Greenshot.Addon.Office.OfficeExport.Entities
|
|||
{
|
||||
get
|
||||
{
|
||||
OneNoteNotebook notebook = Parent.Parent;
|
||||
var notebook = Parent.Parent;
|
||||
if (string.IsNullOrEmpty(notebook.Name))
|
||||
{
|
||||
return string.Format("{0} / {1}", Parent.Name, Name);
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
/// <returns>ComDisposable for Excel.Application</returns>
|
||||
private static IDisposableCom<Application> GetOrCreateExcelApplication()
|
||||
{
|
||||
IDisposableCom<Application> excelApplication = GetExcelApplication();
|
||||
var excelApplication = GetExcelApplication();
|
||||
if (excelApplication == null)
|
||||
{
|
||||
excelApplication = DisposableCom.Create(new Application());
|
||||
|
|
|
@ -582,7 +582,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
/// <returns>IDisposableCom for Outlook.Application</returns>
|
||||
private IDisposableCom<Application> GetOrCreateOutlookApplication()
|
||||
{
|
||||
IDisposableCom<Application> outlookApplication = GetOutlookApplication();
|
||||
var outlookApplication = GetOutlookApplication();
|
||||
if (outlookApplication == null)
|
||||
{
|
||||
outlookApplication = DisposableCom.Create(new Application());
|
||||
|
@ -620,7 +620,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
/// <returns></returns>
|
||||
private string GetOutlookSignature(EmailFormat format)
|
||||
{
|
||||
using (RegistryKey profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false))
|
||||
using (var profilesKey = Registry.CurrentUser.OpenSubKey(ProfilesKey, false))
|
||||
{
|
||||
if (profilesKey == null)
|
||||
{
|
||||
|
@ -628,7 +628,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
}
|
||||
string defaultProfile = (string)profilesKey.GetValue(DefaultProfileValue);
|
||||
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)
|
||||
{
|
||||
|
@ -636,7 +636,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
foreach (string number in numbers)
|
||||
{
|
||||
Log.Debug().WriteLine("Found subkey {0}", number);
|
||||
using (RegistryKey numberKey = profileKey.OpenSubKey(number, false))
|
||||
using (var numberKey = profileKey.OpenSubKey(number, false))
|
||||
{
|
||||
if (numberKey != null)
|
||||
{
|
||||
|
|
|
@ -257,7 +257,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
/// <returns>ComDisposable for PowerPoint.Application</returns>
|
||||
private IDisposableCom<Application> GetOrCreatePowerPointApplication()
|
||||
{
|
||||
IDisposableCom<Application> powerPointApplication = GetPowerPointApplication();
|
||||
var powerPointApplication = GetPowerPointApplication();
|
||||
if (powerPointApplication == null)
|
||||
{
|
||||
powerPointApplication = DisposableCom.Create(new Application());
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
|||
/// <returns>ComDisposable for Word.Application</returns>
|
||||
private IDisposableCom<Application> GetOrCreateWordApplication()
|
||||
{
|
||||
IDisposableCom<Application> wordApplication = GetWordApplication();
|
||||
var wordApplication = GetWordApplication();
|
||||
if (wordApplication == null)
|
||||
{
|
||||
wordApplication = DisposableCom.Create(new Application());
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class OneDriveLanguageImpl : LanguageBase<IOneDriveLanguage>, IOneDriveLanguage
|
||||
{
|
||||
#region Implementation of IOneDriveLanguage
|
||||
|
|
|
@ -26,6 +26,10 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
public class PhotobucketLanguageImpl : LanguageBase<IPhotobucketLanguage>, IPhotobucketLanguage
|
||||
{
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
public class TfsLanguageImpl : LanguageBase<ITfsLanguage>, ITfsLanguage
|
||||
{
|
||||
#region Implementation of ITfsLanguage
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace Greenshot.Addon.Tfs
|
|||
public async Task<WorkItemList> GetOwnWorkitems()
|
||||
{
|
||||
_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 workitemsQueryUri = apiUri.AppendSegments("wit", "wiql");
|
||||
|
@ -127,7 +127,7 @@ namespace Greenshot.Addon.Tfs
|
|||
_tfsHttpBehaviour.MakeCurrent();
|
||||
|
||||
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 attachmentUri = apiUri.AppendSegments("wit", "attachments").ExtendQuery("fileName", filename);
|
||||
|
@ -159,7 +159,7 @@ namespace Greenshot.Addon.Tfs
|
|||
_tfsHttpBehaviour.MakeCurrent();
|
||||
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
|
||||
var linkAttachmentUri = apiUri.AppendSegments("wit", "workItems", workItem.Id);
|
||||
var linkAttachmentRequest = new List<Operation>
|
||||
|
|
|
@ -34,11 +34,23 @@ namespace Greenshot.Addons.Animation
|
|||
/// </summary>
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
s *= 2;
|
||||
|
@ -50,6 +62,12 @@ namespace Greenshot.Addons.Animation
|
|||
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)
|
||||
{
|
||||
var sign = power % 2 == 0 ? -1 : 1;
|
||||
|
|
|
@ -3,7 +3,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
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")]
|
||||
#pragma warning disable CS1591
|
||||
internal class GreenshotLanguageImpl : LanguageBase<IGreenshotLanguage>, IGreenshotLanguage
|
||||
{
|
||||
#region Implementation of ICoreTranslations
|
||||
|
|
|
@ -36,8 +36,7 @@ namespace Greenshot.Addons.Core
|
|||
{
|
||||
public virtual int CompareTo(object obj)
|
||||
{
|
||||
var other = obj as IProcessor;
|
||||
if (other == null)
|
||||
if (!(obj is IProcessor other))
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
@ -52,20 +51,14 @@ namespace Greenshot.Addons.Core
|
|||
|
||||
public abstract string Description { get; }
|
||||
|
||||
public virtual int Priority
|
||||
{
|
||||
get { return 10; }
|
||||
}
|
||||
public virtual int Priority => 10;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
|
||||
public virtual bool IsActive
|
||||
{
|
||||
get { return true; }
|
||||
}
|
||||
public virtual bool IsActive => true;
|
||||
|
||||
public abstract bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails);
|
||||
|
||||
|
|
|
@ -38,23 +38,31 @@ namespace Greenshot.Addons.Core
|
|||
/// </summary>
|
||||
public class CaptureDetails : ICaptureDetails
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public CaptureDetails()
|
||||
{
|
||||
DateTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public string Filename { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTime DateTime { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public float DpiX { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public float DpiY { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public Dictionary<string, string> MetaData { get; } = new Dictionary<string, string>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddMetaData(string key, string value)
|
||||
{
|
||||
if (MetaData.ContainsKey(key))
|
||||
|
@ -67,15 +75,19 @@ namespace Greenshot.Addons.Core
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CaptureMode CaptureMode { get; set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public List<IDestination> CaptureDestinations { get; set; } = new List<IDestination>();
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ClearDestinations()
|
||||
{
|
||||
CaptureDestinations.Clear();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void RemoveDestination(IDestination destination)
|
||||
{
|
||||
if (CaptureDestinations.Contains(destination))
|
||||
|
@ -84,6 +96,7 @@ namespace Greenshot.Addons.Core
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddDestination(IDestination captureDestination)
|
||||
{
|
||||
if (!CaptureDestinations.Contains(captureDestination))
|
||||
|
@ -92,6 +105,7 @@ namespace Greenshot.Addons.Core
|
|||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool HasDestination(string designation)
|
||||
{
|
||||
foreach (var destination in CaptureDestinations)
|
||||
|
|
|
@ -131,7 +131,7 @@ namespace Greenshot.Addons.Core
|
|||
// Make sure we have clipboard formats, otherwise a paste doesn't make sense!
|
||||
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
|
||||
|
|
|
@ -546,8 +546,10 @@ namespace Greenshot.Addons.Core
|
|||
else if (Equals(imageFormat, ImageFormat.Icon))
|
||||
{
|
||||
// FEATURE-916: Added Icon support
|
||||
IList<Bitmap> bitmaps = new List<Bitmap>();
|
||||
bitmaps.Add(bitmapToSave);
|
||||
IList<Bitmap> bitmaps = new List<Bitmap>
|
||||
{
|
||||
bitmapToSave
|
||||
};
|
||||
WriteIcon(stream, bitmaps);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -23,9 +23,18 @@
|
|||
|
||||
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
|
||||
{
|
||||
EDIT,
|
||||
EXPORT
|
||||
/// <summary>
|
||||
/// Render for editing
|
||||
/// </summary>
|
||||
Edit,
|
||||
/// <summary>
|
||||
/// Render for exporting
|
||||
/// </summary>
|
||||
Export
|
||||
}
|
||||
}
|
|
@ -75,7 +75,7 @@ namespace Greenshot.Core.Extensions
|
|||
public static ICaptureElement<BitmapSource> CaptureFromScreen(this IInteropWindow interopWindow, bool clientBounds = false)
|
||||
{
|
||||
var bounds = clientBounds ? interopWindow.GetInfo().ClientBounds: interopWindow.GetInfo().Bounds;
|
||||
ICaptureElement<BitmapSource> result = ScreenSource.CaptureRectangle(bounds);
|
||||
var result = ScreenSource.CaptureRectangle(bounds);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -57,8 +57,7 @@ namespace Greenshot.Gfx
|
|||
{
|
||||
using (var tmpImage = Image.FromStream(stream, true, true))
|
||||
{
|
||||
var bitmap = tmpImage as Bitmap;
|
||||
if (bitmap == null)
|
||||
if (!(tmpImage is Bitmap bitmap))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -69,8 +68,6 @@ namespace Greenshot.Gfx
|
|||
|
||||
static BitmapHelper()
|
||||
{
|
||||
|
||||
|
||||
// Fallback
|
||||
StreamConverters[""] = FromStreamReader;
|
||||
|
||||
|
|
|
@ -26,7 +26,11 @@ using Dapplo.Config.Language;
|
|||
|
||||
namespace Greenshot.Configuration.Impl
|
||||
{
|
||||
/// <summary>
|
||||
/// This implements IConfigTranslations and takes care of storing, all setters are replaced via AutoProperties.Fody
|
||||
/// </summary>
|
||||
[SuppressMessage("ReSharper", "UnassignedGetOnlyAutoProperty")]
|
||||
#pragma warning disable CS1591
|
||||
internal class ConfigTranslationsImpl : LanguageBase<IConfigTranslations>, IConfigTranslations
|
||||
{
|
||||
public string Filter { get; }
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -723,7 +723,7 @@ namespace Greenshot.Helpers
|
|||
/// <returns>WindowDetails with the target Window OR a replacement</returns>
|
||||
public static IInteropWindow SelectCaptureWindow(IInteropWindow windowToCapture)
|
||||
{
|
||||
NativeRect windowRectangle = windowToCapture.GetInfo().Bounds;
|
||||
var windowRectangle = windowToCapture.GetInfo().Bounds;
|
||||
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);
|
||||
|
@ -784,7 +784,7 @@ namespace Greenshot.Helpers
|
|||
{
|
||||
captureForWindow = new Capture();
|
||||
}
|
||||
NativeRect windowRectangle = windowToCapture.GetInfo().Bounds;
|
||||
var windowRectangle = windowToCapture.GetInfo().Bounds;
|
||||
|
||||
// When Vista & DWM (Aero) enabled
|
||||
var dwmEnabled = Dwm.IsDwmEnabled;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue