mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -07:00
allow surface to be resized
(cherry picked from commit b936c1004d542c5033c4a721f412588c316a1134)
This commit is contained in:
parent
2b3685e08d
commit
547e02d868
4 changed files with 60 additions and 0 deletions
|
@ -40,6 +40,7 @@ namespace Greenshot.Base.Interfaces
|
||||||
event SurfaceMessageEventHandler SurfaceMessage;
|
event SurfaceMessageEventHandler SurfaceMessage;
|
||||||
event SurfaceDrawingModeEventHandler DrawingModeChanged;
|
event SurfaceDrawingModeEventHandler DrawingModeChanged;
|
||||||
event SurfaceElementEventHandler MovingElementChanged;
|
event SurfaceElementEventHandler MovingElementChanged;
|
||||||
|
event SurfaceExpandedEventHandler SurfaceExpanded;
|
||||||
event SurfaceForegroundColorEventHandler ForegroundColorChanged;
|
event SurfaceForegroundColorEventHandler ForegroundColorChanged;
|
||||||
event SurfaceBackgroundColorEventHandler BackgroundColorChanged;
|
event SurfaceBackgroundColorEventHandler BackgroundColorChanged;
|
||||||
event SurfaceLineThicknessEventHandler LineThicknessChanged;
|
event SurfaceLineThicknessEventHandler LineThicknessChanged;
|
||||||
|
@ -203,6 +204,7 @@ namespace Greenshot.Base.Interfaces
|
||||||
void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable = true, bool invalidate = true, bool generateEvents = true);
|
void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable = true, bool invalidate = true, bool generateEvents = true);
|
||||||
|
|
||||||
void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message);
|
void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message);
|
||||||
|
void ResizeCanvas(int left, int right, int top, int bottom);
|
||||||
void ApplyBitmapEffect(IEffect effect);
|
void ApplyBitmapEffect(IEffect effect);
|
||||||
void RemoveCursor();
|
void RemoveCursor();
|
||||||
bool HasCursor { get; }
|
bool HasCursor { get; }
|
||||||
|
|
27
src/Greenshot.Base/Interfaces/SurfaceExpandedEventHandler.cs
Normal file
27
src/Greenshot.Base/Interfaces/SurfaceExpandedEventHandler.cs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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.Base.Interfaces
|
||||||
|
{
|
||||||
|
public delegate void SurfaceExpandedEventHandler(object sender, EventArgs e);
|
||||||
|
}
|
|
@ -105,6 +105,14 @@ namespace Greenshot.Editor.Drawing
|
||||||
remove => _surfaceSizeChanged -= value;
|
remove => _surfaceSizeChanged -= value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NonSerialized] private SurfaceExpandedEventHandler _surfaceExpanded;
|
||||||
|
|
||||||
|
public event SurfaceExpandedEventHandler SurfaceExpanded
|
||||||
|
{
|
||||||
|
add => _surfaceExpanded += value;
|
||||||
|
remove => _surfaceExpanded -= value;
|
||||||
|
}
|
||||||
|
|
||||||
[NonSerialized] private SurfaceMessageEventHandler _surfaceMessage;
|
[NonSerialized] private SurfaceMessageEventHandler _surfaceMessage;
|
||||||
|
|
||||||
public event SurfaceMessageEventHandler SurfaceMessage
|
public event SurfaceMessageEventHandler SurfaceMessage
|
||||||
|
@ -1032,6 +1040,20 @@ namespace Greenshot.Editor.Drawing
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set the canvas to a new size using the given bounds.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="left"></param>
|
||||||
|
/// <param name="right"></param>
|
||||||
|
/// <param name="top"></param>
|
||||||
|
/// <param name="bottom"></param>
|
||||||
|
public void ResizeCanvas(int left, int right, int top, int bottom)
|
||||||
|
{
|
||||||
|
var resizeEffect = new ResizeCanvasEffect(left, right, top, bottom);
|
||||||
|
ApplyBitmapEffect(resizeEffect);
|
||||||
|
_surfaceExpanded(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply a bitmap effect to the surface
|
/// Apply a bitmap effect to the surface
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -246,6 +246,7 @@ namespace Greenshot.Editor.Forms
|
||||||
_surface.MovingElementChanged += delegate { RefreshEditorControls(); };
|
_surface.MovingElementChanged += delegate { RefreshEditorControls(); };
|
||||||
_surface.DrawingModeChanged += Surface_DrawingModeChanged;
|
_surface.DrawingModeChanged += Surface_DrawingModeChanged;
|
||||||
_surface.SurfaceSizeChanged += SurfaceSizeChanged;
|
_surface.SurfaceSizeChanged += SurfaceSizeChanged;
|
||||||
|
_surface.SurfaceExpanded += SurfaceExpanded;
|
||||||
_surface.SurfaceMessage += SurfaceMessageReceived;
|
_surface.SurfaceMessage += SurfaceMessageReceived;
|
||||||
_surface.ForegroundColorChanged += ForegroundColorChanged;
|
_surface.ForegroundColorChanged += ForegroundColorChanged;
|
||||||
_surface.BackgroundColorChanged += BackgroundColorChanged;
|
_surface.BackgroundColorChanged += BackgroundColorChanged;
|
||||||
|
@ -566,6 +567,14 @@ namespace Greenshot.Editor.Forms
|
||||||
AlignCanvasPositionAfterResize();
|
AlignCanvasPositionAfterResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Used when expanding the surface in one direction to accomodate shifting an object to one side.
|
||||||
|
/// </summary>
|
||||||
|
private void SurfaceExpanded(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
UpdateUndoRedoSurfaceDependencies();
|
||||||
|
}
|
||||||
|
|
||||||
public ISurface Surface
|
public ISurface Surface
|
||||||
{
|
{
|
||||||
get { return _surface; }
|
get { return _surface; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue