Some left over fixes for the move to Dapplo.Windows, also updated dependencies.

This commit is contained in:
Robin Krom 2022-06-26 01:40:53 +02:00
commit 4c7494dd74
No known key found for this signature in database
GPG key ID: BCC01364F1371490
15 changed files with 208 additions and 80 deletions

View file

@ -46,7 +46,7 @@
</PropertyGroup>
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.255">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.107">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>

View file

@ -6,13 +6,13 @@
<ItemGroup>
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="1.0.18" />
<PackageReference Include="Dapplo.Windows.Clipboard" Version="1.0.25" />
<PackageReference Include="Dapplo.Windows.Dpi" Version="1.0.25" />
<PackageReference Include="Dapplo.Windows.Gdi32" Version="1.0.25" />
<PackageReference Include="Dapplo.Windows.Icons" Version="1.0.25" />
<PackageReference Include="Dapplo.Windows.Kernel32" Version="1.0.25" />
<PackageReference Include="Dapplo.Windows.Multimedia" Version="1.0.25" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.42" />
<PackageReference Include="Dapplo.Windows.Clipboard" Version="1.0.26" />
<PackageReference Include="Dapplo.Windows.Dpi" Version="1.0.26" />
<PackageReference Include="Dapplo.Windows.Gdi32" Version="1.0.26" />
<PackageReference Include="Dapplo.Windows.Icons" Version="1.0.26" />
<PackageReference Include="Dapplo.Windows.Kernel32" Version="1.0.26" />
<PackageReference Include="Dapplo.Windows.Multimedia" Version="1.0.26" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.43" />
<PackageReference Include="log4net" version="2.0.14" />
<PackageReference Include="Svg" Version="3.4.2" />
<Reference Include="Accessibility" />

View file

@ -100,8 +100,10 @@ namespace Greenshot.Editor.Drawing.Adorners
// reset "workbench" rectangle to current bounds
_boundsAfterResize = _boundsBeforeResize;
var scaleOptions = (Owner as IHaveScaleOptions)?.GetScaleOptions();
// calculate scaled rectangle
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, Position, new NativePointFloat(mouseEventArgs.X, mouseEventArgs.Y), scaleOptions);
// apply scaled bounds to this DrawableContainer
Owner.ApplyBounds(_boundsAfterResize);

View file

@ -248,7 +248,7 @@ namespace Greenshot.Editor.Drawing
_boundsBeforeResize.Left, _boundsBeforeResize.Top,
x - _boundsAfterResize.Left, y - _boundsAfterResize.Top);
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, Positions.TopLeft, x, y, GetAngleRoundProcessor());
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, x, y, GetAngleRoundProcessor());
break;
}
}

View file

@ -533,7 +533,8 @@ namespace Greenshot.Editor.Drawing
// reset "workbench" rectangle to current bounds
_boundsAfterResize = new NativeRectFloat(_boundsBeforeResize.Left, _boundsBeforeResize.Top, x - _boundsAfterResize.Left, y - _boundsAfterResize.Top);
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, Positions.TopLeft, x, y, GetAngleRoundProcessor());
var scaleOptions = (this as IHaveScaleOptions)?.GetScaleOptions();
_boundsAfterResize = ScaleHelper.Scale(_boundsAfterResize, x, y, GetAngleRoundProcessor(), scaleOptions);
// apply scaled bounds to this DrawableContainer
ApplyBounds(_boundsAfterResize);
@ -666,9 +667,9 @@ namespace Greenshot.Editor.Drawing
Height = points[1].Y - points[0].Y;
}
protected virtual ScaleHelper.IDoubleProcessor GetAngleRoundProcessor()
protected virtual IDoubleProcessor GetAngleRoundProcessor()
{
return ScaleHelper.ShapeAngleRoundBehavior.INSTANCE;
return ShapeAngleRoundBehavior.INSTANCE;
}
public virtual bool HasContextMenu => true;

View file

@ -115,9 +115,9 @@ namespace Greenshot.Editor.Drawing
return false;
}
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor()
protected override IDoubleProcessor GetAngleRoundProcessor()
{
return ScaleHelper.LineAngleRoundBehavior.INSTANCE;
return LineAngleRoundBehavior.INSTANCE;
}
}
}

View file

@ -0,0 +1,28 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://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 <https://www.gnu.org/licenses/>.
*/
namespace Greenshot.Editor.Helpers
{
public interface IDoubleProcessor
{
double Process(double d);
}
}

View file

@ -0,0 +1,28 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom, Francis Noel
*
* For more information see: https://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 <https://www.gnu.org/licenses/>.
*/
namespace Greenshot.Editor.Helpers
{
public interface IHaveScaleOptions
{
ScaleOptions GetScaleOptions();
}
}

View file

@ -0,0 +1,39 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://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 <https://www.gnu.org/licenses/>.
*/
using System;
namespace Greenshot.Editor.Helpers
{
public class LineAngleRoundBehavior : IDoubleProcessor
{
public static readonly LineAngleRoundBehavior INSTANCE = new();
private LineAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round(angle / 15) * 15;
}
}
}

