mirror of
https://github.com/greenshot/greenshot
synced 2025-08-23 06:36:20 -07:00
Removed a lot of static references in favor of DI (#109)
* Downgrade dotnet core, to test with devops. * Added a way to set the output directory. Changed the dotnet core SDK version for the builds, so they should run.
This commit is contained in:
parent
688741f602
commit
20467f7acf
109 changed files with 1167 additions and 888 deletions
|
@ -9,5 +9,6 @@
|
||||||
<add key="Dapplo.Windows" value="https://ci.appveyor.com/nuget/dapplo-windows-pjnkjqjp7t6a" />
|
<add key="Dapplo.Windows" value="https://ci.appveyor.com/nuget/dapplo-windows-pjnkjqjp7t6a" />
|
||||||
<add key="myget.dotnetcore" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
<add key="myget.dotnetcore" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||||
<add key="dotnet-core-latest" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
<add key="dotnet-core-latest" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||||
|
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||||
</packageSources>
|
</packageSources>
|
||||||
</configuration>
|
</configuration>
|
|
@ -15,7 +15,7 @@ steps:
|
||||||
- task: DotNetCoreInstaller@0
|
- task: DotNetCoreInstaller@0
|
||||||
displayName: 'Use .NET Core sdk 3.0'
|
displayName: 'Use .NET Core sdk 3.0'
|
||||||
inputs:
|
inputs:
|
||||||
version: '3.0.100-preview-009825'
|
version: '3.0.100-preview-009812'
|
||||||
|
|
||||||
- task: NuGetToolInstaller@0
|
- task: NuGetToolInstaller@0
|
||||||
displayName: 'Use NuGet 4.9.2'
|
displayName: 'Use NuGet 4.9.2'
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<UseWindowsForms>false</UseWindowsForms>
|
<UseWindowsForms>false</UseWindowsForms>
|
||||||
<OsProductName>$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@ProductName)</OsProductName>
|
<OsProductName>$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@ProductName)</OsProductName>
|
||||||
|
<RuntimeIdentifiers>win10-x64;win10-x86;win-x64;win-x86</RuntimeIdentifiers>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)' != 'Debug' And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
|
<PropertyGroup Condition="'$(Configuration)' != 'Debug' And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
|
||||||
|
@ -45,8 +46,8 @@
|
||||||
<DebugSymbols>True</DebugSymbols>
|
<DebugSymbols>True</DebugSymbols>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
|
<ItemGroup>
|
||||||
<PackageReference Include="Nerdbank.GitVersioning" Version="2.2.33">
|
<PackageReference Include="Nerdbank.GitVersioning" Version="2.3.38">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -187,7 +187,7 @@ namespace Greenshot.Addon.Confluence
|
||||||
|
|
||||||
private bool Upload(ISurface surfaceToUpload, Content page, string filename, out string errorMessage)
|
private bool Upload(ISurface surfaceToUpload, Content page, string filename, out string errorMessage)
|
||||||
{
|
{
|
||||||
var outputSettings = new SurfaceOutputSettings(_confluenceConfiguration.UploadFormat, _confluenceConfiguration.UploadJpegQuality, _confluenceConfiguration.UploadReduceColors);
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration, _confluenceConfiguration.UploadFormat, _confluenceConfiguration.UploadJpegQuality, _confluenceConfiguration.UploadReduceColors);
|
||||||
errorMessage = null;
|
errorMessage = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Greenshot.Addon.Confluence
|
||||||
var pages = new List<Content>();
|
var pages = new List<Content>();
|
||||||
var pageIdRegex = new Regex(@"pageId=(\d+)");
|
var pageIdRegex = new Regex(@"pageId=(\d+)");
|
||||||
var spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
|
var spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
|
||||||
foreach (var browserurl in IEHelper.GetIEUrls().Distinct())
|
foreach (var browserurl in InternetExplorerHelper.GetIEUrls().Distinct())
|
||||||
{
|
{
|
||||||
string url;
|
string url;
|
||||||
try
|
try
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Dapplo.Confluence" Version="0.8.16" />
|
<PackageReference Include="Dapplo.Confluence" Version="0.8.16" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -41,8 +41,8 @@
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="CliWrap" Version="2.1.0" />
|
<PackageReference Include="CliWrap" Version="2.2.0" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
using Autofac;
|
||||||
|
using Dapplo.Addons;
|
||||||
|
|
||||||
|
namespace Greenshot.Addon.InternetExplorer
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public class InternetExplorerAddonModulenModule : AddonModule
|
||||||
|
{
|
||||||
|
protected override void Load(ContainerBuilder builder)
|
||||||
|
{
|
||||||
|
builder
|
||||||
|
.RegisterType<InternetExplorerCaptureHelper>()
|
||||||
|
.AsSelf()
|
||||||
|
.SingleInstance();
|
||||||
|
base.Load(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -36,7 +36,7 @@ using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.Desktop;
|
using Dapplo.Windows.Desktop;
|
||||||
using Dapplo.Windows.Messages;
|
using Dapplo.Windows.Messages;
|
||||||
using Dapplo.Windows.User32;
|
using Dapplo.Windows.User32;
|
||||||
using Greenshot.Addon.InternetExplorer.IEInterop;
|
using Greenshot.Addon.InternetExplorer.InternetExplorerInterop;
|
||||||
using Greenshot.Addons.Config.Impl;
|
using Greenshot.Addons.Config.Impl;
|
||||||
using Greenshot.Addons.Controls;
|
using Greenshot.Addons.Controls;
|
||||||
using Greenshot.Addons.Core;
|
using Greenshot.Addons.Core;
|
||||||
|
@ -54,20 +54,24 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// On top I modified it to use the already available code in Greenshot.
|
/// On top I modified it to use the already available code in Greenshot.
|
||||||
/// Many thanks to all the people who contributed here!
|
/// Many thanks to all the people who contributed here!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class IeCaptureHelper
|
public class InternetExplorerCaptureHelper
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
|
||||||
|
public InternetExplorerCaptureHelper(ICoreConfiguration coreConfiguration)
|
||||||
|
{
|
||||||
|
_coreConfiguration = coreConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method to activate a certain IE Tab
|
/// Helper method to activate a certain IE Tab
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="nativeIeWindow">IInteropWindow</param>
|
/// <param name="nativeIeWindow">IInteropWindow</param>
|
||||||
/// <param name="tabIndex">int</param>
|
/// <param name="tabIndex">int</param>
|
||||||
public static void ActivateIeTab(IInteropWindow nativeIeWindow, int tabIndex)
|
public void ActivateIeTab(IInteropWindow nativeIeWindow, int tabIndex)
|
||||||
{
|
{
|
||||||
var directUiInteropWindow = IEHelper.GetDirectUi(nativeIeWindow);
|
var directUiInteropWindow = InternetExplorerHelper.GetDirectUi(nativeIeWindow);
|
||||||
if (directUiInteropWindow == null)
|
if (directUiInteropWindow == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
@ -87,7 +91,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// <param name="someWindow">InteropWindow to check</param>
|
/// <param name="someWindow">InteropWindow to check</param>
|
||||||
/// <param name="minimumPercentage">min percentage</param>
|
/// <param name="minimumPercentage">min percentage</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsMostlyIeWindow(IInteropWindow someWindow, int minimumPercentage)
|
public bool IsMostlyIeWindow(IInteropWindow someWindow, int minimumPercentage)
|
||||||
{
|
{
|
||||||
var ieWindow = someWindow.GetChildren().FirstOrDefault(window => window.GetClassname() == "Internet Explorer_Server");
|
var ieWindow = someWindow.GetChildren().FirstOrDefault(window => window.GetClassname() == "Internet Explorer_Server");
|
||||||
if (ieWindow == null)
|
if (ieWindow == null)
|
||||||
|
@ -106,13 +110,13 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="someWindow"></param>
|
/// <param name="someWindow"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool IsIeWindow(IInteropWindow someWindow)
|
public bool IsIeWindow(IInteropWindow someWindow)
|
||||||
{
|
{
|
||||||
if ("IEFrame".Equals(someWindow.GetClassname()))
|
if ("IEFrame".Equals(someWindow.GetClassname()))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (CoreConfig.WindowClassesToCheckForIE != null && CoreConfig.WindowClassesToCheckForIE.Contains(someWindow.Classname))
|
if (_coreConfiguration.WindowClassesToCheckForIE != null && _coreConfiguration.WindowClassesToCheckForIE.Contains(someWindow.Classname))
|
||||||
{
|
{
|
||||||
return someWindow.GetChildren().Any(window => window.GetClassname() == "Internet Explorer_Server");
|
return someWindow.GetChildren().Any(window => window.GetClassname() == "Internet Explorer_Server");
|
||||||
}
|
}
|
||||||
|
@ -123,7 +127,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// Get Windows displaying an IE
|
/// Get Windows displaying an IE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>IEnumerable IInteropWindow</returns>
|
/// <returns>IEnumerable IInteropWindow</returns>
|
||||||
public static IEnumerable<IInteropWindow> GetIeWindows()
|
public IEnumerable<IInteropWindow> GetIeWindows()
|
||||||
{
|
{
|
||||||
return WindowsEnumerator.EnumerateWindows().Where(IsIeWindow);
|
return WindowsEnumerator.EnumerateWindows().Where(IsIeWindow);
|
||||||
}
|
}
|
||||||
|
@ -132,7 +136,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// Simple check if IE is running
|
/// Simple check if IE is running
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>bool</returns>
|
/// <returns>bool</returns>
|
||||||
public static bool IsIeRunning()
|
public bool IsIeRunning()
|
||||||
{
|
{
|
||||||
return GetIeWindows().Any();
|
return GetIeWindows().Any();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +145,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// Gets a list of all IE Windows & tabs with the captions of the instances
|
/// Gets a list of all IE Windows & tabs with the captions of the instances
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>List with KeyValuePair of InteropWindow and string</returns>
|
/// <returns>List with KeyValuePair of InteropWindow and string</returns>
|
||||||
public static IList<KeyValuePair<IInteropWindow, string>> GetBrowserTabs()
|
public IList<KeyValuePair<IInteropWindow, string>> GetBrowserTabs()
|
||||||
{
|
{
|
||||||
var ieHandleList = new List<IntPtr>();
|
var ieHandleList = new List<IntPtr>();
|
||||||
var browserWindows = new Dictionary<IInteropWindow, List<string>>();
|
var browserWindows = new Dictionary<IInteropWindow, List<string>>();
|
||||||
|
@ -157,14 +161,14 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
}
|
}
|
||||||
if ("IEFrame".Equals(ieWindow.GetClassname()))
|
if ("IEFrame".Equals(ieWindow.GetClassname()))
|
||||||
{
|
{
|
||||||
var directUiwd = IEHelper.GetDirectUi(ieWindow);
|
var directUiwd = InternetExplorerHelper.GetDirectUi(ieWindow);
|
||||||
if (directUiwd != null)
|
if (directUiwd != null)
|
||||||
{
|
{
|
||||||
var accessible = new Accessible(directUiwd.Handle);
|
var accessible = new Accessible(directUiwd.Handle);
|
||||||
browserWindows.Add(ieWindow, accessible.IETabCaptions);
|
browserWindows.Add(ieWindow, accessible.IETabCaptions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (CoreConfig.WindowClassesToCheckForIE != null && CoreConfig.WindowClassesToCheckForIE.Contains(ieWindow.Classname))
|
else if (_coreConfiguration.WindowClassesToCheckForIE != null && _coreConfiguration.WindowClassesToCheckForIE.Contains(ieWindow.Classname))
|
||||||
{
|
{
|
||||||
var singleWindowText = new List<string>();
|
var singleWindowText = new List<string>();
|
||||||
try
|
try
|
||||||
|
@ -211,7 +215,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mainWindow"></param>
|
/// <param name="mainWindow"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static IHTMLDocument2 GetHtmlDocument(IInteropWindow mainWindow)
|
private IHTMLDocument2 GetHtmlDocument(IInteropWindow mainWindow)
|
||||||
{
|
{
|
||||||
var ieServer = "Internet Explorer_Server".Equals(mainWindow.GetClassname())
|
var ieServer = "Internet Explorer_Server".Equals(mainWindow.GetClassname())
|
||||||
? mainWindow
|
? mainWindow
|
||||||
|
@ -250,7 +254,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="browserWindow">The InteropWindow to get the IHTMLDocument2 for</param>
|
/// <param name="browserWindow">The InteropWindow to get the IHTMLDocument2 for</param>
|
||||||
/// <returns>DocumentContainer</returns>
|
/// <returns>DocumentContainer</returns>
|
||||||
private static DocumentContainer CreateDocumentContainer(IInteropWindow browserWindow)
|
private DocumentContainer CreateDocumentContainer(IInteropWindow browserWindow)
|
||||||
{
|
{
|
||||||
DocumentContainer returnDocumentContainer = null;
|
DocumentContainer returnDocumentContainer = null;
|
||||||
InteropWindow returnWindow = null;
|
InteropWindow returnWindow = null;
|
||||||
|
@ -265,7 +269,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
Log.Debug().WriteLine("Processing {0} - {1}", ieWindow.Classname, ieWindow.Text);
|
Log.Debug().WriteLine("Processing {0} - {1}", ieWindow.Classname, ieWindow.Text);
|
||||||
|
|
||||||
Accessible ieAccessible = null;
|
Accessible ieAccessible = null;
|
||||||
var directUiwd = IEHelper.GetDirectUi(ieWindow);
|
var directUiwd = InternetExplorerHelper.GetDirectUi(ieWindow);
|
||||||
if (directUiwd != null)
|
if (directUiwd != null)
|
||||||
{
|
{
|
||||||
ieAccessible = new Accessible(directUiwd.Handle);
|
ieAccessible = new Accessible(directUiwd.Handle);
|
||||||
|
@ -390,7 +394,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// <param name="capture">ICapture where the capture needs to be stored</param>
|
/// <param name="capture">ICapture where the capture needs to be stored</param>
|
||||||
/// <param name="windowToCapture">window to use</param>
|
/// <param name="windowToCapture">window to use</param>
|
||||||
/// <returns>ICapture with the content (if any)</returns>
|
/// <returns>ICapture with the content (if any)</returns>
|
||||||
public static ICapture CaptureIe(ICapture capture, IInteropWindow windowToCapture = null)
|
public ICapture CaptureIe(ICapture capture, IInteropWindow windowToCapture = null)
|
||||||
{
|
{
|
||||||
if (windowToCapture == null)
|
if (windowToCapture == null)
|
||||||
{
|
{
|
||||||
|
@ -542,7 +546,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// <param name="documentContainer"></param>
|
/// <param name="documentContainer"></param>
|
||||||
/// <param name="capture"></param>
|
/// <param name="capture"></param>
|
||||||
/// <returns>Size of the complete page</returns>
|
/// <returns>Size of the complete page</returns>
|
||||||
private static Size PrepareCapture(DocumentContainer documentContainer, ICapture capture)
|
private Size PrepareCapture(DocumentContainer documentContainer, ICapture capture)
|
||||||
{
|
{
|
||||||
// Calculate the page size
|
// Calculate the page size
|
||||||
var pageWidth = documentContainer.ScrollWidth;
|
var pageWidth = documentContainer.ScrollWidth;
|
||||||
|
@ -645,7 +649,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// <param name="documentContainer">The document wrapped in a container</param>
|
/// <param name="documentContainer">The document wrapped in a container</param>
|
||||||
/// <param name="pageSize"></param>
|
/// <param name="pageSize"></param>
|
||||||
/// <returns>Bitmap with the page content as an image</returns>
|
/// <returns>Bitmap with the page content as an image</returns>
|
||||||
private static Bitmap CapturePage(DocumentContainer documentContainer, Size pageSize)
|
private Bitmap CapturePage(DocumentContainer documentContainer, Size pageSize)
|
||||||
{
|
{
|
||||||
var contentWindowDetails = documentContainer.ContentWindow;
|
var contentWindowDetails = documentContainer.ContentWindow;
|
||||||
|
|
||||||
|
@ -685,7 +689,7 @@ namespace Greenshot.Addon.InternetExplorer
|
||||||
/// <param name="contentWindowDetails">Needed for referencing the location of the frame</param>
|
/// <param name="contentWindowDetails">Needed for referencing the location of the frame</param>
|
||||||
/// <param name="graphicsTarget">Graphics</param>
|
/// <param name="graphicsTarget">Graphics</param>
|
||||||
/// <returns>Bitmap with the capture</returns>
|
/// <returns>Bitmap with the capture</returns>
|
||||||
private static void DrawDocument(DocumentContainer documentContainer, IInteropWindow contentWindowDetails, Graphics graphicsTarget)
|
private void DrawDocument(DocumentContainer documentContainer, IInteropWindow contentWindowDetails, Graphics graphicsTarget)
|
||||||
{
|
{
|
||||||
documentContainer.SetAttribute("scroll", 1);
|
documentContainer.SetAttribute("scroll", 1);
|
||||||
|
|
|
@ -27,10 +27,10 @@ using Dapplo.Windows.Desktop;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace Greenshot.Addon.InternetExplorer {
|
namespace Greenshot.Addon.InternetExplorer {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of IEHelper.
|
/// Util code for Internet Explorer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class IEHelper {
|
public class InternetExplorerHelper {
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
|
|
||||||
// Internet explorer Registry key
|
// Internet explorer Registry key
|
|
@ -37,7 +37,7 @@ using IServiceProvider = Greenshot.Addons.Interop.IServiceProvider;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Greenshot.Addon.InternetExplorer.IEInterop
|
namespace Greenshot.Addon.InternetExplorer.InternetExplorerInterop
|
||||||
{
|
{
|
||||||
public class DocumentContainer
|
public class DocumentContainer
|
||||||
{
|
{
|
|
@ -27,7 +27,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
namespace Greenshot.Addon.InternetExplorer.IEInterop
|
namespace Greenshot.Addon.InternetExplorer.InternetExplorerInterop
|
||||||
{
|
{
|
||||||
// IWebBrowser: EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B
|
// IWebBrowser: EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B
|
||||||
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
|
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
|
|
@ -4,92 +4,6 @@
|
||||||
<xs:element name="Weavers">
|
<xs:element name="Weavers">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:all>
|
<xs:all>
|
||||||
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:all>
|
|
||||||
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
</xs:all>
|
|
||||||
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="DisableCompression" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="DisableCleanup" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="ExcludeAssemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="IncludeAssemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
<xs:attribute name="PreloadOrder" type="xs:string">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
</xs:attribute>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
|
<xs:element name="AutoProperties" minOccurs="0" maxOccurs="1" type="xs:anyType" />
|
||||||
</xs:all>
|
</xs:all>
|
||||||
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
<xs:attribute name="VerifyAssembly" type="xs:boolean">
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<PackageReference Include="Dapplo.Utils" Version="1.1.9" />
|
<PackageReference Include="Dapplo.Utils" Version="1.1.9" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Dapplo.Jira" Version="0.8.9" />
|
<PackageReference Include="Dapplo.Jira" Version="0.8.9" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
private static readonly AdjustableArrowCap ARROW_CAP = new AdjustableArrowCap(4, 6);
|
private static readonly AdjustableArrowCap ARROW_CAP = new AdjustableArrowCap(4, 6);
|
||||||
|
|
||||||
public ArrowContainer(Surface parent) : base(parent)
|
public ArrowContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,12 +61,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
private Bitmap _bitmap;
|
private Bitmap _bitmap;
|
||||||
|
|
||||||
public BitmapContainer(Surface parent, string filename) : this(parent)
|
public BitmapContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : this(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Load(filename);
|
Load(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BitmapContainer(Surface parent) : base(parent)
|
public BitmapContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
FieldChanged += BitmapContainer_OnFieldChanged;
|
FieldChanged += BitmapContainer_OnFieldChanged;
|
||||||
Init();
|
Init();
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CropContainer : DrawableContainer
|
public class CropContainer : DrawableContainer
|
||||||
{
|
{
|
||||||
public CropContainer(Surface parent) : base(parent)
|
public CropContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,12 +46,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
protected Cursor cursor;
|
protected Cursor cursor;
|
||||||
|
|
||||||
public CursorContainer(Surface parent) : base(parent)
|
public CursorContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public CursorContainer(Surface parent, string filename) : this(parent)
|
public CursorContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : this(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Load(filename);
|
Load(filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
private const int M11 = 0;
|
private const int M11 = 0;
|
||||||
private const int M22 = 3;
|
private const int M22 = 3;
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
protected static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// List of available Adorners
|
/// List of available Adorners
|
||||||
|
@ -98,7 +96,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
|
|
||||||
public DrawableContainer(Surface parent)
|
public DrawableContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
|
||||||
{
|
{
|
||||||
InitializeFields();
|
InitializeFields();
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
|
|
|
@ -41,8 +41,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class EllipseContainer : DrawableContainer
|
public class EllipseContainer : DrawableContainer
|
||||||
{
|
{
|
||||||
public EllipseContainer(Surface parent) : base(parent)
|
public EllipseContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
CreateDefaultAdorners();
|
CreateDefaultAdorners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
public abstract class AbstractFieldHolder : IFieldHolder
|
public abstract class AbstractFieldHolder : IFieldHolder
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
|
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private readonly IDictionary<IField, PropertyChangedEventHandler> _handlers = new Dictionary<IField, PropertyChangedEventHandler>();
|
private readonly IDictionary<IField, PropertyChangedEventHandler> _handlers = new Dictionary<IField, PropertyChangedEventHandler>();
|
||||||
|
@ -61,7 +59,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
private IDictionary<IFieldType, IField> _fieldsByType = new Dictionary<IFieldType, IField>();
|
private IDictionary<IFieldType, IField> _fieldsByType = new Dictionary<IFieldType, IField>();
|
||||||
private readonly IList<IField> fields = new List<IField>();
|
private readonly IList<IField> fields = new List<IField>();
|
||||||
|
|
||||||
[OnDeserialized]
|
[NonSerialized]
|
||||||
|
protected readonly IEditorConfiguration _editorConfiguration;
|
||||||
|
|
||||||
|
[OnDeserialized]
|
||||||
private void OnDeserialized(StreamingContext context)
|
private void OnDeserialized(StreamingContext context)
|
||||||
{
|
{
|
||||||
_fieldsByType = new Dictionary<IFieldType, IField>();
|
_fieldsByType = new Dictionary<IFieldType, IField>();
|
||||||
|
@ -73,9 +74,13 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbstractFieldHolder(IEditorConfiguration editorConfiguration)
|
||||||
|
{
|
||||||
|
_editorConfiguration = editorConfiguration;
|
||||||
|
}
|
||||||
public void AddField(Type requestingType, IFieldType fieldType, object fieldValue)
|
public void AddField(Type requestingType, IFieldType fieldType, object fieldValue)
|
||||||
{
|
{
|
||||||
AddField(EditorConfig.CreateField(requestingType, fieldType, fieldValue));
|
AddField(_editorConfiguration.CreateField(requestingType, fieldType, fieldValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void AddField(IField field)
|
public virtual void AddField(IField field)
|
||||||
|
|
|
@ -46,7 +46,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
|
|
||||||
[NonSerialized] private EventHandler childrenChanged;
|
[NonSerialized] private EventHandler childrenChanged;
|
||||||
|
|
||||||
public AbstractFieldHolderWithChildren()
|
public AbstractFieldHolderWithChildren(IEditorConfiguration editorConfiguration) : base(editorConfiguration)
|
||||||
{
|
{
|
||||||
_fieldChangedEventHandler = OnFieldChanged;
|
_fieldChangedEventHandler = OnFieldChanged;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,13 +49,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public sealed class FieldAggregator : AbstractFieldHolder
|
public sealed class FieldAggregator : AbstractFieldHolder
|
||||||
{
|
{
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
|
|
||||||
|
|
||||||
private readonly IDrawableContainerList _boundContainers;
|
private readonly IDrawableContainerList _boundContainers;
|
||||||
private bool _internalUpdateRunning;
|
private bool _internalUpdateRunning;
|
||||||
|
|
||||||
public FieldAggregator(ISurface parent)
|
public FieldAggregator(ISurface parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
|
||||||
{
|
{
|
||||||
foreach (var fieldType in FieldTypes.Values)
|
foreach (var fieldType in FieldTypes.Values)
|
||||||
{
|
{
|
||||||
|
@ -225,7 +222,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
|
||||||
|
|
||||||
drawableContainerField.Value = field.Value;
|
drawableContainerField.Value = field.Value;
|
||||||
// update last used from DC field, so that scope is honored
|
// update last used from DC field, so that scope is honored
|
||||||
EditorConfig.UpdateLastFieldValue(drawableContainerField);
|
_editorConfiguration.UpdateLastFieldValue(drawableContainerField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
HIGHLIGHT
|
HIGHLIGHT
|
||||||
}
|
}
|
||||||
|
|
||||||
public FilterContainer(Surface parent) : base(parent)
|
public FilterContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
|
|
||||||
[NonSerialized] private PropertyChangedEventHandler propertyChanged;
|
[NonSerialized] private PropertyChangedEventHandler propertyChanged;
|
||||||
|
|
||||||
public AbstractFilter(DrawableContainer parent)
|
public AbstractFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
|
||||||
{
|
{
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
{
|
{
|
||||||
public double previewQuality;
|
public double previewQuality;
|
||||||
|
|
||||||
public BlurFilter(DrawableContainer parent) : base(parent)
|
public BlurFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
AddField(GetType(), FieldTypes.BLUR_RADIUS, 3);
|
AddField(GetType(), FieldTypes.BLUR_RADIUS, 3);
|
||||||
AddField(GetType(), FieldTypes.PREVIEW_QUALITY, 1.0d);
|
AddField(GetType(), FieldTypes.PREVIEW_QUALITY, 1.0d);
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class BrightnessFilter : AbstractFilter
|
public class BrightnessFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
public BrightnessFilter(DrawableContainer parent) : base(parent)
|
public BrightnessFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
AddField(GetType(), FieldTypes.BRIGHTNESS, 0.9d);
|
AddField(GetType(), FieldTypes.BRIGHTNESS, 0.9d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class GrayscaleFilter : AbstractFilter
|
public class GrayscaleFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
public GrayscaleFilter(DrawableContainer parent) : base(parent)
|
public GrayscaleFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class HighlightFilter : AbstractFilter
|
public class HighlightFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
public HighlightFilter(DrawableContainer parent) : base(parent)
|
public HighlightFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
AddField(GetType(), FieldTypes.FILL_COLOR, Color.Yellow);
|
AddField(GetType(), FieldTypes.FILL_COLOR, Color.Yellow);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class MagnifierFilter : AbstractFilter
|
public class MagnifierFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
public MagnifierFilter(DrawableContainer parent) : base(parent)
|
public MagnifierFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
AddField(GetType(), FieldTypes.MAGNIFICATION_FACTOR, 2);
|
AddField(GetType(), FieldTypes.MAGNIFICATION_FACTOR, 2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class PixelizationFilter : AbstractFilter
|
public class PixelizationFilter : AbstractFilter
|
||||||
{
|
{
|
||||||
public PixelizationFilter(DrawableContainer parent) : base(parent)
|
public PixelizationFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
AddField(GetType(), FieldTypes.PIXEL_SIZE, 5);
|
AddField(GetType(), FieldTypes.PIXEL_SIZE, 5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,18 +44,19 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
||||||
private NativeRect myBounds = NativeRect.Empty;
|
private NativeRect myBounds = NativeRect.Empty;
|
||||||
private NativePoint lastMouse = NativePoint.Empty;
|
private NativePoint lastMouse = NativePoint.Empty;
|
||||||
private readonly List<NativePointFloat> capturePoints = new List<NativePointFloat>();
|
private readonly List<NativePointFloat> capturePoints = new List<NativePointFloat>();
|
||||||
[NonSerialized] private GraphicsPath freehandPath = new GraphicsPath();
|
[NonSerialized]
|
||||||
|
private GraphicsPath freehandPath = new GraphicsPath();
|
||||||
private bool isRecalculated;
|
private bool isRecalculated;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FreehandContainer(Surface parent) : base(parent) {
|
public FreehandContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration) {
|
||||||
Width = parent.Width;
|
Width = parent.Width;
|
||||||
Height = parent.Height;
|
Height = parent.Height;
|
||||||
Top = 0;
|
Top = 0;
|
||||||
Left = 0;
|
Left = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void InitializeFields() {
|
protected override void InitializeFields() {
|
||||||
AddField(GetType(), FieldTypes.LINE_THICKNESS, 3);
|
AddField(GetType(), FieldTypes.LINE_THICKNESS, 3);
|
||||||
|
@ -105,10 +106,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
||||||
public override bool HandleMouseMove(int mouseX, int mouseY) {
|
public override bool HandleMouseMove(int mouseX, int mouseY) {
|
||||||
NativePoint previousPoint = capturePoints[capturePoints.Count-1];
|
NativePoint previousPoint = capturePoints[capturePoints.Count-1];
|
||||||
|
|
||||||
if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY) >= 2*EditorConfig.FreehandSensitivity) {
|
if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY) >= 2* _editorConfiguration.FreehandSensitivity) {
|
||||||
capturePoints.Add(new NativePoint(mouseX, mouseY));
|
capturePoints.Add(new NativePoint(mouseX, mouseY));
|
||||||
}
|
}
|
||||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) < EditorConfig.FreehandSensitivity)
|
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) < _editorConfiguration.FreehandSensitivity)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public override void HandleMouseUp(int mouseX, int mouseY) {
|
public override void HandleMouseUp(int mouseX, int mouseY) {
|
||||||
// Make sure we don't loose the ending point
|
// Make sure we don't loose the ending point
|
||||||
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= EditorConfig.FreehandSensitivity) {
|
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= _editorConfiguration.FreehandSensitivity) {
|
||||||
capturePoints.Add(new NativePoint(mouseX, mouseY));
|
capturePoints.Add(new NativePoint(mouseX, mouseY));
|
||||||
}
|
}
|
||||||
RecalculatePath();
|
RecalculatePath();
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class HighlightContainer : FilterContainer
|
public class HighlightContainer : FilterContainer
|
||||||
{
|
{
|
||||||
public HighlightContainer(Surface parent) : base(parent)
|
public HighlightContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -86,29 +86,29 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
switch (preset)
|
switch (preset)
|
||||||
{
|
{
|
||||||
case PreparedFilter.TEXT_HIGHTLIGHT:
|
case PreparedFilter.TEXT_HIGHTLIGHT:
|
||||||
Add(new HighlightFilter(this));
|
Add(new HighlightFilter(this, _editorConfiguration));
|
||||||
break;
|
break;
|
||||||
case PreparedFilter.AREA_HIGHLIGHT:
|
case PreparedFilter.AREA_HIGHLIGHT:
|
||||||
var brightnessFilter = new BrightnessFilter(this)
|
var brightnessFilter = new BrightnessFilter(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Invert = true
|
Invert = true
|
||||||
};
|
};
|
||||||
Add(brightnessFilter);
|
Add(brightnessFilter);
|
||||||
var blurFilter = new BlurFilter(this)
|
var blurFilter = new BlurFilter(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Invert = true
|
Invert = true
|
||||||
};
|
};
|
||||||
Add(blurFilter);
|
Add(blurFilter);
|
||||||
break;
|
break;
|
||||||
case PreparedFilter.GRAYSCALE:
|
case PreparedFilter.GRAYSCALE:
|
||||||
AbstractFilter f = new GrayscaleFilter(this)
|
AbstractFilter f = new GrayscaleFilter(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Invert = true
|
Invert = true
|
||||||
};
|
};
|
||||||
Add(f);
|
Add(f);
|
||||||
break;
|
break;
|
||||||
case PreparedFilter.MAGNIFICATION:
|
case PreparedFilter.MAGNIFICATION:
|
||||||
Add(new MagnifierFilter(this));
|
Add(new MagnifierFilter(this, _editorConfiguration));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,12 +45,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
protected Icon icon;
|
protected Icon icon;
|
||||||
|
|
||||||
public IconContainer(Surface parent) : base(parent)
|
public IconContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IconContainer(Surface parent, string filename) : base(parent)
|
public IconContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Load(filename);
|
Load(filename);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
{
|
{
|
||||||
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
|
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
|
||||||
|
|
||||||
public LineContainer(Surface parent) : base(parent)
|
public LineContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ObfuscateContainer : FilterContainer
|
public class ObfuscateContainer : FilterContainer
|
||||||
{
|
{
|
||||||
public ObfuscateContainer(Surface parent) : base(parent)
|
public ObfuscateContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
switch (preset)
|
switch (preset)
|
||||||
{
|
{
|
||||||
case PreparedFilter.BLUR:
|
case PreparedFilter.BLUR:
|
||||||
Add(new BlurFilter(this));
|
Add(new BlurFilter(this, _editorConfiguration));
|
||||||
break;
|
break;
|
||||||
case PreparedFilter.PIXELIZE:
|
case PreparedFilter.PIXELIZE:
|
||||||
Add(new PixelizationFilter(this));
|
Add(new PixelizationFilter(this, _editorConfiguration));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class RectangleContainer : DrawableContainer {
|
public class RectangleContainer : DrawableContainer {
|
||||||
|
|
||||||
public RectangleContainer(Surface parent) : base(parent) {
|
public RectangleContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration) {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,8 +46,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
{
|
{
|
||||||
private NativePoint _initialGripperPoint;
|
private NativePoint _initialGripperPoint;
|
||||||
|
|
||||||
public SpeechbubbleContainer(Surface parent)
|
public SpeechbubbleContainer(Surface parent, IEditorConfiguration editorConfiguration)
|
||||||
: base(parent)
|
: base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
private float fontSize = 16;
|
private float fontSize = 16;
|
||||||
|
|
||||||
public StepLabelContainer(Surface parent) : base(parent)
|
public StepLabelContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
parent.AddStepLabel(this);
|
parent.AddStepLabel(this);
|
||||||
InitContent();
|
InitContent();
|
||||||
|
|
|
@ -57,8 +57,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
public sealed class Surface : Control, ISurface, INotifyPropertyChanged
|
public sealed class Surface : Control, ISurface, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration conf = new CoreConfigurationImpl();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The number of Surfaces in existance
|
/// The number of Surfaces in existance
|
||||||
|
@ -70,7 +68,15 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly IDrawableContainerList _elements;
|
private readonly IDrawableContainerList _elements;
|
||||||
|
|
||||||
[NonSerialized] private readonly Stack<IMemento> _redoStack = new Stack<IMemento>();
|
|
||||||
|
[NonSerialized]
|
||||||
|
private readonly IEditorConfiguration _editorConfiguration;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
|
|
||||||
|
[NonSerialized]
|
||||||
|
private readonly Stack<IMemento> _redoStack = new Stack<IMemento>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// all stepLabels for the surface, needed with serialization
|
/// all stepLabels for the surface, needed with serialization
|
||||||
|
@ -80,12 +86,14 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Undo/Redo stacks, should not be serialized as the file would be way to big
|
/// Undo/Redo stacks, should not be serialized as the file would be way to big
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private readonly Stack<IMemento> _undoStack = new Stack<IMemento>();
|
[NonSerialized]
|
||||||
|
private readonly Stack<IMemento> _undoStack = new Stack<IMemento>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// all selected elements, do not serialize
|
/// all selected elements, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private readonly IDrawableContainerList selectedElements;
|
[NonSerialized]
|
||||||
|
private readonly IDrawableContainerList selectedElements;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The buffer is only for drawing on it when using filters (to supply access)
|
/// The buffer is only for drawing on it when using filters (to supply access)
|
||||||
|
@ -94,7 +102,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// The actual bitmap is in the paintbox...
|
/// The actual bitmap is in the paintbox...
|
||||||
/// TODO: Check if this buffer is still needed!
|
/// TODO: Check if this buffer is still needed!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private Bitmap _buffer;
|
[NonSerialized]
|
||||||
|
private Bitmap _buffer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This value is used to start counting the step labels
|
/// This value is used to start counting the step labels
|
||||||
|
@ -104,7 +113,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the cropcontainer, when cropping this is set, do not serialize
|
/// the cropcontainer, when cropping this is set, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private IDrawableContainer _cropContainer;
|
[NonSerialized]
|
||||||
|
private IDrawableContainer _cropContainer;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the cursor container, needed with serialization as we need a direct acces to it.
|
/// the cursor container, needed with serialization as we need a direct acces to it.
|
||||||
|
@ -114,14 +124,17 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the element we are drawing with, do not serialize
|
/// the element we are drawing with, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private IDrawableContainer _drawingElement;
|
[NonSerialized]
|
||||||
|
private IDrawableContainer _drawingElement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// current drawing mode, do not serialize!
|
/// current drawing mode, do not serialize!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private DrawingModes _drawingMode = DrawingModes.None;
|
[NonSerialized]
|
||||||
|
private DrawingModes _drawingMode = DrawingModes.None;
|
||||||
|
|
||||||
[NonSerialized] private SurfaceDrawingModeEventHandler _drawingModeChanged;
|
[NonSerialized]
|
||||||
|
private SurfaceDrawingModeEventHandler _drawingModeChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// all elements on the surface, needed with serialization
|
/// all elements on the surface, needed with serialization
|
||||||
|
@ -136,22 +149,26 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// inUndoRedo makes sure we don't undo/redo while in a undo/redo action
|
/// inUndoRedo makes sure we don't undo/redo while in a undo/redo action
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private bool _inUndoRedo;
|
[NonSerialized]
|
||||||
|
private bool _inUndoRedo;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make only one surfacemove cycle undoable, see SurfaceMouseMove
|
/// Make only one surfacemove cycle undoable, see SurfaceMouseMove
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private bool _isSurfaceMoveMadeUndoable;
|
[NonSerialized]
|
||||||
|
private bool _isSurfaceMoveMadeUndoable;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the keyslocked flag helps with focus issues
|
/// the keyslocked flag helps with focus issues
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private bool _keysLocked;
|
[NonSerialized]
|
||||||
|
private bool _keysLocked;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Last save location, do not serialize!
|
/// Last save location, do not serialize!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private string _lastSaveFullPath;
|
[NonSerialized]
|
||||||
|
private string _lastSaveFullPath;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the modified flag specifies if the surface has had modifications after the last export.
|
/// the modified flag specifies if the surface has had modifications after the last export.
|
||||||
|
@ -164,47 +181,56 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// are we in a mouse down, do not serialize
|
/// are we in a mouse down, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private bool _mouseDown;
|
[NonSerialized]
|
||||||
|
private bool _mouseDown;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The selected element for the mouse down, do not serialize
|
/// The selected element for the mouse down, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private IDrawableContainer _mouseDownElement;
|
[NonSerialized]
|
||||||
|
private IDrawableContainer _mouseDownElement;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Location of the mouse-down (it "starts" here), do not serialize
|
/// Location of the mouse-down (it "starts" here), do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private NativePoint _mouseStart = NativePoint.Empty;
|
[NonSerialized]
|
||||||
|
private NativePoint _mouseStart = NativePoint.Empty;
|
||||||
|
|
||||||
[NonSerialized] private SurfaceElementEventHandler _movingElementChanged;
|
[NonSerialized]
|
||||||
|
private SurfaceElementEventHandler _movingElementChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event handlers (do not serialize!)
|
/// Event handlers (do not serialize!)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private PropertyChangedEventHandler _propertyChanged;
|
[NonSerialized]
|
||||||
|
private PropertyChangedEventHandler _propertyChanged;
|
||||||
|
|
||||||
[NonSerialized] private SurfaceMessageEventHandler _surfaceMessage;
|
[NonSerialized]
|
||||||
|
private SurfaceMessageEventHandler _surfaceMessage;
|
||||||
|
|
||||||
[NonSerialized] private SurfaceSizeChangeEventHandler _surfaceSizeChanged;
|
[NonSerialized]
|
||||||
|
private SurfaceSizeChangeEventHandler _surfaceSizeChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the brush which is used for transparent backgrounds, set by the editor, do not serialize
|
/// the brush which is used for transparent backgrounds, set by the editor, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private Brush _transparencyBackgroundBrush;
|
[NonSerialized]
|
||||||
|
private Brush _transparencyBackgroundBrush;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the element we want to draw with (not yet drawn), do not serialize
|
/// the element we want to draw with (not yet drawn), do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized] private IDrawableContainer _undrawnElement;
|
[NonSerialized]
|
||||||
|
private IDrawableContainer _undrawnElement;
|
||||||
|
|
||||||
// Property to identify the Surface ID
|
// Property to identify the Surface ID
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base Surface constructor
|
/// Base Surface constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Surface()
|
public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration)
|
||||||
{
|
{
|
||||||
_fieldAggregator = new FieldAggregator(this);
|
_fieldAggregator = new FieldAggregator(this, editorConfiguration);
|
||||||
Count++;
|
Count++;
|
||||||
_elements = new DrawableContainerList(ID);
|
_elements = new DrawableContainerList(ID);
|
||||||
selectedElements = new DrawableContainerList(ID);
|
selectedElements = new DrawableContainerList(ID);
|
||||||
|
@ -234,7 +260,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// Surface constructor with an image
|
/// Surface constructor with an image
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="newBitmap">Bitmap</param>
|
/// <param name="newBitmap">Bitmap</param>
|
||||||
public Surface(Bitmap newBitmap) : this()
|
public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, Bitmap newBitmap) : this(coreConfiguration, editorConfiguration)
|
||||||
{
|
{
|
||||||
Log.Debug().WriteLine("Got Bitmap with dimensions {0} and format {1}", newBitmap.Size, newBitmap.PixelFormat);
|
Log.Debug().WriteLine("Got Bitmap with dimensions {0} and format {1}", newBitmap.Size, newBitmap.PixelFormat);
|
||||||
SetBitmap(newBitmap, true);
|
SetBitmap(newBitmap, true);
|
||||||
|
@ -244,7 +270,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
/// Surface contructor with a capture
|
/// Surface contructor with a capture
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capture"></param>
|
/// <param name="capture"></param>
|
||||||
public Surface(ICapture capture) : this()
|
public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, ICapture capture) : this(coreConfiguration, editorConfiguration)
|
||||||
{
|
{
|
||||||
SetCapture(capture);
|
SetCapture(capture);
|
||||||
}
|
}
|
||||||
|
@ -1135,41 +1161,41 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
switch (DrawingMode)
|
switch (DrawingMode)
|
||||||
{
|
{
|
||||||
case DrawingModes.Rect:
|
case DrawingModes.Rect:
|
||||||
_undrawnElement = new RectangleContainer(this);
|
_undrawnElement = new RectangleContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Ellipse:
|
case DrawingModes.Ellipse:
|
||||||
_undrawnElement = new EllipseContainer(this);
|
_undrawnElement = new EllipseContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Text:
|
case DrawingModes.Text:
|
||||||
_undrawnElement = new TextContainer(this);
|
_undrawnElement = new TextContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.SpeechBubble:
|
case DrawingModes.SpeechBubble:
|
||||||
_undrawnElement = new SpeechbubbleContainer(this);
|
_undrawnElement = new SpeechbubbleContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.StepLabel:
|
case DrawingModes.StepLabel:
|
||||||
_undrawnElement = new StepLabelContainer(this);
|
_undrawnElement = new StepLabelContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Line:
|
case DrawingModes.Line:
|
||||||
_undrawnElement = new LineContainer(this);
|
_undrawnElement = new LineContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Arrow:
|
case DrawingModes.Arrow:
|
||||||
_undrawnElement = new ArrowContainer(this);
|
_undrawnElement = new ArrowContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Highlight:
|
case DrawingModes.Highlight:
|
||||||
_undrawnElement = new HighlightContainer(this);
|
_undrawnElement = new HighlightContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Obfuscate:
|
case DrawingModes.Obfuscate:
|
||||||
_undrawnElement = new ObfuscateContainer(this);
|
_undrawnElement = new ObfuscateContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Crop:
|
case DrawingModes.Crop:
|
||||||
_cropContainer = new CropContainer(this);
|
_cropContainer = new CropContainer(this, _editorConfiguration);
|
||||||
_undrawnElement = _cropContainer;
|
_undrawnElement = _cropContainer;
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Bitmap:
|
case DrawingModes.Bitmap:
|
||||||
_undrawnElement = new BitmapContainer(this);
|
_undrawnElement = new BitmapContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.Path:
|
case DrawingModes.Path:
|
||||||
_undrawnElement = new FreehandContainer(this);
|
_undrawnElement = new FreehandContainer(this, _editorConfiguration);
|
||||||
break;
|
break;
|
||||||
case DrawingModes.None:
|
case DrawingModes.None:
|
||||||
_undrawnElement = null;
|
_undrawnElement = null;
|
||||||
|
@ -1190,7 +1216,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
NativeRect cropRectangle;
|
NativeRect cropRectangle;
|
||||||
using (var tmpImage = GetBitmapForExport())
|
using (var tmpImage = GetBitmapForExport())
|
||||||
{
|
{
|
||||||
cropRectangle = tmpImage.FindAutoCropRectangle(conf.AutoCropDifference);
|
cropRectangle = tmpImage.FindAutoCropRectangle(_coreConfiguration.AutoCropDifference);
|
||||||
}
|
}
|
||||||
if (!IsCropPossible(ref cropRectangle))
|
if (!IsCropPossible(ref cropRectangle))
|
||||||
{
|
{
|
||||||
|
@ -1880,7 +1906,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public IBitmapContainer AddImageContainer(Bitmap bitmap, int x, int y)
|
public IBitmapContainer AddImageContainer(Bitmap bitmap, int x, int y)
|
||||||
{
|
{
|
||||||
var bitmapContainer = new BitmapContainer(this)
|
var bitmapContainer = new BitmapContainer(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Bitmap = bitmap,
|
Bitmap = bitmap,
|
||||||
Left = x,
|
Left = x,
|
||||||
|
@ -1892,7 +1918,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public IBitmapContainer AddImageContainer(string filename, int x, int y)
|
public IBitmapContainer AddImageContainer(string filename, int x, int y)
|
||||||
{
|
{
|
||||||
var bitmapContainer = new BitmapContainer(this);
|
var bitmapContainer = new BitmapContainer(this, _editorConfiguration);
|
||||||
bitmapContainer.Load(filename);
|
bitmapContainer.Load(filename);
|
||||||
bitmapContainer.Left = x;
|
bitmapContainer.Left = x;
|
||||||
bitmapContainer.Top = y;
|
bitmapContainer.Top = y;
|
||||||
|
@ -1902,7 +1928,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public IIconContainer AddIconContainer(Icon icon, int x, int y)
|
public IIconContainer AddIconContainer(Icon icon, int x, int y)
|
||||||
{
|
{
|
||||||
var iconContainer = new IconContainer(this)
|
var iconContainer = new IconContainer(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
Left = x,
|
Left = x,
|
||||||
|
@ -1914,7 +1940,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public IIconContainer AddIconContainer(string filename, int x, int y)
|
public IIconContainer AddIconContainer(string filename, int x, int y)
|
||||||
{
|
{
|
||||||
var iconContainer = new IconContainer(this);
|
var iconContainer = new IconContainer(this, _editorConfiguration);
|
||||||
iconContainer.Load(filename);
|
iconContainer.Load(filename);
|
||||||
iconContainer.Left = x;
|
iconContainer.Left = x;
|
||||||
iconContainer.Top = y;
|
iconContainer.Top = y;
|
||||||
|
@ -1924,7 +1950,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public ICursorContainer AddCursorContainer(Cursor cursor, int x, int y)
|
public ICursorContainer AddCursorContainer(Cursor cursor, int x, int y)
|
||||||
{
|
{
|
||||||
var cursorContainer = new CursorContainer(this)
|
var cursorContainer = new CursorContainer(this, _editorConfiguration)
|
||||||
{
|
{
|
||||||
Cursor = cursor,
|
Cursor = cursor,
|
||||||
Left = x,
|
Left = x,
|
||||||
|
@ -1936,7 +1962,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
|
|
||||||
public ICursorContainer AddCursorContainer(string filename, int x, int y)
|
public ICursorContainer AddCursorContainer(string filename, int x, int y)
|
||||||
{
|
{
|
||||||
var cursorContainer = new CursorContainer(this);
|
var cursorContainer = new CursorContainer(this, _editorConfiguration);
|
||||||
cursorContainer.Load(filename);
|
cursorContainer.Load(filename);
|
||||||
cursorContainer.Left = x;
|
cursorContainer.Left = x;
|
||||||
cursorContainer.Top = y;
|
cursorContainer.Top = y;
|
||||||
|
@ -1947,7 +1973,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
public ITextContainer AddTextContainer(string text, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, FontFamily family, float size,
|
public ITextContainer AddTextContainer(string text, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, FontFamily family, float size,
|
||||||
bool italic, bool bold, bool shadow, int borderSize, Color color, Color fillColor)
|
bool italic, bool bold, bool shadow, int borderSize, Color color, Color fillColor)
|
||||||
{
|
{
|
||||||
var textContainer = new TextContainer(this) {Text = text};
|
var textContainer = new TextContainer(this, _editorConfiguration) {Text = text};
|
||||||
textContainer.SetFieldValue(FieldTypes.FONT_FAMILY, family.Name);
|
textContainer.SetFieldValue(FieldTypes.FONT_FAMILY, family.Name);
|
||||||
textContainer.SetFieldValue(FieldTypes.FONT_BOLD, bold);
|
textContainer.SetFieldValue(FieldTypes.FONT_BOLD, bold);
|
||||||
textContainer.SetFieldValue(FieldTypes.FONT_ITALIC, italic);
|
textContainer.SetFieldValue(FieldTypes.FONT_ITALIC, italic);
|
||||||
|
|
|
@ -90,7 +90,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextContainer(Surface parent) : base(parent)
|
public TextContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Greenshot.Addon.OCR
|
||||||
/// <param name="surface">Has the Image and the capture details</param>
|
/// <param name="surface">Has the Image and the capture details</param>
|
||||||
public string DoOcr(ISurface surface)
|
public string DoOcr(ISurface surface)
|
||||||
{
|
{
|
||||||
var outputSettings = new SurfaceOutputSettings(OutputFormats.bmp, 0, true)
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.bmp, 0, true)
|
||||||
{
|
{
|
||||||
ReduceColors = true,
|
ReduceColors = true,
|
||||||
SaveBackgroundOnly = true
|
SaveBackgroundOnly = true
|
||||||
|
|
|
@ -118,7 +118,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
var imageFile = captureDetails.Filename;
|
var imageFile = captureDetails.Filename;
|
||||||
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
if (imageFile == null || surface.Modified || !Regex.IsMatch(imageFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
||||||
{
|
{
|
||||||
imageFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
imageFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(CoreConfiguration).PreventGreenshotFormat());
|
||||||
createdFile = true;
|
createdFile = true;
|
||||||
}
|
}
|
||||||
if (_workbookName != null)
|
if (_workbookName != null)
|
||||||
|
|
|
@ -47,7 +47,8 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
[Destination("OneNote", DestinationOrder.OneNote)]
|
[Destination("OneNote", DestinationOrder.OneNote)]
|
||||||
public class OneNoteDestination : AbstractDestination
|
public class OneNoteDestination : AbstractDestination
|
||||||
{
|
{
|
||||||
private readonly ExportNotification _exportNotification;
|
private readonly OneNoteExporter _oneNoteExporter;
|
||||||
|
private readonly ExportNotification _exportNotification;
|
||||||
private const int IconApplication = 0;
|
private const int IconApplication = 0;
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
private readonly string _exePath;
|
private readonly string _exePath;
|
||||||
|
@ -60,11 +61,13 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
||||||
/// <param name="exportNotification">ExportNotification</param>
|
/// <param name="exportNotification">ExportNotification</param>
|
||||||
public OneNoteDestination(
|
public OneNoteDestination(
|
||||||
|
OneNoteExporter oneNoteExporter,
|
||||||
ICoreConfiguration coreConfiguration,
|
ICoreConfiguration coreConfiguration,
|
||||||
IGreenshotLanguage greenshotLanguage,
|
IGreenshotLanguage greenshotLanguage,
|
||||||
ExportNotification exportNotification
|
ExportNotification exportNotification
|
||||||
) : base(coreConfiguration, greenshotLanguage)
|
) : base(coreConfiguration, greenshotLanguage)
|
||||||
{
|
{
|
||||||
|
this._oneNoteExporter = oneNoteExporter;
|
||||||
_exportNotification = exportNotification;
|
_exportNotification = exportNotification;
|
||||||
_exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
_exePath = PluginUtils.GetExePath("ONENOTE.EXE");
|
||||||
if (_exePath != null && !File.Exists(_exePath))
|
if (_exePath != null && !File.Exists(_exePath))
|
||||||
|
@ -80,11 +83,12 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
||||||
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
/// <param name="greenshotLanguage">IGreenshotLanguage</param>
|
||||||
/// <param name="exportNotification">ExportNotification</param>
|
/// <param name="exportNotification">ExportNotification</param>
|
||||||
protected OneNoteDestination(OneNotePage page,
|
protected OneNoteDestination(OneNoteExporter oneNoteExporter,
|
||||||
|
OneNotePage page,
|
||||||
ICoreConfiguration coreConfiguration,
|
ICoreConfiguration coreConfiguration,
|
||||||
IGreenshotLanguage greenshotLanguage,
|
IGreenshotLanguage greenshotLanguage,
|
||||||
ExportNotification exportNotification
|
ExportNotification exportNotification
|
||||||
) : this(coreConfiguration, greenshotLanguage, exportNotification)
|
) : this(oneNoteExporter, coreConfiguration, greenshotLanguage, exportNotification)
|
||||||
{
|
{
|
||||||
_page = page;
|
_page = page;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +123,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return OneNoteExporter.GetPages().Where(currentPage => currentPage.IsCurrentlyViewed).Select(currentPage => new OneNoteDestination(currentPage, CoreConfiguration, GreenshotLanguage, _exportNotification));
|
return _oneNoteExporter.GetPages().Where(currentPage => currentPage.IsCurrentlyViewed).Select(currentPage => new OneNoteDestination(_oneNoteExporter, currentPage, CoreConfiguration, GreenshotLanguage, _exportNotification));
|
||||||
}
|
}
|
||||||
catch (COMException cEx)
|
catch (COMException cEx)
|
||||||
{
|
{
|
||||||
|
@ -145,7 +149,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
exportInformation.ExportMade = OneNoteExporter.ExportToNewPage(surface);
|
exportInformation.ExportMade = _oneNoteExporter.ExportToNewPage(surface);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +161,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
exportInformation.ExportMade = OneNoteExporter.ExportToPage(surface, _page);
|
exportInformation.ExportMade = _oneNoteExporter.ExportToPage(surface, _page);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -172,7 +172,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
var tmpFile = captureDetails.Filename;
|
var tmpFile = captureDetails.Filename;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
||||||
{
|
{
|
||||||
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(CoreConfiguration).PreventGreenshotFormat());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -141,7 +141,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
var imageSize = Size.Empty;
|
var imageSize = Size.Empty;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
||||||
{
|
{
|
||||||
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(CoreConfiguration).PreventGreenshotFormat());
|
||||||
imageSize = surface.Screenshot.Size;
|
imageSize = surface.Screenshot.Size;
|
||||||
}
|
}
|
||||||
if (_presentationName != null)
|
if (_presentationName != null)
|
||||||
|
|
|
@ -126,7 +126,7 @@ namespace Greenshot.Addon.Office.Destinations
|
||||||
var tmpFile = captureDetails.Filename;
|
var tmpFile = captureDetails.Filename;
|
||||||
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
if (tmpFile == null || surface.Modified || !Regex.IsMatch(tmpFile, @".*(\.png|\.gif|\.jpg|\.jpeg|\.tiff|\.bmp)$"))
|
||||||
{
|
{
|
||||||
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings().PreventGreenshotFormat());
|
tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(CoreConfiguration).PreventGreenshotFormat());
|
||||||
}
|
}
|
||||||
if (_documentCaption != null)
|
if (_documentCaption != null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300">
|
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300">
|
||||||
<EmbedInteropTypes>True</EmbedInteropTypes>
|
<EmbedInteropTypes>True</EmbedInteropTypes>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -29,6 +29,7 @@ using Dapplo.Config.Language;
|
||||||
using Greenshot.Addon.Office.Configuration;
|
using Greenshot.Addon.Office.Configuration;
|
||||||
using Greenshot.Addon.Office.Configuration.Impl;
|
using Greenshot.Addon.Office.Configuration.Impl;
|
||||||
using Greenshot.Addon.Office.Destinations;
|
using Greenshot.Addon.Office.Destinations;
|
||||||
|
using Greenshot.Addon.Office.OfficeExport;
|
||||||
using Greenshot.Addon.Office.ViewModels;
|
using Greenshot.Addon.Office.ViewModels;
|
||||||
using Greenshot.Addons.Components;
|
using Greenshot.Addons.Components;
|
||||||
using Greenshot.Addons.Core;
|
using Greenshot.Addons.Core;
|
||||||
|
@ -80,6 +81,11 @@ namespace Greenshot.Addon.Office
|
||||||
.RegisterType<OneNoteDestination>()
|
.RegisterType<OneNoteDestination>()
|
||||||
.As<IDestination>()
|
.As<IDestination>()
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.RegisterType<OneNoteExporter>()
|
||||||
|
.AsSelf()
|
||||||
|
.SingleInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PluginUtils.GetExePath("OUTLOOK.EXE") != null)
|
if (PluginUtils.GetExePath("OUTLOOK.EXE") != null)
|
||||||
|
|
|
@ -45,19 +45,25 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// OneNote exporter
|
/// OneNote exporter
|
||||||
/// More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
|
/// More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class OneNoteExporter
|
public class OneNoteExporter
|
||||||
{
|
{
|
||||||
private const string XmlImageContent = "<one:Image format=\"png\"><one:Size width=\"{1}.0\" height=\"{2}.0\" isSetByUser=\"true\" /><one:Data>{0}</one:Data></one:Image>";
|
private const string XmlImageContent = "<one:Image format=\"png\"><one:Size width=\"{1}.0\" height=\"{2}.0\" isSetByUser=\"true\" /><one:Data>{0}</one:Data></one:Image>";
|
||||||
private const string XmlOutline = "<?xml version=\"1.0\"?><one:Page xmlns:one=\"{2}\" ID=\"{1}\"><one:Title><one:OE><one:T><![CDATA[{3}]]></one:T></one:OE></one:Title>{0}</one:Page>";
|
private const string XmlOutline = "<?xml version=\"1.0\"?><one:Page xmlns:one=\"{2}\" ID=\"{1}\"><one:Title><one:OE><one:T><![CDATA[{3}]]></one:T></one:OE></one:Title>{0}</one:Page>";
|
||||||
private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
|
private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
|
|
||||||
|
public OneNoteExporter(ICoreConfiguration coreConfiguration)
|
||||||
|
{
|
||||||
|
_coreConfiguration = coreConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
|
/// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surfaceToUpload">ISurface</param>
|
/// <param name="surfaceToUpload">ISurface</param>
|
||||||
/// <returns>bool true if export worked</returns>
|
/// <returns>bool true if export worked</returns>
|
||||||
public static bool ExportToNewPage(ISurface surfaceToUpload)
|
public bool ExportToNewPage(ISurface surfaceToUpload)
|
||||||
{
|
{
|
||||||
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
|
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
|
||||||
{
|
{
|
||||||
|
@ -83,7 +89,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// <param name="surfaceToUpload">ISurface</param>
|
/// <param name="surfaceToUpload">ISurface</param>
|
||||||
/// <param name="page">OneNotePage</param>
|
/// <param name="page">OneNotePage</param>
|
||||||
/// <returns>bool true if everything worked</returns>
|
/// <returns>bool true if everything worked</returns>
|
||||||
public static bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
|
public bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
|
||||||
{
|
{
|
||||||
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
|
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
|
||||||
{
|
{
|
||||||
|
@ -98,7 +104,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// <param name="surfaceToUpload">ISurface</param>
|
/// <param name="surfaceToUpload">ISurface</param>
|
||||||
/// <param name="page">OneNotePage</param>
|
/// <param name="page">OneNotePage</param>
|
||||||
/// <returns>bool true if everything worked</returns>
|
/// <returns>bool true if everything worked</returns>
|
||||||
private static bool ExportToPage(IDisposableCom<Application> oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
|
private bool ExportToPage(IDisposableCom<Application> oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
|
||||||
{
|
{
|
||||||
if (oneNoteApplication == null)
|
if (oneNoteApplication == null)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +113,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
|
|
||||||
using (var pngStream = new MemoryStream())
|
using (var pngStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
|
var pngOutputSettings = new SurfaceOutputSettings(_coreConfiguration, OutputFormats.png, 100, false);
|
||||||
ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
|
ImageOutput.SaveToStream(surfaceToUpload, pngStream, pngOutputSettings);
|
||||||
var base64String = Convert.ToBase64String(pngStream.GetBuffer());
|
var base64String = Convert.ToBase64String(pngStream.GetBuffer());
|
||||||
var imageXmlStr = string.Format(XmlImageContent, base64String, surfaceToUpload.Screenshot.Width, surfaceToUpload.Screenshot.Height);
|
var imageXmlStr = string.Format(XmlImageContent, base64String, surfaceToUpload.Screenshot.Width, surfaceToUpload.Screenshot.Height);
|
||||||
|
@ -130,7 +136,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// Call this to get the running Excel application, returns null if there isn't any.
|
/// Call this to get the running Excel application, returns null if there isn't any.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>ComDisposable for Excel.Application or null</returns>
|
/// <returns>ComDisposable for Excel.Application or null</returns>
|
||||||
private static IDisposableCom<Application> GetOneNoteApplication()
|
private IDisposableCom<Application> GetOneNoteApplication()
|
||||||
{
|
{
|
||||||
IDisposableCom<Application> oneNoteApplication;
|
IDisposableCom<Application> oneNoteApplication;
|
||||||
try
|
try
|
||||||
|
@ -149,7 +155,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// Call this to get the running OneNote application, or create a new instance
|
/// Call this to get the running OneNote application, or create a new instance
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>ComDisposable for OneNote.Application</returns>
|
/// <returns>ComDisposable for OneNote.Application</returns>
|
||||||
private static IDisposableCom<Application> GetOrCreateOneNoteApplication()
|
private IDisposableCom<Application> GetOrCreateOneNoteApplication()
|
||||||
{
|
{
|
||||||
var oneNoteApplication = GetOneNoteApplication();
|
var oneNoteApplication = GetOneNoteApplication();
|
||||||
if (oneNoteApplication == null)
|
if (oneNoteApplication == null)
|
||||||
|
@ -163,7 +169,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// Get the captions of all the open word documents
|
/// Get the captions of all the open word documents
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static IList<OneNotePage> GetPages()
|
public IList<OneNotePage> GetPages()
|
||||||
{
|
{
|
||||||
var pages = new List<OneNotePage>();
|
var pages = new List<OneNotePage>();
|
||||||
try
|
try
|
||||||
|
@ -276,7 +282,7 @@ namespace Greenshot.Addon.Office.OfficeExport
|
||||||
/// <param name="oneNoteApplication"></param>
|
/// <param name="oneNoteApplication"></param>
|
||||||
/// <param name="specialLocation">SpecialLocation</param>
|
/// <param name="specialLocation">SpecialLocation</param>
|
||||||
/// <returns>string with section ID</returns>
|
/// <returns>string with section ID</returns>
|
||||||
private static string GetSectionId(IDisposableCom<Application> oneNoteApplication, SpecialLocation specialLocation)
|
private string GetSectionId(IDisposableCom<Application> oneNoteApplication, SpecialLocation specialLocation)
|
||||||
{
|
{
|
||||||
if (oneNoteApplication == null)
|
if (oneNoteApplication == null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.19" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
<PackageReference Include="MahApps.Metro" Version="2.0.0-alpha0170" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net471'">
|
||||||
<!-- Light up Windows 10 features -->
|
<!-- Light up Windows 10 features -->
|
||||||
|
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="5.0.1" />
|
||||||
|
<!--PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview1-27018-01" />-->
|
||||||
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
<Reference Include="System.Runtime.WindowsRuntime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
|
<HintPath>C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll</HintPath>
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
using Autofac;
|
using Autofac;
|
||||||
using Dapplo.Addons;
|
using Dapplo.Addons;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
using Dapplo.Windows.Common;
|
using Dapplo.Windows.Common;
|
||||||
using Greenshot.Addons.Components;
|
using Greenshot.Addons.Components;
|
||||||
|
|
||||||
|
@ -37,6 +38,14 @@ namespace Greenshot.Addon.Win10
|
||||||
.RegisterType<Win10OcrDestination>()
|
.RegisterType<Win10OcrDestination>()
|
||||||
.As<IDestination>()
|
.As<IDestination>()
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
|
|
||||||
|
#if !NETCOREAPP3_0
|
||||||
|
builder
|
||||||
|
.RegisterType<Win10FormEnhancer>()
|
||||||
|
.As<IFormEnhancer>()
|
||||||
|
.SingleInstance();
|
||||||
|
#endif
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.RegisterType<Win10ShareDestination>()
|
.RegisterType<Win10ShareDestination>()
|
||||||
.As<IDestination>()
|
.As<IDestination>()
|
||||||
|
|
90
src/Greenshot.Addon.Win10/Win10FormEnhancer.cs
Normal file
90
src/Greenshot.Addon.Win10/Win10FormEnhancer.cs
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#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
|
||||||
|
|
||||||
|
#if !NETCOREAPP3_0
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
|
using Microsoft.Toolkit.Forms.UI.XamlHost;
|
||||||
|
|
||||||
|
namespace Greenshot.Addon.Win10
|
||||||
|
{
|
||||||
|
public class Win10FormEnhancer : IFormEnhancer
|
||||||
|
{
|
||||||
|
private WindowsXamlHost inkCanvasHost;
|
||||||
|
private WindowsXamlHost inkToolbarHost;
|
||||||
|
private Windows.UI.Xaml.Controls.InkCanvas inkCanvas;
|
||||||
|
private Windows.UI.Xaml.Controls.InkToolbar inkToolbar;
|
||||||
|
|
||||||
|
public void InitializeComponent(Form target)
|
||||||
|
{
|
||||||
|
// TODO: Fix the code below, when the following is solved: https://github.com/windows-toolkit/Microsoft.Toolkit.Win32/issues/16#issuecomment-451337186
|
||||||
|
return;
|
||||||
|
// InkCanvas
|
||||||
|
inkCanvasHost = new WindowsXamlHost();
|
||||||
|
inkCanvasHost.InitialTypeName = "Windows.UI.Xaml.Controls.InkCanvas";
|
||||||
|
inkCanvasHost.ChildChanged += InkCanvas_ChildChanged;
|
||||||
|
// InkToolbar
|
||||||
|
inkToolbarHost = new WindowsXamlHost();
|
||||||
|
inkToolbarHost.InitialTypeName = "Windows.UI.Xaml.Controls.InkToolbar";
|
||||||
|
inkToolbarHost.ChildChanged += InkToolbar_ChildChanged;
|
||||||
|
// Layout
|
||||||
|
inkToolbarHost.Top = 0;
|
||||||
|
inkToolbarHost.Left = 0;
|
||||||
|
inkToolbarHost.Height = 50;
|
||||||
|
inkToolbarHost.Dock = DockStyle.Top;
|
||||||
|
|
||||||
|
inkCanvasHost.Dock = DockStyle.Fill;
|
||||||
|
inkCanvasHost.BackColor = Color.Transparent;
|
||||||
|
|
||||||
|
// Add to Window
|
||||||
|
target.Controls.Add(inkToolbarHost);
|
||||||
|
target.Controls.Add(inkCanvasHost);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InkToolbar_ChildChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
inkToolbar = ((WindowsXamlHost)sender).Child as Windows.UI.Xaml.Controls.InkToolbar;
|
||||||
|
InitializeUwpControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InkCanvas_ChildChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
inkCanvas = ((WindowsXamlHost)sender).Child as Windows.UI.Xaml.Controls.InkCanvas;
|
||||||
|
InitializeUwpControls();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeUwpControls()
|
||||||
|
{
|
||||||
|
if (inkToolbar == null || inkCanvas == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
inkToolbar.TargetInkCanvas = inkCanvas;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -84,7 +84,7 @@ namespace Greenshot.Addon.Win10
|
||||||
var ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages();
|
var ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages();
|
||||||
using (var imageStream = new MemoryStream())
|
using (var imageStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings());
|
ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings(CoreConfiguration));
|
||||||
imageStream.Position = 0;
|
imageStream.Position = 0;
|
||||||
|
|
||||||
var decoder = await BitmapDecoder.CreateAsync(imageStream.AsRandomAccessStream());
|
var decoder = await BitmapDecoder.CreateAsync(imageStream.AsRandomAccessStream());
|
||||||
|
|
|
@ -159,7 +159,7 @@ namespace Greenshot.Addon.Win10
|
||||||
using (var logoStream = new MemoryRandomAccessStream())
|
using (var logoStream = new MemoryRandomAccessStream())
|
||||||
using (var thumbnailStream = new MemoryRandomAccessStream())
|
using (var thumbnailStream = new MemoryRandomAccessStream())
|
||||||
{
|
{
|
||||||
var outputSettings = new SurfaceOutputSettings();
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration);
|
||||||
outputSettings.PreventGreenshotFormat();
|
outputSettings.PreventGreenshotFormat();
|
||||||
|
|
||||||
// Create capture for export
|
// Create capture for export
|
||||||
|
|
|
@ -45,13 +45,28 @@ namespace Greenshot.Addons
|
||||||
.As<ICoreConfiguration>()
|
.As<ICoreConfiguration>()
|
||||||
.As<IUiConfiguration>()
|
.As<IUiConfiguration>()
|
||||||
.As<IIniSection>()
|
.As<IIniSection>()
|
||||||
.SingleInstance();
|
.SingleInstance()
|
||||||
|
.OnActivated(args =>
|
||||||
|
{
|
||||||
|
// Workaround for static access in different helper classes and extensions
|
||||||
|
ClipboardHelper.CoreConfiguration = args.Instance;
|
||||||
|
FilenameHelper.CoreConfiguration = args.Instance;
|
||||||
|
ImageOutput.CoreConfiguration = args.Instance;
|
||||||
|
InteropWindowCaptureExtensions.CoreConfiguration = args.Instance;
|
||||||
|
WindowCapture.CoreConfiguration = args.Instance;
|
||||||
|
PluginUtils.CoreConfiguration = args.Instance;
|
||||||
|
});
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.RegisterType<GreenshotLanguageImpl>()
|
.RegisterType<GreenshotLanguageImpl>()
|
||||||
.As<IGreenshotLanguage>()
|
.As<IGreenshotLanguage>()
|
||||||
.As<ILanguage>()
|
.As<ILanguage>()
|
||||||
.SingleInstance();
|
.SingleInstance()
|
||||||
|
.OnActivated(args =>
|
||||||
|
{
|
||||||
|
// Workaround for static access in different helper classes and extensions
|
||||||
|
ImageOutput.GreenshotLanguage = args.Instance;
|
||||||
|
});
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.RegisterType<HttpConfigurationImpl>()
|
.RegisterType<HttpConfigurationImpl>()
|
||||||
|
|
|
@ -26,6 +26,7 @@ using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using Dapplo.Config.Ini;
|
using Dapplo.Config.Ini;
|
||||||
|
using Dapplo.Log;
|
||||||
using Dapplo.Windows.Common.Structs;
|
using Dapplo.Windows.Common.Structs;
|
||||||
using Dapplo.Windows.User32.Structs;
|
using Dapplo.Windows.User32.Structs;
|
||||||
using Greenshot.Addons.Core;
|
using Greenshot.Addons.Core;
|
||||||
|
|
|
@ -39,14 +39,18 @@ namespace Greenshot.Addons.Controls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer
|
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer
|
||||||
{
|
{
|
||||||
// TODO: Solve, was static reference!
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
|
||||||
|
public ContextMenuToolStripProfessionalRenderer(ICoreConfiguration coreConfiguration)
|
||||||
|
{
|
||||||
|
_coreConfiguration = coreConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
private Image _scaledCheckbox;
|
private Image _scaledCheckbox;
|
||||||
private bool _newImage;
|
private bool _newImage;
|
||||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
|
||||||
{
|
{
|
||||||
if (_scaledCheckbox == null || (NativeSize)_scaledCheckbox.Size != CoreConfig.IconSize)
|
if (_scaledCheckbox == null || (NativeSize)_scaledCheckbox.Size != _coreConfiguration.IconSize)
|
||||||
{
|
{
|
||||||
if (_newImage)
|
if (_newImage)
|
||||||
{
|
{
|
||||||
|
|
|
@ -43,23 +43,18 @@ namespace Greenshot.Addons.Controls
|
||||||
public class SaveImageFileDialog : IDisposable
|
public class SaveImageFileDialog : IDisposable
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
private static readonly ICoreConfiguration CoreConfiguration = new CoreConfigurationImpl();
|
|
||||||
private readonly ICaptureDetails _captureDetails;
|
private readonly ICaptureDetails _captureDetails;
|
||||||
private DirectoryInfo _eagerlyCreatedDirectory;
|
private DirectoryInfo _eagerlyCreatedDirectory;
|
||||||
private FilterOption[] _filterOptions;
|
private FilterOption[] _filterOptions;
|
||||||
protected SaveFileDialog SaveFileDialog;
|
protected SaveFileDialog SaveFileDialog;
|
||||||
|
|
||||||
public SaveImageFileDialog()
|
public SaveImageFileDialog(ICoreConfiguration coreConfiguration, ICaptureDetails captureDetails = null)
|
||||||
{
|
{
|
||||||
Init();
|
_coreConfiguration = coreConfiguration;
|
||||||
}
|
_captureDetails = captureDetails;
|
||||||
|
Init();
|
||||||
public SaveImageFileDialog(ICaptureDetails captureDetails)
|
}
|
||||||
{
|
|
||||||
_captureDetails = captureDetails;
|
|
||||||
Init();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// filename exactly as typed in the filename field
|
/// filename exactly as typed in the filename field
|
||||||
|
@ -146,21 +141,21 @@ namespace Greenshot.Addons.Controls
|
||||||
string initialDirectory = null;
|
string initialDirectory = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CoreConfiguration.ValidateAndCorrect();
|
_coreConfiguration.ValidateAndCorrect();
|
||||||
initialDirectory = Path.GetDirectoryName(CoreConfiguration.OutputFileAsFullpath);
|
initialDirectory = Path.GetDirectoryName(_coreConfiguration.OutputFileAsFullpath);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
Log.Warn().WriteLine("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", CoreConfiguration.OutputFileAsFullpath);
|
Log.Warn().WriteLine("OutputFileAsFullpath was set to {0}, ignoring due to problem in path.", _coreConfiguration.OutputFileAsFullpath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
|
if (!string.IsNullOrEmpty(initialDirectory) && Directory.Exists(initialDirectory))
|
||||||
{
|
{
|
||||||
SaveFileDialog.InitialDirectory = initialDirectory;
|
SaveFileDialog.InitialDirectory = initialDirectory;
|
||||||
}
|
}
|
||||||
else if (Directory.Exists(CoreConfiguration.OutputFilePath))
|
else if (Directory.Exists(_coreConfiguration.OutputFilePath))
|
||||||
{
|
{
|
||||||
SaveFileDialog.InitialDirectory = CoreConfiguration.OutputFilePath;
|
SaveFileDialog.InitialDirectory = _coreConfiguration.OutputFilePath;
|
||||||
}
|
}
|
||||||
// The following property fixes a problem that the directory where we save is locked (bug #2899790)
|
// The following property fixes a problem that the directory where we save is locked (bug #2899790)
|
||||||
SaveFileDialog.RestoreDirectory = true;
|
SaveFileDialog.RestoreDirectory = true;
|
||||||
|
@ -175,7 +170,7 @@ namespace Greenshot.Addons.Controls
|
||||||
PrepareFilterOptions();
|
PrepareFilterOptions();
|
||||||
var fdf = "";
|
var fdf = "";
|
||||||
var preselect = 0;
|
var preselect = 0;
|
||||||
var outputFileFormatAsString = Enum.GetName(typeof(OutputFormats), CoreConfiguration.OutputFileFormat);
|
var outputFileFormatAsString = Enum.GetName(typeof(OutputFormats), _coreConfiguration.OutputFileFormat);
|
||||||
for (var i = 0; i < _filterOptions.Length; i++)
|
for (var i = 0; i < _filterOptions.Length; i++)
|
||||||
{
|
{
|
||||||
var fo = _filterOptions[i];
|
var fo = _filterOptions[i];
|
||||||
|
@ -224,7 +219,7 @@ namespace Greenshot.Addons.Controls
|
||||||
private void ApplySuggestedValues()
|
private void ApplySuggestedValues()
|
||||||
{
|
{
|
||||||
// build the full path and set dialog properties
|
// build the full path and set dialog properties
|
||||||
FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfiguration.OutputFileFilenamePattern, _captureDetails);
|
FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(_coreConfiguration.OutputFileFilenamePattern, _captureDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CleanUp()
|
private void CleanUp()
|
||||||
|
|
|
@ -48,17 +48,14 @@ namespace Greenshot.Addons.Controls
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ThumbnailForm : FormWithoutActivation
|
public sealed class ThumbnailForm : FormWithoutActivation
|
||||||
{
|
{
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration coreConfiguration = new CoreConfigurationImpl();
|
|
||||||
|
|
||||||
private IntPtr _thumbnailHandle = IntPtr.Zero;
|
private IntPtr _thumbnailHandle = IntPtr.Zero;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor for the Thumbnail form
|
/// Constructor for the Thumbnail form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ThumbnailForm()
|
public ThumbnailForm(ICoreConfiguration coreConfiguration)
|
||||||
{
|
{
|
||||||
ShowInTaskbar = false;
|
ShowInTaskbar = false;
|
||||||
FormBorderStyle = FormBorderStyle.None;
|
FormBorderStyle = FormBorderStyle.None;
|
||||||
TopMost = false;
|
TopMost = false;
|
||||||
Enabled = false;
|
Enabled = false;
|
||||||
|
|
|
@ -101,8 +101,11 @@ EndSelection:<<<<<<<4
|
||||||
private const int BITMAPFILEHEADER_LENGTH = 14;
|
private const int BITMAPFILEHEADER_LENGTH = 14;
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
private static readonly object ClipboardLockObject = new object();
|
private static readonly object ClipboardLockObject = new object();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
/// <summary>
|
||||||
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static ICoreConfiguration CoreConfiguration { get; set; }
|
||||||
private static readonly string FORMAT_FILECONTENTS = "FileContents";
|
private static readonly string FORMAT_FILECONTENTS = "FileContents";
|
||||||
private static readonly string FORMAT_PNG = "PNG";
|
private static readonly string FORMAT_PNG = "PNG";
|
||||||
private static readonly string FORMAT_PNG_OFFICEART = "PNG+Office Art";
|
private static readonly string FORMAT_PNG_OFFICEART = "PNG+Office Art";
|
||||||
|
@ -470,7 +473,7 @@ EndSelection:<<<<<<<4
|
||||||
// TODO: add "HTML Format" support here...
|
// TODO: add "HTML Format" support here...
|
||||||
return clipboardObject as Bitmap;
|
return clipboardObject as Bitmap;
|
||||||
}
|
}
|
||||||
if (CoreConfig.EnableSpecialDIBClipboardReader)
|
if (CoreConfiguration.EnableSpecialDIBClipboardReader)
|
||||||
{
|
{
|
||||||
if (format == FORMAT_17 || format == DataFormats.Dib)
|
if (format == FORMAT_17 || format == DataFormats.Dib)
|
||||||
{
|
{
|
||||||
|
@ -648,17 +651,17 @@ EndSelection:<<<<<<<4
|
||||||
var disposeImage = false;
|
var disposeImage = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var outputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png, 100, false);
|
||||||
// Create the image which is going to be saved so we don't create it multiple times
|
// Create the image which is going to be saved so we don't create it multiple times
|
||||||
disposeImage = ImageOutput.CreateBitmapFromSurface(surface, outputSettings, out bitmapToSave);
|
disposeImage = ImageOutput.CreateBitmapFromSurface(surface, outputSettings, out bitmapToSave);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Create PNG stream
|
// Create PNG stream
|
||||||
if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.PNG))
|
if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.PNG))
|
||||||
{
|
{
|
||||||
pngStream = new MemoryStream();
|
pngStream = new MemoryStream();
|
||||||
// PNG works for e.g. Powerpoint
|
// PNG works for e.g. Powerpoint
|
||||||
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
|
var pngOutputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png, 100, false);
|
||||||
ImageOutput.SaveToStream(bitmapToSave, null, pngStream, pngOutputSettings);
|
ImageOutput.SaveToStream(bitmapToSave, null, pngStream, pngOutputSettings);
|
||||||
pngStream.Seek(0, SeekOrigin.Begin);
|
pngStream.Seek(0, SeekOrigin.Begin);
|
||||||
// Set the PNG stream
|
// Set the PNG stream
|
||||||
|
@ -672,12 +675,12 @@ EndSelection:<<<<<<<4
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.DIB))
|
if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.DIB))
|
||||||
{
|
{
|
||||||
using (var tmpBmpStream = new MemoryStream())
|
using (var tmpBmpStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
// Save image as BMP
|
// Save image as BMP
|
||||||
var bmpOutputSettings = new SurfaceOutputSettings(OutputFormats.bmp, 100, false);
|
var bmpOutputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.bmp, 100, false);
|
||||||
ImageOutput.SaveToStream(bitmapToSave, null, tmpBmpStream, bmpOutputSettings);
|
ImageOutput.SaveToStream(bitmapToSave, null, tmpBmpStream, bmpOutputSettings);
|
||||||
|
|
||||||
dibStream = new MemoryStream();
|
dibStream = new MemoryStream();
|
||||||
|
@ -697,7 +700,7 @@ EndSelection:<<<<<<<4
|
||||||
// CF_DibV5
|
// CF_DibV5
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.DIBV5))
|
if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.DIBV5))
|
||||||
{
|
{
|
||||||
// Create the stream for the clipboard
|
// Create the stream for the clipboard
|
||||||
dibV5Stream = new MemoryStream();
|
dibV5Stream = new MemoryStream();
|
||||||
|
@ -734,18 +737,18 @@ EndSelection:<<<<<<<4
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the HTML
|
// Set the HTML
|
||||||
if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.HTML))
|
if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.HTML))
|
||||||
{
|
{
|
||||||
var tmpFile = ImageOutput.SaveToTmpFile(surface, new SurfaceOutputSettings(OutputFormats.png, 100, false), null);
|
var tmpFile = ImageOutput.SaveToTmpFile(surface, new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png, 100, false), null);
|
||||||
var html = GetHtmlString(surface, tmpFile);
|
var html = GetHtmlString(surface, tmpFile);
|
||||||
dataObject.SetText(html, TextDataFormat.Html);
|
dataObject.SetText(html, TextDataFormat.Html);
|
||||||
}
|
}
|
||||||
else if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.HTMLDATAURL))
|
else if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.HTMLDATAURL))
|
||||||
{
|
{
|
||||||
string html;
|
string html;
|
||||||
using (var tmpPngStream = new MemoryStream())
|
using (var tmpPngStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false)
|
var pngOutputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png, 100, false)
|
||||||
{
|
{
|
||||||
// Do not allow to reduce the colors, some applications dislike 256 color images
|
// Do not allow to reduce the colors, some applications dislike 256 color images
|
||||||
// reported with bug #3594681
|
// reported with bug #3594681
|
||||||
|
@ -769,7 +772,7 @@ EndSelection:<<<<<<<4
|
||||||
{
|
{
|
||||||
// we need to use the SetDataOject before the streams are closed otherwise the buffer will be gone!
|
// we need to use the SetDataOject before the streams are closed otherwise the buffer will be gone!
|
||||||
// Check if Bitmap is wanted
|
// Check if Bitmap is wanted
|
||||||
if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.BITMAP))
|
if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.BITMAP))
|
||||||
{
|
{
|
||||||
dataObject.SetImage(bitmapToSave);
|
dataObject.SetImage(bitmapToSave);
|
||||||
// Place the DataObject to the clipboard
|
// Place the DataObject to the clipboard
|
||||||
|
|
|
@ -28,6 +28,7 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using Dapplo.Log;
|
||||||
using Greenshot.Addons.Core.Enums;
|
using Greenshot.Addons.Core.Enums;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -39,6 +40,8 @@ namespace Greenshot.Addons.Core
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class CoreConfigurationExtensions
|
public static class CoreConfigurationExtensions
|
||||||
{
|
{
|
||||||
|
private static readonly LogSource Log = new LogSource();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validate the values in the ICoreConfiguration, correct them where needed
|
/// Validate the values in the ICoreConfiguration, correct them where needed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -194,6 +197,30 @@ namespace Greenshot.Addons.Core
|
||||||
coreConfiguration.WebRequestReadWriteTimeout = 100;
|
coreConfiguration.WebRequestReadWriteTimeout = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TitleFix processor
|
||||||
|
var corruptKeys = new List<string>();
|
||||||
|
foreach (var key in coreConfiguration.ActiveTitleFixes)
|
||||||
|
{
|
||||||
|
if (coreConfiguration.TitleFixMatcher.ContainsKey(key))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Log.Warn().WriteLine("Key {0} not found, configuration is broken! Disabling this key!", key);
|
||||||
|
corruptKeys.Add(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix configuration if needed
|
||||||
|
if (corruptKeys.Count <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach (var corruptKey in corruptKeys)
|
||||||
|
{
|
||||||
|
// Removing any reference to the key
|
||||||
|
coreConfiguration.ActiveTitleFixes.Remove(corruptKey);
|
||||||
|
coreConfiguration.TitleFixMatcher.Remove(corruptKey);
|
||||||
|
coreConfiguration.TitleFixReplacer.Remove(corruptKey);
|
||||||
|
}
|
||||||
coreConfiguration.ValidateAndCorrect();
|
coreConfiguration.ValidateAndCorrect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,8 +53,10 @@ namespace Greenshot.Addons.Core
|
||||||
private static readonly Regex CmdVarRegexp = new Regex(@"%(?<variable>[^%]+)%", RegexOptions.Compiled);
|
private static readonly Regex CmdVarRegexp = new Regex(@"%(?<variable>[^%]+)%", RegexOptions.Compiled);
|
||||||
|
|
||||||
private static readonly Regex SplitRegexp = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
|
private static readonly Regex SplitRegexp = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
|
||||||
// TODO: Solve, was static reference!
|
/// <summary>
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static ICoreConfiguration CoreConfiguration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remove invalid characters from the fully qualified filename
|
/// Remove invalid characters from the fully qualified filename
|
||||||
|
@ -134,7 +136,7 @@ namespace Greenshot.Addons.Core
|
||||||
/// <returns>The filename which should be used to save the image</returns>
|
/// <returns>The filename which should be used to save the image</returns>
|
||||||
public static string GetFilename(OutputFormats format, ICaptureDetails captureDetails)
|
public static string GetFilename(OutputFormats format, ICaptureDetails captureDetails)
|
||||||
{
|
{
|
||||||
var pattern = CoreConfig.OutputFileFilenamePattern;
|
var pattern = CoreConfiguration.OutputFileFilenamePattern;
|
||||||
if (string.IsNullOrEmpty(pattern?.Trim()))
|
if (string.IsNullOrEmpty(pattern?.Trim()))
|
||||||
{
|
{
|
||||||
pattern = "greenshot ${capturetime}";
|
pattern = "greenshot ${capturetime}";
|
||||||
|
@ -395,8 +397,8 @@ namespace Greenshot.Addons.Core
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "NUM":
|
case "NUM":
|
||||||
CoreConfig.OutputFileIncrementingNumber++;
|
CoreConfiguration.OutputFileIncrementingNumber++;
|
||||||
replaceValue = CoreConfig.OutputFileIncrementingNumber.ToString();
|
replaceValue = CoreConfiguration.OutputFileIncrementingNumber.ToString();
|
||||||
if (padWidth == 0)
|
if (padWidth == 0)
|
||||||
{
|
{
|
||||||
padWidth = -6;
|
padWidth = -6;
|
||||||
|
|
|
@ -57,9 +57,18 @@ namespace Greenshot.Addons.Core
|
||||||
public static class ImageOutput
|
public static class ImageOutput
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
/// <summary>
|
||||||
private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static ICoreConfiguration CoreConfiguration { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static IGreenshotLanguage GreenshotLanguage { get; set; }
|
||||||
|
|
||||||
|
private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
|
||||||
private static readonly Cache<string, string> TmpFileCache = new Cache<string, string>(10 * 60 * 60, RemoveExpiredTmpFile);
|
private static readonly Cache<string, string> TmpFileCache = new Cache<string, string>(10 * 60 * 60, RemoveExpiredTmpFile);
|
||||||
|
|
||||||
static ImageOutput()
|
static ImageOutput()
|
||||||
|
@ -128,7 +137,7 @@ namespace Greenshot.Addons.Core
|
||||||
public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
|
public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
|
||||||
{
|
{
|
||||||
string returnValue = null;
|
string returnValue = null;
|
||||||
using (var saveImageFileDialog = new SaveImageFileDialog(captureDetails))
|
using (var saveImageFileDialog = new SaveImageFileDialog(CoreConfiguration, captureDetails))
|
||||||
{
|
{
|
||||||
var dialogResult = saveImageFileDialog.ShowDialog();
|
var dialogResult = saveImageFileDialog.ShowDialog();
|
||||||
if (dialogResult.Equals(DialogResult.OK))
|
if (dialogResult.Equals(DialogResult.OK))
|
||||||
|
@ -136,15 +145,15 @@ namespace Greenshot.Addons.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
|
var fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
|
||||||
var outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration, FormatForFilename(fileNameWithExtension));
|
||||||
if (CoreConfig.OutputFilePromptQuality)
|
if (CoreConfiguration.OutputFilePromptQuality)
|
||||||
{
|
{
|
||||||
// TODO: Resolve, was static reference
|
// TODO: Use factory
|
||||||
var qualityDialog = new QualityDialog(outputSettings, CoreConfig, new GreenshotLanguageImpl());
|
var qualityDialog = new QualityDialog(outputSettings, CoreConfiguration, GreenshotLanguage);
|
||||||
qualityDialog.ShowDialog();
|
qualityDialog.ShowDialog();
|
||||||
}
|
}
|
||||||
// TODO: For now we always overwrite, should be changed
|
// TODO: For now we always overwrite, should be changed
|
||||||
Save(surface, fileNameWithExtension, true, outputSettings, CoreConfig.OutputFileCopyPathToClipboard);
|
Save(surface, fileNameWithExtension, true, outputSettings, CoreConfiguration.OutputFileCopyPathToClipboard);
|
||||||
returnValue = fileNameWithExtension;
|
returnValue = fileNameWithExtension;
|
||||||
}
|
}
|
||||||
catch (ExternalException)
|
catch (ExternalException)
|
||||||
|
@ -170,7 +179,7 @@ namespace Greenshot.Addons.Core
|
||||||
/// <returns>Path to image file</returns>
|
/// <returns>Path to image file</returns>
|
||||||
public static string SaveNamedTmpFile(ISurface surface, ICaptureDetails captureDetails, SurfaceOutputSettings outputSettings)
|
public static string SaveNamedTmpFile(ISurface surface, ICaptureDetails captureDetails, SurfaceOutputSettings outputSettings)
|
||||||
{
|
{
|
||||||
var pattern = CoreConfig.OutputFileFilenamePattern;
|
var pattern = CoreConfiguration.OutputFileFilenamePattern;
|
||||||
if (string.IsNullOrEmpty(pattern?.Trim()))
|
if (string.IsNullOrEmpty(pattern?.Trim()))
|
||||||
{
|
{
|
||||||
pattern = "greenshot ${capturetime}";
|
pattern = "greenshot ${capturetime}";
|
||||||
|
@ -564,7 +573,7 @@ namespace Greenshot.Addons.Core
|
||||||
AddTag(bitmapToSave);
|
AddTag(bitmapToSave);
|
||||||
// Added for OptiPNG
|
// Added for OptiPNG
|
||||||
var processed = false;
|
var processed = false;
|
||||||
if (Equals(imageFormat, ImageFormat.Png) && !string.IsNullOrEmpty(CoreConfig.OptimizePNGCommand))
|
if (Equals(imageFormat, ImageFormat.Png) && !string.IsNullOrEmpty(CoreConfiguration.OptimizePNGCommand))
|
||||||
{
|
{
|
||||||
processed = ProcessPngImageExternally(bitmapToSave, targetStream);
|
processed = ProcessPngImageExternally(bitmapToSave, targetStream);
|
||||||
}
|
}
|
||||||
|
@ -616,13 +625,13 @@ namespace Greenshot.Addons.Core
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private static bool ProcessPngImageExternally(Image imageToProcess, Stream targetStream)
|
private static bool ProcessPngImageExternally(Image imageToProcess, Stream targetStream)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(CoreConfig.OptimizePNGCommand))
|
if (string.IsNullOrEmpty(CoreConfiguration.OptimizePNGCommand))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!File.Exists(CoreConfig.OptimizePNGCommand))
|
if (!File.Exists(CoreConfiguration.OptimizePNGCommand))
|
||||||
{
|
{
|
||||||
Log.Warn().WriteLine("Can't find 'OptimizePNGCommand' {0}", CoreConfig.OptimizePNGCommand);
|
Log.Warn().WriteLine("Can't find 'OptimizePNGCommand' {0}", CoreConfiguration.OptimizePNGCommand);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var tmpFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".png");
|
var tmpFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".png");
|
||||||
|
@ -639,12 +648,12 @@ namespace Greenshot.Addons.Core
|
||||||
}
|
}
|
||||||
if (Log.IsDebugEnabled())
|
if (Log.IsDebugEnabled())
|
||||||
{
|
{
|
||||||
Log.Debug().WriteLine("Starting : {0}", CoreConfig.OptimizePNGCommand);
|
Log.Debug().WriteLine("Starting : {0}", CoreConfiguration.OptimizePNGCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
var processStartInfo = new ProcessStartInfo(CoreConfig.OptimizePNGCommand)
|
var processStartInfo = new ProcessStartInfo(CoreConfiguration.OptimizePNGCommand)
|
||||||
{
|
{
|
||||||
Arguments = string.Format(CoreConfig.OptimizePNGCommandArguments, tmpFileName),
|
Arguments = string.Format(CoreConfiguration.OptimizePNGCommandArguments, tmpFileName),
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
|
@ -735,12 +744,12 @@ namespace Greenshot.Addons.Core
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for color reduction, forced or automatically, only when the DisableReduceColors is false
|
// check for color reduction, forced or automatically, only when the DisableReduceColors is false
|
||||||
if (outputSettings.DisableReduceColors || !CoreConfig.OutputFileAutoReduceColors && !outputSettings.ReduceColors)
|
if (outputSettings.DisableReduceColors || !CoreConfiguration.OutputFileAutoReduceColors && !outputSettings.ReduceColors)
|
||||||
{
|
{
|
||||||
return disposeImage;
|
return disposeImage;
|
||||||
}
|
}
|
||||||
var isAlpha = Image.IsAlphaPixelFormat(bitmapToSave.PixelFormat);
|
var isAlpha = Image.IsAlphaPixelFormat(bitmapToSave.PixelFormat);
|
||||||
if (outputSettings.ReduceColors || !isAlpha && CoreConfig.OutputFileAutoReduceColors)
|
if (outputSettings.ReduceColors || !isAlpha && CoreConfiguration.OutputFileAutoReduceColors)
|
||||||
{
|
{
|
||||||
using (var quantizer = new WuQuantizer(bitmapToSave))
|
using (var quantizer = new WuQuantizer(bitmapToSave))
|
||||||
{
|
{
|
||||||
|
@ -753,7 +762,7 @@ namespace Greenshot.Addons.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Log.Info().WriteLine("Reducing colors on bitmap to 256.");
|
Log.Info().WriteLine("Reducing colors on bitmap to 256.");
|
||||||
tmpBitmap = quantizer.GetQuantizedImage(CoreConfig.OutputFileReduceColorsTo);
|
tmpBitmap = quantizer.GetQuantizedImage(CoreConfiguration.OutputFileReduceColorsTo);
|
||||||
if (disposeImage)
|
if (disposeImage)
|
||||||
{
|
{
|
||||||
bitmapToSave.Dispose();
|
bitmapToSave.Dispose();
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
#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
|
|
||||||
|
|
||||||
#region Usings
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
using Dapplo.Log;
|
|
||||||
using Greenshot.Addons.Interfaces;
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
namespace Greenshot.Addons.Core
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Description of InterfaceUtils.
|
|
||||||
/// </summary>
|
|
||||||
public static class InterfaceUtils
|
|
||||||
{
|
|
||||||
private static readonly LogSource Log = new LogSource();
|
|
||||||
|
|
||||||
public static List<Type> GetSubclassesOf(Type type, bool excludeSystemTypes)
|
|
||||||
{
|
|
||||||
var list = new List<Type>();
|
|
||||||
foreach (var currentAssembly in Thread.GetDomain().GetAssemblies())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var types = currentAssembly.GetTypes();
|
|
||||||
if (!excludeSystemTypes || excludeSystemTypes && !currentAssembly.FullName.StartsWith("System."))
|
|
||||||
{
|
|
||||||
foreach (var currentType in types)
|
|
||||||
{
|
|
||||||
if (type.IsInterface)
|
|
||||||
{
|
|
||||||
if (currentType.GetInterface(type.FullName) != null)
|
|
||||||
{
|
|
||||||
list.Add(currentType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (currentType.IsSubclassOf(type))
|
|
||||||
{
|
|
||||||
list.Add(currentType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.Warn().WriteLine("Problem getting subclasses of type: {0}, message: {1}", type.FullName, ex.Message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<IProcessor> GetProcessors()
|
|
||||||
{
|
|
||||||
var processors = new List<IProcessor>();
|
|
||||||
foreach (var processorType in GetSubclassesOf(typeof(IProcessor), true))
|
|
||||||
{
|
|
||||||
if (!processorType.IsAbstract)
|
|
||||||
{
|
|
||||||
var processor = (IProcessor) Activator.CreateInstance(processorType);
|
|
||||||
if (processor.IsActive)
|
|
||||||
{
|
|
||||||
Log.Debug().WriteLine("Found processor {0} with designation {1}", processorType.Name, processor.Designation);
|
|
||||||
processors.Add(processor);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.Debug().WriteLine("Ignoring processor {0} with designation {1}", processorType.Name, processor.Designation);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return processors;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -56,8 +56,11 @@ namespace Greenshot.Addons.Core
|
||||||
public static class InteropWindowCaptureExtensions
|
public static class InteropWindowCaptureExtensions
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration CoreConfiguration = new CoreConfigurationImpl();
|
/// <summary>
|
||||||
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static ICoreConfiguration CoreConfiguration { get; set; }
|
||||||
private static Color _transparentColor = Color.Transparent;
|
private static Color _transparentColor = Color.Transparent;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -48,22 +48,24 @@ namespace Greenshot.Addons.Core
|
||||||
private const string PathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
private const string PathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
private static bool _isHooked = false;
|
private static bool _isHooked = false;
|
||||||
private static readonly IDictionary<string, Bitmap> ExeIconCache = new Dictionary<string, Bitmap>();
|
private static readonly Dictionary<string, Bitmap> ExeIconCache = new Dictionary<string, Bitmap>();
|
||||||
|
private static ICoreConfiguration coreConfiguration;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// TODO: Replace this, as soon as we have fixed the configuration, this should not be done via a static class...
|
/// Set from DI via AddonsModule
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static void SetupIconResizing()
|
internal static ICoreConfiguration CoreConfiguration {
|
||||||
{
|
get
|
||||||
if (!_isHooked)
|
{
|
||||||
{
|
return coreConfiguration;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
_isHooked = true;
|
set
|
||||||
var coreConfiguration = new CoreConfigurationImpl();
|
{
|
||||||
coreConfiguration.PropertyChanged += OnIconSizeChanged;
|
coreConfiguration = value;
|
||||||
}
|
coreConfiguration.PropertyChanged += OnIconSizeChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clear icon cache
|
/// Clear icon cache
|
||||||
|
@ -140,8 +142,6 @@ namespace Greenshot.Addons.Core
|
||||||
Bitmap returnValue;
|
Bitmap returnValue;
|
||||||
lock (ExeIconCache)
|
lock (ExeIconCache)
|
||||||
{
|
{
|
||||||
SetupIconResizing();
|
|
||||||
|
|
||||||
if (ExeIconCache.TryGetValue(cacheKey, out returnValue))
|
if (ExeIconCache.TryGetValue(cacheKey, out returnValue))
|
||||||
{
|
{
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
|
|
@ -56,8 +56,11 @@ namespace Greenshot.Addons.Core
|
||||||
public static class WindowCapture
|
public static class WindowCapture
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration Configuration = new CoreConfigurationImpl();
|
/// <summary>
|
||||||
|
/// Set from DI via AddonsModule
|
||||||
|
/// </summary>
|
||||||
|
internal static ICoreConfiguration CoreConfiguration { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7. This implementation
|
/// Retrieves the cursor location safely, accounting for DPI settings in Vista/Windows 7. This implementation
|
||||||
|
@ -173,7 +176,7 @@ namespace Greenshot.Addons.Core
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Configuration.NoDWMCaptureForProduct == null || Configuration.NoDWMCaptureForProduct.Count <= 0)
|
if (CoreConfiguration.NoDWMCaptureForProduct == null || CoreConfiguration.NoDWMCaptureForProduct.Count <= 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +184,7 @@ namespace Greenshot.Addons.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var productName = process.MainModule.FileVersionInfo.ProductName;
|
var productName = process.MainModule.FileVersionInfo.ProductName;
|
||||||
if (productName != null && Configuration.NoDWMCaptureForProduct.Contains(productName.ToLower()))
|
if (productName != null && CoreConfiguration.NoDWMCaptureForProduct.Contains(productName.ToLower()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -205,7 +208,7 @@ namespace Greenshot.Addons.Core
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Configuration.NoGDICaptureForProduct == null || Configuration.NoGDICaptureForProduct.Count <= 0)
|
if (CoreConfiguration.NoGDICaptureForProduct == null || CoreConfiguration.NoGDICaptureForProduct.Count <= 0)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -213,7 +216,7 @@ namespace Greenshot.Addons.Core
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var productName = process.MainModule.FileVersionInfo.ProductName;
|
var productName = process.MainModule.FileVersionInfo.ProductName;
|
||||||
if (productName != null && Configuration.NoGDICaptureForProduct.Contains(productName.ToLower()))
|
if (productName != null && CoreConfiguration.NoGDICaptureForProduct.Contains(productName.ToLower()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,12 +195,12 @@ namespace Greenshot.Addons.Extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
||||||
/// <param name="surface">ISurface</param>
|
/// <param name="surface">ISurface</param>
|
||||||
public static void SetAsFormat17(this IClipboardAccessToken clipboardAccessToken, ISurface surface)
|
public static void SetAsFormat17(this IClipboardAccessToken clipboardAccessToken, ISurface surface, ICoreConfiguration coreConfiguration)
|
||||||
{
|
{
|
||||||
// Create the stream for the clipboard
|
// Create the stream for the clipboard
|
||||||
using (var dibV5Stream = new MemoryStream())
|
using (var dibV5Stream = new MemoryStream())
|
||||||
{
|
{
|
||||||
var outputSettings = new SurfaceOutputSettings(OutputFormats.bmp, 100, false);
|
var outputSettings = new SurfaceOutputSettings(coreConfiguration, OutputFormats.bmp, 100, false);
|
||||||
bool dispose = ImageOutput.CreateBitmapFromSurface(surface, outputSettings, out var bitmapToSave);
|
bool dispose = ImageOutput.CreateBitmapFromSurface(surface, outputSettings, out var bitmapToSave);
|
||||||
// Create the BITMAPINFOHEADER
|
// Create the BITMAPINFOHEADER
|
||||||
var header = BitmapInfoHeader.Create(bitmapToSave.Width, bitmapToSave.Height, 32);
|
var header = BitmapInfoHeader.Create(bitmapToSave.Width, bitmapToSave.Height, 32);
|
||||||
|
@ -269,11 +269,11 @@ namespace Greenshot.Addons.Extensions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
||||||
/// <param name="surface">ISurface</param>
|
/// <param name="surface">ISurface</param>
|
||||||
public static void SetAsDeviceIndependendBitmap(this IClipboardAccessToken clipboardAccessToken, ISurface surface)
|
public static void SetAsDeviceIndependendBitmap(this IClipboardAccessToken clipboardAccessToken, ISurface surface, ICoreConfiguration coreConfiguration)
|
||||||
{
|
{
|
||||||
using (var bitmapStream = new MemoryStream())
|
using (var bitmapStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
ImageOutput.SaveToStream(surface, bitmapStream, new SurfaceOutputSettings{Format = OutputFormats.bmp});
|
ImageOutput.SaveToStream(surface, bitmapStream, new SurfaceOutputSettings(coreConfiguration) {Format = OutputFormats.bmp});
|
||||||
bitmapStream.Seek(Marshal.SizeOf(typeof(BitmapFileHeader)), SeekOrigin.Begin);
|
bitmapStream.Seek(Marshal.SizeOf(typeof(BitmapFileHeader)), SeekOrigin.Begin);
|
||||||
// Set the stream
|
// Set the stream
|
||||||
clipboardAccessToken.SetAsStream(StandardClipboardFormats.DeviceIndependentBitmap, bitmapStream);
|
clipboardAccessToken.SetAsStream(StandardClipboardFormats.DeviceIndependentBitmap, bitmapStream);
|
||||||
|
|
|
@ -136,9 +136,9 @@ EndSelection:<<<<<<<4
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
||||||
/// <param name="surface">ISurface</param>
|
/// <param name="surface">ISurface</param>
|
||||||
public static void SetAsHtml(this IClipboardAccessToken clipboardAccessToken, ISurface surface)
|
public static void SetAsHtml(this IClipboardAccessToken clipboardAccessToken, ISurface surface, ICoreConfiguration coreConfiguration)
|
||||||
{
|
{
|
||||||
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
|
var pngOutputSettings = new SurfaceOutputSettings(coreConfiguration, OutputFormats.png, 100, false);
|
||||||
// This file is automatically deleted when Greenshot exits.
|
// This file is automatically deleted when Greenshot exits.
|
||||||
var filename = ImageOutput.SaveNamedTmpFile(surface, surface.CaptureDetails, pngOutputSettings);
|
var filename = ImageOutput.SaveNamedTmpFile(surface, surface.CaptureDetails, pngOutputSettings);
|
||||||
// Set the PNG stream
|
// Set the PNG stream
|
||||||
|
@ -152,11 +152,11 @@ EndSelection:<<<<<<<4
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
/// <param name="clipboardAccessToken">IClipboardAccessToken</param>
|
||||||
/// <param name="surface">ISurface</param>
|
/// <param name="surface">ISurface</param>
|
||||||
public static void SetAsEmbeddedHtml(this IClipboardAccessToken clipboardAccessToken, ISurface surface)
|
public static void SetAsEmbeddedHtml(this IClipboardAccessToken clipboardAccessToken, ISurface surface, ICoreConfiguration coreConfiguration)
|
||||||
{
|
{
|
||||||
using (var pngStream = new MemoryStream())
|
using (var pngStream = new MemoryStream())
|
||||||
{
|
{
|
||||||
var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
|
var pngOutputSettings = new SurfaceOutputSettings(coreConfiguration, OutputFormats.png, 100, false);
|
||||||
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
|
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
|
||||||
pngStream.Seek(0, SeekOrigin.Begin);
|
pngStream.Seek(0, SeekOrigin.Begin);
|
||||||
// Set the PNG stream
|
// Set the PNG stream
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
<PackageReference Include="Dapplo.Windows.Icons">
|
<PackageReference Include="Dapplo.Windows.Icons">
|
||||||
<Version>0.8.3</Version>
|
<Version>0.8.3</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
16
src/Greenshot.Addons/Interfaces/IFormEnhancer.cs
Normal file
16
src/Greenshot.Addons/Interfaces/IFormEnhancer.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace Greenshot.Addons.Interfaces
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This interface makes it possible to enhance forms by e.g. injecting components
|
||||||
|
/// </summary>
|
||||||
|
public interface IFormEnhancer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is called during the InitializeComponent of the form
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="target">Form</param>
|
||||||
|
void InitializeComponent(Form target);
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,38 +35,32 @@ namespace Greenshot.Addons.Interfaces.Plugin
|
||||||
{
|
{
|
||||||
public class SurfaceOutputSettings
|
public class SurfaceOutputSettings
|
||||||
{
|
{
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
|
||||||
private bool _disableReduceColors;
|
private bool _disableReduceColors;
|
||||||
private bool _reduceColors;
|
private bool _reduceColors;
|
||||||
|
|
||||||
public SurfaceOutputSettings()
|
public SurfaceOutputSettings(IFileConfiguration fileConfiguration)
|
||||||
{
|
{
|
||||||
_disableReduceColors = false;
|
_disableReduceColors = false;
|
||||||
Format = CoreConfig.OutputFileFormat;
|
Format = fileConfiguration.OutputFileFormat;
|
||||||
JPGQuality = CoreConfig.OutputFileJpegQuality;
|
JPGQuality = fileConfiguration.OutputFileJpegQuality;
|
||||||
ReduceColors = CoreConfig.OutputFileReduceColors;
|
ReduceColors = fileConfiguration.OutputFileReduceColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurfaceOutputSettings(OutputFormats format) : this()
|
public SurfaceOutputSettings(IFileConfiguration fileConfiguration, OutputFormats format) : this(fileConfiguration)
|
||||||
{
|
{
|
||||||
Format = format;
|
Format = format;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurfaceOutputSettings(OutputFormats format, int quality) : this(format)
|
public SurfaceOutputSettings(IFileConfiguration fileConfiguration, OutputFormats format, int quality) : this(fileConfiguration, format)
|
||||||
{
|
{
|
||||||
JPGQuality = quality;
|
JPGQuality = quality;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurfaceOutputSettings(OutputFormats format, int quality, bool reduceColors) : this(format, quality)
|
public SurfaceOutputSettings(IFileConfiguration fileConfiguration, OutputFormats format, int quality, bool reduceColors) : this(fileConfiguration, format, quality)
|
||||||
{
|
{
|
||||||
ReduceColors = reduceColors;
|
ReduceColors = reduceColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SurfaceOutputSettings(IFileConfiguration fileConfiguration) : this(fileConfiguration.OutputFileFormat, fileConfiguration.OutputFileJpegQuality, fileConfiguration.OutputFileReduceColors)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public OutputFormats Format { get; set; }
|
public OutputFormats Format { get; set; }
|
||||||
|
|
||||||
public int JPGQuality { get; set; }
|
public int JPGQuality { get; set; }
|
||||||
|
|
|
@ -97,6 +97,26 @@ namespace Greenshot.Addons.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This opens the directory selection dialog
|
||||||
|
/// </summary>
|
||||||
|
public void SelectOutputPath()
|
||||||
|
{
|
||||||
|
using (var folderBrowserDialog = new System.Windows.Forms.FolderBrowserDialog())
|
||||||
|
{
|
||||||
|
// Get the storage location and replace the environment variables
|
||||||
|
folderBrowserDialog.SelectedPath = FilenameHelper.FillVariables(CoreConfiguration.OutputFilePath, false);
|
||||||
|
if (folderBrowserDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||||
|
{
|
||||||
|
// Only change if there is a change, otherwise we might overwrite the environment variables
|
||||||
|
if (folderBrowserDialog.SelectedPath != null && !folderBrowserDialog.SelectedPath.Equals(FilenameHelper.FillVariables(CoreConfiguration.OutputFilePath, false)))
|
||||||
|
{
|
||||||
|
CoreConfiguration.OutputFilePath = folderBrowserDialog.SelectedPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Specifies if the global settings can be modified, which is the case when there are is no DestinationFileConfiguration
|
/// Specifies if the global settings can be modified, which is the case when there are is no DestinationFileConfiguration
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -23,6 +23,12 @@
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
<CheckBox Content="{Binding GreenshotLanguage.SettingsReducecolors}" IsChecked="{Binding FileConfiguration.OutputFileReduceColors}"/>
|
<CheckBox Content="{Binding GreenshotLanguage.SettingsReducecolors}" IsChecked="{Binding FileConfiguration.OutputFileReduceColors}"/>
|
||||||
|
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<Label Content="{Binding GreenshotLanguage.SettingsOutput}" Width="100" />
|
||||||
|
<Button Content="..." Name="SelectOutputPath" />
|
||||||
|
<TextBox Text="{Binding FileConfiguration.OutputFilePath}"/>
|
||||||
|
</DockPanel>
|
||||||
|
|
||||||
<DockPanel LastChildFill="True">
|
<DockPanel LastChildFill="True">
|
||||||
<Label Content="{Binding GreenshotLanguage.SettingsFilenamepattern}" Width="100" />
|
<Label Content="{Binding GreenshotLanguage.SettingsFilenamepattern}" Width="100" />
|
||||||
<TextBox Text="{Binding FileConfiguration.OutputFileFilenamePattern}"/>
|
<TextBox Text="{Binding FileConfiguration.OutputFileFilenamePattern}"/>
|
||||||
|
|
|
@ -170,6 +170,7 @@ Global
|
||||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.Build.0 = Debug|Any CPU
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.ActiveCfg = Release|Any CPU
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.Build.0 = Release|Any CPU
|
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{D106F86C-CD3D-44FF-B151-2A5D47268B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{D106F86C-CD3D-44FF-B151-2A5D47268B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
|
34
src/Greenshot/Components/CaptureSupportInfo.cs
Normal file
34
src/Greenshot/Components/CaptureSupportInfo.cs
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Greenshot.Addon.InternetExplorer;
|
||||||
|
using Greenshot.Addons.Core;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
|
|
||||||
|
namespace Greenshot.Components
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is the information which is needed for making captures possible.
|
||||||
|
/// </summary>
|
||||||
|
public class CaptureSupportInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for DI
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="internetExplorerCaptureHelper">InternetExplorerCaptureHelper</param>
|
||||||
|
/// <param name="formEnhancers">IEnumerable with IFormEnhancer</param>
|
||||||
|
public CaptureSupportInfo(
|
||||||
|
ICoreConfiguration coreConfiguration,
|
||||||
|
InternetExplorerCaptureHelper internetExplorerCaptureHelper,
|
||||||
|
IEnumerable<IFormEnhancer> formEnhancers = null
|
||||||
|
)
|
||||||
|
{
|
||||||
|
CoreConfiguration = coreConfiguration;
|
||||||
|
InternetExplorerCaptureHelper = internetExplorerCaptureHelper;
|
||||||
|
FormEnhancers = formEnhancers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICoreConfiguration CoreConfiguration { get; }
|
||||||
|
public InternetExplorerCaptureHelper InternetExplorerCaptureHelper { get; }
|
||||||
|
|
||||||
|
public IEnumerable<IFormEnhancer> FormEnhancers { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
#region Usings
|
#region Usings
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
@ -60,6 +61,7 @@ namespace Greenshot.Components
|
||||||
private readonly HotkeyService _hotkeyService;
|
private readonly HotkeyService _hotkeyService;
|
||||||
private readonly DestinationHolder _destinationHolder;
|
private readonly DestinationHolder _destinationHolder;
|
||||||
private ServiceHost _host;
|
private ServiceHost _host;
|
||||||
|
private CaptureSupportInfo _captureSupportInfo;
|
||||||
|
|
||||||
public static string Identity
|
public static string Identity
|
||||||
{
|
{
|
||||||
|
@ -75,8 +77,10 @@ namespace Greenshot.Components
|
||||||
ICoreConfiguration coreConfiguration,
|
ICoreConfiguration coreConfiguration,
|
||||||
MainForm mainForm,
|
MainForm mainForm,
|
||||||
HotkeyService hotkeyService,
|
HotkeyService hotkeyService,
|
||||||
DestinationHolder destinationHolder)
|
DestinationHolder destinationHolder,
|
||||||
|
CaptureSupportInfo captureSupportInfo)
|
||||||
{
|
{
|
||||||
|
_captureSupportInfo = captureSupportInfo;
|
||||||
_coreConfiguration = coreConfiguration;
|
_coreConfiguration = coreConfiguration;
|
||||||
_mainForm = mainForm;
|
_mainForm = mainForm;
|
||||||
_hotkeyService = hotkeyService;
|
_hotkeyService = hotkeyService;
|
||||||
|
@ -137,7 +141,7 @@ namespace Greenshot.Components
|
||||||
Log.Debug().WriteLine("Open file requested: {0}", filename);
|
Log.Debug().WriteLine("Open file requested: {0}", filename);
|
||||||
if (File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
{
|
{
|
||||||
CaptureHelper.CaptureFile(filename);
|
CaptureHelper.CaptureFile(_captureSupportInfo, filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -167,13 +171,13 @@ namespace Greenshot.Components
|
||||||
switch (captureMode.ToLower())
|
switch (captureMode.ToLower())
|
||||||
{
|
{
|
||||||
case "region":
|
case "region":
|
||||||
CaptureHelper.CaptureRegion(false, destination);
|
CaptureHelper.CaptureRegion(_captureSupportInfo, false, destination);
|
||||||
break;
|
break;
|
||||||
case "window":
|
case "window":
|
||||||
CaptureHelper.CaptureWindow(false, destination);
|
CaptureHelper.CaptureWindow(_captureSupportInfo, false, destination);
|
||||||
break;
|
break;
|
||||||
case "fullscreen":
|
case "fullscreen":
|
||||||
CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen, destination);
|
CaptureHelper.CaptureFullscreen(_captureSupportInfo, false, ScreenCaptureMode.FullScreen, destination);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.Warn().WriteLine("Unknown capture option");
|
Log.Warn().WriteLine("Unknown capture option");
|
||||||
|
|
|
@ -22,12 +22,14 @@
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Caliburn.Micro;
|
using Caliburn.Micro;
|
||||||
using Dapplo.Addons;
|
using Dapplo.Addons;
|
||||||
using Dapplo.Log;
|
using Dapplo.Log;
|
||||||
using Dapplo.Windows.Input.Keyboard;
|
using Dapplo.Windows.Input.Keyboard;
|
||||||
using Greenshot.Addons.Core;
|
using Greenshot.Addons.Core;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
|
|
||||||
namespace Greenshot.Components
|
namespace Greenshot.Components
|
||||||
|
@ -40,11 +42,13 @@ namespace Greenshot.Components
|
||||||
{
|
{
|
||||||
private static readonly LogSource Log = new LogSource();
|
private static readonly LogSource Log = new LogSource();
|
||||||
private readonly ICoreConfiguration _coreConfiguration;
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
|
private readonly CaptureSupportInfo _captureSupportInfo;
|
||||||
private IDisposable _subscriptions;
|
private IDisposable _subscriptions;
|
||||||
|
|
||||||
public HotkeyService(ICoreConfiguration coreConfiguration)
|
public HotkeyService(ICoreConfiguration coreConfiguration, CaptureSupportInfo captureSupportInfo)
|
||||||
{
|
{
|
||||||
_coreConfiguration = coreConfiguration;
|
_coreConfiguration = coreConfiguration;
|
||||||
|
_captureSupportInfo = captureSupportInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -116,36 +120,36 @@ namespace Greenshot.Components
|
||||||
|
|
||||||
private void CaptureRegion(KeyboardHookEventArgs keyboardHookEventArgs)
|
private void CaptureRegion(KeyboardHookEventArgs keyboardHookEventArgs)
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureRegion(true));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureRegion(_captureSupportInfo, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureWindow(KeyboardHookEventArgs keyboardHookEventArgs)
|
private void CaptureWindow(KeyboardHookEventArgs keyboardHookEventArgs)
|
||||||
{
|
{
|
||||||
if (_coreConfiguration.CaptureWindowsInteractive)
|
if (_coreConfiguration.CaptureWindowsInteractive)
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindowInteractive(true));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindowInteractive(_captureSupportInfo, true));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindow(true));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindow(_captureSupportInfo, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureFullscreen(KeyboardHookEventArgs keyboardHookEventArgs)
|
private void CaptureFullscreen(KeyboardHookEventArgs keyboardHookEventArgs)
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureFullscreen(true, _coreConfiguration.ScreenCaptureMode));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureFullscreen(_captureSupportInfo, true, _coreConfiguration.ScreenCaptureMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureLast(KeyboardHookEventArgs keyboardHookEventArgs)
|
private void CaptureLast(KeyboardHookEventArgs keyboardHookEventArgs)
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureLastRegion(true));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureLastRegion(_captureSupportInfo, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureIe(KeyboardHookEventArgs keyboardHookEventArgs)
|
private void CaptureIe(KeyboardHookEventArgs keyboardHookEventArgs)
|
||||||
{
|
{
|
||||||
if (_coreConfiguration.IECapture)
|
if (_coreConfiguration.IECapture)
|
||||||
{
|
{
|
||||||
Execute.BeginOnUIThread(() => CaptureHelper.CaptureIe(true, null));
|
Execute.BeginOnUIThread(() => CaptureHelper.CaptureIe(_captureSupportInfo, true, null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,22 +83,22 @@ namespace Greenshot.Destinations
|
||||||
switch (clipboardFormat)
|
switch (clipboardFormat)
|
||||||
{
|
{
|
||||||
case ClipboardFormats.DIB:
|
case ClipboardFormats.DIB:
|
||||||
clipboardAccessToken.SetAsDeviceIndependendBitmap(surface);
|
clipboardAccessToken.SetAsDeviceIndependendBitmap(surface, CoreConfiguration);
|
||||||
break;
|
break;
|
||||||
case ClipboardFormats.DIBV5:
|
case ClipboardFormats.DIBV5:
|
||||||
clipboardAccessToken.SetAsFormat17(surface);
|
clipboardAccessToken.SetAsFormat17(surface, CoreConfiguration);
|
||||||
break;
|
break;
|
||||||
case ClipboardFormats.PNG:
|
case ClipboardFormats.PNG:
|
||||||
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.png));
|
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png));
|
||||||
break;
|
break;
|
||||||
case ClipboardFormats.BITMAP:
|
case ClipboardFormats.BITMAP:
|
||||||
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.bmp));
|
clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(CoreConfiguration, OutputFormats.bmp));
|
||||||
break;
|
break;
|
||||||
case ClipboardFormats.HTML:
|
case ClipboardFormats.HTML:
|
||||||
clipboardAccessToken.SetAsHtml(surface);
|
clipboardAccessToken.SetAsHtml(surface, CoreConfiguration);
|
||||||
break;
|
break;
|
||||||
case ClipboardFormats.HTMLDATAURL:
|
case ClipboardFormats.HTMLDATAURL:
|
||||||
clipboardAccessToken.SetAsEmbeddedHtml(surface);
|
clipboardAccessToken.SetAsEmbeddedHtml(surface, CoreConfiguration);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ using Greenshot.Addons.Components;
|
||||||
using Greenshot.Addons.Core;
|
using Greenshot.Addons.Core;
|
||||||
using Greenshot.Addons.Interfaces;
|
using Greenshot.Addons.Interfaces;
|
||||||
using Greenshot.Addons.Resources;
|
using Greenshot.Addons.Resources;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers.Mapi;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ namespace Greenshot.Destinations
|
||||||
bool overwrite;
|
bool overwrite;
|
||||||
string fullPath;
|
string fullPath;
|
||||||
// Get output settings from the configuration
|
// Get output settings from the configuration
|
||||||
var outputSettings = new SurfaceOutputSettings();
|
var outputSettings = new SurfaceOutputSettings(CoreConfiguration);
|
||||||
|
|
||||||
if (captureDetails?.Filename != null)
|
if (captureDetails?.Filename != null)
|
||||||
{
|
{
|
||||||
|
|
9
src/Greenshot/Forms/CaptureForm.Designer.cs
generated
9
src/Greenshot/Forms/CaptureForm.Designer.cs
generated
|
@ -67,6 +67,15 @@ namespace Greenshot.Forms {
|
||||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown);
|
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown);
|
||||||
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyUp);
|
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyUp);
|
||||||
this.Visible = false;
|
this.Visible = false;
|
||||||
|
|
||||||
|
if (_formEnhancers != null)
|
||||||
|
{
|
||||||
|
foreach (var enhancer in _formEnhancers)
|
||||||
|
{
|
||||||
|
enhancer.InitializeComponent(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace Greenshot.Forms
|
||||||
private readonly ICapture _capture;
|
private readonly ICapture _capture;
|
||||||
private readonly bool _isZoomerTransparent;
|
private readonly bool _isZoomerTransparent;
|
||||||
private readonly IList<IInteropWindow> _windows;
|
private readonly IList<IInteropWindow> _windows;
|
||||||
|
private readonly IEnumerable<IFormEnhancer> _formEnhancers;
|
||||||
private NativeRect _captureRect = NativeRect.Empty;
|
private NativeRect _captureRect = NativeRect.Empty;
|
||||||
private NativePoint _cursorPos;
|
private NativePoint _cursorPos;
|
||||||
private FixMode _fixMode = FixMode.None;
|
private FixMode _fixMode = FixMode.None;
|
||||||
|
@ -94,7 +95,7 @@ namespace Greenshot.Forms
|
||||||
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
/// <param name="coreConfiguration">ICoreConfiguration</param>
|
||||||
/// <param name="capture">ICapture</param>
|
/// <param name="capture">ICapture</param>
|
||||||
/// <param name="windows">IList of IInteropWindow</param>
|
/// <param name="windows">IList of IInteropWindow</param>
|
||||||
public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList<IInteropWindow> windows) : base(coreConfiguration, null)
|
public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList<IInteropWindow> windows, IEnumerable<IFormEnhancer> formEnhancers) : base(coreConfiguration, null)
|
||||||
{
|
{
|
||||||
_isZoomerTransparent = _coreConfiguration.ZoomerOpacity < 1;
|
_isZoomerTransparent = _coreConfiguration.ZoomerOpacity < 1;
|
||||||
ManualLanguageApply = true;
|
ManualLanguageApply = true;
|
||||||
|
@ -105,6 +106,7 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
_capture = capture;
|
_capture = capture;
|
||||||
_windows = windows;
|
_windows = windows;
|
||||||
|
_formEnhancers = formEnhancers;
|
||||||
UsedCaptureMode = capture.CaptureDetails.CaptureMode;
|
UsedCaptureMode = capture.CaptureDetails.CaptureMode;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -348,8 +350,8 @@ namespace Greenshot.Forms
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The mousedown handler of the capture form
|
/// The mousedown handler of the capture form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender">object</param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e">MouseEventArgs</param>
|
||||||
private void OnMouseDown(object sender, MouseEventArgs e)
|
private void OnMouseDown(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Button == MouseButtons.Left)
|
if (e.Button == MouseButtons.Left)
|
||||||
|
@ -449,8 +451,8 @@ namespace Greenshot.Forms
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The mouse move handler of the capture form
|
/// The mouse move handler of the capture form
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender">object</param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e">MouseEventArgs</param>
|
||||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
var cursorLocation = User32Api.GetCursorLocation();
|
var cursorLocation = User32Api.GetCursorLocation();
|
||||||
|
@ -463,7 +465,7 @@ namespace Greenshot.Forms
|
||||||
/// Helper method to simplify check
|
/// Helper method to simplify check
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="animator"></param>
|
/// <param name="animator"></param>
|
||||||
/// <returns></returns>
|
/// <returns>bool</returns>
|
||||||
private bool IsAnimating(IAnimator animator)
|
private bool IsAnimating(IAnimator animator)
|
||||||
{
|
{
|
||||||
return animator != null && animator.HasNext;
|
return animator != null && animator.HasNext;
|
||||||
|
|
2
src/Greenshot/Forms/MainForm.Designer.cs
generated
2
src/Greenshot/Forms/MainForm.Designer.cs
generated
|
@ -105,7 +105,7 @@ namespace Greenshot.Forms {
|
||||||
this.contextMenu.Name = "contextMenu";
|
this.contextMenu.Name = "contextMenu";
|
||||||
this.contextMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ContextMenuClosing);
|
this.contextMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ContextMenuClosing);
|
||||||
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
|
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
|
||||||
this.contextMenu.Renderer = new ContextMenuToolStripProfessionalRenderer();
|
this.contextMenu.Renderer = new ContextMenuToolStripProfessionalRenderer(_coreConfiguration);
|
||||||
//
|
//
|
||||||
// contextmenu_capturearea
|
// contextmenu_capturearea
|
||||||
//
|
//
|
||||||
|
|
|
@ -62,6 +62,8 @@ using Screen = System.Windows.Forms.Screen;
|
||||||
using Dapplo.Config.Ini;
|
using Dapplo.Config.Ini;
|
||||||
using Dapplo.Windows.User32;
|
using Dapplo.Windows.User32;
|
||||||
using Greenshot.Addons.Resources;
|
using Greenshot.Addons.Resources;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
|
using Greenshot.Components;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -76,6 +78,7 @@ namespace Greenshot.Forms
|
||||||
private readonly ICoreConfiguration _coreConfiguration;
|
private readonly ICoreConfiguration _coreConfiguration;
|
||||||
private readonly IWindowManager _windowManager;
|
private readonly IWindowManager _windowManager;
|
||||||
private readonly IGreenshotLanguage _greenshotLanguage;
|
private readonly IGreenshotLanguage _greenshotLanguage;
|
||||||
|
private readonly InternetExplorerCaptureHelper _internetExplorerCaptureHelper;
|
||||||
private readonly Func<Owned<ConfigViewModel>> _configViewModelFactory;
|
private readonly Func<Owned<ConfigViewModel>> _configViewModelFactory;
|
||||||
private readonly Func<Owned<AboutForm>> _aboutFormFactory;
|
private readonly Func<Owned<AboutForm>> _aboutFormFactory;
|
||||||
|
|
||||||
|
@ -83,6 +86,8 @@ namespace Greenshot.Forms
|
||||||
private readonly Timer _doubleClickTimer = new Timer();
|
private readonly Timer _doubleClickTimer = new Timer();
|
||||||
|
|
||||||
private readonly DestinationHolder _destinationHolder;
|
private readonly DestinationHolder _destinationHolder;
|
||||||
|
private readonly CaptureSupportInfo _captureSupportInfo;
|
||||||
|
|
||||||
// Thumbnail preview
|
// Thumbnail preview
|
||||||
private ThumbnailForm _thumbnailForm;
|
private ThumbnailForm _thumbnailForm;
|
||||||
|
|
||||||
|
@ -91,17 +96,22 @@ namespace Greenshot.Forms
|
||||||
public MainForm(ICoreConfiguration coreConfiguration,
|
public MainForm(ICoreConfiguration coreConfiguration,
|
||||||
IWindowManager windowManager,
|
IWindowManager windowManager,
|
||||||
IGreenshotLanguage greenshotLanguage,
|
IGreenshotLanguage greenshotLanguage,
|
||||||
|
InternetExplorerCaptureHelper internetExplorerCaptureHelper,
|
||||||
GreenshotResources greenshotResources,
|
GreenshotResources greenshotResources,
|
||||||
Func<Owned<ConfigViewModel>> configViewModelFactory,
|
Func<Owned<ConfigViewModel>> configViewModelFactory,
|
||||||
Func<Owned<AboutForm>> aboutFormFactory,
|
Func<Owned<AboutForm>> aboutFormFactory,
|
||||||
DestinationHolder destinationHolder) : base(greenshotLanguage)
|
DestinationHolder destinationHolder,
|
||||||
|
CaptureSupportInfo captureSupportInfo
|
||||||
|
) : base(greenshotLanguage)
|
||||||
{
|
{
|
||||||
_coreConfiguration = coreConfiguration;
|
_coreConfiguration = coreConfiguration;
|
||||||
_windowManager = windowManager;
|
_windowManager = windowManager;
|
||||||
_greenshotLanguage = greenshotLanguage;
|
_greenshotLanguage = greenshotLanguage;
|
||||||
|
_internetExplorerCaptureHelper = internetExplorerCaptureHelper;
|
||||||
_configViewModelFactory = configViewModelFactory;
|
_configViewModelFactory = configViewModelFactory;
|
||||||
_aboutFormFactory = aboutFormFactory;
|
_aboutFormFactory = aboutFormFactory;
|
||||||
_destinationHolder = destinationHolder;
|
_destinationHolder = destinationHolder;
|
||||||
|
_captureSupportInfo = captureSupportInfo;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +291,7 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
if (File.Exists(_coreConfiguration.OutputFileAsFullpath))
|
if (File.Exists(_coreConfiguration.OutputFileAsFullpath))
|
||||||
{
|
{
|
||||||
CaptureHelper.CaptureFile(_coreConfiguration.OutputFileAsFullpath, _destinationHolder.SortedActiveDestinations.Find("Editor"));
|
CaptureHelper.CaptureFile(_captureSupportInfo, _coreConfiguration.OutputFileAsFullpath, _destinationHolder.SortedActiveDestinations.Find("Editor"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ClickActions.OPEN_SETTINGS:
|
case ClickActions.OPEN_SETTINGS:
|
||||||
|
@ -453,7 +463,7 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
if (File.Exists(openFileDialog.FileName))
|
if (File.Exists(openFileDialog.FileName))
|
||||||
{
|
{
|
||||||
CaptureHelper.CaptureFile(openFileDialog.FileName);
|
CaptureHelper.CaptureFile(_captureSupportInfo, openFileDialog.FileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -461,7 +471,7 @@ namespace Greenshot.Forms
|
||||||
{
|
{
|
||||||
if (_coreConfiguration.IECapture)
|
if (_coreConfiguration.IECapture)
|
||||||
{
|
{
|
||||||
CaptureHelper.CaptureIe(true, null);
|
CaptureHelper.CaptureIe(_captureSupportInfo, true, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +490,7 @@ namespace Greenshot.Forms
|
||||||
// IE context menu code
|
// IE context menu code
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_coreConfiguration.IECapture && IeCaptureHelper.IsIeRunning())
|
if (_coreConfiguration.IECapture && _internetExplorerCaptureHelper.IsIeRunning())
|
||||||
{
|
{
|
||||||
contextmenu_captureie.Enabled = true;
|
contextmenu_captureie.Enabled = true;
|
||||||
contextmenu_captureiefromlist.Enabled = true;
|
contextmenu_captureiefromlist.Enabled = true;
|
||||||
|
@ -537,7 +547,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var tabs = IeCaptureHelper.GetBrowserTabs();
|
var tabs = _internetExplorerCaptureHelper.GetBrowserTabs();
|
||||||
contextmenu_captureiefromlist.DropDownItems.Clear();
|
contextmenu_captureiefromlist.DropDownItems.Clear();
|
||||||
if (tabs.Count > 0)
|
if (tabs.Count > 0)
|
||||||
{
|
{
|
||||||
|
@ -600,7 +610,7 @@ namespace Greenshot.Forms
|
||||||
var allScreensBounds = DisplayInfo.ScreenBounds;
|
var allScreensBounds = DisplayInfo.ScreenBounds;
|
||||||
|
|
||||||
var captureScreenItem = new ToolStripMenuItem(_greenshotLanguage.ContextmenuCapturefullscreenAll);
|
var captureScreenItem = new ToolStripMenuItem(_greenshotLanguage.ContextmenuCapturefullscreenAll);
|
||||||
captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen)));
|
captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureFullscreen(_captureSupportInfo, false, ScreenCaptureMode.FullScreen)));
|
||||||
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
||||||
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
|
||||||
{
|
{
|
||||||
|
@ -623,7 +633,7 @@ namespace Greenshot.Forms
|
||||||
deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenRight;
|
deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenRight;
|
||||||
}
|
}
|
||||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||||
captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureRegion(false, screenToCapture.Bounds)));
|
captureScreenItem.Click += (o, args) => BeginInvoke((MethodInvoker) (() => CaptureHelper.CaptureRegion(_captureSupportInfo, false, screenToCapture.Bounds)));
|
||||||
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
captureScreenMenuItem.DropDownItems.Add(captureScreenItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -666,7 +676,7 @@ namespace Greenshot.Forms
|
||||||
var window = captureWindowItem.Tag as IInteropWindow;
|
var window = captureWindowItem.Tag as IInteropWindow;
|
||||||
if (_thumbnailForm == null)
|
if (_thumbnailForm == null)
|
||||||
{
|
{
|
||||||
_thumbnailForm = new ThumbnailForm();
|
_thumbnailForm = new ThumbnailForm(_coreConfiguration);
|
||||||
}
|
}
|
||||||
_thumbnailForm.ShowThumbnail(window, captureWindowItem.GetCurrentParent().TopLevelControl);
|
_thumbnailForm.ShowThumbnail(window, captureWindowItem.GetCurrentParent().TopLevelControl);
|
||||||
}
|
}
|
||||||
|
@ -718,12 +728,12 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e)
|
private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureRegion(false); });
|
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureRegion(_captureSupportInfo, false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e)
|
private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke(new System.Action(() => CaptureHelper.CaptureClipboard()));
|
BeginInvoke(new System.Action(() => CaptureHelper.CaptureClipboard(_captureSupportInfo)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OpenFileToolStripMenuItemClick(object sender, EventArgs e)
|
private void OpenFileToolStripMenuItemClick(object sender, EventArgs e)
|
||||||
|
@ -733,17 +743,17 @@ namespace Greenshot.Forms
|
||||||
|
|
||||||
private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e)
|
private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureFullscreen(false, _coreConfiguration.ScreenCaptureMode); });
|
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureFullscreen(_captureSupportInfo, false, _coreConfiguration.ScreenCaptureMode); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Contextmenu_capturelastregionClick(object sender, EventArgs e)
|
private void Contextmenu_capturelastregionClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureLastRegion(false); });
|
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureLastRegion(_captureSupportInfo, false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Contextmenu_capturewindow_Click(object sender, EventArgs e)
|
private void Contextmenu_capturewindow_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureWindowInteractive(false); });
|
BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureWindowInteractive(_captureSupportInfo, false); });
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Contextmenu_capturewindowfromlist_Click(object sender, EventArgs e)
|
private void Contextmenu_capturewindowfromlist_Click(object sender, EventArgs e)
|
||||||
|
@ -754,7 +764,7 @@ namespace Greenshot.Forms
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var windowToCapture = (InteropWindow) clickedItem.Tag;
|
var windowToCapture = (InteropWindow) clickedItem.Tag;
|
||||||
CaptureHelper.CaptureWindow(windowToCapture);
|
CaptureHelper.CaptureWindow(_captureSupportInfo, windowToCapture);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -786,7 +796,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IeCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
|
_internetExplorerCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -794,7 +804,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CaptureHelper.CaptureIe(false, ieWindowToCapture);
|
CaptureHelper.CaptureIe(_captureSupportInfo, false, ieWindowToCapture);
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
|
@ -912,7 +922,7 @@ namespace Greenshot.Forms
|
||||||
if (!_coreConfiguration.IsWriteProtected("Destinations"))
|
if (!_coreConfiguration.IsWriteProtected("Destinations"))
|
||||||
{
|
{
|
||||||
// screenshot destination
|
// screenshot destination
|
||||||
selectList = new ToolStripMenuSelectList("destinations", true)
|
selectList = new ToolStripMenuSelectList(_coreConfiguration, "destinations", true)
|
||||||
{
|
{
|
||||||
Text = _greenshotLanguage.SettingsDestination
|
Text = _greenshotLanguage.SettingsDestination
|
||||||
};
|
};
|
||||||
|
@ -929,7 +939,7 @@ namespace Greenshot.Forms
|
||||||
if (!_coreConfiguration.IsWriteProtected("WindowCaptureMode"))
|
if (!_coreConfiguration.IsWriteProtected("WindowCaptureMode"))
|
||||||
{
|
{
|
||||||
// Capture Modes
|
// Capture Modes
|
||||||
selectList = new ToolStripMenuSelectList("capturemodes", false)
|
selectList = new ToolStripMenuSelectList(_coreConfiguration,"capturemodes", false)
|
||||||
{
|
{
|
||||||
Text = _greenshotLanguage.SettingsWindowCaptureMode
|
Text = _greenshotLanguage.SettingsWindowCaptureMode
|
||||||
};
|
};
|
||||||
|
@ -951,7 +961,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
|
|
||||||
// print options
|
// print options
|
||||||
selectList = new ToolStripMenuSelectList("printoptions", true)
|
selectList = new ToolStripMenuSelectList(_coreConfiguration, "printoptions", true)
|
||||||
{
|
{
|
||||||
Text = _greenshotLanguage.SettingsPrintoptions
|
Text = _greenshotLanguage.SettingsPrintoptions
|
||||||
};
|
};
|
||||||
|
@ -979,7 +989,7 @@ namespace Greenshot.Forms
|
||||||
}
|
}
|
||||||
|
|
||||||
// effects
|
// effects
|
||||||
selectList = new ToolStripMenuSelectList("effects", true)
|
selectList = new ToolStripMenuSelectList(_coreConfiguration, "effects", true)
|
||||||
{
|
{
|
||||||
Text = _greenshotLanguage.SettingsVisualization
|
Text = _greenshotLanguage.SettingsVisualization
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,30 +41,28 @@ namespace Greenshot.Forms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed class ToolStripMenuSelectList : ToolStripMenuItem
|
public sealed class ToolStripMenuSelectList : ToolStripMenuItem
|
||||||
{
|
{
|
||||||
// TODO: Solve, was static reference!
|
|
||||||
private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
|
|
||||||
private static Image _defaultImage;
|
private static Image _defaultImage;
|
||||||
private readonly bool _multiCheckAllowed;
|
private readonly bool _multiCheckAllowed;
|
||||||
private bool _updateInProgress;
|
private bool _updateInProgress;
|
||||||
|
|
||||||
public ToolStripMenuSelectList(object identifier, bool allowMultiCheck)
|
public ToolStripMenuSelectList(ICoreConfiguration coreConfig, object identifier, bool allowMultiCheck)
|
||||||
{
|
{
|
||||||
Identifier = identifier;
|
Identifier = identifier;
|
||||||
CheckOnClick = false;
|
CheckOnClick = false;
|
||||||
_multiCheckAllowed = allowMultiCheck;
|
_multiCheckAllowed = allowMultiCheck;
|
||||||
if (_defaultImage == null || _defaultImage.Size != CoreConfig.IconSize)
|
if (_defaultImage == null || _defaultImage.Size != coreConfig.IconSize)
|
||||||
{
|
{
|
||||||
_defaultImage?.Dispose();
|
_defaultImage?.Dispose();
|
||||||
_defaultImage = BitmapFactory.CreateEmpty(CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, PixelFormat.Format32bppArgb, Color.Transparent);
|
_defaultImage = BitmapFactory.CreateEmpty(coreConfig.IconSize.Width, coreConfig.IconSize.Height, PixelFormat.Format32bppArgb, Color.Transparent);
|
||||||
}
|
}
|
||||||
Image = _defaultImage;
|
Image = _defaultImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolStripMenuSelectList() : this(null, false)
|
public ToolStripMenuSelectList(ICoreConfiguration coreConfig) : this(coreConfig, null, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public ToolStripMenuSelectList(object identifier) : this(identifier, false)
|
public ToolStripMenuSelectList(ICoreConfiguration coreConfig, object identifier) : this(coreConfig, identifier, false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
<ApplicationManifest>greenshot.manifest</ApplicationManifest>
|
<ApplicationManifest>greenshot.manifest</ApplicationManifest>
|
||||||
<AssemblyTitle>Greenshot</AssemblyTitle>
|
<AssemblyTitle>Greenshot</AssemblyTitle>
|
||||||
<AssemblyName>Greenshot</AssemblyName>
|
<AssemblyName>Greenshot</AssemblyName>
|
||||||
|
<!--RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
|
<SelfContained>true</SelfContained-->
|
||||||
|
<Platforms>AnyCPU;x86</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -91,7 +94,7 @@
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.3" />
|
||||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.3" />
|
||||||
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.3" />
|
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.3" />
|
||||||
<PackageReference Include="Fody" Version="3.3.3">
|
<PackageReference Include="Fody" Version="3.3.5">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|
|
@ -32,11 +32,14 @@ using Dapplo.CaliburnMicro.Security;
|
||||||
using Dapplo.Config.Ini;
|
using Dapplo.Config.Ini;
|
||||||
using Dapplo.Config.Language;
|
using Dapplo.Config.Language;
|
||||||
using Greenshot.Addons.Components;
|
using Greenshot.Addons.Components;
|
||||||
|
using Greenshot.Addons.Interfaces;
|
||||||
using Greenshot.Components;
|
using Greenshot.Components;
|
||||||
using Greenshot.Configuration;
|
using Greenshot.Configuration;
|
||||||
using Greenshot.Configuration.Impl;
|
using Greenshot.Configuration.Impl;
|
||||||
using Greenshot.Forms;
|
using Greenshot.Forms;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
|
using Greenshot.Helpers.Mapi;
|
||||||
|
using Greenshot.Processors;
|
||||||
using Greenshot.Ui.Configuration.ViewModels;
|
using Greenshot.Ui.Configuration.ViewModels;
|
||||||
using Greenshot.Ui.Misc.ViewModels;
|
using Greenshot.Ui.Misc.ViewModels;
|
||||||
using Greenshot.Ui.Notifications.ViewModels;
|
using Greenshot.Ui.Notifications.ViewModels;
|
||||||
|
@ -70,6 +73,16 @@ namespace Greenshot
|
||||||
.As<IIniSection>()
|
.As<IIniSection>()
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
|
|
||||||
|
builder
|
||||||
|
.RegisterType<CaptureSupportInfo>()
|
||||||
|
.AsSelf()
|
||||||
|
.SingleInstance()
|
||||||
|
.OnActivated(args =>
|
||||||
|
{
|
||||||
|
// Workaround for static access in different helper classes and extensions
|
||||||
|
MapiMailMessage.CoreConfiguration = args.Instance.CoreConfiguration;
|
||||||
|
});
|
||||||
|
|
||||||
builder
|
builder
|
||||||
.RegisterType<ConfigTranslationsImpl>()
|
.RegisterType<ConfigTranslationsImpl>()
|
||||||
.As<IConfigTranslations>()
|
.As<IConfigTranslations>()
|
||||||
|
@ -134,6 +147,12 @@ namespace Greenshot
|
||||||
.AsSelf()
|
.AsSelf()
|
||||||
.SingleInstance();
|
.SingleInstance();
|
||||||
|
|
||||||
|
// Processors
|
||||||
|
builder
|
||||||
|
.RegisterType<TitleFixProcessor>()
|
||||||
|
.As<IProcessor>()
|
||||||
|
.SingleInstance();
|
||||||
|
|
||||||
// Destinations
|
// Destinations
|
||||||
builder
|
builder
|
||||||
.RegisterAssemblyTypes(ThisAssembly)
|
.RegisterAssemblyTypes(ThisAssembly)
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue