/* * 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 . */ using System; using System.Drawing; using System.Drawing.Drawing2D; using System.IO; using System.Windows.Forms; using Dapplo.Windows.Common.Structs; using Greenshot.Base.Core; using Greenshot.Base.Effects; using Greenshot.Base.Interfaces.Drawing; namespace Greenshot.Base.Interfaces { /// /// The interface to the Surface object, so Plugins can use it. /// public interface ISurface : IDisposable { event SurfaceSizeChangeEventHandler SurfaceSizeChanged; event SurfaceMessageEventHandler SurfaceMessage; event SurfaceDrawingModeEventHandler DrawingModeChanged; event SurfaceElementEventHandler MovingElementChanged; event SurfaceForegroundColorEventHandler ForegroundColorChanged; event SurfaceBackgroundColorEventHandler BackgroundColorChanged; event SurfaceLineThicknessEventHandler LineThicknessChanged; event SurfaceShadowEventHandler ShadowChanged; /// /// Start value of the step-labels (counts) /// int CounterStart { get; set; } /// /// Unique ID of the Surface /// Guid ID { get; set; } IDrawableContainerList Elements { get; } /// /// Get/Set the image to the Surface /// get will give the image as is currently visible /// set will overwrite both the visible image as the underlying image /// /// important notice: /// The setter will clone the passed bitmap and dispose it when the Surface is disposed /// This means that the supplied image needs to be disposed by the calling code (if needed!) /// Image Image { get; set; } /// /// Get the current Image from the Editor for Exporting (save/upload etc) /// Don't forget to call image.Dispose() when finished!!! /// /// Bitmap Image GetImageForExport(); /// /// Add a TextContainer, at the given location, to the Surface. /// The TextContainer will be "re"sized to the text size. /// /// String to show /// Where to put the container, X coordinate in the Image coordinate space /// Where to put the container, Y coordinate in the Image coordinate space /// FontFamily /// Font Size in float /// bool true if italic /// bool true if bold /// bool true if shadow /// size of border (0 for none) /// Color of string /// Color of background (e.g. Color.Transparent) ITextContainer AddTextContainer(string text, int x, int y, FontFamily family, float size, bool italic, bool bold, bool shadow, int borderSize, Color color, Color fillColor); IImageContainer AddImageContainer(Image image, int x, int y); ICursorContainer AddCursorContainer(Cursor cursor, int x, int y); IIconContainer AddIconContainer(Icon icon, int x, int y); IImageContainer AddImageContainer(string filename, int x, int y); ICursorContainer AddCursorContainer(string filename, int x, int y); IIconContainer AddIconContainer(string filename, int x, int y); long SaveElementsToStream(Stream stream); void LoadElementsFromStream(Stream stream); /// /// Provides the selected elements /// IDrawableContainerList SelectedElements { get; } /// /// Is there an element selected on the surface? /// bool HasSelectedElements { get; } /// /// Remove all selected elements /// void RemoveSelectedElements(); /// /// Cut the selected elements to the clipboard /// void CutSelectedElements(); /// /// Copy the selected elements to the clipboard /// void CopySelectedElements(); /// /// Paste the elements from the clipboard /// void PasteElementFromClipboard(); /// /// Duplicate the selected elements /// void DuplicateSelectedElements(); /// /// Deselected the specified element /// void DeselectElement(IDrawableContainer container, bool generateEvents = true); /// /// Deselected all elements /// void DeselectAllElements(); /// /// Add an element to the surface /// /// IDrawableContainerList /// Should it be placed on the undo stack? void AddElements(IDrawableContainerList elements, bool makeUndoable = true); void RemoveElements(IDrawableContainerList elements, bool makeUndoable = true); void SelectElements(IDrawableContainerList elements); /// /// Add an element to the surface /// /// IDrawableContainer /// Should it be placed on the undo stack? /// Should it be invalidated (draw) void AddElement(IDrawableContainer element, bool makeUndoable = true, bool invalidate = true); /// /// Select the supplied container /// /// IDrawableContainer /// false to skip invalidation /// false to skip event generation void SelectElement(IDrawableContainer container, bool invalidate = true, bool generateEvents = true); /// /// Is the supplied container "on" the surface? /// /// /// This returns false if the container is deleted but still in the undo stack bool IsOnSurface(IDrawableContainer container); void Invalidate(); /// /// Invalidates the specified region of the Surface. /// Takes care of the Surface zoom level, accepts rectangle in the coordinate space of the Image. /// /// NativeRect Bounding rectangle for updated elements, in the coordinate space of the Image. void InvalidateElements(NativeRect rectangleToInvalidate); bool Modified { get; set; } string LastSaveFullPath { get; set; } string UploadUrl { get; set; } /// /// Remove an element of the elements list /// /// Element to remove /// flag specifying if the remove needs to be undoable /// flag specifying if an surface invalidate needs to be called /// flag specifying if the deselect needs to generate an event void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable = true, bool invalidate = true, bool generateEvents = true); void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message); void ApplyBitmapEffect(IEffect effect); void RemoveCursor(); bool HasCursor { get; } ICaptureDetails CaptureDetails { get; set; } /// /// Zoom value applied to the surface. /// Fraction ZoomFactor { get; set; } /// /// Translate a point from image coordinate space to surface coordinate space. /// /// A point in the coordinate space of the image. NativePoint ToSurfaceCoordinates(NativePoint point); /// /// Translate a rectangle from image coordinate space to surface coordinate space. /// /// NativeRect in the coordinate space of the image. NativeRect ToSurfaceCoordinates(NativeRect rc); /// /// Translate a point from surface coordinate space to image coordinate space. /// /// NativePoint in the coordinate space of the surface. NativePoint ToImageCoordinates(NativePoint point); /// /// Translate a NativeRect from surface coordinate space to image coordinate space. /// /// NativeRect in the coordinate space of the surface. NativeRect ToImageCoordinates(NativeRect rc); /// /// Make it possible to undo the specified IMemento /// /// IMemento /// bool to specify if the action can be merged, e.g. we do not want an undo for every part of a resize void MakeUndoable(IMemento memento, bool allowMerge); /// /// The IFieldAggregator /// IFieldAggregator FieldAggregator { get; } /// /// This reverses a change of the background image /// /// Image /// Matrix void UndoBackgroundChange(Image previous, Matrix matrix); } }