/* * Greenshot - a free and open source screenshot tool * Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom * * For more information see: http://getgreenshot.org/ * The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/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.Collections.Generic; using System.Drawing; using System.IO; using System.Windows.Forms; using GreenshotPlugin.Core; namespace Greenshot.Plugin { [Serializable] [AttributeUsageAttribute(AttributeTargets.Assembly, Inherited = false, AllowMultiple = false)] sealed public class PluginAttribute : Attribute, IComparable { public string Name { get; set; } public string CreatedBy { get; set; } public string Version { get; set; } public string EntryType { get; private set; } public bool Configurable { get; private set; } public string DllFile { get; set; } public PluginAttribute(string entryType, bool configurable) { this.EntryType = entryType; this.Configurable = configurable; } public int CompareTo(object obj) { PluginAttribute other = obj as PluginAttribute; if (other != null) { return Name.CompareTo(other.Name); } throw new ArgumentException("object is not a PluginAttribute"); } } // Delegates for hooking up events. public delegate void HotKeyHandler(); /// /// This interface is the GreenshotPluginHost, that which "Hosts" the plugin. /// For Greenshot this is implmented in the PluginHelper /// public interface IGreenshotHost { ContextMenuStrip MainMenu { get; } /// /// Saves the image to the supplied stream using the specified extension as the format /// /// The Image to save /// The Stream to save to /// The format to save with (png, jpg etc) /// Jpeg quality /// reduce the amount of colors to 256 void SaveToStream(Image image, Stream stream, OutputFormat format, int quality, bool reduceColors); /// /// Saves the image to a temp file (random name) using the specified outputformat /// /// The Image to save /// The format to save with (png, jpg etc) /// Jpeg quality /// reduce the amount of colors to 256 string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality, bool reduceColors); /// /// Saves the image to a temp file, but the name is build with the capture details & pattern /// /// The Image to save /// captureDetails with the information to build the filename /// The format to save with (png, jpg etc) /// Jpeg quality /// reduce the amount of colors to 256 string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality, bool reduceColors); /// /// Return a filename for the current image format (png,jpg etc) with the default file pattern /// that is specified in the configuration /// /// A string with the format /// The filename which should be used to save the image string GetFilename(OutputFormat format, ICaptureDetails captureDetails); /// /// Create a Thumbnail /// /// Image of which we need a Thumbnail /// Image with Thumbnail Image GetThumbnail(Image image, int width, int height); /// /// List of available plugins with their PluginAttributes /// This can be usefull for a plugin manager plugin... /// IDictionary Plugins { get; } /// /// Make region capture with specified Handler /// /// bool false if the mouse should not be captured, true if the configuration should be checked /// IDestination destination void CaptureRegion(bool captureMouseCursor, IDestination destination); /// /// Use the supplied capture, and handle it as if it's captured. /// /// ICapture to import void ImportCapture(ICapture captureToImport); /// /// Use the supplied image, and ICapture a capture object for it /// /// Image to create capture for /// ICapture ICapture GetCapture(Image imageToCapture); /// /// Get the core language object /// /// ILanguage for the Greenshot core ILanguage CoreLanguage { get; } } public interface IGreenshotPlugin { /// /// Is called after the plugin is instanciated, the Plugin should keep a copy of the host and pluginAttribute. /// /// The IPluginHost that will be hosting the plugin /// The PluginAttribute for the actual plugin /// true if plugin is initialized, false if not (doesn't show) bool Initialize(IGreenshotHost host, PluginAttribute pluginAttribute); /// /// Unload of the plugin /// void Shutdown(); /// /// Open the Configuration Form, will/should not be called before handshaking is done /// void Configure(); /// /// Return IDestination's, if the plugin wants to /// IEnumerable Destinations(); /// /// Return IProcessor's, if the plugin wants to /// IEnumerable Processors(); } }