View file

@ -33,25 +33,6 @@ namespace Greenshot.Editor.Helpers
/// </summary>
public static class ScaleHelper
{
[Flags]
public enum ScaleOptions
{
/// <summary>
/// Default scale behavior.
/// </summary>
Default = 0x00,
/// <summary>
/// Scale a rectangle in two our four directions, mirrored at it's center coordinates
/// </summary>
Centered = 0x01,
/// <summary>
/// Scale a rectangle maintaining it's aspect ratio
/// </summary>
Rational = 0x02
}
/// <summary>
/// calculates the Size an element must be resized to, in order to fit another element, keeping aspect ratio
/// </summary>
@ -231,18 +212,18 @@ namespace Greenshot.Editor.Helpers
/// Scale the boundsBeforeResize with the specified position and new location, using the angle angleRoundBehavior
/// </summary>
/// <param name="boundsBeforeResize">NativeRect</param>
/// <param name="gripperPosition">Positions</param>
/// <param name="cursorX">int</param>
/// <param name="cursorY">int</param>
/// <param name="angleRoundBehavior">IDoubleProcessor</param>
/// <param name="scaleOptions">ScaleOptions</param>
/// <returns>NativeRectFloat</returns>
public static NativeRectFloat Scale(NativeRect boundsBeforeResize, Positions gripperPosition, int cursorX, int cursorY, IDoubleProcessor angleRoundBehavior)
public static NativeRectFloat Scale(NativeRect boundsBeforeResize, int cursorX, int cursorY, IDoubleProcessor angleRoundBehavior, ScaleOptions? scaleOptions = null)
{
ScaleOptions opts = GetScaleOptions();
scaleOptions ??= GetScaleOptions();
NativeRectFloat result = boundsBeforeResize;
bool rationalScale = (opts & ScaleOptions.Rational) == ScaleOptions.Rational;
bool centeredScale = (opts & ScaleOptions.Centered) == ScaleOptions.Centered;
bool rationalScale = (scaleOptions & ScaleOptions.Rational) == ScaleOptions.Rational;
bool centeredScale = (scaleOptions & ScaleOptions.Centered) == ScaleOptions.Centered;
if (rationalScale)
{
@ -280,38 +261,5 @@ namespace Greenshot.Editor.Helpers
if (maintainAspectRatio) opts |= ScaleOptions.Rational;
return opts;
}
public interface IDoubleProcessor
{
double Process(double d);
}
public class ShapeAngleRoundBehavior : IDoubleProcessor
{
public static readonly ShapeAngleRoundBehavior INSTANCE = new();
private ShapeAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round((angle + 45) / 90) * 90 - 45;
}
}
public class LineAngleRoundBehavior : IDoubleProcessor
{
public static readonly LineAngleRoundBehavior INSTANCE = new();
private LineAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round(angle / 15) * 15;
}
}
}
}

View file

@ -0,0 +1,44 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://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 <https://www.gnu.org/licenses/>.
*/
using System;
namespace Greenshot.Editor.Helpers
{
[Flags]
public enum ScaleOptions
{
/// <summary>
/// Default scale behavior.
/// </summary>
Default = 0x00,
/// <summary>
/// Scale a rectangle in two our four directions, mirrored at it's center coordinates
/// </summary>
Centered = 0x01,
/// <summary>
/// Scale a rectangle maintaining it's aspect ratio
/// </summary>
Rational = 0x02
}
}

View file

@ -0,0 +1,39 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://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 <https://www.gnu.org/licenses/>.
*/
using System;
namespace Greenshot.Editor.Helpers
{
public class ShapeAngleRoundBehavior : IDoubleProcessor
{
public static readonly ShapeAngleRoundBehavior INSTANCE = new();
private ShapeAngleRoundBehavior()
{
}
public double Process(double angle)
{
return Math.Round((angle + 45) / 90) * 90 - 45;
}
}
}

View file

@ -78,23 +78,23 @@
</ItemGroup>
</Target>
<ItemGroup>
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0">
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0.2">
<EmbedInteropTypes>true</EmbedInteropTypes>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000">
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1001">
<EmbedInteropTypes>true</EmbedInteropTypes>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1003">
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1004">
<EmbedInteropTypes>true</EmbedInteropTypes>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1017">
<PackageReference Include="Microsoft.Office.Interop.PowerPoint" Version="15.0.4420.1018">
<EmbedInteropTypes>true</EmbedInteropTypes>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1003">
<PackageReference Include="Microsoft.Office.Interop.Word" Version="15.0.4797.1004">
<EmbedInteropTypes>true</EmbedInteropTypes>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>

View file

@ -11,8 +11,7 @@
<loadFromRemoteSources enabled="true" />
<relativeBindForResources enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Addons" />
<probing privatePath="App\Greenshot" />
<probing privatePath="Addons,App\Greenshot" />
</assemblyBinding>
</runtime>
</configuration>

View file

@ -17,7 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Tools.InnoSetup" version="6.2.0" GeneratePathProperty="true" />
<PackageReference Include="Tools.InnoSetup" version="6.2.1" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>