Moving back to trunk!

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1602 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-01-24 19:24:36 +00:00
commit 8d458998a1
332 changed files with 17647 additions and 9466 deletions

View file

@ -21,71 +21,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Plugin {
/// <summary>
/// The capture mode for Greenshot
/// </summary>
public enum CaptureMode { None, Region, FullScreen, ActiveWindow, Window, LastRegion, Clipboard, File, IE };
/// <summary>
/// The destinations for the capture, these will be set during capture and can be modified by plugins
/// </summary>
public enum CaptureDestination {File, FileWithDialog, Clipboard, Printer, Editor, EMail};
public enum CaptureMode { None, Region, FullScreen, ActiveWindow, Window, LastRegion, Clipboard, File, IE, Video, Import };
/// <summary>
/// Handler for the MakeCapture in ICaptureHost
/// </summary>
public delegate void CaptureHandler(object sender, CaptureTakenEventArgs e);
/// <summary>
/// The ICaptureHost is more or less the Interface that "Greenshot" itself implements (the MainForm)
/// over this Interface it is possible to register to the main ContextMenu or pass a Bitmap for processing
/// </summary>
public interface ICaptureHost {
/// <summary>
/// Process a bitmap like it was captured
/// </summary>
void HandleCapture(Bitmap bitmap);
/// <summary>
/// Make Capture with default destinations
/// </summary>
/// <param name="mode">CaptureMode</param>
/// <param name="captureMouseCursor">bool false if the mouse should not be captured, true if the configuration should be checked</param>
void MakeCapture(CaptureMode mode, bool captureMouseCursor);
/// <summary>
/// Make Capture with specified destinations
/// </summary>
/// <param name="mode">CaptureMode</param>
/// <param name="captureMouseCursor">bool false if the mouse should not be captured, true if the configuration should be checked</param>
/// <param name="captureDestinations">List<CaptureDestination> with destinations</param>
void MakeCapture(CaptureMode mode, bool captureMouseCursor, List<CaptureDestination> captureDestinations);
/// <summary>
/// Make Capture with specified Handler
/// </summary>
/// <param name="mode"></param>
/// <param name="captureMouseCursor">bool false if the mouse should not be captured, true if the configuration should be checked</param>
/// <param name="captureHandler">CaptureHandler delegate</param>
void MakeCapture(CaptureMode mode, bool captureMouseCursor, CaptureHandler captureHandler);
/// <summary>
/// Make capture of window
/// </summary>
/// <param name="window">WindowDetails of the window to capture</param>
//void MakeCapture(WindowDetails window);
/// <summary>
/// Make capture of window
/// </summary>
/// <param name="window">WindowDetails of the window to capture</param>
/// <param name="captureMouseCursor">bool false if the mouse should not be captured, true if the configuration should be checked</param>
//void MakeCapture(WindowDetails window, CaptureHandler captureHandler);
}
/// <summary>
/// Details for the capture, like the window title and date/time etc.
/// </summary>
@ -104,7 +46,7 @@ namespace Greenshot.Plugin {
set;
}
List<CaptureDestination> CaptureDestinations {
List<IDestination> CaptureDestinations {
get;
set;
}
@ -121,13 +63,9 @@ namespace Greenshot.Plugin {
void AddMetaData(string key, string value);
void ClearDestinations();
void RemoveDestination(CaptureDestination captureDestination);
void AddDestination(CaptureDestination captureDestination);
CaptureHandler CaptureHandler {
get;
set;
}
void RemoveDestination(IDestination captureDestination);
void AddDestination(IDestination captureDestination);
bool HasDestination(string designation);
CaptureMode CaptureMode {
get;
@ -144,6 +82,23 @@ namespace Greenshot.Plugin {
}
}
public interface ICaptureElement {
List<ICaptureElement> Children {
get;
set;
}
Rectangle Bounds {
get;
set;
}
string Name {
get;
set;
}
ICaptureElement FindElementUnderPoint(Point p);
}
/// <summary>
/// The interface to the Capture object, so Plugins can use it.
/// </summary>
@ -193,12 +148,32 @@ namespace Greenshot.Plugin {
bool Crop(Rectangle cropRectangle);
/// <summary>
/// Apply a translate to the mouse location.
/// e.g. needed for crop
/// Apply a translate to the mouse location. e.g. needed for crop
/// </summary>
/// <param name="x">x coordinates to move the mouse</param>
/// <param name="y">y coordinates to move the mouse</param>
void MoveMouseLocation(int x, int y);
/// <summary>
/// Apply a translate to the elements e.g. needed for crop
/// </summary>
/// <param name="x">x coordinates to move the elements</param>
/// <param name="y">y coordinates to move the elements</param>
void MoveElements(int x, int y);
/// <summary>
/// Add a new element to the capture
/// </summary>
/// <param name="element">Rectangle</param>
void AddElement(ICaptureElement element);
/// <summary>
/// Returns a list of rectangles which represent objects that are "on" the capture
/// </summary>
List<ICaptureElement> Elements {
get;
set;
}
}
}

View file

@ -21,11 +21,8 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using Greenshot.Plugin;
namespace Greenshot.Plugin.Drawing {
public enum RenderMode {EDIT, EXPORT};
public enum EditStatus {UNDRAWN, DRAWING, MOVING, RESIZING, IDLE};
@ -59,6 +56,14 @@ namespace Greenshot.Plugin.Drawing {
set;
}
Point Location {
get;
}
Size Size {
get;
}
Rectangle Bounds {
get;
}

View file

@ -32,10 +32,37 @@ namespace Greenshot.Plugin {
//public enum HorizontalAlignment {LEFT, CENTER, RIGHT};
public enum VerticalAlignment {TOP, CENTER, BOTTOM};
public enum SurfaceMessageTyp {
FileSaved,
Error,
Info
}
public class SurfaceMessageEventArgs : EventArgs {
public SurfaceMessageTyp MessageType {
get;
set;
}
public string Message {
get;
set;
}
public ISurface Surface {
get;
set;
}
}
public delegate void SurfaceSizeChangeEventHandler(object source);
public delegate void SurfaceMessageEventHandler(object source, SurfaceMessageEventArgs eventArgs);
/// <summary>
/// The interface to the Surface object, so Plugins can use it.
/// </summary>
public interface ISurface {
public interface ISurface : IDisposable {
event SurfaceSizeChangeEventHandler SurfaceSizeChanged;
event SurfaceMessageEventHandler SurfaceMessage;
/// <summary>
/// Get/Set the image to the Surface
/// get will give the image as is currently visible
@ -98,5 +125,10 @@ namespace Greenshot.Plugin {
get;
set;
}
string LastSaveFullPath {
get;
set;
}
void SendMessageEvent(object source, SurfaceMessageTyp messageType, string message);
}
}

View file

@ -0,0 +1,100 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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 <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Plugin {
/// <summary>
/// Description of IDestination.
/// </summary>
public interface IDestination : IDisposable, IComparable {
/// <summary>
/// Simple "designation" like "File", "Editor" etc, used to store the configuration
/// </summary>
string Designation {
get;
}
/// <summary>
/// Description which will be shown in the settings form, destination picker etc
/// </summary>
string Description {
get;
}
/// <summary>
/// Priority, used for sorting
/// </summary>
int Priority {
get;
}
/// <summary>
/// Gets an icon for the destination
/// </summary>
Image DisplayIcon {
get;
}
/// <summary>
/// Returns if the destination is active
/// </summary>
bool isActive {
get;
}
/// <summary>
/// Return a menu item
/// </summary>
/// <param name="destinationClickHandler"></param>
/// <returns>ToolStripMenuItem</returns>
ToolStripMenuItem GetMenuItem(EventHandler destinationClickHandler);
/// <summary>
/// Gets the ShortcutKeys for the Editor
/// </summary>
Keys EditorShortcutKeys {
get;
}
/// <summary>
/// Gets the dynamic destinations
/// </summary>
IEnumerable<IDestination> DynamicDestinations();
/// <summary>
/// Returns true if this destination can be dynamic
/// </summary>
bool isDynamic {
get;
}
/// <summary>
/// If a capture is made, and the destination is enabled, this method is called.
/// </summary>
/// <param name="surface"></param>
/// <param name="captureDetails"></param>
/// <returns>true if the destination has "exported" the capture</returns>
bool ExportCapture(ISurface surface, ICaptureDetails captureDetails);
}
}

View file

@ -0,0 +1,67 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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 <http://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Plugin {
/// <summary>
/// Description of IProcessor.
/// </summary>
public interface IProcessor : IDisposable, IComparable {
/// <summary>
/// Simple "designation" like "FixTitle"
/// </summary>
string Designation {
get;
}
/// <summary>
/// Description which will be shown in the settings form, destination picker etc
/// </summary>
string Description {
get;
}
/// <summary>
/// Priority, used for sorting
/// </summary>
int Priority {
get;
}
/// <summary>
/// Returns if the destination is active
/// </summary>
bool isActive {
get;
}
/// <summary>
/// If a capture is made, and the destination is enabled, this method is called.
/// </summary>
/// <param name="surface"></param>
/// <param name="captureDetails"></param>
/// <returns>true if the processor has "processed" the capture</returns>
bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails);
}
}

View file

@ -58,101 +58,14 @@ namespace Greenshot.Plugin {
}
}
#region EventArgs
[Serializable]
public class ImageEditorOpenEventArgs : EventArgs {
private readonly IImageEditor imageEditor;
public IImageEditor ImageEditor {
get { return imageEditor;}
}
public ImageEditorOpenEventArgs(IImageEditor imageEditor) {
this.imageEditor = imageEditor;
}
}
[Serializable]
public class CaptureTakenEventArgs : EventArgs {
private readonly ICapture capture;
public ICapture Capture {
get { return capture;}
}
public CaptureTakenEventArgs(ICapture capture) {
this.capture = capture;
}
}
[Serializable]
public class SurfaceFromCaptureEventArgs : EventArgs {
private readonly ICapture capture;
public ICapture Capture {
get { return capture;}
}
private readonly ISurface surface;
public ISurface Surface {
get { return surface;}
}
public SurfaceFromCaptureEventArgs(ICapture capture, ISurface surface) {
this.capture = capture;
this.surface = surface;
}
}
[Serializable]
public class ImageOutputEventArgs : EventArgs {
private readonly string fullPath;
public string FullPath {
get { return fullPath;}
}
private readonly Image image;
public Image Image {
get { return image;}
}
private readonly ICaptureDetails captureDetails;
public ICaptureDetails CaptureDetails {
get { return captureDetails;}
}
public ImageOutputEventArgs(string fullPath, Image image, ICaptureDetails captureDetails) {
this.image = image;
this.fullPath = fullPath;
this.captureDetails = captureDetails;
}
}
#endregion
// Delegates for hooking up events.
public delegate void OnImageEditorOpenHandler(object sender, ImageEditorOpenEventArgs e);
public delegate void OnCaptureTakenHandler(object sender, CaptureTakenEventArgs e);
public delegate void OnSurfaceFromCaptureHandler(object sender, SurfaceFromCaptureEventArgs e);
public delegate void OnImageOutputHandler(object sender, ImageOutputEventArgs e);
public delegate void HotKeyHandler();
/// <summary>
/// This interface is the GreenshotPluginHost, that which "Hosts" the plugin.
/// For Greenshot this is implmented in the PluginHelper
/// </summary>
public interface IGreenshotPluginHost {
/// The Plugin can register to be called after every a newly opened ImageEditor
/// and will be passed the IImageEditor interface so it can register itself e.g. in the Menu
event OnImageEditorOpenHandler OnImageEditorOpen;
/// The Plugin can register to be called after every take Capture
/// and will be passed the ICapture interface so it can do something with it
event OnCaptureTakenHandler OnCaptureTaken;
/// The Plugin can register to be called after a Surface is created from a Capture
/// and will be passed the ICapture and ISurface interfaces so it can do something with it
event OnSurfaceFromCaptureHandler OnSurfaceFromCapture;
/// <summary>
/// Return the location of the configuration, if any
/// </summary>
string ConfigurationPath {
get;
}
public interface IGreenshotHost {
ContextMenuStrip MainMenu {
get;
}
@ -165,7 +78,24 @@ namespace Greenshot.Plugin {
/// <param name="format">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
void SaveToStream(Image image, Stream stream, OutputFormat format, int quality);
/// <summary>
/// Saves the image to a temp file (random name) using the specified outputformat
/// </summary>
/// <param name="image">The Image to save</param>
/// <param name="format">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
string SaveToTmpFile(Image image, OutputFormat outputFormat, int quality);
/// <summary>
/// Saves the image to a temp file, but the name is build with the capture details & pattern
/// </summary>
/// <param name="image">The Image to save</param>
/// <param name="captureDetails">captureDetails with the information to build the filename</param>
/// <param name="outputformat">The format to save with (png, jpg etc)</param>
/// <param name="quality">Jpeg quality</param>
string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputFormat outputFormat, int quality);
/// <summary>
/// Return a filename for the current image format (png,jpg etc) with the default file pattern
/// that is specified in the configuration
@ -188,6 +118,34 @@ namespace Greenshot.Plugin {
Dictionary<PluginAttribute, IGreenshotPlugin> Plugins {
get;
}
/// <summary>
/// Make region capture with specified Handler
/// </summary>
/// <param name="captureMouseCursor">bool false if the mouse should not be captured, true if the configuration should be checked</param>
/// <param name="destination">IDestination destination</param>
void CaptureRegion(bool captureMouseCursor, IDestination destination);
/// <summary>
/// Use the supplied capture, and handle it as if it's captured.
/// </summary>
/// <param name="captureToImport">ICapture to import</param>
void ImportCapture(ICapture captureToImport);
/// <summary>
/// Use the supplied image, and ICapture a capture object for it
/// </summary>
/// <param name="imageToCapture">Image to create capture for</param>
/// <returns>ICapture</returns>
ICapture GetCapture(Image imageToCapture);
/// <summary>
/// Get the core language object
/// </summary>
/// <returns>ILanguage for the Greenshot core</returns>
ILanguage CoreLanguage {
get;
}
}
public interface IGreenshotPlugin {
@ -196,7 +154,8 @@ namespace Greenshot.Plugin {
/// </summary>
/// <param name="host">The IPluginHost that will be hosting the plugin</param>
/// <param name="pluginAttribute">The PluginAttribute for the actual plugin</param>
void Initialize(IGreenshotPluginHost host, ICaptureHost captureHost, PluginAttribute pluginAttribute);
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
bool Initialize(IGreenshotHost host, PluginAttribute pluginAttribute);
/// <summary>
/// Unload of the plugin
@ -207,5 +166,15 @@ namespace Greenshot.Plugin {
/// Open the Configuration Form, will/should not be called before handshaking is done
/// </summary>
void Configure();
/// <summary>
/// Return IDestination's, if the plugin wants to
/// </summary>
IEnumerable<IDestination> Destinations();
/// <summary>
/// Return IProcessor's, if the plugin wants to
/// </summary>
IEnumerable<IProcessor> Processors();
}
}