mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -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>
|
/// <summary>
|
||||||
/// Handle the drag/drop
|
/// Handle the drag/drop
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -929,6 +950,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
{
|
{
|
||||||
drawableContainer.Left = Location.X;
|
drawableContainer.Left = Location.X;
|
||||||
drawableContainer.Top = Location.Y;
|
drawableContainer.Top = Location.Y;
|
||||||
|
FitContainer(drawableContainer);
|
||||||
AddElement(drawableContainer);
|
AddElement(drawableContainer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -939,6 +961,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
{
|
{
|
||||||
drawableContainer.Left = mouse.X;
|
drawableContainer.Left = mouse.X;
|
||||||
drawableContainer.Top = mouse.Y;
|
drawableContainer.Top = mouse.Y;
|
||||||
|
FitContainer(drawableContainer);
|
||||||
AddElement(drawableContainer);
|
AddElement(drawableContainer);
|
||||||
mouse.Offset(10, 10);
|
mouse.Offset(10, 10);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue