mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 22:13:23 -07:00
Added logic to fit any images being placed on the canvas, this is not perfect yet.
This commit is contained in:
parent
baad75aacc
commit
7a47b4f6ff
1 changed files with 23 additions and 0 deletions
|
@ -910,6 +910,27 @@ namespace Greenshot.Editor.Drawing
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will help to fit the container to the surface
|
||||
/// </summary>
|
||||
/// <param name="drawableContainer">IDrawableContainer</param>
|
||||
private void FitContainer(IDrawableContainer drawableContainer)
|
||||
{
|
||||
double factor = 1;
|
||||
if (drawableContainer.Width > this.Width)
|
||||
{
|
||||
factor = drawableContainer.Width / (double)Width;
|
||||
}
|
||||
if (drawableContainer.Height > this.Height)
|
||||
{
|
||||
var otherFactor = drawableContainer.Height / (double)Height;
|
||||
factor = Math.Max(factor, otherFactor);
|
||||
}
|
||||
|
||||
drawableContainer.Width = (int)(drawableContainer.Width / factor);
|
||||
drawableContainer.Height = (int)(drawableContainer.Height / factor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handle the drag/drop
|
||||
/// </summary>
|
||||
|
@ -929,6 +950,7 @@ namespace Greenshot.Editor.Drawing
|
|||
{
|
||||
drawableContainer.Left = Location.X;
|
||||
drawableContainer.Top = Location.Y;
|
||||
FitContainer(drawableContainer);
|
||||
AddElement(drawableContainer);
|
||||
return;
|
||||
}
|
||||
|
@ -939,6 +961,7 @@ namespace Greenshot.Editor.Drawing
|
|||
{
|
||||
drawableContainer.Left = mouse.X;
|
||||
drawableContainer.Top = mouse.Y;
|
||||
FitContainer(drawableContainer);
|
||||
AddElement(drawableContainer);
|
||||
mouse.Offset(10, 10);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue