diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 26199bf03..c243b2d10 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,7 +15,7 @@ steps: - task: DotNetCoreInstaller@0 displayName: 'Install .NET Core SDK 3.0' inputs: - version: '3.0.100-preview6-012162' + version: '3.0.100-preview7-012279' - task: NuGetToolInstaller@0 displayName: 'Use NuGet 5.0.0' @@ -35,7 +35,7 @@ steps: command: 'publish' publishWebProjects: false projects: 'src\Greenshot\Greenshot.csproj' - arguments: '-f netcoreapp3.0 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:UseAppHost=true /p:RuntimeIdentifier=win-x64' + arguments: '-f netcoreapp3.0 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:RuntimeIdentifier=win-x64' zipAfterPublish: false - task: CmdLine@2 @@ -49,7 +49,7 @@ steps: command: 'publish' publishWebProjects: false projects: 'src\Greenshot\Greenshot.csproj' - arguments: '-f netcoreapp3.0 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:UseAppHost=true /p:RuntimeIdentifier=win-x86' + arguments: '-f netcoreapp3.0 -c Release /p:PublishSingleFile=true /p:PublishTrimmed=true /p:RuntimeIdentifier=win-x86' zipAfterPublish: false - task: CmdLine@2 diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 01d7c9ec3..2b5a36c42 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -14,10 +14,7 @@ 1.0.0 true true - $(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion@ProductName) - - true - true + win10-x64;win10-x86;win-x64;win-x86 true @@ -28,6 +25,16 @@ CS1591 + + + + + + + false + true + + false true @@ -53,19 +60,15 @@ True - - true - - all runtime; build; native; contentfiles; analyzers - + - + { surface.Elements.PullElementsToTop(this); surface.Elements.Invalidate(); }; menu.Items.Add(item); - item = new ToolStripMenuItem(editorLanguage.EditorUponelevel); + item = new ToolStripMenuItem(_editorLanguage.EditorUponelevel); item.Click += (sender, args) => { surface.Elements.PullElementsUp(this); @@ -434,14 +437,14 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { } // Push "down" if (push) { - item = new ToolStripMenuItem(editorLanguage.EditorDowntobottom); + item = new ToolStripMenuItem(_editorLanguage.EditorDowntobottom); item.Click += (sender, args) => { surface.Elements.PushElementsToBottom(this); surface.Elements.Invalidate(); }; menu.Items.Add(item); - item = new ToolStripMenuItem(editorLanguage.EditorDownonelevel); + item = new ToolStripMenuItem(_editorLanguage.EditorDownonelevel); item.Click += (sender, args) => { surface.Elements.PushElementsDown(this); @@ -451,7 +454,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { } // Duplicate - item = new ToolStripMenuItem(editorLanguage.EditorDuplicate); + item = new ToolStripMenuItem(_editorLanguage.EditorDuplicate); item.Click += (sender, args) => { IDrawableContainerList dcs = this.Clone(); @@ -464,7 +467,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { menu.Items.Add(item); // Copy - item = new ToolStripMenuItem(editorLanguage.EditorCopytoclipboard) + item = new ToolStripMenuItem(_editorLanguage.EditorCopytoclipboard) { Image = GreenshotResources.Instance.GetBitmap("copyToolStripMenuItem.Image", GetType()).NativeBitmap }; @@ -472,7 +475,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { menu.Items.Add(item); // Cut - item = new ToolStripMenuItem(editorLanguage.EditorCuttoclipboard) + item = new ToolStripMenuItem(_editorLanguage.EditorCuttoclipboard) { Image = GreenshotResources.Instance.GetBitmap("btnCut.Image", GetType()).NativeBitmap }; @@ -484,7 +487,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { menu.Items.Add(item); // Delete - item = new ToolStripMenuItem(editorLanguage.EditorDeleteelement) + item = new ToolStripMenuItem(_editorLanguage.EditorDeleteelement) { Image = GreenshotResources.Instance.GetBitmap("removeObjectToolStripMenuItem.Image", GetType()).NativeBitmap }; @@ -507,7 +510,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing { return; } - item = new ToolStripMenuItem(editorLanguage.EditorResetsize); + item = new ToolStripMenuItem(_editorLanguage.EditorResetsize); //item.Image = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image"))); item.Click += (sender, args) => { diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs index 1b7cd3786..d8cc5e067 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Fields/FieldAggregator.cs @@ -43,14 +43,14 @@ namespace Greenshot.Addon.LegacyEditor.Drawing.Fields private readonly IDrawableContainerList _boundContainers; private bool _internalUpdateRunning; - public FieldAggregator(ISurface parent, IEditorConfiguration editorConfiguration) : base(editorConfiguration) + public FieldAggregator(ISurface parent, IEditorConfiguration editorConfiguration, IEditorLanguage editorLanguage) : base(editorConfiguration) { foreach (var fieldType in FieldTypes.Values) { var field = new Field(fieldType, GetType()); AddField(field); } - _boundContainers = new DrawableContainerList + _boundContainers = new DrawableContainerList(editorLanguage) { Parent = parent }; diff --git a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs index f749a7384..853244b13 100644 --- a/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs +++ b/src/Greenshot.Addon.LegacyEditor/Drawing/Surface.cs @@ -63,6 +63,8 @@ namespace Greenshot.Addon.LegacyEditor.Drawing [NonSerialized] private readonly IEditorConfiguration _editorConfiguration; + private readonly IEditorLanguage _editorLanguage; + [NonSerialized] private readonly ICoreConfiguration _coreConfiguration; @@ -102,7 +104,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing private int _counterStart = 1; /// - /// the cropcontainer, when cropping this is set, do not serialize + /// the crop container, when cropping this is set, do not serialize /// [NonSerialized] private IDrawableContainer _cropContainer; @@ -219,14 +221,15 @@ namespace Greenshot.Addon.LegacyEditor.Drawing /// /// Base Surface constructor /// - public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration) + public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, IEditorLanguage editorLanguage) { _editorConfiguration = editorConfiguration; + _editorLanguage = editorLanguage; _coreConfiguration = coreConfiguration; - _fieldAggregator = new FieldAggregator(this, editorConfiguration); + _fieldAggregator = new FieldAggregator(this, editorConfiguration, editorLanguage); Count++; - _elements = new DrawableContainerList(Id); - _selectedElements = new DrawableContainerList(Id); + _elements = new DrawableContainerList(Id, _editorLanguage); + _selectedElements = new DrawableContainerList(Id, _editorLanguage); Log.Debug().WriteLine("Creating surface!"); MouseDown += SurfaceMouseDown; MouseUp += SurfaceMouseUp; @@ -255,7 +258,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing /// ICoreConfiguration /// IEditorConfiguration /// IBitmapWithNativeSupport - public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, IBitmapWithNativeSupport newBitmap) : this(coreConfiguration, editorConfiguration) + public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, IEditorLanguage editorLanguage, IBitmapWithNativeSupport newBitmap) : this(coreConfiguration, editorConfiguration, editorLanguage) { Log.Debug().WriteLine("Got Bitmap with dimensions {0} and format {1}", newBitmap.Size, newBitmap.PixelFormat); SetBitmap(newBitmap, true); @@ -267,7 +270,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing /// ICoreConfiguration /// IEditorConfiguration /// ICapture - public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, ICapture capture) : this(coreConfiguration, editorConfiguration) + public Surface(ICoreConfiguration coreConfiguration, IEditorConfiguration editorConfiguration, IEditorLanguage editorLanguage, ICapture capture) : this(coreConfiguration, editorConfiguration, editorLanguage) { SetCapture(capture); } @@ -665,7 +668,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing public void RemoveElements(IDrawableContainerList elementsToRemove, bool makeUndoable = true) { // fix potential issues with iterating a changing list - var cloned = new DrawableContainerList(); + var cloned = new DrawableContainerList(_editorLanguage); cloned.AddRange(elementsToRemove); if (makeUndoable) { @@ -724,7 +727,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing public void AddElements(IDrawableContainerList elementsToAdd, bool makeUndoable = true) { // fix potential issues with iterating a changing list - var cloned = new DrawableContainerList(); + var cloned = new DrawableContainerList(_editorLanguage); cloned.AddRange(elementsToAdd); if (makeUndoable) { @@ -1400,7 +1403,7 @@ namespace Greenshot.Addon.LegacyEditor.Drawing var rightClickedContainer = _elements.ClickableElementAt(_mouseStart.X, _mouseStart.Y); if (rightClickedContainer != null) { - selectedList = new DrawableContainerList(Id) {rightClickedContainer}; + selectedList = new DrawableContainerList(Id, _editorLanguage) {rightClickedContainer}; } } if (selectedList != null && selectedList.Count > 0) diff --git a/src/Greenshot.Addon.LegacyEditor/EditorAddonModule.cs b/src/Greenshot.Addon.LegacyEditor/EditorAddonModule.cs index 15a2a5e3a..f5b74f4ba 100644 --- a/src/Greenshot.Addon.LegacyEditor/EditorAddonModule.cs +++ b/src/Greenshot.Addon.LegacyEditor/EditorAddonModule.cs @@ -61,6 +61,7 @@ namespace Greenshot.Addon.LegacyEditor .RegisterType() .AsSelf() .SingleInstance(); + builder .RegisterType() .AsSelf(); diff --git a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj index aaa2e0fb9..908de6233 100644 --- a/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj +++ b/src/Greenshot.Addon.LegacyEditor/Greenshot.Addon.LegacyEditor.csproj @@ -111,7 +111,6 @@ - all runtime; build; native; contentfiles; analyzers diff --git a/src/Greenshot.Addon.LegacyEditor/Memento/DrawableContainerBoundsChangeMemento.cs b/src/Greenshot.Addon.LegacyEditor/Memento/DrawableContainerBoundsChangeMemento.cs index e245052fd..95d90ffd9 100644 --- a/src/Greenshot.Addon.LegacyEditor/Memento/DrawableContainerBoundsChangeMemento.cs +++ b/src/Greenshot.Addon.LegacyEditor/Memento/DrawableContainerBoundsChangeMemento.cs @@ -34,16 +34,18 @@ namespace Greenshot.Addon.LegacyEditor.Memento private readonly List _points = new List(); private readonly List _sizes = new List(); private IDrawableContainerList _listOfdrawableContainer; + private readonly IEditorLanguage _editorLanguage; - public DrawableContainerBoundsChangeMemento(IDrawableContainerList listOfdrawableContainer) + public DrawableContainerBoundsChangeMemento(IDrawableContainerList listOfdrawableContainer, IEditorLanguage editorLanguage) { _listOfdrawableContainer = listOfdrawableContainer; - StoreBounds(); + _editorLanguage = editorLanguage; + StoreBounds(); } public DrawableContainerBoundsChangeMemento(IDrawableContainer drawableContainer) { - _listOfdrawableContainer = new DrawableContainerList + _listOfdrawableContainer = new DrawableContainerList(_editorLanguage) { drawableContainer }; @@ -73,7 +75,7 @@ namespace Greenshot.Addon.LegacyEditor.Memento public IMemento Restore() { - var oldState = new DrawableContainerBoundsChangeMemento(_listOfdrawableContainer); + var oldState = new DrawableContainerBoundsChangeMemento(_listOfdrawableContainer, _editorLanguage); for (var index = 0; index < _listOfdrawableContainer.Count; index++) { var drawableContainer = _listOfdrawableContainer[index]; diff --git a/src/Greenshot.Addon.Win10/Win10AddonModule.cs b/src/Greenshot.Addon.Win10/Win10AddonModule.cs index dc8a81008..78ca41863 100644 --- a/src/Greenshot.Addon.Win10/Win10AddonModule.cs +++ b/src/Greenshot.Addon.Win10/Win10AddonModule.cs @@ -33,25 +33,31 @@ namespace Greenshot.Addon.Win10 /// protected override void Load(ContainerBuilder builder) { - if (WindowsVersion.IsWindows10OrLater) + if (!WindowsVersion.IsWindows10OrLater) { - builder - .RegisterType() - .As() - .SingleInstance(); - -#if !NETCOREAPP3_0 - builder - .RegisterType() - .As() - .SingleInstance(); -#endif - - builder - .RegisterType() - .As() - .SingleInstance(); + // Workaround: Remove the assembly out of the visibility of CaliburnMicro so we don't get an exception + builder.RegisterBuildCallback(container => + { + var assemblyResolver = container.Resolve(); + assemblyResolver.LoadedAssemblies.Remove(ThisAssembly.GetName().Name); + }); + return; } + + builder + .RegisterType() + .As() + .SingleInstance(); + + builder + .RegisterType() + .As() + .SingleInstance(); + + builder + .RegisterType() + .As() + .SingleInstance(); base.Load(builder); } } diff --git a/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs b/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs index 1e9b53568..4b0736053 100644 --- a/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs +++ b/src/Greenshot.Addon.Win10/Win10FormEnhancer.cs @@ -17,8 +17,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if !NETCOREAPP3_0 - using System; using System.Drawing; using System.Windows.Forms; @@ -90,5 +88,4 @@ namespace Greenshot.Addon.Win10 _inkToolbar.TargetInkCanvas = _inkCanvas; } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Greenshot.Addons/Greenshot.Addons.csproj b/src/Greenshot.Addons/Greenshot.Addons.csproj index fe923acc9..292dcb0fd 100644 --- a/src/Greenshot.Addons/Greenshot.Addons.csproj +++ b/src/Greenshot.Addons/Greenshot.Addons.csproj @@ -18,10 +18,10 @@ - - - - + + + + diff --git a/src/Greenshot.Gfx/Greenshot.Gfx.csproj b/src/Greenshot.Gfx/Greenshot.Gfx.csproj index 97a50a411..fbb179b94 100644 --- a/src/Greenshot.Gfx/Greenshot.Gfx.csproj +++ b/src/Greenshot.Gfx/Greenshot.Gfx.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/Greenshot.Tests/UpdateTests.cs b/src/Greenshot.Tests/UpdateTests.cs index 1157bd479..a298ac1fd 100644 --- a/src/Greenshot.Tests/UpdateTests.cs +++ b/src/Greenshot.Tests/UpdateTests.cs @@ -17,7 +17,6 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -#if !NETCOREAPP3_0 using System; using System.ServiceModel.Syndication; using System.Threading.Tasks; @@ -51,5 +50,4 @@ namespace Greenshot.Tests } } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/Greenshot/Greenshot.csproj b/src/Greenshot/Greenshot.csproj index 2349b5a19..ff898211a 100644 --- a/src/Greenshot/Greenshot.csproj +++ b/src/Greenshot/Greenshot.csproj @@ -9,8 +9,6 @@ greenshot.manifest Greenshot Greenshot - win-x64;win-x86 - AnyCPU;x64 @@ -36,11 +34,9 @@ - - - + @@ -48,22 +44,16 @@ all runtime; build; native; contentfiles; analyzers - + - - - - - - - + diff --git a/src/Greenshot/Startup.cs b/src/Greenshot/Startup.cs index 3d4363a3a..96479c434 100644 --- a/src/Greenshot/Startup.cs +++ b/src/Greenshot/Startup.cs @@ -72,9 +72,6 @@ namespace Greenshot .WithMutex("F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08") .WithCaliburnMicro() .WithoutCopyOfEmbeddedAssemblies() -#if !NETCOREAPP3_0 - .WithoutCopyOfAssembliesToProbingPath() -#endif .WithAssemblyPatterns("Greenshot.Addon.*") .BuildApplicationConfig(); @@ -93,7 +90,7 @@ namespace Greenshot return -1; } - //RegisterErrorHandlers(application); + RegisterErrorHandlers(application); application.Run(); return 0; @@ -118,28 +115,39 @@ namespace Greenshot /// Exception private static async void DisplayErrorViewModel(Dapplication application, Exception exception) { - var windowManager = application.Bootstrapper.Container?.Resolve(); - if (windowManager == null) + var log = new LogSource(); + log.Error().WriteLine(exception, "An error occured:", null); + try { - Debugger.Break(); - return; - } - using (var errorViewModel = application.Bootstrapper.Container.Resolve>()) - { - if (errorViewModel == null) + var windowManager = application.Bootstrapper.Container?.Resolve(); + if (windowManager == null) { + Debugger.Break(); return; } - errorViewModel.Value.SetExceptionToDisplay(exception); - if (!UiContext.HasUiAccess) + + using (var errorViewModel = application.Bootstrapper.Container.Resolve>()) { - await UiContext.RunOn(() => windowManager.ShowDialog(errorViewModel.Value)); - } - else - { - windowManager.ShowDialog(errorViewModel.Value); + if (errorViewModel == null) + { + return; + } + + errorViewModel.Value.SetExceptionToDisplay(exception); + if (!UiContext.HasUiAccess) + { + await UiContext.RunOn(() => windowManager.ShowDialog(errorViewModel.Value)); + } + else + { + windowManager.ShowDialog(errorViewModel.Value); + } } } + catch (Exception ex) + { + log.Error().WriteLine(ex, "An error occured while displaying the error:", null); + } } /// @@ -174,7 +182,6 @@ namespace Greenshot using (var multiInstanceForm = new DpiAwareForm { - // TODO: Fix a problem that in this case instance is null Icon = greenshotResources.GetGreenshotIcon(), ShowInTaskbar = true, MaximizeBox = false,