mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Some left over fixes for the move to Dapplo.Windows, also updated dependencies.
This commit is contained in:
parent
3f6f9863f8
commit
4c7494dd74
15 changed files with 208 additions and 80 deletions
|
@ -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>
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
28
src/Greenshot.Editor/Helpers/IDoubleProcessor.cs
Normal file
28
src/Greenshot.Editor/Helpers/IDoubleProcessor.cs
Normal 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);
|
||||
}
|
||||
}
|
28
src/Greenshot.Editor/Helpers/IHaveScaleOptions.cs
Normal file
28
src/Greenshot.Editor/Helpers/IHaveScaleOptions.cs
Normal 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();
|
||||
}
|
||||
}
|
39
src/Greenshot.Editor/Helpers/LineAngleRoundBehavior.cs
Normal file
39
src/Greenshot.Editor/Helpers/LineAngleRoundBehavior.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
src/Greenshot.Editor/Helpers/ScaleOptions.cs
Normal file
44
src/Greenshot.Editor/Helpers/ScaleOptions.cs
Normal 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
|
||||
}
|
||||
}
|
39
src/Greenshot.Editor/Helpers/ShapeAngleRoundBehavior.cs
Normal file
39
src/Greenshot.Editor/Helpers/ShapeAngleRoundBehavior.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue