diff --git a/NuGet.Config b/NuGet.Config
index 8d3dbb9f2..ec28e4393 100644
--- a/NuGet.Config
+++ b/NuGet.Config
@@ -9,5 +9,6 @@
+
\ No newline at end of file
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 5fef17f58..8997b4ba6 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -15,7 +15,7 @@ steps:
- task: DotNetCoreInstaller@0
displayName: 'Use .NET Core sdk 3.0'
inputs:
- version: '3.0.100-preview-009825'
+ version: '3.0.100-preview-009812'
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.9.2'
diff --git a/src/Directory.Build.props b/src/Directory.Build.props
index 439362dbc..112f96987 100644
--- a/src/Directory.Build.props
+++ b/src/Directory.Build.props
@@ -17,6 +17,7 @@
true
false
$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@ProductName)
+ win10-x64;win10-x86;win-x64;win-x86
@@ -45,8 +46,8 @@
True
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj
index 0be249c8e..1b70fe12e 100644
--- a/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj
+++ b/src/Greenshot.Addon.Box/Greenshot.Addon.Box.csproj
@@ -50,7 +50,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs b/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs
index a3bbc75ae..4ba520885 100644
--- a/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs
+++ b/src/Greenshot.Addon.Confluence/ConfluenceDestination.cs
@@ -187,7 +187,7 @@ namespace Greenshot.Addon.Confluence
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;
try
{
diff --git a/src/Greenshot.Addon.Confluence/ConfluenceUtils.cs b/src/Greenshot.Addon.Confluence/ConfluenceUtils.cs
index d391b64f6..ecfbb84f7 100644
--- a/src/Greenshot.Addon.Confluence/ConfluenceUtils.cs
+++ b/src/Greenshot.Addon.Confluence/ConfluenceUtils.cs
@@ -50,7 +50,7 @@ namespace Greenshot.Addon.Confluence
var pages = new List();
var pageIdRegex = new Regex(@"pageId=(\d+)");
var spacePageRegex = new Regex(@"\/display\/([^\/]+)\/([^#]+)");
- foreach (var browserurl in IEHelper.GetIEUrls().Distinct())
+ foreach (var browserurl in InternetExplorerHelper.GetIEUrls().Distinct())
{
string url;
try
diff --git a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj
index 6b238ab83..2f918bc42 100644
--- a/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj
+++ b/src/Greenshot.Addon.Confluence/Greenshot.Addon.Confluence.csproj
@@ -57,7 +57,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj
index d0a379fbc..709463db2 100644
--- a/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj
+++ b/src/Greenshot.Addon.Dropbox/Greenshot.Addon.Dropbox.csproj
@@ -52,7 +52,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
index e65b37a41..e782bdad0 100644
--- a/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
+++ b/src/Greenshot.Addon.ExternalCommand/Greenshot.Addon.ExternalCommand.csproj
@@ -41,8 +41,8 @@
-
-
+
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj
index c7df32b05..39310dd89 100644
--- a/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj
+++ b/src/Greenshot.Addon.Flickr/Greenshot.Addon.Flickr.csproj
@@ -50,7 +50,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj
index 9d4879965..112c2a3cf 100644
--- a/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj
+++ b/src/Greenshot.Addon.GooglePhotos/Greenshot.Addon.GooglePhotos.csproj
@@ -50,7 +50,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj
index 20cfc9298..83082750a 100644
--- a/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj
+++ b/src/Greenshot.Addon.Imgur/Greenshot.Addon.Imgur.csproj
@@ -51,7 +51,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.InternetExplorer/InternetExplorerAddonModule.cs b/src/Greenshot.Addon.InternetExplorer/InternetExplorerAddonModule.cs
new file mode 100644
index 000000000..adbd45b16
--- /dev/null
+++ b/src/Greenshot.Addon.InternetExplorer/InternetExplorerAddonModule.cs
@@ -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 .
+
+#endregion
+
+using Autofac;
+using Dapplo.Addons;
+
+namespace Greenshot.Addon.InternetExplorer
+{
+ ///
+ public class InternetExplorerAddonModulenModule : AddonModule
+ {
+ protected override void Load(ContainerBuilder builder)
+ {
+ builder
+ .RegisterType()
+ .AsSelf()
+ .SingleInstance();
+ base.Load(builder);
+ }
+ }
+}
diff --git a/src/Greenshot.Addon.InternetExplorer/IECaptureHelper.cs b/src/Greenshot.Addon.InternetExplorer/InternetExplorerCaptureHelper.cs
similarity index 91%
rename from src/Greenshot.Addon.InternetExplorer/IECaptureHelper.cs
rename to src/Greenshot.Addon.InternetExplorer/InternetExplorerCaptureHelper.cs
index 14e210269..47d9dc976 100644
--- a/src/Greenshot.Addon.InternetExplorer/IECaptureHelper.cs
+++ b/src/Greenshot.Addon.InternetExplorer/InternetExplorerCaptureHelper.cs
@@ -36,7 +36,7 @@ using Dapplo.Windows.Common.Structs;
using Dapplo.Windows.Desktop;
using Dapplo.Windows.Messages;
using Dapplo.Windows.User32;
-using Greenshot.Addon.InternetExplorer.IEInterop;
+using Greenshot.Addon.InternetExplorer.InternetExplorerInterop;
using Greenshot.Addons.Config.Impl;
using Greenshot.Addons.Controls;
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.
/// Many thanks to all the people who contributed here!
///
- public static class IeCaptureHelper
+ public class InternetExplorerCaptureHelper
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+ private readonly ICoreConfiguration _coreConfiguration;
+
+ public InternetExplorerCaptureHelper(ICoreConfiguration coreConfiguration)
+ {
+ _coreConfiguration = coreConfiguration;
+ }
///
/// Helper method to activate a certain IE Tab
///
/// IInteropWindow
/// int
- 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)
{
return;
@@ -87,7 +91,7 @@ namespace Greenshot.Addon.InternetExplorer
/// InteropWindow to check
/// min percentage
///
- 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");
if (ieWindow == null)
@@ -106,13 +110,13 @@ namespace Greenshot.Addon.InternetExplorer
///
///
///
- public static bool IsIeWindow(IInteropWindow someWindow)
+ public bool IsIeWindow(IInteropWindow someWindow)
{
if ("IEFrame".Equals(someWindow.GetClassname()))
{
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");
}
@@ -123,7 +127,7 @@ namespace Greenshot.Addon.InternetExplorer
/// Get Windows displaying an IE
///
/// IEnumerable IInteropWindow
- public static IEnumerable GetIeWindows()
+ public IEnumerable GetIeWindows()
{
return WindowsEnumerator.EnumerateWindows().Where(IsIeWindow);
}
@@ -132,7 +136,7 @@ namespace Greenshot.Addon.InternetExplorer
/// Simple check if IE is running
///
/// bool
- public static bool IsIeRunning()
+ public bool IsIeRunning()
{
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
///
/// List with KeyValuePair of InteropWindow and string
- public static IList> GetBrowserTabs()
+ public IList> GetBrowserTabs()
{
var ieHandleList = new List();
var browserWindows = new Dictionary>();
@@ -157,14 +161,14 @@ namespace Greenshot.Addon.InternetExplorer
}
if ("IEFrame".Equals(ieWindow.GetClassname()))
{
- var directUiwd = IEHelper.GetDirectUi(ieWindow);
+ var directUiwd = InternetExplorerHelper.GetDirectUi(ieWindow);
if (directUiwd != null)
{
var accessible = new Accessible(directUiwd.Handle);
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();
try
@@ -211,7 +215,7 @@ namespace Greenshot.Addon.InternetExplorer
///
///
///
- private static IHTMLDocument2 GetHtmlDocument(IInteropWindow mainWindow)
+ private IHTMLDocument2 GetHtmlDocument(IInteropWindow mainWindow)
{
var ieServer = "Internet Explorer_Server".Equals(mainWindow.GetClassname())
? mainWindow
@@ -250,7 +254,7 @@ namespace Greenshot.Addon.InternetExplorer
///
/// The InteropWindow to get the IHTMLDocument2 for
/// DocumentContainer
- private static DocumentContainer CreateDocumentContainer(IInteropWindow browserWindow)
+ private DocumentContainer CreateDocumentContainer(IInteropWindow browserWindow)
{
DocumentContainer returnDocumentContainer = null;
InteropWindow returnWindow = null;
@@ -265,7 +269,7 @@ namespace Greenshot.Addon.InternetExplorer
Log.Debug().WriteLine("Processing {0} - {1}", ieWindow.Classname, ieWindow.Text);
Accessible ieAccessible = null;
- var directUiwd = IEHelper.GetDirectUi(ieWindow);
+ var directUiwd = InternetExplorerHelper.GetDirectUi(ieWindow);
if (directUiwd != null)
{
ieAccessible = new Accessible(directUiwd.Handle);
@@ -390,7 +394,7 @@ namespace Greenshot.Addon.InternetExplorer
/// ICapture where the capture needs to be stored
/// window to use
/// ICapture with the content (if any)
- public static ICapture CaptureIe(ICapture capture, IInteropWindow windowToCapture = null)
+ public ICapture CaptureIe(ICapture capture, IInteropWindow windowToCapture = null)
{
if (windowToCapture == null)
{
@@ -542,7 +546,7 @@ namespace Greenshot.Addon.InternetExplorer
///
///
/// Size of the complete page
- private static Size PrepareCapture(DocumentContainer documentContainer, ICapture capture)
+ private Size PrepareCapture(DocumentContainer documentContainer, ICapture capture)
{
// Calculate the page size
var pageWidth = documentContainer.ScrollWidth;
@@ -645,7 +649,7 @@ namespace Greenshot.Addon.InternetExplorer
/// The document wrapped in a container
///
/// Bitmap with the page content as an image
- private static Bitmap CapturePage(DocumentContainer documentContainer, Size pageSize)
+ private Bitmap CapturePage(DocumentContainer documentContainer, Size pageSize)
{
var contentWindowDetails = documentContainer.ContentWindow;
@@ -685,7 +689,7 @@ namespace Greenshot.Addon.InternetExplorer
/// Needed for referencing the location of the frame
/// Graphics
/// Bitmap with the capture
- private static void DrawDocument(DocumentContainer documentContainer, IInteropWindow contentWindowDetails, Graphics graphicsTarget)
+ private void DrawDocument(DocumentContainer documentContainer, IInteropWindow contentWindowDetails, Graphics graphicsTarget)
{
documentContainer.SetAttribute("scroll", 1);
diff --git a/src/Greenshot.Addon.InternetExplorer/IEHelper.cs b/src/Greenshot.Addon.InternetExplorer/InternetExplorerHelper.cs
similarity index 93%
rename from src/Greenshot.Addon.InternetExplorer/IEHelper.cs
rename to src/Greenshot.Addon.InternetExplorer/InternetExplorerHelper.cs
index 88a1a9648..0616c72d6 100644
--- a/src/Greenshot.Addon.InternetExplorer/IEHelper.cs
+++ b/src/Greenshot.Addon.InternetExplorer/InternetExplorerHelper.cs
@@ -27,10 +27,10 @@ using Dapplo.Windows.Desktop;
using Microsoft.Win32;
namespace Greenshot.Addon.InternetExplorer {
- ///
- /// Description of IEHelper.
- ///
- public static class IEHelper {
+ ///
+ /// Util code for Internet Explorer
+ ///
+ public class InternetExplorerHelper {
private static readonly LogSource Log = new LogSource();
// Internet explorer Registry key
diff --git a/src/Greenshot.Addon.InternetExplorer/IEInterop/IEContainer.cs b/src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/DocumentContainer.cs
similarity index 96%
rename from src/Greenshot.Addon.InternetExplorer/IEInterop/IEContainer.cs
rename to src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/DocumentContainer.cs
index 6c0beb688..667bb8c72 100644
--- a/src/Greenshot.Addon.InternetExplorer/IEInterop/IEContainer.cs
+++ b/src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/DocumentContainer.cs
@@ -37,7 +37,7 @@ using IServiceProvider = Greenshot.Addons.Interop.IServiceProvider;
#endregion
-namespace Greenshot.Addon.InternetExplorer.IEInterop
+namespace Greenshot.Addon.InternetExplorer.InternetExplorerInterop
{
public class DocumentContainer
{
diff --git a/src/Greenshot.Addon.InternetExplorer/IEInterop/IWebBrowser2.cs b/src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/IWebBrowser2.cs
similarity index 94%
rename from src/Greenshot.Addon.InternetExplorer/IEInterop/IWebBrowser2.cs
rename to src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/IWebBrowser2.cs
index 1f3e8f65d..006550574 100644
--- a/src/Greenshot.Addon.InternetExplorer/IEInterop/IWebBrowser2.cs
+++ b/src/Greenshot.Addon.InternetExplorer/InternetExplorerInterop/IWebBrowser2.cs
@@ -27,7 +27,7 @@ using System.Runtime.InteropServices;
#endregion
-namespace Greenshot.Addon.InternetExplorer.IEInterop
+namespace Greenshot.Addon.InternetExplorer.InternetExplorerInterop
{
// IWebBrowser: EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
diff --git a/src/Greenshot.Addon.Jira/FodyWeavers.xsd b/src/Greenshot.Addon.Jira/FodyWeavers.xsd
index 197a7d95d..6e1ac6983 100644
--- a/src/Greenshot.Addon.Jira/FodyWeavers.xsd
+++ b/src/Greenshot.Addon.Jira/FodyWeavers.xsd
@@ -4,92 +4,6 @@
-
-
-
-
-
- A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
-
-
-
-
- A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
-
-
-
-
- A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
-
-
-
-
- A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
-
-
-
-
- The order of preloaded assemblies, delimited with line breaks.
-
-
-
-
-
- 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.
-
-
-
-
- Controls if .pdbs for reference assemblies are also embedded.
-
-
-
-
- Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
-
-
-
-
- As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
-
-
-
-
- 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.
-
-
-
-
- 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.
-
-
-
-
- A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
-
-
-
-
- A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
-
-
-
-
- A list of unmanaged 32 bit assembly names to include, delimited with |.
-
-
-
-
- A list of unmanaged 64 bit assembly names to include, delimited with |.
-
-
-
-
- The order of preloaded assemblies, delimited with |.
-
-
-
-
diff --git a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj
index a8d3a7394..9f83e1477 100644
--- a/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj
+++ b/src/Greenshot.Addon.Jira/Greenshot.Addon.Jira.csproj
@@ -55,7 +55,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/ArrowContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/ArrowContainer.cs
index 90904118a..65ede67dc 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/ArrowContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/ArrowContainer.cs
@@ -51,7 +51,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
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)
{
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/BitmapContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/BitmapContainer.cs
index 12d62724b..15ba4db10 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/BitmapContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/BitmapContainer.cs
@@ -61,12 +61,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
private Bitmap _bitmap;
- public BitmapContainer(Surface parent, string filename) : this(parent)
+ public BitmapContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : this(parent, editorConfiguration)
{
Load(filename);
}
- public BitmapContainer(Surface parent) : base(parent)
+ public BitmapContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
FieldChanged += BitmapContainer_OnFieldChanged;
Init();
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/CropContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/CropContainer.cs
index 0ff4449c2..891878567 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/CropContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/CropContainer.cs
@@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
public class CropContainer : DrawableContainer
{
- public CropContainer(Surface parent) : base(parent)
+ public CropContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/CursorContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/CursorContainer.cs
index df18480e6..db892e64f 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/CursorContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/CursorContainer.cs
@@ -46,12 +46,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
protected Cursor cursor;
- public CursorContainer(Surface parent) : base(parent)
+ public CursorContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
- public CursorContainer(Surface parent, string filename) : this(parent)
+ public CursorContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : this(parent, editorConfiguration)
{
Load(filename);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs
index 86e64c120..b91bedcc0 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/DrawableContainer.cs
@@ -59,8 +59,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
private const int M11 = 0;
private const int M22 = 3;
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- protected static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
///
/// List of available Adorners
@@ -98,7 +96,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
private int width;
- public DrawableContainer(Surface parent)
+ public DrawableContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
{
InitializeFields();
_parent = parent;
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/EllipseContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/EllipseContainer.cs
index e3c2d3671..337c72ffe 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/EllipseContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/EllipseContainer.cs
@@ -41,8 +41,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
[Serializable]
public class EllipseContainer : DrawableContainer
{
- public EllipseContainer(Surface parent) : base(parent)
- {
+ public EllipseContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
+ {
CreateDefaultAdorners();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolder.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolder.cs
index 0e44a9437..2204e4a61 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolder.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolder.cs
@@ -37,8 +37,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
public abstract class AbstractFieldHolder : IFieldHolder
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
[NonSerialized]
private readonly IDictionary _handlers = new Dictionary();
@@ -61,7 +59,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
private IDictionary _fieldsByType = new Dictionary();
private readonly IList fields = new List();
- [OnDeserialized]
+ [NonSerialized]
+ protected readonly IEditorConfiguration _editorConfiguration;
+
+ [OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
_fieldsByType = new Dictionary();
@@ -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)
{
- AddField(EditorConfig.CreateField(requestingType, fieldType, fieldValue));
+ AddField(_editorConfiguration.CreateField(requestingType, fieldType, fieldValue));
}
public virtual void AddField(IField field)
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolderWithChildren.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolderWithChildren.cs
index 2a3513652..93fca750a 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolderWithChildren.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/AbstractFieldHolderWithChildren.cs
@@ -46,7 +46,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
[NonSerialized] private EventHandler childrenChanged;
- public AbstractFieldHolderWithChildren()
+ public AbstractFieldHolderWithChildren(IEditorConfiguration editorConfiguration) : base(editorConfiguration)
{
_fieldChangedEventHandler = OnFieldChanged;
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs
index 7e4773948..e11bcbb5c 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs
@@ -49,13 +49,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
[Serializable]
public sealed class FieldAggregator : AbstractFieldHolder
{
- // TODO: Solve, was static reference!
- private static readonly IEditorConfiguration EditorConfig = new EditorConfigurationImpl();
-
private readonly IDrawableContainerList _boundContainers;
private bool _internalUpdateRunning;
- public FieldAggregator(ISurface parent)
+ public FieldAggregator(ISurface parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
{
foreach (var fieldType in FieldTypes.Values)
{
@@ -225,7 +222,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields
drawableContainerField.Value = field.Value;
// update last used from DC field, so that scope is honored
- EditorConfig.UpdateLastFieldValue(drawableContainerField);
+ _editorConfiguration.UpdateLastFieldValue(drawableContainerField);
}
}
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/FilterContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/FilterContainer.cs
index cefdc51a0..d6f7e1037 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/FilterContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/FilterContainer.cs
@@ -58,7 +58,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
HIGHLIGHT
}
- public FilterContainer(Surface parent) : base(parent)
+ public FilterContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/AbstractFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/AbstractFilter.cs
index b2ae8feed..51fb9ba4b 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/AbstractFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/AbstractFilter.cs
@@ -48,7 +48,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[NonSerialized] private PropertyChangedEventHandler propertyChanged;
- public AbstractFilter(DrawableContainer parent)
+ public AbstractFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration)
{
this.parent = parent;
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BlurFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BlurFilter.cs
index 966716f33..23c186940 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BlurFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BlurFilter.cs
@@ -40,7 +40,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
{
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.PREVIEW_QUALITY, 1.0d);
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BrightnessFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BrightnessFilter.cs
index 9c82ef2f7..85bfd8787 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BrightnessFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/BrightnessFilter.cs
@@ -38,7 +38,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[Serializable]
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);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/GrayscaleFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/GrayscaleFilter.cs
index 15ba9c189..084723cc0 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/GrayscaleFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/GrayscaleFilter.cs
@@ -40,7 +40,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[Serializable]
public class GrayscaleFilter : AbstractFilter
{
- public GrayscaleFilter(DrawableContainer parent) : base(parent)
+ public GrayscaleFilter(DrawableContainer parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/HighlightFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/HighlightFilter.cs
index bc545895b..a7f9ee247 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/HighlightFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/HighlightFilter.cs
@@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[Serializable]
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);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/MagnifierFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/MagnifierFilter.cs
index 8453a8512..7817c3e2f 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/MagnifierFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/MagnifierFilter.cs
@@ -38,7 +38,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[Serializable]
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);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/PixelizationFilter.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/PixelizationFilter.cs
index d230c7184..385ab0e20 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/PixelizationFilter.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Filters/PixelizationFilter.cs
@@ -43,7 +43,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Filters
[Serializable]
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);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/FreehandContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/FreehandContainer.cs
index e102a32a5..d084a8eba 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/FreehandContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/FreehandContainer.cs
@@ -44,18 +44,19 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
private NativeRect myBounds = NativeRect.Empty;
private NativePoint lastMouse = NativePoint.Empty;
private readonly List capturePoints = new List();
- [NonSerialized] private GraphicsPath freehandPath = new GraphicsPath();
+ [NonSerialized]
+ private GraphicsPath freehandPath = new GraphicsPath();
private bool isRecalculated;
///
/// Constructor
///
- public FreehandContainer(Surface parent) : base(parent) {
+ public FreehandContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration) {
Width = parent.Width;
Height = parent.Height;
Top = 0;
Left = 0;
- }
+ }
protected override void InitializeFields() {
AddField(GetType(), FieldTypes.LINE_THICKNESS, 3);
@@ -105,10 +106,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
public override bool HandleMouseMove(int mouseX, int mouseY) {
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));
}
- if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) < EditorConfig.FreehandSensitivity)
+ if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) < _editorConfiguration.FreehandSensitivity)
{
return true;
}
@@ -131,7 +132,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
///
public override void HandleMouseUp(int mouseX, int mouseY) {
// 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));
}
RecalculatePath();
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/HighlightContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/HighlightContainer.cs
index 9d0d5d1aa..4b2aea6d0 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/HighlightContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/HighlightContainer.cs
@@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
[Serializable]
public class HighlightContainer : FilterContainer
{
- public HighlightContainer(Surface parent) : base(parent)
+ public HighlightContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
@@ -86,29 +86,29 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
switch (preset)
{
case PreparedFilter.TEXT_HIGHTLIGHT:
- Add(new HighlightFilter(this));
+ Add(new HighlightFilter(this, _editorConfiguration));
break;
case PreparedFilter.AREA_HIGHLIGHT:
- var brightnessFilter = new BrightnessFilter(this)
+ var brightnessFilter = new BrightnessFilter(this, _editorConfiguration)
{
Invert = true
};
Add(brightnessFilter);
- var blurFilter = new BlurFilter(this)
+ var blurFilter = new BlurFilter(this, _editorConfiguration)
{
Invert = true
};
Add(blurFilter);
break;
case PreparedFilter.GRAYSCALE:
- AbstractFilter f = new GrayscaleFilter(this)
+ AbstractFilter f = new GrayscaleFilter(this, _editorConfiguration)
{
Invert = true
};
Add(f);
break;
case PreparedFilter.MAGNIFICATION:
- Add(new MagnifierFilter(this));
+ Add(new MagnifierFilter(this, _editorConfiguration));
break;
}
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/IconContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/IconContainer.cs
index 58528e93d..5c56f417c 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/IconContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/IconContainer.cs
@@ -45,12 +45,12 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
protected Icon icon;
- public IconContainer(Surface parent) : base(parent)
+ public IconContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
- public IconContainer(Surface parent, string filename) : base(parent)
+ public IconContainer(Surface parent, string filename, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Load(filename);
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs
index a2599496a..9a1ddf9c6 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/LineContainer.cs
@@ -44,7 +44,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
{
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();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/ObfuscateContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/ObfuscateContainer.cs
index 48c5b19e8..9d1f7e4e4 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/ObfuscateContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/ObfuscateContainer.cs
@@ -39,7 +39,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
[Serializable]
public class ObfuscateContainer : FilterContainer
{
- public ObfuscateContainer(Surface parent) : base(parent)
+ public ObfuscateContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
Init();
}
@@ -83,10 +83,10 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
switch (preset)
{
case PreparedFilter.BLUR:
- Add(new BlurFilter(this));
+ Add(new BlurFilter(this, _editorConfiguration));
break;
case PreparedFilter.PIXELIZE:
- Add(new PixelizationFilter(this));
+ Add(new PixelizationFilter(this, _editorConfiguration));
break;
}
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/RectangleContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/RectangleContainer.cs
index ef54e388d..ae35cc46b 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/RectangleContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/RectangleContainer.cs
@@ -35,7 +35,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing {
[Serializable]
public class RectangleContainer : DrawableContainer {
- public RectangleContainer(Surface parent) : base(parent) {
+ public RectangleContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration) {
Init();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/SpeechbubbleContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/SpeechbubbleContainer.cs
index 3064769ba..e924b2b7c 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/SpeechbubbleContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/SpeechbubbleContainer.cs
@@ -46,8 +46,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
{
private NativePoint _initialGripperPoint;
- public SpeechbubbleContainer(Surface parent)
- : base(parent)
+ public SpeechbubbleContainer(Surface parent, IEditorConfiguration editorConfiguration)
+ : base(parent, editorConfiguration)
{
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/StepLabelContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/StepLabelContainer.cs
index b2ef862f9..c2d3234e1 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/StepLabelContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/StepLabelContainer.cs
@@ -50,7 +50,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
private float fontSize = 16;
- public StepLabelContainer(Surface parent) : base(parent)
+ public StepLabelContainer(Surface parent, IEditorConfiguration editorConfiguration) : base(parent, editorConfiguration)
{
parent.AddStepLabel(this);
InitContent();
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs
index 577677fdc..f317562ff 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs
@@ -57,8 +57,6 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public sealed class Surface : Control, ISurface, INotifyPropertyChanged
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration conf = new CoreConfigurationImpl();
///
/// The number of Surfaces in existance
@@ -70,7 +68,15 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
private readonly IDrawableContainerList _elements;
- [NonSerialized] private readonly Stack _redoStack = new Stack();
+
+ [NonSerialized]
+ private readonly IEditorConfiguration _editorConfiguration;
+
+ [NonSerialized]
+ private readonly ICoreConfiguration _coreConfiguration;
+
+ [NonSerialized]
+ private readonly Stack _redoStack = new Stack();
///
/// all stepLabels for the surface, needed with serialization
@@ -80,12 +86,14 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
/// Undo/Redo stacks, should not be serialized as the file would be way to big
///
- [NonSerialized] private readonly Stack _undoStack = new Stack();
+ [NonSerialized]
+ private readonly Stack _undoStack = new Stack();
///
/// all selected elements, do not serialize
///
- [NonSerialized] private readonly IDrawableContainerList selectedElements;
+ [NonSerialized]
+ private readonly IDrawableContainerList selectedElements;
///
/// 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...
/// TODO: Check if this buffer is still needed!
///
- [NonSerialized] private Bitmap _buffer;
+ [NonSerialized]
+ private Bitmap _buffer;
///
/// This value is used to start counting the step labels
@@ -104,7 +113,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
/// the cropcontainer, when cropping this is set, do not serialize
///
- [NonSerialized] private IDrawableContainer _cropContainer;
+ [NonSerialized]
+ private IDrawableContainer _cropContainer;
///
/// the cursor container, needed with serialization as we need a direct acces to it.
@@ -114,14 +124,17 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
/// the element we are drawing with, do not serialize
///
- [NonSerialized] private IDrawableContainer _drawingElement;
+ [NonSerialized]
+ private IDrawableContainer _drawingElement;
///
/// current drawing mode, do not serialize!
///
- [NonSerialized] private DrawingModes _drawingMode = DrawingModes.None;
+ [NonSerialized]
+ private DrawingModes _drawingMode = DrawingModes.None;
- [NonSerialized] private SurfaceDrawingModeEventHandler _drawingModeChanged;
+ [NonSerialized]
+ private SurfaceDrawingModeEventHandler _drawingModeChanged;
///
/// all elements on the surface, needed with serialization
@@ -136,22 +149,26 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
/// inUndoRedo makes sure we don't undo/redo while in a undo/redo action
///
- [NonSerialized] private bool _inUndoRedo;
+ [NonSerialized]
+ private bool _inUndoRedo;
///
/// Make only one surfacemove cycle undoable, see SurfaceMouseMove
///
- [NonSerialized] private bool _isSurfaceMoveMadeUndoable;
+ [NonSerialized]
+ private bool _isSurfaceMoveMadeUndoable;
///
/// the keyslocked flag helps with focus issues
///
- [NonSerialized] private bool _keysLocked;
+ [NonSerialized]
+ private bool _keysLocked;
///
/// Last save location, do not serialize!
///
- [NonSerialized] private string _lastSaveFullPath;
+ [NonSerialized]
+ private string _lastSaveFullPath;
///
/// the modified flag specifies if the surface has had modifications after the last export.
@@ -164,47 +181,56 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
///
/// are we in a mouse down, do not serialize
///
- [NonSerialized] private bool _mouseDown;
+ [NonSerialized]
+ private bool _mouseDown;
///
/// The selected element for the mouse down, do not serialize
///
- [NonSerialized] private IDrawableContainer _mouseDownElement;
+ [NonSerialized]
+ private IDrawableContainer _mouseDownElement;
///
/// Location of the mouse-down (it "starts" here), do not serialize
///
- [NonSerialized] private NativePoint _mouseStart = NativePoint.Empty;
+ [NonSerialized]
+ private NativePoint _mouseStart = NativePoint.Empty;
- [NonSerialized] private SurfaceElementEventHandler _movingElementChanged;
+ [NonSerialized]
+ private SurfaceElementEventHandler _movingElementChanged;
///
/// Event handlers (do not serialize!)
///
- [NonSerialized] private PropertyChangedEventHandler _propertyChanged;
+ [NonSerialized]
+ private PropertyChangedEventHandler _propertyChanged;
- [NonSerialized] private SurfaceMessageEventHandler _surfaceMessage;
+ [NonSerialized]
+ private SurfaceMessageEventHandler _surfaceMessage;
- [NonSerialized] private SurfaceSizeChangeEventHandler _surfaceSizeChanged;
+ [NonSerialized]
+ private SurfaceSizeChangeEventHandler _surfaceSizeChanged;
///
/// the brush which is used for transparent backgrounds, set by the editor, do not serialize
///
- [NonSerialized] private Brush _transparencyBackgroundBrush;
+ [NonSerialized]
+ private Brush _transparencyBackgroundBrush;
///
/// the element we want to draw with (not yet drawn), do not serialize
///
- [NonSerialized] private IDrawableContainer _undrawnElement;
+ [NonSerialized]
+ private IDrawableContainer _undrawnElement;
// Property to identify the Surface ID
///
/// Base Surface constructor
///
- public Surface()
+ public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration)
{
- _fieldAggregator = new FieldAggregator(this);
+ _fieldAggregator = new FieldAggregator(this, editorConfiguration);
Count++;
_elements = new DrawableContainerList(ID);
selectedElements = new DrawableContainerList(ID);
@@ -234,7 +260,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
/// Surface constructor with an image
///
/// Bitmap
- 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);
SetBitmap(newBitmap, true);
@@ -244,7 +270,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
/// Surface contructor with a capture
///
///
- public Surface(ICapture capture) : this()
+ public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, ICapture capture) : this(coreConfiguration, editorConfiguration)
{
SetCapture(capture);
}
@@ -1135,41 +1161,41 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
switch (DrawingMode)
{
case DrawingModes.Rect:
- _undrawnElement = new RectangleContainer(this);
+ _undrawnElement = new RectangleContainer(this, _editorConfiguration);
break;
case DrawingModes.Ellipse:
- _undrawnElement = new EllipseContainer(this);
+ _undrawnElement = new EllipseContainer(this, _editorConfiguration);
break;
case DrawingModes.Text:
- _undrawnElement = new TextContainer(this);
+ _undrawnElement = new TextContainer(this, _editorConfiguration);
break;
case DrawingModes.SpeechBubble:
- _undrawnElement = new SpeechbubbleContainer(this);
+ _undrawnElement = new SpeechbubbleContainer(this, _editorConfiguration);
break;
case DrawingModes.StepLabel:
- _undrawnElement = new StepLabelContainer(this);
+ _undrawnElement = new StepLabelContainer(this, _editorConfiguration);
break;
case DrawingModes.Line:
- _undrawnElement = new LineContainer(this);
+ _undrawnElement = new LineContainer(this, _editorConfiguration);
break;
case DrawingModes.Arrow:
- _undrawnElement = new ArrowContainer(this);
+ _undrawnElement = new ArrowContainer(this, _editorConfiguration);
break;
case DrawingModes.Highlight:
- _undrawnElement = new HighlightContainer(this);
+ _undrawnElement = new HighlightContainer(this, _editorConfiguration);
break;
case DrawingModes.Obfuscate:
- _undrawnElement = new ObfuscateContainer(this);
+ _undrawnElement = new ObfuscateContainer(this, _editorConfiguration);
break;
case DrawingModes.Crop:
- _cropContainer = new CropContainer(this);
+ _cropContainer = new CropContainer(this, _editorConfiguration);
_undrawnElement = _cropContainer;
break;
case DrawingModes.Bitmap:
- _undrawnElement = new BitmapContainer(this);
+ _undrawnElement = new BitmapContainer(this, _editorConfiguration);
break;
case DrawingModes.Path:
- _undrawnElement = new FreehandContainer(this);
+ _undrawnElement = new FreehandContainer(this, _editorConfiguration);
break;
case DrawingModes.None:
_undrawnElement = null;
@@ -1190,7 +1216,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
NativeRect cropRectangle;
using (var tmpImage = GetBitmapForExport())
{
- cropRectangle = tmpImage.FindAutoCropRectangle(conf.AutoCropDifference);
+ cropRectangle = tmpImage.FindAutoCropRectangle(_coreConfiguration.AutoCropDifference);
}
if (!IsCropPossible(ref cropRectangle))
{
@@ -1880,7 +1906,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public IBitmapContainer AddImageContainer(Bitmap bitmap, int x, int y)
{
- var bitmapContainer = new BitmapContainer(this)
+ var bitmapContainer = new BitmapContainer(this, _editorConfiguration)
{
Bitmap = bitmap,
Left = x,
@@ -1892,7 +1918,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public IBitmapContainer AddImageContainer(string filename, int x, int y)
{
- var bitmapContainer = new BitmapContainer(this);
+ var bitmapContainer = new BitmapContainer(this, _editorConfiguration);
bitmapContainer.Load(filename);
bitmapContainer.Left = x;
bitmapContainer.Top = y;
@@ -1902,7 +1928,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public IIconContainer AddIconContainer(Icon icon, int x, int y)
{
- var iconContainer = new IconContainer(this)
+ var iconContainer = new IconContainer(this, _editorConfiguration)
{
Icon = icon,
Left = x,
@@ -1914,7 +1940,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public IIconContainer AddIconContainer(string filename, int x, int y)
{
- var iconContainer = new IconContainer(this);
+ var iconContainer = new IconContainer(this, _editorConfiguration);
iconContainer.Load(filename);
iconContainer.Left = x;
iconContainer.Top = y;
@@ -1924,7 +1950,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public ICursorContainer AddCursorContainer(Cursor cursor, int x, int y)
{
- var cursorContainer = new CursorContainer(this)
+ var cursorContainer = new CursorContainer(this, _editorConfiguration)
{
Cursor = cursor,
Left = x,
@@ -1936,7 +1962,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing
public ICursorContainer AddCursorContainer(string filename, int x, int y)
{
- var cursorContainer = new CursorContainer(this);
+ var cursorContainer = new CursorContainer(this, _editorConfiguration);
cursorContainer.Load(filename);
cursorContainer.Left = x;
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,
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_BOLD, bold);
textContainer.SetFieldValue(FieldTypes.FONT_ITALIC, italic);
diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/TextContainer.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/TextContainer.cs
index 469989ea5..7e70aea8d 100644
--- a/src/Greenshot.Addon.LegacyEditor/Drawing/TextContainer.cs
+++ b/src/Greenshot.Addon.LegacyEditor/Drawing/TextContainer.cs
@@ -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();
}
diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj
index 4085fdfde..a6a552ec8 100644
--- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj
+++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj
@@ -138,7 +138,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj
index 1f6341ef2..c64d6ee66 100644
--- a/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj
+++ b/src/Greenshot.Addon.Lutim/Greenshot.Addon.Lutim.csproj
@@ -52,7 +52,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj
index 81244eb51..b9bf28d8c 100644
--- a/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj
+++ b/src/Greenshot.Addon.OCR/Greenshot.Addon.OCR.csproj
@@ -41,7 +41,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.OCR/OCRDestination.cs b/src/Greenshot.Addon.OCR/OCRDestination.cs
index a96242fae..9efa32a2d 100644
--- a/src/Greenshot.Addon.OCR/OCRDestination.cs
+++ b/src/Greenshot.Addon.OCR/OCRDestination.cs
@@ -106,7 +106,7 @@ namespace Greenshot.Addon.OCR
/// Has the Image and the capture details
public string DoOcr(ISurface surface)
{
- var outputSettings = new SurfaceOutputSettings(OutputFormats.bmp, 0, true)
+ var outputSettings = new SurfaceOutputSettings(CoreConfiguration, OutputFormats.bmp, 0, true)
{
ReduceColors = true,
SaveBackgroundOnly = true
diff --git a/src/Greenshot.Addon.Office/Destinations/ExcelDestination.cs b/src/Greenshot.Addon.Office/Destinations/ExcelDestination.cs
index cfc40cbab..61f18bb42 100644
--- a/src/Greenshot.Addon.Office/Destinations/ExcelDestination.cs
+++ b/src/Greenshot.Addon.Office/Destinations/ExcelDestination.cs
@@ -118,7 +118,7 @@ namespace Greenshot.Addon.Office.Destinations
var imageFile = captureDetails.Filename;
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;
}
if (_workbookName != null)
diff --git a/src/Greenshot.Addon.Office/Destinations/OneNoteDestination.cs b/src/Greenshot.Addon.Office/Destinations/OneNoteDestination.cs
index ca569839b..b3b29c1b7 100644
--- a/src/Greenshot.Addon.Office/Destinations/OneNoteDestination.cs
+++ b/src/Greenshot.Addon.Office/Destinations/OneNoteDestination.cs
@@ -47,7 +47,8 @@ namespace Greenshot.Addon.Office.Destinations
[Destination("OneNote", DestinationOrder.OneNote)]
public class OneNoteDestination : AbstractDestination
{
- private readonly ExportNotification _exportNotification;
+ private readonly OneNoteExporter _oneNoteExporter;
+ private readonly ExportNotification _exportNotification;
private const int IconApplication = 0;
private static readonly LogSource Log = new LogSource();
private readonly string _exePath;
@@ -60,11 +61,13 @@ namespace Greenshot.Addon.Office.Destinations
/// IGreenshotLanguage
/// ExportNotification
public OneNoteDestination(
+ OneNoteExporter oneNoteExporter,
ICoreConfiguration coreConfiguration,
IGreenshotLanguage greenshotLanguage,
ExportNotification exportNotification
) : base(coreConfiguration, greenshotLanguage)
{
+ this._oneNoteExporter = oneNoteExporter;
_exportNotification = exportNotification;
_exePath = PluginUtils.GetExePath("ONENOTE.EXE");
if (_exePath != null && !File.Exists(_exePath))
@@ -80,11 +83,12 @@ namespace Greenshot.Addon.Office.Destinations
/// ICoreConfiguration
/// IGreenshotLanguage
/// ExportNotification
- protected OneNoteDestination(OneNotePage page,
+ protected OneNoteDestination(OneNoteExporter oneNoteExporter,
+ OneNotePage page,
ICoreConfiguration coreConfiguration,
IGreenshotLanguage greenshotLanguage,
ExportNotification exportNotification
- ) : this(coreConfiguration, greenshotLanguage, exportNotification)
+ ) : this(oneNoteExporter, coreConfiguration, greenshotLanguage, exportNotification)
{
_page = page;
}
@@ -119,7 +123,7 @@ namespace Greenshot.Addon.Office.Destinations
{
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)
{
@@ -145,7 +149,7 @@ namespace Greenshot.Addon.Office.Destinations
{
try
{
- exportInformation.ExportMade = OneNoteExporter.ExportToNewPage(surface);
+ exportInformation.ExportMade = _oneNoteExporter.ExportToNewPage(surface);
}
catch (Exception ex)
{
@@ -157,7 +161,7 @@ namespace Greenshot.Addon.Office.Destinations
{
try
{
- exportInformation.ExportMade = OneNoteExporter.ExportToPage(surface, _page);
+ exportInformation.ExportMade = _oneNoteExporter.ExportToPage(surface, _page);
}
catch (Exception ex)
{
diff --git a/src/Greenshot.Addon.Office/Destinations/OutlookDestination.cs b/src/Greenshot.Addon.Office/Destinations/OutlookDestination.cs
index 2feb71e9d..ddb9261cc 100644
--- a/src/Greenshot.Addon.Office/Destinations/OutlookDestination.cs
+++ b/src/Greenshot.Addon.Office/Destinations/OutlookDestination.cs
@@ -172,7 +172,7 @@ namespace Greenshot.Addon.Office.Destinations
var tmpFile = captureDetails.Filename;
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
{
diff --git a/src/Greenshot.Addon.Office/Destinations/PowerpointDestination.cs b/src/Greenshot.Addon.Office/Destinations/PowerpointDestination.cs
index a9675415e..acb256a12 100644
--- a/src/Greenshot.Addon.Office/Destinations/PowerpointDestination.cs
+++ b/src/Greenshot.Addon.Office/Destinations/PowerpointDestination.cs
@@ -141,7 +141,7 @@ namespace Greenshot.Addon.Office.Destinations
var imageSize = Size.Empty;
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;
}
if (_presentationName != null)
diff --git a/src/Greenshot.Addon.Office/Destinations/WordDestination.cs b/src/Greenshot.Addon.Office/Destinations/WordDestination.cs
index 4ad6f5255..253e0e496 100644
--- a/src/Greenshot.Addon.Office/Destinations/WordDestination.cs
+++ b/src/Greenshot.Addon.Office/Destinations/WordDestination.cs
@@ -126,7 +126,7 @@ namespace Greenshot.Addon.Office.Destinations
var tmpFile = captureDetails.Filename;
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)
{
diff --git a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj
index 67b7e1def..d6bdf952e 100644
--- a/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj
+++ b/src/Greenshot.Addon.Office/Greenshot.Addon.Office.csproj
@@ -50,7 +50,7 @@
True
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Office/OfficeAddonModule.cs b/src/Greenshot.Addon.Office/OfficeAddonModule.cs
index da83d0a9f..c39376d2e 100644
--- a/src/Greenshot.Addon.Office/OfficeAddonModule.cs
+++ b/src/Greenshot.Addon.Office/OfficeAddonModule.cs
@@ -29,6 +29,7 @@ using Dapplo.Config.Language;
using Greenshot.Addon.Office.Configuration;
using Greenshot.Addon.Office.Configuration.Impl;
using Greenshot.Addon.Office.Destinations;
+using Greenshot.Addon.Office.OfficeExport;
using Greenshot.Addon.Office.ViewModels;
using Greenshot.Addons.Components;
using Greenshot.Addons.Core;
@@ -80,6 +81,11 @@ namespace Greenshot.Addon.Office
.RegisterType()
.As()
.SingleInstance();
+
+ builder
+ .RegisterType()
+ .AsSelf()
+ .SingleInstance();
}
if (PluginUtils.GetExePath("OUTLOOK.EXE") != null)
diff --git a/src/Greenshot.Addon.Office/OfficeExport/OneNoteExporter.cs b/src/Greenshot.Addon.Office/OfficeExport/OneNoteExporter.cs
index 6a3333f55..9f6a82189 100644
--- a/src/Greenshot.Addon.Office/OfficeExport/OneNoteExporter.cs
+++ b/src/Greenshot.Addon.Office/OfficeExport/OneNoteExporter.cs
@@ -45,19 +45,25 @@ namespace Greenshot.Addon.Office.OfficeExport
/// OneNote exporter
/// More details about OneNote: http://msdn.microsoft.com/en-us/magazine/ff796230.aspx
///
- public static class OneNoteExporter
+ public class OneNoteExporter
{
private const string XmlImageContent = "{0}";
private const string XmlOutline = "{0}";
private const string OnenoteNamespace2010 = "http://schemas.microsoft.com/office/onenote/2010/onenote";
private static readonly LogSource Log = new LogSource();
+ private readonly ICoreConfiguration _coreConfiguration;
+
+ public OneNoteExporter(ICoreConfiguration coreConfiguration)
+ {
+ _coreConfiguration = coreConfiguration;
+ }
///
/// Create a new page in the "unfiled notes section", with the title of the capture, and export the capture there.
///
/// ISurface
/// bool true if export worked
- public static bool ExportToNewPage(ISurface surfaceToUpload)
+ public bool ExportToNewPage(ISurface surfaceToUpload)
{
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
{
@@ -83,7 +89,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// ISurface
/// OneNotePage
/// bool true if everything worked
- public static bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
+ public bool ExportToPage(ISurface surfaceToUpload, OneNotePage page)
{
using (var oneNoteApplication = GetOrCreateOneNoteApplication())
{
@@ -98,7 +104,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// ISurface
/// OneNotePage
/// bool true if everything worked
- private static bool ExportToPage(IDisposableCom oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
+ private bool ExportToPage(IDisposableCom oneNoteApplication, ISurface surfaceToUpload, OneNotePage page)
{
if (oneNoteApplication == null)
{
@@ -107,7 +113,7 @@ namespace Greenshot.Addon.Office.OfficeExport
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);
var base64String = Convert.ToBase64String(pngStream.GetBuffer());
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.
///
/// ComDisposable for Excel.Application or null
- private static IDisposableCom GetOneNoteApplication()
+ private IDisposableCom GetOneNoteApplication()
{
IDisposableCom oneNoteApplication;
try
@@ -149,7 +155,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// Call this to get the running OneNote application, or create a new instance
///
/// ComDisposable for OneNote.Application
- private static IDisposableCom GetOrCreateOneNoteApplication()
+ private IDisposableCom GetOrCreateOneNoteApplication()
{
var oneNoteApplication = GetOneNoteApplication();
if (oneNoteApplication == null)
@@ -163,7 +169,7 @@ namespace Greenshot.Addon.Office.OfficeExport
/// Get the captions of all the open word documents
///
///
- public static IList GetPages()
+ public IList GetPages()
{
var pages = new List();
try
@@ -276,7 +282,7 @@ namespace Greenshot.Addon.Office.OfficeExport
///
/// SpecialLocation
/// string with section ID
- private static string GetSectionId(IDisposableCom oneNoteApplication, SpecialLocation specialLocation)
+ private string GetSectionId(IDisposableCom oneNoteApplication, SpecialLocation specialLocation)
{
if (oneNoteApplication == null)
{
diff --git a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj
index 04f045d9b..3aa1032fc 100644
--- a/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj
+++ b/src/Greenshot.Addon.OneDrive/Greenshot.Addon.OneDrive.csproj
@@ -52,7 +52,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj
index 7167aa53a..70d1bd7d6 100644
--- a/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj
+++ b/src/Greenshot.Addon.Photobucket/Greenshot.Addon.Photobucket.csproj
@@ -50,7 +50,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj
index 6fb64be85..a6884cfc0 100644
--- a/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj
+++ b/src/Greenshot.Addon.Tfs/Greenshot.Addon.Tfs.csproj
@@ -52,7 +52,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj
index 38a48cb0b..4dee2c9b8 100644
--- a/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj
+++ b/src/Greenshot.Addon.Win10/Greenshot.Addon.Win10.csproj
@@ -21,6 +21,8 @@
+
+
False
C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.WindowsRuntime.dll
diff --git a/src/Greenshot.Addon.Win10/Win10AddonModule.cs b/src/Greenshot.Addon.Win10/Win10AddonModule.cs
index 99294bc58..084183f0a 100644
--- a/src/Greenshot.Addon.Win10/Win10AddonModule.cs
+++ b/src/Greenshot.Addon.Win10/Win10AddonModule.cs
@@ -21,6 +21,7 @@
using Autofac;
using Dapplo.Addons;
+using Greenshot.Addons.Interfaces;
using Dapplo.Windows.Common;
using Greenshot.Addons.Components;
@@ -37,6 +38,14 @@ namespace Greenshot.Addon.Win10
.RegisterType()
.As()
.SingleInstance();
+
+#if !NETCOREAPP3_0
+ builder
+ .RegisterType()
+ .As()
+ .SingleInstance();
+#endif
+
builder
.RegisterType()
.As()
diff --git a/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs b/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs
new file mode 100644
index 000000000..e43e33a68
--- /dev/null
+++ b/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs
@@ -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 .
+
+#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
\ No newline at end of file
diff --git a/src/Greenshot.Addon.Win10/Win10OcrDestination.cs b/src/Greenshot.Addon.Win10/Win10OcrDestination.cs
index e9a57147d..44f6d7b8b 100644
--- a/src/Greenshot.Addon.Win10/Win10OcrDestination.cs
+++ b/src/Greenshot.Addon.Win10/Win10OcrDestination.cs
@@ -84,7 +84,7 @@ namespace Greenshot.Addon.Win10
var ocrEngine = OcrEngine.TryCreateFromUserProfileLanguages();
using (var imageStream = new MemoryStream())
{
- ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings());
+ ImageOutput.SaveToStream(surface, imageStream, new SurfaceOutputSettings(CoreConfiguration));
imageStream.Position = 0;
var decoder = await BitmapDecoder.CreateAsync(imageStream.AsRandomAccessStream());
diff --git a/src/Greenshot.Addon.Win10/Win10ShareDestination.cs b/src/Greenshot.Addon.Win10/Win10ShareDestination.cs
index 5a6f23402..57e00cbc8 100644
--- a/src/Greenshot.Addon.Win10/Win10ShareDestination.cs
+++ b/src/Greenshot.Addon.Win10/Win10ShareDestination.cs
@@ -159,7 +159,7 @@ namespace Greenshot.Addon.Win10
using (var logoStream = new MemoryRandomAccessStream())
using (var thumbnailStream = new MemoryRandomAccessStream())
{
- var outputSettings = new SurfaceOutputSettings();
+ var outputSettings = new SurfaceOutputSettings(CoreConfiguration);
outputSettings.PreventGreenshotFormat();
// Create capture for export
diff --git a/src/Greenshot.Addons/AddonsModule.cs b/src/Greenshot.Addons/AddonsModule.cs
index 09f128f08..0f925fdf0 100644
--- a/src/Greenshot.Addons/AddonsModule.cs
+++ b/src/Greenshot.Addons/AddonsModule.cs
@@ -45,13 +45,28 @@ namespace Greenshot.Addons
.As()
.As()
.As()
- .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
.RegisterType()
.As()
.As()
- .SingleInstance();
+ .SingleInstance()
+ .OnActivated(args =>
+ {
+ // Workaround for static access in different helper classes and extensions
+ ImageOutput.GreenshotLanguage = args.Instance;
+ });
builder
.RegisterType()
diff --git a/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs b/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs
index 1eac3c3e4..7019ec044 100644
--- a/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs
+++ b/src/Greenshot.Addons/Config/Impl/CoreConfigurationImpl.cs
@@ -26,6 +26,7 @@ using System.Collections.Generic;
using System.Drawing;
using System.Windows;
using Dapplo.Config.Ini;
+using Dapplo.Log;
using Dapplo.Windows.Common.Structs;
using Dapplo.Windows.User32.Structs;
using Greenshot.Addons.Core;
diff --git a/src/Greenshot.Addons/Controls/ContextMenuToolStripProfessionalRenderer.cs b/src/Greenshot.Addons/Controls/ContextMenuToolStripProfessionalRenderer.cs
index 7ba5aaeee..27df331fe 100644
--- a/src/Greenshot.Addons/Controls/ContextMenuToolStripProfessionalRenderer.cs
+++ b/src/Greenshot.Addons/Controls/ContextMenuToolStripProfessionalRenderer.cs
@@ -39,14 +39,18 @@ namespace Greenshot.Addons.Controls
///
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer
{
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+ private readonly ICoreConfiguration _coreConfiguration;
+
+ public ContextMenuToolStripProfessionalRenderer(ICoreConfiguration coreConfiguration)
+ {
+ _coreConfiguration = coreConfiguration;
+ }
private Image _scaledCheckbox;
private bool _newImage;
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e)
{
- if (_scaledCheckbox == null || (NativeSize)_scaledCheckbox.Size != CoreConfig.IconSize)
+ if (_scaledCheckbox == null || (NativeSize)_scaledCheckbox.Size != _coreConfiguration.IconSize)
{
if (_newImage)
{
diff --git a/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs b/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs
index 7a6de3ad1..a7a34a887 100644
--- a/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs
+++ b/src/Greenshot.Addons/Controls/SaveImageFileDialog.cs
@@ -43,23 +43,18 @@ namespace Greenshot.Addons.Controls
public class SaveImageFileDialog : IDisposable
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfiguration = new CoreConfigurationImpl();
+ private readonly ICoreConfiguration _coreConfiguration;
private readonly ICaptureDetails _captureDetails;
private DirectoryInfo _eagerlyCreatedDirectory;
private FilterOption[] _filterOptions;
protected SaveFileDialog SaveFileDialog;
- public SaveImageFileDialog()
+ public SaveImageFileDialog(ICoreConfiguration coreConfiguration, ICaptureDetails captureDetails = null)
{
- Init();
- }
-
- public SaveImageFileDialog(ICaptureDetails captureDetails)
- {
- _captureDetails = captureDetails;
- Init();
- }
+ _coreConfiguration = coreConfiguration;
+ _captureDetails = captureDetails;
+ Init();
+ }
///
/// filename exactly as typed in the filename field
@@ -146,21 +141,21 @@ namespace Greenshot.Addons.Controls
string initialDirectory = null;
try
{
- CoreConfiguration.ValidateAndCorrect();
- initialDirectory = Path.GetDirectoryName(CoreConfiguration.OutputFileAsFullpath);
+ _coreConfiguration.ValidateAndCorrect();
+ initialDirectory = Path.GetDirectoryName(_coreConfiguration.OutputFileAsFullpath);
}
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))
{
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)
SaveFileDialog.RestoreDirectory = true;
@@ -175,7 +170,7 @@ namespace Greenshot.Addons.Controls
PrepareFilterOptions();
var fdf = "";
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++)
{
var fo = _filterOptions[i];
@@ -224,7 +219,7 @@ namespace Greenshot.Addons.Controls
private void ApplySuggestedValues()
{
// build the full path and set dialog properties
- FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(CoreConfiguration.OutputFileFilenamePattern, _captureDetails);
+ FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(_coreConfiguration.OutputFileFilenamePattern, _captureDetails);
}
private void CleanUp()
diff --git a/src/Greenshot.Addons/Controls/ThumbnailForm.cs b/src/Greenshot.Addons/Controls/ThumbnailForm.cs
index 5ccc63869..919ff55d2 100644
--- a/src/Greenshot.Addons/Controls/ThumbnailForm.cs
+++ b/src/Greenshot.Addons/Controls/ThumbnailForm.cs
@@ -48,17 +48,14 @@ namespace Greenshot.Addons.Controls
///
public sealed class ThumbnailForm : FormWithoutActivation
{
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration coreConfiguration = new CoreConfigurationImpl();
-
private IntPtr _thumbnailHandle = IntPtr.Zero;
///
/// Constructor for the Thumbnail form
///
- public ThumbnailForm()
+ public ThumbnailForm(ICoreConfiguration coreConfiguration)
{
- ShowInTaskbar = false;
+ ShowInTaskbar = false;
FormBorderStyle = FormBorderStyle.None;
TopMost = false;
Enabled = false;
diff --git a/src/Greenshot.Addons/Core/ClipboardHelper.cs b/src/Greenshot.Addons/Core/ClipboardHelper.cs
index a503b3afa..3f593d3c2 100644
--- a/src/Greenshot.Addons/Core/ClipboardHelper.cs
+++ b/src/Greenshot.Addons/Core/ClipboardHelper.cs
@@ -101,8 +101,11 @@ EndSelection:<<<<<<<4
private const int BITMAPFILEHEADER_LENGTH = 14;
private static readonly LogSource Log = new LogSource();
private static readonly object ClipboardLockObject = new object();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
private static readonly string FORMAT_FILECONTENTS = "FileContents";
private static readonly string FORMAT_PNG = "PNG";
private static readonly string FORMAT_PNG_OFFICEART = "PNG+Office Art";
@@ -470,7 +473,7 @@ EndSelection:<<<<<<<4
// TODO: add "HTML Format" support here...
return clipboardObject as Bitmap;
}
- if (CoreConfig.EnableSpecialDIBClipboardReader)
+ if (CoreConfiguration.EnableSpecialDIBClipboardReader)
{
if (format == FORMAT_17 || format == DataFormats.Dib)
{
@@ -648,17 +651,17 @@ EndSelection:<<<<<<<4
var disposeImage = false;
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
disposeImage = ImageOutput.CreateBitmapFromSurface(surface, outputSettings, out bitmapToSave);
try
{
// Create PNG stream
- if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.PNG))
+ if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.PNG))
{
pngStream = new MemoryStream();
// 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);
pngStream.Seek(0, SeekOrigin.Begin);
// Set the PNG stream
@@ -672,12 +675,12 @@ EndSelection:<<<<<<<4
try
{
- if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.DIB))
+ if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.DIB))
{
using (var tmpBmpStream = new MemoryStream())
{
// 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);
dibStream = new MemoryStream();
@@ -697,7 +700,7 @@ EndSelection:<<<<<<<4
// CF_DibV5
try
{
- if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.DIBV5))
+ if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.DIBV5))
{
// Create the stream for the clipboard
dibV5Stream = new MemoryStream();
@@ -734,18 +737,18 @@ EndSelection:<<<<<<<4
}
// 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);
dataObject.SetText(html, TextDataFormat.Html);
}
- else if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.HTMLDATAURL))
+ else if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.HTMLDATAURL))
{
string html;
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
// 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!
// Check if Bitmap is wanted
- if (CoreConfig.ClipboardFormats.Contains(ClipboardFormats.BITMAP))
+ if (CoreConfiguration.ClipboardFormats.Contains(ClipboardFormats.BITMAP))
{
dataObject.SetImage(bitmapToSave);
// Place the DataObject to the clipboard
diff --git a/src/Greenshot.Addons/Core/CoreConfigurationExtensions.cs b/src/Greenshot.Addons/Core/CoreConfigurationExtensions.cs
index 70e838201..1316980a0 100644
--- a/src/Greenshot.Addons/Core/CoreConfigurationExtensions.cs
+++ b/src/Greenshot.Addons/Core/CoreConfigurationExtensions.cs
@@ -28,6 +28,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
+using Dapplo.Log;
using Greenshot.Addons.Core.Enums;
#endregion
@@ -39,6 +40,8 @@ namespace Greenshot.Addons.Core
///
public static class CoreConfigurationExtensions
{
+ private static readonly LogSource Log = new LogSource();
+
///
/// Validate the values in the ICoreConfiguration, correct them where needed
///
@@ -194,6 +197,30 @@ namespace Greenshot.Addons.Core
coreConfiguration.WebRequestReadWriteTimeout = 100;
}
+ // TitleFix processor
+ var corruptKeys = new List();
+ 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();
}
}
diff --git a/src/Greenshot.Addons/Core/FilenameHelper.cs b/src/Greenshot.Addons/Core/FilenameHelper.cs
index 27ec291a9..b6a55ae6f 100644
--- a/src/Greenshot.Addons/Core/FilenameHelper.cs
+++ b/src/Greenshot.Addons/Core/FilenameHelper.cs
@@ -53,8 +53,10 @@ namespace Greenshot.Addons.Core
private static readonly Regex CmdVarRegexp = new Regex(@"%(?[^%]+)%", RegexOptions.Compiled);
private static readonly Regex SplitRegexp = new Regex(";(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", RegexOptions.Compiled);
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
///
/// Remove invalid characters from the fully qualified filename
@@ -134,7 +136,7 @@ namespace Greenshot.Addons.Core
/// The filename which should be used to save the image
public static string GetFilename(OutputFormats format, ICaptureDetails captureDetails)
{
- var pattern = CoreConfig.OutputFileFilenamePattern;
+ var pattern = CoreConfiguration.OutputFileFilenamePattern;
if (string.IsNullOrEmpty(pattern?.Trim()))
{
pattern = "greenshot ${capturetime}";
@@ -395,8 +397,8 @@ namespace Greenshot.Addons.Core
}
break;
case "NUM":
- CoreConfig.OutputFileIncrementingNumber++;
- replaceValue = CoreConfig.OutputFileIncrementingNumber.ToString();
+ CoreConfiguration.OutputFileIncrementingNumber++;
+ replaceValue = CoreConfiguration.OutputFileIncrementingNumber.ToString();
if (padWidth == 0)
{
padWidth = -6;
diff --git a/src/Greenshot.Addons/Core/ImageOutput.cs b/src/Greenshot.Addons/Core/ImageOutput.cs
index eae932b08..7a01ae02f 100644
--- a/src/Greenshot.Addons/Core/ImageOutput.cs
+++ b/src/Greenshot.Addons/Core/ImageOutput.cs
@@ -57,9 +57,18 @@ namespace Greenshot.Addons.Core
public static class ImageOutput
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
- private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static IGreenshotLanguage GreenshotLanguage { get; set; }
+
+ private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
private static readonly Cache TmpFileCache = new Cache(10 * 60 * 60, RemoveExpiredTmpFile);
static ImageOutput()
@@ -128,7 +137,7 @@ namespace Greenshot.Addons.Core
public static string SaveWithDialog(ISurface surface, ICaptureDetails captureDetails)
{
string returnValue = null;
- using (var saveImageFileDialog = new SaveImageFileDialog(captureDetails))
+ using (var saveImageFileDialog = new SaveImageFileDialog(CoreConfiguration, captureDetails))
{
var dialogResult = saveImageFileDialog.ShowDialog();
if (dialogResult.Equals(DialogResult.OK))
@@ -136,15 +145,15 @@ namespace Greenshot.Addons.Core
try
{
var fileNameWithExtension = saveImageFileDialog.FileNameWithExtension;
- var outputSettings = new SurfaceOutputSettings(FormatForFilename(fileNameWithExtension));
- if (CoreConfig.OutputFilePromptQuality)
+ var outputSettings = new SurfaceOutputSettings(CoreConfiguration, FormatForFilename(fileNameWithExtension));
+ if (CoreConfiguration.OutputFilePromptQuality)
{
- // TODO: Resolve, was static reference
- var qualityDialog = new QualityDialog(outputSettings, CoreConfig, new GreenshotLanguageImpl());
+ // TODO: Use factory
+ var qualityDialog = new QualityDialog(outputSettings, CoreConfiguration, GreenshotLanguage);
qualityDialog.ShowDialog();
}
// 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;
}
catch (ExternalException)
@@ -170,7 +179,7 @@ namespace Greenshot.Addons.Core
/// Path to image file
public static string SaveNamedTmpFile(ISurface surface, ICaptureDetails captureDetails, SurfaceOutputSettings outputSettings)
{
- var pattern = CoreConfig.OutputFileFilenamePattern;
+ var pattern = CoreConfiguration.OutputFileFilenamePattern;
if (string.IsNullOrEmpty(pattern?.Trim()))
{
pattern = "greenshot ${capturetime}";
@@ -564,7 +573,7 @@ namespace Greenshot.Addons.Core
AddTag(bitmapToSave);
// Added for OptiPNG
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);
}
@@ -616,13 +625,13 @@ namespace Greenshot.Addons.Core
///
private static bool ProcessPngImageExternally(Image imageToProcess, Stream targetStream)
{
- if (string.IsNullOrEmpty(CoreConfig.OptimizePNGCommand))
+ if (string.IsNullOrEmpty(CoreConfiguration.OptimizePNGCommand))
{
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;
}
var tmpFileName = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName() + ".png");
@@ -639,12 +648,12 @@ namespace Greenshot.Addons.Core
}
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,
RedirectStandardOutput = true,
RedirectStandardError = true,
@@ -735,12 +744,12 @@ namespace Greenshot.Addons.Core
}
// 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;
}
var isAlpha = Image.IsAlphaPixelFormat(bitmapToSave.PixelFormat);
- if (outputSettings.ReduceColors || !isAlpha && CoreConfig.OutputFileAutoReduceColors)
+ if (outputSettings.ReduceColors || !isAlpha && CoreConfiguration.OutputFileAutoReduceColors)
{
using (var quantizer = new WuQuantizer(bitmapToSave))
{
@@ -753,7 +762,7 @@ namespace Greenshot.Addons.Core
try
{
Log.Info().WriteLine("Reducing colors on bitmap to 256.");
- tmpBitmap = quantizer.GetQuantizedImage(CoreConfig.OutputFileReduceColorsTo);
+ tmpBitmap = quantizer.GetQuantizedImage(CoreConfiguration.OutputFileReduceColorsTo);
if (disposeImage)
{
bitmapToSave.Dispose();
diff --git a/src/Greenshot.Addons/Core/InterfaceUtils.cs b/src/Greenshot.Addons/Core/InterfaceUtils.cs
deleted file mode 100644
index 70206311d..000000000
--- a/src/Greenshot.Addons/Core/InterfaceUtils.cs
+++ /dev/null
@@ -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 .
-
-#endregion
-
-#region Usings
-
-using System;
-using System.Collections.Generic;
-using System.Threading;
-using Dapplo.Log;
-using Greenshot.Addons.Interfaces;
-
-#endregion
-
-namespace Greenshot.Addons.Core
-{
- ///
- /// Description of InterfaceUtils.
- ///
- public static class InterfaceUtils
- {
- private static readonly LogSource Log = new LogSource();
-
- public static List GetSubclassesOf(Type type, bool excludeSystemTypes)
- {
- var list = new List();
- 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 GetProcessors()
- {
- var processors = new List();
- 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;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Greenshot.Addons/Core/InteropWindowCaptureExtensions.cs b/src/Greenshot.Addons/Core/InteropWindowCaptureExtensions.cs
index 9a9836120..28b628715 100644
--- a/src/Greenshot.Addons/Core/InteropWindowCaptureExtensions.cs
+++ b/src/Greenshot.Addons/Core/InteropWindowCaptureExtensions.cs
@@ -56,8 +56,11 @@ namespace Greenshot.Addons.Core
public static class InteropWindowCaptureExtensions
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfiguration = new CoreConfigurationImpl();
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
private static Color _transparentColor = Color.Transparent;
///
diff --git a/src/Greenshot.Addons/Core/PluginUtils.cs b/src/Greenshot.Addons/Core/PluginUtils.cs
index 50ea53b39..5695bf6b1 100644
--- a/src/Greenshot.Addons/Core/PluginUtils.cs
+++ b/src/Greenshot.Addons/Core/PluginUtils.cs
@@ -48,22 +48,24 @@ namespace Greenshot.Addons.Core
private const string PathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
private static readonly LogSource Log = new LogSource();
private static bool _isHooked = false;
- private static readonly IDictionary ExeIconCache = new Dictionary();
+ private static readonly Dictionary ExeIconCache = new Dictionary();
+ private static ICoreConfiguration coreConfiguration;
///
- /// 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
///
- private static void SetupIconResizing()
- {
- if (!_isHooked)
- {
- return;
- }
+ internal static ICoreConfiguration CoreConfiguration {
+ get
+ {
+ return coreConfiguration;
+ }
- _isHooked = true;
- var coreConfiguration = new CoreConfigurationImpl();
- coreConfiguration.PropertyChanged += OnIconSizeChanged;
- }
+ set
+ {
+ coreConfiguration = value;
+ coreConfiguration.PropertyChanged += OnIconSizeChanged;
+ }
+ }
///
/// Clear icon cache
@@ -140,8 +142,6 @@ namespace Greenshot.Addons.Core
Bitmap returnValue;
lock (ExeIconCache)
{
- SetupIconResizing();
-
if (ExeIconCache.TryGetValue(cacheKey, out returnValue))
{
return returnValue;
diff --git a/src/Greenshot.Addons/Core/WindowCapture.cs b/src/Greenshot.Addons/Core/WindowCapture.cs
index 06e65e3a1..cdacb70fb 100644
--- a/src/Greenshot.Addons/Core/WindowCapture.cs
+++ b/src/Greenshot.Addons/Core/WindowCapture.cs
@@ -56,8 +56,11 @@ namespace Greenshot.Addons.Core
public static class WindowCapture
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration Configuration = new CoreConfigurationImpl();
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
///
/// 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;
}
- if (Configuration.NoDWMCaptureForProduct == null || Configuration.NoDWMCaptureForProduct.Count <= 0)
+ if (CoreConfiguration.NoDWMCaptureForProduct == null || CoreConfiguration.NoDWMCaptureForProduct.Count <= 0)
{
return true;
}
@@ -181,7 +184,7 @@ namespace Greenshot.Addons.Core
try
{
var productName = process.MainModule.FileVersionInfo.ProductName;
- if (productName != null && Configuration.NoDWMCaptureForProduct.Contains(productName.ToLower()))
+ if (productName != null && CoreConfiguration.NoDWMCaptureForProduct.Contains(productName.ToLower()))
{
return false;
}
@@ -205,7 +208,7 @@ namespace Greenshot.Addons.Core
return true;
}
- if (Configuration.NoGDICaptureForProduct == null || Configuration.NoGDICaptureForProduct.Count <= 0)
+ if (CoreConfiguration.NoGDICaptureForProduct == null || CoreConfiguration.NoGDICaptureForProduct.Count <= 0)
{
return true;
}
@@ -213,7 +216,7 @@ namespace Greenshot.Addons.Core
try
{
var productName = process.MainModule.FileVersionInfo.ProductName;
- if (productName != null && Configuration.NoGDICaptureForProduct.Contains(productName.ToLower()))
+ if (productName != null && CoreConfiguration.NoGDICaptureForProduct.Contains(productName.ToLower()))
{
return false;
}
diff --git a/src/Greenshot.Addons/Extensions/ClipboardBitmapExtensions.cs b/src/Greenshot.Addons/Extensions/ClipboardBitmapExtensions.cs
index 3d57ac9f5..5dcf85e67 100644
--- a/src/Greenshot.Addons/Extensions/ClipboardBitmapExtensions.cs
+++ b/src/Greenshot.Addons/Extensions/ClipboardBitmapExtensions.cs
@@ -195,12 +195,12 @@ namespace Greenshot.Addons.Extensions
///
/// IClipboardAccessToken
/// ISurface
- 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
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);
// Create the BITMAPINFOHEADER
var header = BitmapInfoHeader.Create(bitmapToSave.Width, bitmapToSave.Height, 32);
@@ -269,11 +269,11 @@ namespace Greenshot.Addons.Extensions
///
/// IClipboardAccessToken
/// ISurface
- 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())
{
- 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);
// Set the stream
clipboardAccessToken.SetAsStream(StandardClipboardFormats.DeviceIndependentBitmap, bitmapStream);
diff --git a/src/Greenshot.Addons/Extensions/ClipboardHtmlExtensions.cs b/src/Greenshot.Addons/Extensions/ClipboardHtmlExtensions.cs
index 418086cee..f74bb9bdb 100644
--- a/src/Greenshot.Addons/Extensions/ClipboardHtmlExtensions.cs
+++ b/src/Greenshot.Addons/Extensions/ClipboardHtmlExtensions.cs
@@ -136,9 +136,9 @@ EndSelection:<<<<<<<4
///
/// IClipboardAccessToken
/// ISurface
- 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.
var filename = ImageOutput.SaveNamedTmpFile(surface, surface.CaptureDetails, pngOutputSettings);
// Set the PNG stream
@@ -152,11 +152,11 @@ EndSelection:<<<<<<<4
///
/// IClipboardAccessToken
/// ISurface
- 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())
{
- var pngOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
+ var pngOutputSettings = new SurfaceOutputSettings(coreConfiguration, OutputFormats.png, 100, false);
ImageOutput.SaveToStream(surface, pngStream, pngOutputSettings);
pngStream.Seek(0, SeekOrigin.Begin);
// Set the PNG stream
diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj
index aa725251a..8c47e1c4b 100644
--- a/src/Greenshot.Addons/Greenshot.Addons.csproj
+++ b/src/Greenshot.Addons/Greenshot.Addons.csproj
@@ -67,7 +67,7 @@
0.8.3
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot.Addons/Interfaces/IFormEnhancer.cs b/src/Greenshot.Addons/Interfaces/IFormEnhancer.cs
new file mode 100644
index 000000000..b188cb599
--- /dev/null
+++ b/src/Greenshot.Addons/Interfaces/IFormEnhancer.cs
@@ -0,0 +1,16 @@
+using System.Windows.Forms;
+
+namespace Greenshot.Addons.Interfaces
+{
+ ///
+ /// This interface makes it possible to enhance forms by e.g. injecting components
+ ///
+ public interface IFormEnhancer
+ {
+ ///
+ /// This is called during the InitializeComponent of the form
+ ///
+ /// Form
+ void InitializeComponent(Form target);
+ }
+}
diff --git a/src/Greenshot.Addons/Interfaces/Plugin/SurfaceOutputSettings.cs b/src/Greenshot.Addons/Interfaces/Plugin/SurfaceOutputSettings.cs
index cebb2de72..b06c53945 100644
--- a/src/Greenshot.Addons/Interfaces/Plugin/SurfaceOutputSettings.cs
+++ b/src/Greenshot.Addons/Interfaces/Plugin/SurfaceOutputSettings.cs
@@ -35,38 +35,32 @@ namespace Greenshot.Addons.Interfaces.Plugin
{
public class SurfaceOutputSettings
{
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
private bool _disableReduceColors;
private bool _reduceColors;
- public SurfaceOutputSettings()
+ public SurfaceOutputSettings(IFileConfiguration fileConfiguration)
{
_disableReduceColors = false;
- Format = CoreConfig.OutputFileFormat;
- JPGQuality = CoreConfig.OutputFileJpegQuality;
- ReduceColors = CoreConfig.OutputFileReduceColors;
+ Format = fileConfiguration.OutputFileFormat;
+ JPGQuality = fileConfiguration.OutputFileJpegQuality;
+ ReduceColors = fileConfiguration.OutputFileReduceColors;
}
- public SurfaceOutputSettings(OutputFormats format) : this()
+ public SurfaceOutputSettings(IFileConfiguration fileConfiguration, OutputFormats format) : this(fileConfiguration)
{
Format = format;
}
- public SurfaceOutputSettings(OutputFormats format, int quality) : this(format)
+ public SurfaceOutputSettings(IFileConfiguration fileConfiguration, OutputFormats format, int quality) : this(fileConfiguration, format)
{
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;
}
- public SurfaceOutputSettings(IFileConfiguration fileConfiguration) : this(fileConfiguration.OutputFileFormat, fileConfiguration.OutputFileJpegQuality, fileConfiguration.OutputFileReduceColors)
- {
- }
-
public OutputFormats Format { get; set; }
public int JPGQuality { get; set; }
diff --git a/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs b/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs
index 26de11e8b..d6ddaed52 100644
--- a/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs
+++ b/src/Greenshot.Addons/ViewModels/FileConfigPartViewModel.cs
@@ -97,6 +97,26 @@ namespace Greenshot.Addons.ViewModels
}
}
+ ///
+ /// This opens the directory selection dialog
+ ///
+ 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;
+ }
+ }
+ }
+ }
+
///
/// Specifies if the global settings can be modified, which is the case when there are is no DestinationFileConfiguration
///
diff --git a/src/Greenshot.Addons/Views/FileConfigPartView.xaml b/src/Greenshot.Addons/Views/FileConfigPartView.xaml
index fd7d92d5e..78ff968d0 100644
--- a/src/Greenshot.Addons/Views/FileConfigPartView.xaml
+++ b/src/Greenshot.Addons/Views/FileConfigPartView.xaml
@@ -23,6 +23,12 @@
+
+
+
+
+
+
diff --git a/src/Greenshot.sln b/src/Greenshot.sln
index b493f13c7..3484b8c5b 100644
--- a/src/Greenshot.sln
+++ b/src/Greenshot.sln
@@ -170,6 +170,7 @@ Global
{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}.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.Build.0 = Release|Any CPU
{D106F86C-CD3D-44FF-B151-2A5D47268B5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/src/Greenshot/Components/CaptureSupportInfo.cs b/src/Greenshot/Components/CaptureSupportInfo.cs
new file mode 100644
index 000000000..1d9720c54
--- /dev/null
+++ b/src/Greenshot/Components/CaptureSupportInfo.cs
@@ -0,0 +1,34 @@
+using System.Collections.Generic;
+using Greenshot.Addon.InternetExplorer;
+using Greenshot.Addons.Core;
+using Greenshot.Addons.Interfaces;
+
+namespace Greenshot.Components
+{
+ ///
+ /// This is the information which is needed for making captures possible.
+ ///
+ public class CaptureSupportInfo
+ {
+ ///
+ /// Constructor for DI
+ ///
+ /// InternetExplorerCaptureHelper
+ /// IEnumerable with IFormEnhancer
+ public CaptureSupportInfo(
+ ICoreConfiguration coreConfiguration,
+ InternetExplorerCaptureHelper internetExplorerCaptureHelper,
+ IEnumerable formEnhancers = null
+ )
+ {
+ CoreConfiguration = coreConfiguration;
+ InternetExplorerCaptureHelper = internetExplorerCaptureHelper;
+ FormEnhancers = formEnhancers;
+ }
+
+ public ICoreConfiguration CoreConfiguration { get; }
+ public InternetExplorerCaptureHelper InternetExplorerCaptureHelper { get; }
+
+ public IEnumerable FormEnhancers { get; }
+ }
+}
diff --git a/src/Greenshot/Components/GreenshotServer.cs b/src/Greenshot/Components/GreenshotServer.cs
index 214ba25fe..129f71a15 100644
--- a/src/Greenshot/Components/GreenshotServer.cs
+++ b/src/Greenshot/Components/GreenshotServer.cs
@@ -26,6 +26,7 @@
#region Usings
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Principal;
@@ -60,6 +61,7 @@ namespace Greenshot.Components
private readonly HotkeyService _hotkeyService;
private readonly DestinationHolder _destinationHolder;
private ServiceHost _host;
+ private CaptureSupportInfo _captureSupportInfo;
public static string Identity
{
@@ -75,8 +77,10 @@ namespace Greenshot.Components
ICoreConfiguration coreConfiguration,
MainForm mainForm,
HotkeyService hotkeyService,
- DestinationHolder destinationHolder)
+ DestinationHolder destinationHolder,
+ CaptureSupportInfo captureSupportInfo)
{
+ _captureSupportInfo = captureSupportInfo;
_coreConfiguration = coreConfiguration;
_mainForm = mainForm;
_hotkeyService = hotkeyService;
@@ -137,7 +141,7 @@ namespace Greenshot.Components
Log.Debug().WriteLine("Open file requested: {0}", filename);
if (File.Exists(filename))
{
- CaptureHelper.CaptureFile(filename);
+ CaptureHelper.CaptureFile(_captureSupportInfo, filename);
}
else
{
@@ -167,13 +171,13 @@ namespace Greenshot.Components
switch (captureMode.ToLower())
{
case "region":
- CaptureHelper.CaptureRegion(false, destination);
+ CaptureHelper.CaptureRegion(_captureSupportInfo, false, destination);
break;
case "window":
- CaptureHelper.CaptureWindow(false, destination);
+ CaptureHelper.CaptureWindow(_captureSupportInfo, false, destination);
break;
case "fullscreen":
- CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen, destination);
+ CaptureHelper.CaptureFullscreen(_captureSupportInfo, false, ScreenCaptureMode.FullScreen, destination);
break;
default:
Log.Warn().WriteLine("Unknown capture option");
diff --git a/src/Greenshot/Components/HotkeyService.cs b/src/Greenshot/Components/HotkeyService.cs
index 2892e600e..226abccdb 100644
--- a/src/Greenshot/Components/HotkeyService.cs
+++ b/src/Greenshot/Components/HotkeyService.cs
@@ -22,12 +22,14 @@
#endregion
using System;
+using System.Collections.Generic;
using System.Reactive.Linq;
using Caliburn.Micro;
using Dapplo.Addons;
using Dapplo.Log;
using Dapplo.Windows.Input.Keyboard;
using Greenshot.Addons.Core;
+using Greenshot.Addons.Interfaces;
using Greenshot.Helpers;
namespace Greenshot.Components
@@ -40,11 +42,13 @@ namespace Greenshot.Components
{
private static readonly LogSource Log = new LogSource();
private readonly ICoreConfiguration _coreConfiguration;
+ private readonly CaptureSupportInfo _captureSupportInfo;
private IDisposable _subscriptions;
- public HotkeyService(ICoreConfiguration coreConfiguration)
+ public HotkeyService(ICoreConfiguration coreConfiguration, CaptureSupportInfo captureSupportInfo)
{
_coreConfiguration = coreConfiguration;
+ _captureSupportInfo = captureSupportInfo;
}
///
@@ -116,36 +120,36 @@ namespace Greenshot.Components
private void CaptureRegion(KeyboardHookEventArgs keyboardHookEventArgs)
{
- Execute.BeginOnUIThread(() => CaptureHelper.CaptureRegion(true));
+ Execute.BeginOnUIThread(() => CaptureHelper.CaptureRegion(_captureSupportInfo, true));
}
private void CaptureWindow(KeyboardHookEventArgs keyboardHookEventArgs)
{
if (_coreConfiguration.CaptureWindowsInteractive)
{
- Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindowInteractive(true));
+ Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindowInteractive(_captureSupportInfo, true));
}
else
{
- Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindow(true));
+ Execute.BeginOnUIThread(() => CaptureHelper.CaptureWindow(_captureSupportInfo, true));
}
}
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)
{
- Execute.BeginOnUIThread(() => CaptureHelper.CaptureLastRegion(true));
+ Execute.BeginOnUIThread(() => CaptureHelper.CaptureLastRegion(_captureSupportInfo, true));
}
private void CaptureIe(KeyboardHookEventArgs keyboardHookEventArgs)
{
if (_coreConfiguration.IECapture)
{
- Execute.BeginOnUIThread(() => CaptureHelper.CaptureIe(true, null));
+ Execute.BeginOnUIThread(() => CaptureHelper.CaptureIe(_captureSupportInfo, true, null));
}
}
}
diff --git a/src/Greenshot/Destinations/ClipboardDestination.cs b/src/Greenshot/Destinations/ClipboardDestination.cs
index 6a24944b1..9378c4d14 100644
--- a/src/Greenshot/Destinations/ClipboardDestination.cs
+++ b/src/Greenshot/Destinations/ClipboardDestination.cs
@@ -83,22 +83,22 @@ namespace Greenshot.Destinations
switch (clipboardFormat)
{
case ClipboardFormats.DIB:
- clipboardAccessToken.SetAsDeviceIndependendBitmap(surface);
+ clipboardAccessToken.SetAsDeviceIndependendBitmap(surface, CoreConfiguration);
break;
case ClipboardFormats.DIBV5:
- clipboardAccessToken.SetAsFormat17(surface);
+ clipboardAccessToken.SetAsFormat17(surface, CoreConfiguration);
break;
case ClipboardFormats.PNG:
- clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.png));
+ clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(CoreConfiguration, OutputFormats.png));
break;
case ClipboardFormats.BITMAP:
- clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(OutputFormats.bmp));
+ clipboardAccessToken.SetAsBitmap(surface, new SurfaceOutputSettings(CoreConfiguration, OutputFormats.bmp));
break;
case ClipboardFormats.HTML:
- clipboardAccessToken.SetAsHtml(surface);
+ clipboardAccessToken.SetAsHtml(surface, CoreConfiguration);
break;
case ClipboardFormats.HTMLDATAURL:
- clipboardAccessToken.SetAsEmbeddedHtml(surface);
+ clipboardAccessToken.SetAsEmbeddedHtml(surface, CoreConfiguration);
break;
}
}
diff --git a/src/Greenshot/Destinations/EmailDestination.cs b/src/Greenshot/Destinations/EmailDestination.cs
index 947186107..525255f18 100644
--- a/src/Greenshot/Destinations/EmailDestination.cs
+++ b/src/Greenshot/Destinations/EmailDestination.cs
@@ -31,7 +31,7 @@ using Greenshot.Addons.Components;
using Greenshot.Addons.Core;
using Greenshot.Addons.Interfaces;
using Greenshot.Addons.Resources;
-using Greenshot.Helpers;
+using Greenshot.Helpers.Mapi;
#endregion
diff --git a/src/Greenshot/Destinations/FileDestination.cs b/src/Greenshot/Destinations/FileDestination.cs
index cb00fb2ad..822136f9c 100644
--- a/src/Greenshot/Destinations/FileDestination.cs
+++ b/src/Greenshot/Destinations/FileDestination.cs
@@ -70,7 +70,7 @@ namespace Greenshot.Destinations
bool overwrite;
string fullPath;
// Get output settings from the configuration
- var outputSettings = new SurfaceOutputSettings();
+ var outputSettings = new SurfaceOutputSettings(CoreConfiguration);
if (captureDetails?.Filename != null)
{
diff --git a/src/Greenshot/Forms/CaptureForm.Designer.cs b/src/Greenshot/Forms/CaptureForm.Designer.cs
index ffb042a16..40efccf91 100644
--- a/src/Greenshot/Forms/CaptureForm.Designer.cs
+++ b/src/Greenshot/Forms/CaptureForm.Designer.cs
@@ -67,6 +67,15 @@ namespace Greenshot.Forms {
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown);
this.KeyUp += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyUp);
this.Visible = false;
+
+ if (_formEnhancers != null)
+ {
+ foreach (var enhancer in _formEnhancers)
+ {
+ enhancer.InitializeComponent(this);
+ }
+ }
+
this.ResumeLayout(false);
}
}
diff --git a/src/Greenshot/Forms/CaptureForm.cs b/src/Greenshot/Forms/CaptureForm.cs
index 5b65492c2..339329460 100644
--- a/src/Greenshot/Forms/CaptureForm.cs
+++ b/src/Greenshot/Forms/CaptureForm.cs
@@ -64,6 +64,7 @@ namespace Greenshot.Forms
private readonly ICapture _capture;
private readonly bool _isZoomerTransparent;
private readonly IList _windows;
+ private readonly IEnumerable _formEnhancers;
private NativeRect _captureRect = NativeRect.Empty;
private NativePoint _cursorPos;
private FixMode _fixMode = FixMode.None;
@@ -94,7 +95,7 @@ namespace Greenshot.Forms
/// ICoreConfiguration
/// ICapture
/// IList of IInteropWindow
- public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList windows) : base(coreConfiguration, null)
+ public CaptureForm(ICoreConfiguration coreConfiguration, ICapture capture, IList windows, IEnumerable formEnhancers) : base(coreConfiguration, null)
{
_isZoomerTransparent = _coreConfiguration.ZoomerOpacity < 1;
ManualLanguageApply = true;
@@ -105,6 +106,7 @@ namespace Greenshot.Forms
_capture = capture;
_windows = windows;
+ _formEnhancers = formEnhancers;
UsedCaptureMode = capture.CaptureDetails.CaptureMode;
//
@@ -348,8 +350,8 @@ namespace Greenshot.Forms
///
/// The mousedown handler of the capture form
///
- ///
- ///
+ /// object
+ /// MouseEventArgs
private void OnMouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
@@ -449,8 +451,8 @@ namespace Greenshot.Forms
///
/// The mouse move handler of the capture form
///
- ///
- ///
+ /// object
+ /// MouseEventArgs
private void OnMouseMove(object sender, MouseEventArgs e)
{
var cursorLocation = User32Api.GetCursorLocation();
@@ -463,7 +465,7 @@ namespace Greenshot.Forms
/// Helper method to simplify check
///
///
- ///
+ /// bool
private bool IsAnimating(IAnimator animator)
{
return animator != null && animator.HasNext;
diff --git a/src/Greenshot/Forms/MainForm.Designer.cs b/src/Greenshot/Forms/MainForm.Designer.cs
index 6b65ccff7..d8faa25ae 100644
--- a/src/Greenshot/Forms/MainForm.Designer.cs
+++ b/src/Greenshot/Forms/MainForm.Designer.cs
@@ -105,7 +105,7 @@ namespace Greenshot.Forms {
this.contextMenu.Name = "contextMenu";
this.contextMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ContextMenuClosing);
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
- this.contextMenu.Renderer = new ContextMenuToolStripProfessionalRenderer();
+ this.contextMenu.Renderer = new ContextMenuToolStripProfessionalRenderer(_coreConfiguration);
//
// contextmenu_capturearea
//
diff --git a/src/Greenshot/Forms/MainForm.cs b/src/Greenshot/Forms/MainForm.cs
index 3f555f600..30512fdd4 100644
--- a/src/Greenshot/Forms/MainForm.cs
+++ b/src/Greenshot/Forms/MainForm.cs
@@ -62,6 +62,8 @@ using Screen = System.Windows.Forms.Screen;
using Dapplo.Config.Ini;
using Dapplo.Windows.User32;
using Greenshot.Addons.Resources;
+using Greenshot.Addons.Interfaces;
+using Greenshot.Components;
#endregion
@@ -76,6 +78,7 @@ namespace Greenshot.Forms
private readonly ICoreConfiguration _coreConfiguration;
private readonly IWindowManager _windowManager;
private readonly IGreenshotLanguage _greenshotLanguage;
+ private readonly InternetExplorerCaptureHelper _internetExplorerCaptureHelper;
private readonly Func> _configViewModelFactory;
private readonly Func> _aboutFormFactory;
@@ -83,6 +86,8 @@ namespace Greenshot.Forms
private readonly Timer _doubleClickTimer = new Timer();
private readonly DestinationHolder _destinationHolder;
+ private readonly CaptureSupportInfo _captureSupportInfo;
+
// Thumbnail preview
private ThumbnailForm _thumbnailForm;
@@ -91,17 +96,22 @@ namespace Greenshot.Forms
public MainForm(ICoreConfiguration coreConfiguration,
IWindowManager windowManager,
IGreenshotLanguage greenshotLanguage,
+ InternetExplorerCaptureHelper internetExplorerCaptureHelper,
GreenshotResources greenshotResources,
Func> configViewModelFactory,
Func> aboutFormFactory,
- DestinationHolder destinationHolder) : base(greenshotLanguage)
+ DestinationHolder destinationHolder,
+ CaptureSupportInfo captureSupportInfo
+ ) : base(greenshotLanguage)
{
_coreConfiguration = coreConfiguration;
_windowManager = windowManager;
_greenshotLanguage = greenshotLanguage;
+ _internetExplorerCaptureHelper = internetExplorerCaptureHelper;
_configViewModelFactory = configViewModelFactory;
_aboutFormFactory = aboutFormFactory;
_destinationHolder = destinationHolder;
+ _captureSupportInfo = captureSupportInfo;
Instance = this;
}
@@ -281,7 +291,7 @@ namespace Greenshot.Forms
if (File.Exists(_coreConfiguration.OutputFileAsFullpath))
{
- CaptureHelper.CaptureFile(_coreConfiguration.OutputFileAsFullpath, _destinationHolder.SortedActiveDestinations.Find("Editor"));
+ CaptureHelper.CaptureFile(_captureSupportInfo, _coreConfiguration.OutputFileAsFullpath, _destinationHolder.SortedActiveDestinations.Find("Editor"));
}
break;
case ClickActions.OPEN_SETTINGS:
@@ -453,7 +463,7 @@ namespace Greenshot.Forms
if (File.Exists(openFileDialog.FileName))
{
- CaptureHelper.CaptureFile(openFileDialog.FileName);
+ CaptureHelper.CaptureFile(_captureSupportInfo, openFileDialog.FileName);
}
}
@@ -461,7 +471,7 @@ namespace Greenshot.Forms
{
if (_coreConfiguration.IECapture)
{
- CaptureHelper.CaptureIe(true, null);
+ CaptureHelper.CaptureIe(_captureSupportInfo, true, null);
}
}
@@ -480,7 +490,7 @@ namespace Greenshot.Forms
// IE context menu code
try
{
- if (_coreConfiguration.IECapture && IeCaptureHelper.IsIeRunning())
+ if (_coreConfiguration.IECapture && _internetExplorerCaptureHelper.IsIeRunning())
{
contextmenu_captureie.Enabled = true;
contextmenu_captureiefromlist.Enabled = true;
@@ -537,7 +547,7 @@ namespace Greenshot.Forms
}
try
{
- var tabs = IeCaptureHelper.GetBrowserTabs();
+ var tabs = _internetExplorerCaptureHelper.GetBrowserTabs();
contextmenu_captureiefromlist.DropDownItems.Clear();
if (tabs.Count > 0)
{
@@ -600,7 +610,7 @@ namespace Greenshot.Forms
var allScreensBounds = DisplayInfo.ScreenBounds;
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);
foreach (var displayInfo in DisplayInfo.AllDisplayInfos)
{
@@ -623,7 +633,7 @@ namespace Greenshot.Forms
deviceAlignment += " " + _greenshotLanguage.ContextmenuCapturefullscreenRight;
}
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);
}
}
@@ -666,7 +676,7 @@ namespace Greenshot.Forms
var window = captureWindowItem.Tag as IInteropWindow;
if (_thumbnailForm == null)
{
- _thumbnailForm = new ThumbnailForm();
+ _thumbnailForm = new ThumbnailForm(_coreConfiguration);
}
_thumbnailForm.ShowThumbnail(window, captureWindowItem.GetCurrentParent().TopLevelControl);
}
@@ -718,12 +728,12 @@ namespace Greenshot.Forms
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)
{
- BeginInvoke(new System.Action(() => CaptureHelper.CaptureClipboard()));
+ BeginInvoke(new System.Action(() => CaptureHelper.CaptureClipboard(_captureSupportInfo)));
}
private void OpenFileToolStripMenuItemClick(object sender, EventArgs e)
@@ -733,17 +743,17 @@ namespace Greenshot.Forms
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)
{
- BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureLastRegion(false); });
+ BeginInvoke((MethodInvoker) delegate { CaptureHelper.CaptureLastRegion(_captureSupportInfo, false); });
}
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)
@@ -754,7 +764,7 @@ namespace Greenshot.Forms
try
{
var windowToCapture = (InteropWindow) clickedItem.Tag;
- CaptureHelper.CaptureWindow(windowToCapture);
+ CaptureHelper.CaptureWindow(_captureSupportInfo, windowToCapture);
}
catch (Exception exception)
{
@@ -786,7 +796,7 @@ namespace Greenshot.Forms
}
try
{
- IeCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
+ _internetExplorerCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
}
catch (Exception exception)
{
@@ -794,7 +804,7 @@ namespace Greenshot.Forms
}
try
{
- CaptureHelper.CaptureIe(false, ieWindowToCapture);
+ CaptureHelper.CaptureIe(_captureSupportInfo, false, ieWindowToCapture);
}
catch (Exception exception)
{
@@ -912,7 +922,7 @@ namespace Greenshot.Forms
if (!_coreConfiguration.IsWriteProtected("Destinations"))
{
// screenshot destination
- selectList = new ToolStripMenuSelectList("destinations", true)
+ selectList = new ToolStripMenuSelectList(_coreConfiguration, "destinations", true)
{
Text = _greenshotLanguage.SettingsDestination
};
@@ -929,7 +939,7 @@ namespace Greenshot.Forms
if (!_coreConfiguration.IsWriteProtected("WindowCaptureMode"))
{
// Capture Modes
- selectList = new ToolStripMenuSelectList("capturemodes", false)
+ selectList = new ToolStripMenuSelectList(_coreConfiguration,"capturemodes", false)
{
Text = _greenshotLanguage.SettingsWindowCaptureMode
};
@@ -951,7 +961,7 @@ namespace Greenshot.Forms
}
// print options
- selectList = new ToolStripMenuSelectList("printoptions", true)
+ selectList = new ToolStripMenuSelectList(_coreConfiguration, "printoptions", true)
{
Text = _greenshotLanguage.SettingsPrintoptions
};
@@ -979,7 +989,7 @@ namespace Greenshot.Forms
}
// effects
- selectList = new ToolStripMenuSelectList("effects", true)
+ selectList = new ToolStripMenuSelectList(_coreConfiguration, "effects", true)
{
Text = _greenshotLanguage.SettingsVisualization
};
diff --git a/src/Greenshot/Forms/ToolStripMenuSelectList.cs b/src/Greenshot/Forms/ToolStripMenuSelectList.cs
index 38bfab424..d4812b86b 100644
--- a/src/Greenshot/Forms/ToolStripMenuSelectList.cs
+++ b/src/Greenshot/Forms/ToolStripMenuSelectList.cs
@@ -41,30 +41,28 @@ namespace Greenshot.Forms
///
public sealed class ToolStripMenuSelectList : ToolStripMenuItem
{
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
private static Image _defaultImage;
private readonly bool _multiCheckAllowed;
private bool _updateInProgress;
- public ToolStripMenuSelectList(object identifier, bool allowMultiCheck)
+ public ToolStripMenuSelectList(ICoreConfiguration coreConfig, object identifier, bool allowMultiCheck)
{
Identifier = identifier;
CheckOnClick = false;
_multiCheckAllowed = allowMultiCheck;
- if (_defaultImage == null || _defaultImage.Size != CoreConfig.IconSize)
+ if (_defaultImage == null || _defaultImage.Size != coreConfig.IconSize)
{
_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;
}
- 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)
{
}
diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj
index 6dab17b4e..fc8eccad6 100644
--- a/src/Greenshot/Greenshot.csproj
+++ b/src/Greenshot/Greenshot.csproj
@@ -9,6 +9,9 @@
greenshot.manifest
Greenshot
Greenshot
+
+ AnyCPU;x86
@@ -91,7 +94,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers
diff --git a/src/Greenshot/GreenshotAutofacModule.cs b/src/Greenshot/GreenshotAutofacModule.cs
index 006cbdd74..b7b071a89 100644
--- a/src/Greenshot/GreenshotAutofacModule.cs
+++ b/src/Greenshot/GreenshotAutofacModule.cs
@@ -32,11 +32,14 @@ using Dapplo.CaliburnMicro.Security;
using Dapplo.Config.Ini;
using Dapplo.Config.Language;
using Greenshot.Addons.Components;
+using Greenshot.Addons.Interfaces;
using Greenshot.Components;
using Greenshot.Configuration;
using Greenshot.Configuration.Impl;
using Greenshot.Forms;
using Greenshot.Helpers;
+using Greenshot.Helpers.Mapi;
+using Greenshot.Processors;
using Greenshot.Ui.Configuration.ViewModels;
using Greenshot.Ui.Misc.ViewModels;
using Greenshot.Ui.Notifications.ViewModels;
@@ -70,6 +73,16 @@ namespace Greenshot
.As()
.SingleInstance();
+ builder
+ .RegisterType()
+ .AsSelf()
+ .SingleInstance()
+ .OnActivated(args =>
+ {
+ // Workaround for static access in different helper classes and extensions
+ MapiMailMessage.CoreConfiguration = args.Instance.CoreConfiguration;
+ });
+
builder
.RegisterType()
.As()
@@ -134,6 +147,12 @@ namespace Greenshot
.AsSelf()
.SingleInstance();
+ // Processors
+ builder
+ .RegisterType()
+ .As()
+ .SingleInstance();
+
// Destinations
builder
.RegisterAssemblyTypes(ThisAssembly)
diff --git a/src/Greenshot/Helpers/CaptureHelper.cs b/src/Greenshot/Helpers/CaptureHelper.cs
index ab843da6f..0de2c87f6 100644
--- a/src/Greenshot/Helpers/CaptureHelper.cs
+++ b/src/Greenshot/Helpers/CaptureHelper.cs
@@ -61,10 +61,10 @@ namespace Greenshot.Helpers
public class CaptureHelper : IDisposable
{
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+ private readonly ICoreConfiguration _coreConfiguration;
private readonly bool _captureMouseCursor;
private ICapture _capture;
+ private readonly CaptureSupportInfo _captureSupportInfo;
private CaptureMode _captureMode;
private NativeRect _captureRect = NativeRect.Empty;
private ScreenCaptureMode _screenCaptureMode = ScreenCaptureMode.Auto;
@@ -74,8 +74,10 @@ namespace Greenshot.Helpers
private readonly DestinationHolder _destinationHolder;
private readonly IEnumerable _processors;
- public CaptureHelper(CaptureMode captureMode)
+ public CaptureHelper(CaptureSupportInfo captureSupportInfo, CaptureMode captureMode)
{
+ _captureSupportInfo = captureSupportInfo;
+ _coreConfiguration = captureSupportInfo.CoreConfiguration;
_captureMode = captureMode;
_capture = new Capture();
_destinationHolder = DestinationHolder.Instance;
@@ -83,18 +85,18 @@ namespace Greenshot.Helpers
_processors = Enumerable.Empty();
}
- public CaptureHelper(CaptureMode captureMode, bool captureMouseCursor) : this(captureMode)
+ public CaptureHelper(CaptureSupportInfo captureSupportInfo, CaptureMode captureMode, bool captureMouseCursor) : this(captureSupportInfo, captureMode)
{
_captureMouseCursor = captureMouseCursor;
}
- public CaptureHelper(CaptureMode captureMode, bool captureMouseCursor, ScreenCaptureMode screenCaptureMode) : this(captureMode)
+ public CaptureHelper(CaptureSupportInfo captureSupportInfo, CaptureMode captureMode, bool captureMouseCursor, ScreenCaptureMode screenCaptureMode) : this(captureSupportInfo, captureMode)
{
_captureMouseCursor = captureMouseCursor;
_screenCaptureMode = screenCaptureMode;
}
- public CaptureHelper(CaptureMode captureMode, bool captureMouseCursor, IDestination destination) : this(captureMode, captureMouseCursor)
+ public CaptureHelper(CaptureSupportInfo captureSupportInfo, CaptureMode captureMode, bool captureMouseCursor, IDestination destination) : this(captureSupportInfo, captureMode, captureMouseCursor)
{
if (destination != null)
{
@@ -132,106 +134,106 @@ namespace Greenshot.Helpers
SelectedCaptureWindow = null;
_capture = null;
// Empty working set after capturing
- if (CoreConfig.MinimizeWorkingSetSize)
+ if (_coreConfiguration.MinimizeWorkingSetSize)
{
PsApi.EmptyWorkingSet();
}
}
- public static void CaptureClipboard(IDestination destination = null)
+ public static void CaptureClipboard(CaptureSupportInfo captureSupportInfo, IDestination destination = null)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.Clipboard, false, destination))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.Clipboard, false, destination))
{
captureHelper.MakeCapture();
}
}
- public static void CaptureRegion(bool captureMouse, IDestination destination = null)
+ public static void CaptureRegion(CaptureSupportInfo captureSupportInfo, bool captureMouse, IDestination destination = null)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.Region, captureMouse, destination))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.Region, captureMouse, destination))
{
captureHelper.MakeCapture();
}
}
- public static void CaptureRegion(bool captureMouse, NativeRect region)
+ public static void CaptureRegion(CaptureSupportInfo captureSupportInfo, bool captureMouse, NativeRect region)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.Region, captureMouse))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.Region, captureMouse))
{
captureHelper.MakeCapture(region);
}
}
- public static void CaptureFullscreen(bool captureMouse, ScreenCaptureMode screenCaptureMode, IDestination destination = null)
+ public static void CaptureFullscreen(CaptureSupportInfo captureSupportInfo, bool captureMouse, ScreenCaptureMode screenCaptureMode, IDestination destination = null)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.FullScreen, captureMouse, destination))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.FullScreen, captureMouse, destination))
{
captureHelper._screenCaptureMode = screenCaptureMode;
captureHelper.MakeCapture();
}
}
- public static void CaptureLastRegion(bool captureMouse)
+ public static void CaptureLastRegion(CaptureSupportInfo captureSupportInfo, bool captureMouse)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.LastRegion, captureMouse))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.LastRegion, captureMouse))
{
captureHelper.MakeCapture();
}
}
- public static void CaptureIe(bool captureMouse, IInteropWindow windowToCapture)
+ public static void CaptureIe(CaptureSupportInfo captureSupportInfo, bool captureMouse, IInteropWindow windowToCapture)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.IE, captureMouse))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.IE, captureMouse))
{
captureHelper.SelectedCaptureWindow = windowToCapture;
captureHelper.MakeCapture();
}
}
- public static void CaptureWindow(bool captureMouse, IDestination destination = null)
+ public static void CaptureWindow(CaptureSupportInfo captureSupportInfo, bool captureMouse, IDestination destination = null)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.ActiveWindow, captureMouse, destination))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.ActiveWindow, captureMouse, destination))
{
captureHelper.MakeCapture();
}
}
- public static void CaptureWindow(IInteropWindow windowToCapture)
+ public static void CaptureWindow(CaptureSupportInfo captureSupportInfo, IInteropWindow windowToCapture)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.ActiveWindow))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.ActiveWindow))
{
captureHelper.SelectedCaptureWindow = windowToCapture;
captureHelper.MakeCapture();
}
}
- public static void CaptureWindowInteractive(bool captureMouse)
+ public static void CaptureWindowInteractive(CaptureSupportInfo captureSupportInfo, bool captureMouse)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.Window))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.Window))
{
captureHelper.MakeCapture();
}
}
- public static void CaptureFile(string filename)
+ public static void CaptureFile(CaptureSupportInfo captureSupportInfo, string filename)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.File))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.File))
{
captureHelper.MakeCapture(filename);
}
}
- public static void CaptureFile(string filename, IDestination destination)
+ public static void CaptureFile(CaptureSupportInfo captureSupportInfo, string filename, IDestination destination)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.File))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.File))
{
captureHelper.AddDestination(destination).MakeCapture(filename);
}
}
- public static void ImportCapture(ICapture captureToImport)
+ public static void ImportCapture(CaptureSupportInfo captureSupportInfo, ICapture captureToImport)
{
- using (var captureHelper = new CaptureHelper(CaptureMode.File))
+ using (var captureHelper = new CaptureHelper(captureSupportInfo, CaptureMode.File))
{
captureHelper._capture = captureToImport;
captureHelper.HandleCapture();
@@ -246,7 +248,7 @@ namespace Greenshot.Helpers
private void DoCaptureFeedback()
{
- if (CoreConfig.PlayCameraSound)
+ if (_coreConfiguration.PlayCameraSound)
{
SoundHelper.Play();
}
@@ -280,7 +282,7 @@ namespace Greenshot.Helpers
{
// This fixes a problem when a balloon is still visible and a capture needs to be taken
// forcefully removes the balloon!
- if (!CoreConfig.HideTrayicon)
+ if (!_coreConfiguration.HideTrayicon)
{
MainForm.Instance.NotifyIcon.Visible = false;
MainForm.Instance.NotifyIcon.Visible = true;
@@ -311,20 +313,20 @@ namespace Greenshot.Helpers
}
// Delay for the Context menu
- if (CoreConfig.CaptureDelay > 0)
+ if (_coreConfiguration.CaptureDelay > 0)
{
- Thread.Sleep(CoreConfig.CaptureDelay);
+ Thread.Sleep(_coreConfiguration.CaptureDelay);
}
else
{
- CoreConfig.CaptureDelay = 0;
+ _coreConfiguration.CaptureDelay = 0;
}
// Capture Mousecursor if we are not loading from file or clipboard, only show when needed
if (_captureMode != CaptureMode.File && _captureMode != CaptureMode.Clipboard)
{
_capture = WindowCapture.CaptureCursor(_capture);
- _capture.CursorVisible = _captureMouseCursor && CoreConfig.CaptureMousepointer;
+ _capture.CursorVisible = _captureMouseCursor && _coreConfiguration.CaptureMousepointer;
}
switch (_captureMode)
@@ -353,7 +355,7 @@ namespace Greenshot.Helpers
HandleCapture();
break;
case CaptureMode.IE:
- if (IeCaptureHelper.CaptureIe(_capture, SelectedCaptureWindow) != null)
+ if (_captureSupportInfo.InternetExplorerCaptureHelper.CaptureIe(_capture, SelectedCaptureWindow) != null)
{
_capture.CaptureDetails.AddMetaData("source", "Internet Explorer");
SetDpi();
@@ -380,9 +382,9 @@ namespace Greenshot.Helpers
}
break;
case ScreenCaptureMode.Fixed:
- if (CoreConfig.ScreenToCapture > 0 && CoreConfig.ScreenToCapture <= Screen.AllScreens.Length)
+ if (_coreConfiguration.ScreenToCapture > 0 && _coreConfiguration.ScreenToCapture <= Screen.AllScreens.Length)
{
- _capture = WindowCapture.CaptureRectangle(_capture, Screen.AllScreens[CoreConfig.ScreenToCapture].Bounds);
+ _capture = WindowCapture.CaptureRectangle(_capture, Screen.AllScreens[_coreConfiguration.ScreenToCapture].Bounds);
captureTaken = true;
}
break;
@@ -495,9 +497,9 @@ namespace Greenshot.Helpers
}
break;
case CaptureMode.LastRegion:
- if (!CoreConfig.LastCapturedRegion.IsEmpty)
+ if (!_coreConfiguration.LastCapturedRegion.IsEmpty)
{
- _capture = WindowCapture.CaptureRectangle(_capture, CoreConfig.LastCapturedRegion);
+ _capture = WindowCapture.CaptureRectangle(_capture, _coreConfiguration.LastCapturedRegion);
// Move cursor, fixing bug #3569703
_capture.MoveMouseLocation(_capture.ScreenBounds.Location.X - _capture.Location.X, _capture.ScreenBounds.Location.Y - _capture.Location.Y);
@@ -557,7 +559,7 @@ namespace Greenshot.Helpers
private void AddConfiguredDestination()
{
- foreach (var destinationDesignation in CoreConfig.OutputDestinations)
+ foreach (var destinationDesignation in _coreConfiguration.OutputDestinations)
{
var destination = _destinationHolder.SortedActiveDestinations.Find(destinationDesignation);
if (destination != null)
@@ -712,8 +714,8 @@ namespace Greenshot.Helpers
return false;
}
// Fix for Bug #3430560
- CoreConfig.LastCapturedRegion = SelectedCaptureWindow.GetInfo().Bounds;
- var returnValue = CaptureWindow(SelectedCaptureWindow, _capture, CoreConfig.WindowCaptureMode) != null;
+ _coreConfiguration.LastCapturedRegion = SelectedCaptureWindow.GetInfo().Bounds;
+ var returnValue = CaptureWindow(SelectedCaptureWindow, _capture, _coreConfiguration.WindowCaptureMode) != null;
return returnValue;
}
@@ -780,7 +782,7 @@ namespace Greenshot.Helpers
/// The capture to store the details
/// What WindowCaptureModes to use
/// ICapture
- public static ICapture CaptureWindow(IInteropWindow windowToCapture, ICapture captureForWindow, WindowCaptureModes windowCaptureMode)
+ public ICapture CaptureWindow(IInteropWindow windowToCapture, ICapture captureForWindow, WindowCaptureModes windowCaptureMode)
{
if (captureForWindow == null)
{
@@ -800,11 +802,11 @@ namespace Greenshot.Helpers
// 3) Otherwise use GDI (Screen might be also okay but might lose content)
if (isAutoMode)
{
- if (CoreConfig.IECapture && IeCaptureHelper.IsIeWindow(windowToCapture))
+ if (_coreConfiguration.IECapture && _captureSupportInfo.InternetExplorerCaptureHelper.IsIeWindow(windowToCapture))
{
try
{
- var ieCapture = IeCaptureHelper.CaptureIe(captureForWindow, windowToCapture);
+ var ieCapture = _captureSupportInfo.InternetExplorerCaptureHelper.CaptureIe(captureForWindow, windowToCapture);
if (ieCapture != null)
{
return ieCapture;
@@ -1030,7 +1032,7 @@ namespace Greenshot.Helpers
// }
//}
- using (var captureForm = new CaptureForm(CoreConfig, _capture, _windows))
+ using (var captureForm = new CaptureForm(_coreConfiguration, _capture, _windows, _captureSupportInfo.FormEnhancers))
{
// Make sure the form is hidden after showing, even if an exception occurs, so all errors will be shown
DialogResult result;
@@ -1084,7 +1086,7 @@ namespace Greenshot.Helpers
// save for re-capturing later and show recapture context menu option
// Important here is that the location needs to be offsetted back to screen coordinates!
var tmpRectangle = _captureRect.Offset(_capture.ScreenBounds.Location.X, _capture.ScreenBounds.Location.Y);
- CoreConfig.LastCapturedRegion = tmpRectangle;
+ _coreConfiguration.LastCapturedRegion = tmpRectangle;
HandleCapture();
}
}
diff --git a/src/Greenshot/Helpers/Mapi/InteropRecipientCollection.cs b/src/Greenshot/Helpers/Mapi/InteropRecipientCollection.cs
new file mode 100644
index 000000000..13eee0adf
--- /dev/null
+++ b/src/Greenshot/Helpers/Mapi/InteropRecipientCollection.cs
@@ -0,0 +1,114 @@
+#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 .
+
+#endregion
+
+#region Usings
+
+using System;
+using System.Runtime.InteropServices;
+
+#endregion
+
+namespace Greenshot.Helpers.Mapi
+{
+ ///
+ /// Struct which contains an interop representation of a colleciton of recipients.
+ ///
+ internal struct InteropRecipientCollection : IDisposable
+ {
+ #region Member Variables
+
+ private int _count;
+
+ #endregion Member Variables
+
+ #region Constructors
+
+ ///
+ /// Default constructor for creating InteropRecipientCollection.
+ ///
+ ///
+ public InteropRecipientCollection(RecipientCollection outer)
+ {
+ _count = outer.Count;
+
+ if (_count == 0)
+ {
+ Handle = IntPtr.Zero;
+ return;
+ }
+
+ // allocate enough memory to hold all recipients
+ var size = Marshal.SizeOf(typeof(MapiMailMessage.MapiHelperInterop.MapiRecipDesc));
+ Handle = Marshal.AllocHGlobal(_count * size);
+
+ // place all interop recipients into the memory just allocated
+ var ptr = Handle;
+ foreach (Recipient native in outer)
+ {
+ var interop = native.GetInteropRepresentation();
+
+ // stick it in the memory block
+ Marshal.StructureToPtr(interop, ptr, false);
+ ptr = new IntPtr(ptr.ToInt64() + size);
+ }
+ }
+
+ #endregion Costructors
+
+ #region Public Properties
+
+ public IntPtr Handle { get; private set; }
+
+ #endregion Public Properties
+
+ #region Public Methods
+
+ ///
+ /// Disposes of resources.
+ ///
+ public void Dispose()
+ {
+ if (Handle != IntPtr.Zero)
+ {
+ var type = typeof(MapiMailMessage.MapiHelperInterop.MapiRecipDesc);
+ var size = Marshal.SizeOf(type);
+
+ // destroy all the structures in the memory area
+ var ptr = Handle;
+ for (var i = 0; i < _count; i++)
+ {
+ Marshal.DestroyStructure(ptr, type);
+ ptr = new IntPtr(ptr.ToInt64() + size);
+ }
+
+ // free the memory
+ Marshal.FreeHGlobal(Handle);
+
+ Handle = IntPtr.Zero;
+ _count = 0;
+ }
+ }
+
+ #endregion Public Methods
+ }
+}
\ No newline at end of file
diff --git a/src/Greenshot/Helpers/MailHelper.cs b/src/Greenshot/Helpers/Mapi/MapiMailMessage.cs
similarity index 61%
rename from src/Greenshot/Helpers/MailHelper.cs
rename to src/Greenshot/Helpers/Mapi/MapiMailMessage.cs
index bb4cb0b32..f09b2bd1e 100644
--- a/src/Greenshot/Helpers/MailHelper.cs
+++ b/src/Greenshot/Helpers/Mapi/MapiMailMessage.cs
@@ -24,7 +24,6 @@
#region Usings
using System;
-using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
@@ -32,53 +31,30 @@ using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using Dapplo.Log;
-using Greenshot.Addons.Config.Impl;
using Greenshot.Addons.Core;
using Greenshot.Addons.Interfaces;
using Greenshot.Addons.Interfaces.Plugin;
#endregion
-namespace Greenshot.Helpers
+namespace Greenshot.Helpers.Mapi
{
- ///
- /// Author: Andrew Baker
- /// Datum: 10.03.2006
- /// Available from here
- ///
- ///
- /// Represents an email message to be sent through MAPI.
- ///
- public class MapiMailMessage : IDisposable
+ ///
+ /// Author: Andrew Baker
+ /// Datum: 10.03.2006
+ /// Available from here
+ ///
+ ///
+ /// Represents an email message to be sent through MAPI.
+ ///
+ public partial class MapiMailMessage : IDisposable
{
- #region Enums
-
- ///
- /// Specifies the valid RecipientTypes for a Recipient.
- ///
- public enum RecipientType
- {
- ///
- /// Recipient will be in the TO list.
- ///
- To = 1,
-
- ///
- /// Recipient will be in the CC list.
- ///
- CC = 2,
-
- ///
- /// Recipient will be in the BCC list.
- ///
- BCC = 3
- }
-
- #endregion Enums
-
private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration CoreConfig = new CoreConfigurationImpl();
+
+ ///
+ /// Set from DI via AddonsModule
+ ///
+ internal static ICoreConfiguration CoreConfiguration { get; set; }
#region Member Variables
@@ -96,17 +72,17 @@ namespace Greenshot.Helpers
using (var message = new MapiMailMessage(title, null))
{
message.Files.Add(fullPath);
- if (!string.IsNullOrEmpty(CoreConfig.MailApiTo))
+ if (!string.IsNullOrEmpty(CoreConfiguration.MailApiTo))
{
- message.Recipients.Add(new Recipient(CoreConfig.MailApiTo, RecipientType.To));
+ message.Recipients.Add(new Recipient(CoreConfiguration.MailApiTo, RecipientType.To));
}
- if (!string.IsNullOrEmpty(CoreConfig.MailApiCC))
+ if (!string.IsNullOrEmpty(CoreConfiguration.MailApiCC))
{
- message.Recipients.Add(new Recipient(CoreConfig.MailApiCC, RecipientType.CC));
+ message.Recipients.Add(new Recipient(CoreConfiguration.MailApiCC, RecipientType.CC));
}
- if (!string.IsNullOrEmpty(CoreConfig.MailApiBCC))
+ if (!string.IsNullOrEmpty(CoreConfiguration.MailApiBCC))
{
- message.Recipients.Add(new Recipient(CoreConfig.MailApiBCC, RecipientType.BCC));
+ message.Recipients.Add(new Recipient(CoreConfiguration.MailApiBCC, RecipientType.BCC));
}
message.ShowDialog();
}
@@ -120,7 +96,7 @@ namespace Greenshot.Helpers
/// ICaptureDetails
public static void SendImage(ISurface surface, ICaptureDetails captureDetails)
{
- var tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings());
+ var tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings(CoreConfiguration));
if (tmpFile != null)
{
@@ -550,242 +526,4 @@ namespace Greenshot.Helpers
#endregion Private Methods
}
-
- #region Public Recipient Class
-
- ///
- /// Represents a Recipient for a MapiMailMessage.
- ///
- public class Recipient
- {
- #region Internal Methods
-
- ///
- /// Returns an interop representation of a recepient.
- ///
- ///
- internal MapiMailMessage.MapiHelperInterop.MapiRecipDesc GetInteropRepresentation()
- {
- var interop = new MapiMailMessage.MapiHelperInterop.MapiRecipDesc();
-
- if (DisplayName == null)
- {
- interop.Name = Address;
- }
- else
- {
- interop.Name = DisplayName;
- interop.Address = Address;
- }
-
- interop.RecipientClass = (int) RecipientType;
-
- return interop;
- }
-
- #endregion Internal Methods
-
- #region Public Properties
-
- ///
- /// The email address of this recipient.
- ///
- public string Address;
-
- ///
- /// The display name of this recipient.
- ///
- public string DisplayName;
-
- ///
- /// How the recipient will receive this message (To, CC, BCC).
- ///
- public MapiMailMessage.RecipientType RecipientType = MapiMailMessage.RecipientType.To;
-
- #endregion Public Properties
-
- #region Constructors
-
- ///
- /// Creates a new recipient with the specified address.
- ///
- public Recipient(string address)
- {
- Address = address;
- }
-
- ///
- /// Creates a new recipient with the specified address and display name.
- ///
- public Recipient(string address, string displayName)
- {
- Address = address;
- DisplayName = displayName;
- }
-
- ///
- /// Creates a new recipient with the specified address and recipient type.
- ///
- public Recipient(string address, MapiMailMessage.RecipientType recipientType)
- {
- Address = address;
- RecipientType = recipientType;
- }
-
- ///
- /// Creates a new recipient with the specified address, display name and recipient type.
- ///
- public Recipient(string address, string displayName, MapiMailMessage.RecipientType recipientType)
- {
- Address = address;
- DisplayName = displayName;
- RecipientType = recipientType;
- }
-
- #endregion Constructors
- }
-
- #endregion Public Recipient Class
-
- #region Public RecipientCollection Class
-
- ///
- /// Represents a colleciton of recipients for a mail message.
- ///
- public class RecipientCollection : CollectionBase
- {
- ///
- /// Returns the recipient stored in this collection at the specified index.
- ///
- public Recipient this[int index] => (Recipient) List[index];
-
- ///
- /// Adds the specified recipient to this collection.
- ///
- public void Add(Recipient value)
- {
- List.Add(value);
- }
-
- ///
- /// Adds a new recipient with the specified address to this collection.
- ///
- public void Add(string address)
- {
- Add(new Recipient(address));
- }
-
- ///
- /// Adds a new recipient with the specified address and display name to this collection.
- ///
- public void Add(string address, string displayName)
- {
- Add(new Recipient(address, displayName));
- }
-
- ///
- /// Adds a new recipient with the specified address and recipient type to this collection.
- ///
- public void Add(string address, MapiMailMessage.RecipientType recipientType)
- {
- Add(new Recipient(address, recipientType));
- }
-
- ///
- /// Adds a new recipient with the specified address, display name and recipient type to this collection.
- ///
- public void Add(string address, string displayName, MapiMailMessage.RecipientType recipientType)
- {
- Add(new Recipient(address, displayName, recipientType));
- }
-
- internal InteropRecipientCollection GetInteropRepresentation()
- {
- return new InteropRecipientCollection(this);
- }
-
- ///
- /// Struct which contains an interop representation of a colleciton of recipients.
- ///
- internal struct InteropRecipientCollection : IDisposable
- {
- #region Member Variables
-
- private int _count;
-
- #endregion Member Variables
-
- #region Constructors
-
- ///
- /// Default constructor for creating InteropRecipientCollection.
- ///
- ///
- public InteropRecipientCollection(RecipientCollection outer)
- {
- _count = outer.Count;
-
- if (_count == 0)
- {
- Handle = IntPtr.Zero;
- return;
- }
-
- // allocate enough memory to hold all recipients
- var size = Marshal.SizeOf(typeof(MapiMailMessage.MapiHelperInterop.MapiRecipDesc));
- Handle = Marshal.AllocHGlobal(_count * size);
-
- // place all interop recipients into the memory just allocated
- var ptr = Handle;
- foreach (Recipient native in outer)
- {
- var interop = native.GetInteropRepresentation();
-
- // stick it in the memory block
- Marshal.StructureToPtr(interop, ptr, false);
- ptr = new IntPtr(ptr.ToInt64() + size);
- }
- }
-
- #endregion Costructors
-
- #region Public Properties
-
- public IntPtr Handle { get; private set; }
-
- #endregion Public Properties
-
- #region Public Methods
-
- ///
- /// Disposes of resources.
- ///
- public void Dispose()
- {
- if (Handle != IntPtr.Zero)
- {
- var type = typeof(MapiMailMessage.MapiHelperInterop.MapiRecipDesc);
- var size = Marshal.SizeOf(type);
-
- // destroy all the structures in the memory area
- var ptr = Handle;
- for (var i = 0; i < _count; i++)
- {
- Marshal.DestroyStructure(ptr, type);
- ptr = new IntPtr(ptr.ToInt64() + size);
- }
-
- // free the memory
- Marshal.FreeHGlobal(Handle);
-
- Handle = IntPtr.Zero;
- _count = 0;
- }
- }
-
- #endregion Public Methods
- }
- }
-
- #endregion Public RecipientCollection Class
}
\ No newline at end of file
diff --git a/src/Greenshot/Helpers/Mapi/Recipient.cs b/src/Greenshot/Helpers/Mapi/Recipient.cs
new file mode 100644
index 000000000..658b9c4c1
--- /dev/null
+++ b/src/Greenshot/Helpers/Mapi/Recipient.cs
@@ -0,0 +1,126 @@
+#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 .
+
+#endregion
+
+#region Usings
+
+
+#endregion
+
+namespace Greenshot.Helpers.Mapi
+{
+ #region Public Recipient Class
+
+ ///
+ /// Represents a Recipient for a MapiMailMessage.
+ ///
+ public class Recipient
+ {
+ #region Internal Methods
+
+ ///
+ /// Returns an interop representation of a recepient.
+ ///
+ ///
+ internal MapiMailMessage.MapiHelperInterop.MapiRecipDesc GetInteropRepresentation()
+ {
+ var interop = new MapiMailMessage.MapiHelperInterop.MapiRecipDesc();
+
+ if (DisplayName == null)
+ {
+ interop.Name = Address;
+ }
+ else
+ {
+ interop.Name = DisplayName;
+ interop.Address = Address;
+ }
+
+ interop.RecipientClass = (int) RecipientType;
+
+ return interop;
+ }
+
+ #endregion Internal Methods
+
+ #region Public Properties
+
+ ///
+ /// The email address of this recipient.
+ ///
+ public string Address;
+
+ ///
+ /// The display name of this recipient.
+ ///
+ public string DisplayName;
+
+ ///
+ /// How the recipient will receive this message (To, CC, BCC).
+ ///
+ public RecipientType RecipientType = RecipientType.To;
+
+ #endregion Public Properties
+
+ #region Constructors
+
+ ///
+ /// Creates a new recipient with the specified address.
+ ///
+ public Recipient(string address)
+ {
+ Address = address;
+ }
+
+ ///
+ /// Creates a new recipient with the specified address and display name.
+ ///
+ public Recipient(string address, string displayName)
+ {
+ Address = address;
+ DisplayName = displayName;
+ }
+
+ ///
+ /// Creates a new recipient with the specified address and recipient type.
+ ///
+ public Recipient(string address, RecipientType recipientType)
+ {
+ Address = address;
+ RecipientType = recipientType;
+ }
+
+ ///
+ /// Creates a new recipient with the specified address, display name and recipient type.
+ ///
+ public Recipient(string address, string displayName, RecipientType recipientType)
+ {
+ Address = address;
+ DisplayName = displayName;
+ RecipientType = recipientType;
+ }
+
+ #endregion Constructors
+ }
+
+ #endregion Public RecipientCollection Class
+}
\ No newline at end of file
diff --git a/src/Greenshot/Helpers/Mapi/RecipientCollection.cs b/src/Greenshot/Helpers/Mapi/RecipientCollection.cs
new file mode 100644
index 000000000..221db6536
--- /dev/null
+++ b/src/Greenshot/Helpers/Mapi/RecipientCollection.cs
@@ -0,0 +1,87 @@
+#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 .
+
+#endregion
+
+#region Usings
+
+using System.Collections;
+
+#endregion
+
+namespace Greenshot.Helpers.Mapi
+{
+ ///
+ /// Represents a colleciton of recipients for a mail message.
+ ///
+ public partial class RecipientCollection : CollectionBase
+ {
+ ///
+ /// Returns the recipient stored in this collection at the specified index.
+ ///
+ public Recipient this[int index] => (Recipient) List[index];
+
+ ///
+ /// Adds the specified recipient to this collection.
+ ///
+ public void Add(Recipient value)
+ {
+ List.Add(value);
+ }
+
+ ///
+ /// Adds a new recipient with the specified address to this collection.
+ ///
+ public void Add(string address)
+ {
+ Add(new Recipient(address));
+ }
+
+ ///
+ /// Adds a new recipient with the specified address and display name to this collection.
+ ///
+ public void Add(string address, string displayName)
+ {
+ Add(new Recipient(address, displayName));
+ }
+
+ ///
+ /// Adds a new recipient with the specified address and recipient type to this collection.
+ ///
+ public void Add(string address, RecipientType recipientType)
+ {
+ Add(new Recipient(address, recipientType));
+ }
+
+ ///
+ /// Adds a new recipient with the specified address, display name and recipient type to this collection.
+ ///
+ public void Add(string address, string displayName, RecipientType recipientType)
+ {
+ Add(new Recipient(address, displayName, recipientType));
+ }
+
+ internal InteropRecipientCollection GetInteropRepresentation()
+ {
+ return new InteropRecipientCollection(this);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Greenshot/Helpers/Mapi/RecipientType.cs b/src/Greenshot/Helpers/Mapi/RecipientType.cs
new file mode 100644
index 000000000..e387afc9f
--- /dev/null
+++ b/src/Greenshot/Helpers/Mapi/RecipientType.cs
@@ -0,0 +1,51 @@
+#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 .
+
+#endregion
+
+#region Usings
+
+
+#endregion
+
+namespace Greenshot.Helpers.Mapi
+{
+ ///
+ /// Specifies the valid RecipientTypes for a Recipient.
+ ///
+ public enum RecipientType
+ {
+ ///
+ /// Recipient will be in the TO list.
+ ///
+ To = 1,
+
+ ///
+ /// Recipient will be in the CC list.
+ ///
+ CC = 2,
+
+ ///
+ /// Recipient will be in the BCC list.
+ ///
+ BCC = 3
+ }
+}
\ No newline at end of file
diff --git a/src/Greenshot/Helpers/PrintHelper.cs b/src/Greenshot/Helpers/PrintHelper.cs
index fc14725f6..0b4126854 100644
--- a/src/Greenshot/Helpers/PrintHelper.cs
+++ b/src/Greenshot/Helpers/PrintHelper.cs
@@ -195,7 +195,7 @@ namespace Greenshot.Helpers
private void DrawImageForPrint(object sender, PrintPageEventArgs e)
{
// Create the output settins
- var printOutputSettings = new SurfaceOutputSettings(OutputFormats.png, 100, false);
+ var printOutputSettings = new SurfaceOutputSettings(_coreConfig, OutputFormats.png, 100, false);
ApplyEffects(printOutputSettings);
diff --git a/src/Greenshot/Processors/TitleFixProcessor.cs b/src/Greenshot/Processors/TitleFixProcessor.cs
index f6980cc97..1a6bd21ae 100644
--- a/src/Greenshot/Processors/TitleFixProcessor.cs
+++ b/src/Greenshot/Processors/TitleFixProcessor.cs
@@ -39,36 +39,12 @@ namespace Greenshot.Processors
///
public class TitleFixProcessor : AbstractProcessor
{
- private static readonly LogSource Log = new LogSource();
- // TODO: Solve, was static reference!
- private static readonly ICoreConfiguration config = new CoreConfigurationImpl();
+ private readonly ICoreConfiguration _coreConfiguration;
- public TitleFixProcessor()
+ public TitleFixProcessor(ICoreConfiguration coreConfiguration)
{
- var corruptKeys = new List();
- foreach (var key in config.ActiveTitleFixes)
- {
- if (config.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
- config.ActiveTitleFixes.Remove(corruptKey);
- config.TitleFixMatcher.Remove(corruptKey);
- config.TitleFixReplacer.Remove(corruptKey);
- }
- }
+ _coreConfiguration = coreConfiguration;
+ }
public override string Designation => "TitleFix";
@@ -81,10 +57,10 @@ namespace Greenshot.Processors
if (!string.IsNullOrEmpty(title))
{
title = title.Trim();
- foreach (var titleIdentifier in config.ActiveTitleFixes)
+ foreach (var titleIdentifier in _coreConfiguration.ActiveTitleFixes)
{
- var regexpString = config.TitleFixMatcher[titleIdentifier];
- var replaceString = config.TitleFixReplacer[titleIdentifier];
+ var regexpString = _coreConfiguration.TitleFixMatcher[titleIdentifier];
+ var replaceString = _coreConfiguration.TitleFixReplacer[titleIdentifier];
if (replaceString == null)
{
replaceString = "";
diff --git a/src/Greenshot/Startup.cs b/src/Greenshot/Startup.cs
index 75d6f1b55..33474b064 100644
--- a/src/Greenshot/Startup.cs
+++ b/src/Greenshot/Startup.cs
@@ -78,7 +78,7 @@ namespace Greenshot
#if !NETCOREAPP3_0
.WithoutCopyOfAssembliesToProbingPath()
#endif
- .WithAssemblyPatterns("Greenshot.Addon*")
+ .WithAssemblyPatterns("Greenshot.Addon.*")
.BuildApplicationConfig();
var application = new Dapplication(applicationConfig)