mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
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:
parent
ad265b2c54
commit
8d458998a1
332 changed files with 17647 additions and 9466 deletions
79
PluginExample/AnnotateProcessor.cs
Normal file
79
PluginExample/AnnotateProcessor.cs
Normal file
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* 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.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// This processor shows how the current surface could be modified before it's passed to the editor or another destination
|
||||
/// </summary>
|
||||
public class AnnotateProcessor : AbstractProcessor {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AnnotateProcessor));
|
||||
private static PluginExampleConfiguration conf = IniConfig.GetIniSection<PluginExampleConfiguration>();
|
||||
|
||||
private IGreenshotHost host;
|
||||
|
||||
public AnnotateProcessor(IGreenshotHost host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "Annotate";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Designation;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isActive {
|
||||
get {
|
||||
return conf.AnnotationProcessor;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails) {
|
||||
surface.SelectElement(surface.AddCursorContainer(Cursors.Hand, 100, 100));
|
||||
// Do something with the screenshot
|
||||
string title = captureDetails.Title;
|
||||
if (title != null) {
|
||||
LOG.Debug("Added title to surface: " + title);
|
||||
surface.SelectElement(surface.AddTextContainer(title, HorizontalAlignment.Center, VerticalAlignment.CENTER,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
}
|
||||
surface.SelectElement(surface.AddTextContainer(Environment.UserName, HorizontalAlignment.Right, VerticalAlignment.TOP,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
surface.SelectElement(surface.AddTextContainer(Environment.MachineName, HorizontalAlignment.Right, VerticalAlignment.BOTTOM,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
surface.SelectElement(surface.AddTextContainer(captureDetails.DateTime.ToLongDateString(), HorizontalAlignment.Left, VerticalAlignment.BOTTOM,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,323 +0,0 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 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.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// The BitmapBuffer is exactly what it says, it buffers a Bitmap.
|
||||
/// And it is possible to Draw on the Bitmap with direct memory access for better performance
|
||||
/// </summary>
|
||||
[Serializable()]
|
||||
public unsafe class BitmapBuffer : IDisposable {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(BitmapBuffer));
|
||||
private Bitmap bitmap;
|
||||
public Bitmap Bitmap {
|
||||
get {return bitmap;}
|
||||
}
|
||||
[NonSerialized]
|
||||
private BitmapData bmData;
|
||||
[NonSerialized]
|
||||
private Rectangle rect;
|
||||
[NonSerialized]
|
||||
private byte* pointer;
|
||||
[NonSerialized]
|
||||
private int stride; /* bytes per pixel row */
|
||||
[NonSerialized]
|
||||
private int aIndex = -1;
|
||||
[NonSerialized]
|
||||
private int rIndex = -1;
|
||||
[NonSerialized]
|
||||
private int gIndex = -1;
|
||||
[NonSerialized]
|
||||
private int bIndex = -1;
|
||||
[NonSerialized]
|
||||
private int bytesPerPixel;
|
||||
[NonSerialized]
|
||||
private bool bitsLocked = false;
|
||||
|
||||
public Size Size {
|
||||
get {return rect.Size;}
|
||||
}
|
||||
public int Length {
|
||||
get {return rect.Width*rect.Height;}
|
||||
}
|
||||
public int Width {
|
||||
get {return rect.Width;}
|
||||
}
|
||||
public int Height {
|
||||
get {return rect.Height;}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with just a Bitmap, the Rectangle is the Bitmap itself
|
||||
*/
|
||||
public BitmapBuffer(Bitmap bmp) : this(bmp, Rectangle.Empty) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a BitmapBuffer from a Bitmap and a Rectangle specifying what part from the Bitmap to take
|
||||
*/
|
||||
public BitmapBuffer(Bitmap sourceBmp, Rectangle applyRect) {
|
||||
Rectangle sourceRect = new Rectangle(applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height);
|
||||
Rectangle bitmapRect = new Rectangle(0,0, sourceBmp.Width, sourceBmp.Height);
|
||||
|
||||
if(sourceRect.Equals(Rectangle.Empty)) {
|
||||
sourceRect = bitmapRect;
|
||||
} else {
|
||||
sourceRect.Intersect(bitmapRect);
|
||||
}
|
||||
// Does the rect have any pixels?
|
||||
if (sourceRect.Height <= 0 || sourceRect.Width <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (SupportsPixelFormat(sourceBmp)) {
|
||||
// Create copy with supported format
|
||||
this.bitmap = sourceBmp.Clone(sourceRect, sourceBmp.PixelFormat);
|
||||
} else {
|
||||
// When sourceRect is the whole bitmap there is a GDI+ bug in Clone
|
||||
// Clone will than return the same PixelFormat as the source
|
||||
// a quick workaround is using new Bitmap which uses a default of Format32bppArgb
|
||||
if (sourceRect.Equals(bitmapRect)) {
|
||||
this.bitmap = new Bitmap(sourceBmp);
|
||||
} else {
|
||||
this.bitmap = sourceBmp.Clone(sourceRect, PixelFormat.Format24bppRgb);
|
||||
}
|
||||
}
|
||||
// Set "this" rect to location 0,0
|
||||
// as the Cloned Bitmap is only the part we want to work with
|
||||
this.rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~BitmapBuffer() {
|
||||
Dispose(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* The public accessible Dispose
|
||||
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
|
||||
*/
|
||||
public void Dispose() {
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
// The bulk of the clean-up code is implemented in Dispose(bool)
|
||||
|
||||
/**
|
||||
* This Dispose is called from the Dispose and the Destructor.
|
||||
* When disposing==true all non-managed resources should be freed too!
|
||||
*/
|
||||
protected virtual void Dispose(bool disposing) {
|
||||
Unlock();
|
||||
if (disposing) {
|
||||
if (bitmap != null) {
|
||||
bitmap.Dispose();
|
||||
}
|
||||
}
|
||||
bitmap = null;
|
||||
bmData = null;
|
||||
pointer = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when deserializing the object
|
||||
*/
|
||||
public BitmapBuffer(SerializationInfo info, StreamingContext ctxt) {
|
||||
this.bitmap = (Bitmap)info.GetValue("bitmap", typeof(Bitmap));
|
||||
this.rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
|
||||
// The rest will be set when Lock is called
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called when serializing the object
|
||||
*/
|
||||
public void GetObjectData(SerializationInfo info, StreamingContext ctxt) {
|
||||
Unlock();
|
||||
info.AddValue("bitmap", this.bitmap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock the bitmap so we have direct access to the memory
|
||||
*/
|
||||
public void Lock() {
|
||||
if(rect.Width > 0 && rect.Height > 0) {
|
||||
bmData = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat);
|
||||
bitsLocked = true;
|
||||
|
||||
System.IntPtr Scan0 = bmData.Scan0;
|
||||
pointer = (byte*)(void*)Scan0;
|
||||
|
||||
PrepareForPixelFormat();
|
||||
stride = bmData.Stride;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unlock the System Memory
|
||||
*/
|
||||
private void Unlock() {
|
||||
if(bitsLocked) {
|
||||
bitmap.UnlockBits(bmData);
|
||||
bitsLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the stored bitmap to the destionation bitmap at the supplied point
|
||||
*/
|
||||
public void DrawTo(Bitmap destinationBitmap, Point destination) {
|
||||
DrawTo(destinationBitmap, null, destination);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw the stored Bitmap on the Destination bitmap with the specified rectangle
|
||||
* Be aware that the stored bitmap will be resized to the specified rectangle!!
|
||||
*/
|
||||
public void DrawTo(Bitmap destinationBitmap, Rectangle destinationRect) {
|
||||
DrawTo(destinationBitmap, destinationRect, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* private helper to draw the bitmap
|
||||
*/
|
||||
private void DrawTo(Bitmap destinationBitmap, Rectangle? destinationRect, Point? destination) {
|
||||
if (destinationRect.HasValue) {
|
||||
// Does the rect have any pixels?
|
||||
if (destinationRect.Value.Height <= 0 || destinationRect.Value.Width <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Make sure this.bitmap is unlocked
|
||||
Unlock();
|
||||
|
||||
using (Graphics graphics = Graphics.FromImage(destinationBitmap)) {
|
||||
if (destinationRect.HasValue) {
|
||||
LOG.Debug(String.Format("Drawing at: {0},{1} {2},{3}", destinationRect.Value.X, destinationRect.Value.Y, destinationRect.Value.Width, destinationRect.Value.Height));
|
||||
graphics.DrawImage(this.bitmap, destinationRect.Value);
|
||||
} else if (destination.HasValue) {
|
||||
LOG.Debug(String.Format("Drawing at: {0},{1}", destination.Value.X, destination.Value.Y));
|
||||
graphics.DrawImage(this.bitmap, destination.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the color at location x,y
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public Color GetColorAt(int x, int y) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset];
|
||||
return Color.FromArgb(a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]);
|
||||
} else {
|
||||
return Color.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color at location x,y
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public void SetColorAt(int x, int y, Color color) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
if(aIndex!=-1) pointer[aIndex+offset] = color.A;
|
||||
pointer[rIndex+offset] = color.R;
|
||||
pointer[gIndex+offset] = color.G;
|
||||
pointer[bIndex+offset] = color.B;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the color at location x,y as an array
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public int[] GetColorArrayAt(int x, int y) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset];
|
||||
return new int[]{a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]};
|
||||
} else {
|
||||
return new int[]{0,0,0,0};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the color at location x,y as an array
|
||||
* Before the first time this is called the Lock() should be called once!
|
||||
*/
|
||||
public void SetColorArrayAt(int x, int y, int[] colors) {
|
||||
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
|
||||
int offset = x*bytesPerPixel+y*stride;
|
||||
if(aIndex!=-1) pointer[aIndex+offset] = (byte)colors[0];
|
||||
pointer[rIndex+offset] = (byte)colors[1];
|
||||
pointer[gIndex+offset] = (byte)colors[2];
|
||||
pointer[bIndex+offset] = (byte)colors[3];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the supplied Bitmap has a PixelFormat we support
|
||||
*/
|
||||
private bool SupportsPixelFormat(Bitmap bitmap) {
|
||||
return (bitmap.PixelFormat.Equals(PixelFormat.Format32bppArgb) ||
|
||||
bitmap.PixelFormat.Equals(PixelFormat.Format32bppRgb) ||
|
||||
bitmap.PixelFormat.Equals(PixelFormat.Format24bppRgb));
|
||||
}
|
||||
|
||||
/**
|
||||
* Set some internal values for accessing the bitmap according to the PixelFormat
|
||||
*/
|
||||
private void PrepareForPixelFormat() {
|
||||
switch(bitmap.PixelFormat) {
|
||||
case PixelFormat.Format32bppArgb:
|
||||
bIndex = 0;
|
||||
gIndex = 1;
|
||||
rIndex = 2;
|
||||
aIndex = 3;
|
||||
bytesPerPixel = 4;
|
||||
break;
|
||||
case PixelFormat.Format32bppRgb:
|
||||
bIndex = 0;
|
||||
gIndex = 1;
|
||||
rIndex = 2;
|
||||
bytesPerPixel = 4;
|
||||
break;
|
||||
case PixelFormat.Format24bppRgb:
|
||||
bIndex = 0;
|
||||
gIndex = 1;
|
||||
rIndex = 2;
|
||||
bytesPerPixel = 3;
|
||||
break;
|
||||
default:
|
||||
throw new FormatException("Bitmap.Pixelformat."+bitmap.PixelFormat+" is currently not supported. Supported: Format32bpp(A)Rgb, Format24bppRgb");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
77
PluginExample/GreyscaleProcessor.cs
Normal file
77
PluginExample/GreyscaleProcessor.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// This processor shows how the current surface could be modified before it's passed to the editor or another destination
|
||||
/// </summary>
|
||||
public class GreyscaleProcessor : AbstractProcessor {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(GreyscaleProcessor));
|
||||
private static PluginExampleConfiguration conf = IniConfig.GetIniSection<PluginExampleConfiguration>();
|
||||
private IGreenshotHost host;
|
||||
|
||||
public GreyscaleProcessor(IGreenshotHost host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "Greyscale";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Designation;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isActive {
|
||||
get {
|
||||
return conf.GreyscaleProcessor;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ProcessCapture(ISurface surface, ICaptureDetails captureDetails) {
|
||||
LOG.DebugFormat("Changing surface to grayscale!");
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(surface.Image as Bitmap, false)) {
|
||||
bbb.Lock();
|
||||
for(int y=0;y<bbb.Height; y++) {
|
||||
for(int x=0;x<bbb.Width; x++) {
|
||||
Color color = bbb.GetColorAt(x, y);
|
||||
int luma = (int)((0.3*color.R) + (0.59*color.G) + (0.11*color.B));
|
||||
color = Color.FromArgb(luma, luma, luma);
|
||||
bbb.SetColorAt(x, y, color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* 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/
|
||||
|
@ -27,6 +27,8 @@ using System.Text;
|
|||
using System.Windows.Forms;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
|
@ -34,37 +36,38 @@ namespace PluginExample {
|
|||
/// </summary>
|
||||
public class PluginExample : IGreenshotPlugin {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(PluginExample));
|
||||
private IGreenshotPluginHost host;
|
||||
private ICaptureHost captureHost = null;
|
||||
private IGreenshotHost host;
|
||||
private PluginAttribute myAttributes;
|
||||
private bool testAnnotations = false;
|
||||
|
||||
public PluginExample() {
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
yield return new SimpleOutputDestination(host);
|
||||
}
|
||||
|
||||
public IEnumerable<IProcessor> Processors() {
|
||||
yield return new AnnotateProcessor(host);
|
||||
yield return new GreyscaleProcessor(host);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IGreenshotPlugin.Initialize
|
||||
/// </summary>
|
||||
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
|
||||
/// <param name="pluginAttribute">My own attributes</param>
|
||||
public virtual void Initialize(IGreenshotPluginHost pluginHost, ICaptureHost captureHost, PluginAttribute myAttributes) {
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
LOG.Debug("Initialize called of " + myAttributes.Name);
|
||||
|
||||
this.host = (IGreenshotPluginHost)pluginHost;
|
||||
this.captureHost = captureHost;
|
||||
this.host = pluginHost;
|
||||
this.myAttributes = myAttributes;
|
||||
|
||||
this.host.OnImageEditorOpen += new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||
this.host.OnSurfaceFromCapture += new OnSurfaceFromCaptureHandler(SurfaceFromCapture);
|
||||
this.host.OnImageOutput += new OnImageOutputHandler(ImageOutput);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Shutdown of " + myAttributes.Name);
|
||||
this.host.OnImageEditorOpen -= new OnImageEditorOpenHandler(ImageEditorOpened);
|
||||
this.host.OnSurfaceFromCapture -= new OnSurfaceFromCaptureHandler(SurfaceFromCapture);
|
||||
this.host.OnImageOutput -= new OnImageOutputHandler(ImageOutput);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -72,123 +75,8 @@ namespace PluginExample {
|
|||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
LOG.Debug("Configure called");
|
||||
SettingsForm settingsForm = new SettingsForm(testAnnotations);
|
||||
DialogResult result = settingsForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
testAnnotations = settingsForm.TestAnnotations;
|
||||
}
|
||||
settingsForm.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the OnImageEditorOpen event
|
||||
/// Using the ImageEditor interface to register in the plugin menu
|
||||
/// </summary>
|
||||
private void ImageEditorOpened(object sender, ImageEditorOpenEventArgs eventArgs) {
|
||||
LOG.Debug("ImageEditorOpened called");
|
||||
ToolStripMenuItem toolStripMenuItem = eventArgs.ImageEditor.GetPluginMenuItem();
|
||||
ToolStripMenuItem saveItem = new ToolStripMenuItem();
|
||||
saveItem.Text = "Save with Plugin";
|
||||
saveItem.Tag = eventArgs.ImageEditor;
|
||||
saveItem.Click += new System.EventHandler(EditMenuClick);
|
||||
toolStripMenuItem.DropDownItems.Add(saveItem);
|
||||
|
||||
ToolStripMenuItem grayscaleItem = new ToolStripMenuItem();
|
||||
grayscaleItem.Text = "Turn bitmap into gray-scales";
|
||||
grayscaleItem.Tag = eventArgs.ImageEditor;
|
||||
grayscaleItem.Click += new System.EventHandler(GrayScaleMenuClick);
|
||||
toolStripMenuItem.DropDownItems.Add(grayscaleItem);
|
||||
}
|
||||
|
||||
private void MainMenuClick(object sender, EventArgs e) {
|
||||
LOG.Debug("Sympathy for the Devil!");
|
||||
Bitmap bitmap = new Bitmap(100, 100, PixelFormat.Format16bppRgb555);
|
||||
captureHost.HandleCapture(bitmap);
|
||||
bitmap.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when the menu item in the Editor is clicked
|
||||
/// Just an example...
|
||||
/// </summary>
|
||||
private void EditMenuClick(object sender, EventArgs e) {
|
||||
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||
|
||||
string file = host.GetFilename("png", null);
|
||||
string filePath = Path.Combine(host.ConfigurationPath,file);
|
||||
using (FileStream stream = new FileStream(filePath, FileMode.Create)) {
|
||||
imageEditor.SaveToStream(stream, "PNG", 100);
|
||||
}
|
||||
LOG.Debug("Saved test file to: " + filePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when the menu item in the Editor is clicked
|
||||
/// Just an example...
|
||||
/// </summary>
|
||||
private void GrayScaleMenuClick(object sender, EventArgs e) {
|
||||
ToolStripMenuItem item = (ToolStripMenuItem)sender;
|
||||
IImageEditor imageEditor = (IImageEditor)item.Tag;
|
||||
ISurface surface = imageEditor.Surface;
|
||||
// copy & do something with the image
|
||||
Image image = (Image)surface.OriginalImage.Clone();
|
||||
|
||||
using (BitmapBuffer bbb = new BitmapBuffer(image as Bitmap)) {
|
||||
// Image is copied, dispose it!
|
||||
image.Dispose();
|
||||
|
||||
bbb.Lock();
|
||||
for(int y=0;y<bbb.Height; y++) {
|
||||
for(int x=0;x<bbb.Width; x++) {
|
||||
Color color = bbb.GetColorAt(x, y);
|
||||
int luma = (int)((0.3*color.R) + (0.59*color.G) + (0.11*color.B));
|
||||
color = Color.FromArgb(luma, luma, luma);
|
||||
bbb.SetColorAt(x, y, color);
|
||||
}
|
||||
}
|
||||
surface.Image = bbb.Bitmap;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handling of the OnImageOutputHandler event from the IGreenshotPlugin
|
||||
/// </summary>
|
||||
/// <param name="ImageOutputEventArgs">Has the FullPath to the image</param>
|
||||
private void ImageOutput(object sender, ImageOutputEventArgs eventArgs) {
|
||||
LOG.Debug("ImageOutput called with full path: " + eventArgs.FullPath);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handling of the OnSurfaceFromCapture event from the IGreenshotPlugin
|
||||
/// </summary>
|
||||
/// <param name="SurfaceFromCaptureEventArgs">Has the ICapture and ISurface</param>
|
||||
public void SurfaceFromCapture(object sender, SurfaceFromCaptureEventArgs eventArgs) {
|
||||
LOG.Debug("SurfaceFromCapture called");
|
||||
if (!testAnnotations) {
|
||||
return;
|
||||
}
|
||||
ISurface surface = eventArgs.Surface;
|
||||
|
||||
surface.SelectElement(surface.AddCursorContainer(Cursors.Hand, 100, 100));
|
||||
// Do something with the screenshot
|
||||
string title = eventArgs.Capture.CaptureDetails.Title;
|
||||
if (title != null) {
|
||||
LOG.Debug("Added title to surface: " + title);
|
||||
surface.SelectElement(surface.AddTextContainer(title, HorizontalAlignment.Center, VerticalAlignment.CENTER,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
surface.SelectElement(surface.AddTextContainer(Environment.UserName, HorizontalAlignment.Right, VerticalAlignment.TOP,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
surface.SelectElement(surface.AddTextContainer(Environment.MachineName, HorizontalAlignment.Right, VerticalAlignment.BOTTOM,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
surface.SelectElement(surface.AddTextContainer(eventArgs.Capture.CaptureDetails.DateTime.ToLongDateString(), HorizontalAlignment.Left, VerticalAlignment.BOTTOM,
|
||||
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Red, Color.White));
|
||||
|
||||
} else {
|
||||
LOG.Debug("No title available, doing nothing.");
|
||||
}
|
||||
SettingsForm settingsForm = new SettingsForm();
|
||||
settingsForm.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{6BD38118-B27F-43A1-951C-FB6464D39260}</ProjectGuid>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
|
@ -48,7 +49,10 @@
|
|||
<Reference Include="System.Windows.Forms" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="DrawingUtils.cs" />
|
||||
<Compile Include="GreyscaleProcessor.cs" />
|
||||
<Compile Include="PluginExampleConfiguration.cs" />
|
||||
<Compile Include="SimpleOutputDestination.cs" />
|
||||
<Compile Include="AnnotateProcessor.cs" />
|
||||
<Compile Include="PluginExample.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="SettingsForm.cs" />
|
||||
|
@ -56,9 +60,6 @@
|
|||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\AssemblyInfo.cs.template" />
|
||||
<EmbeddedResource Include="SettingsForm.resx">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
|
||||
|
|
40
PluginExample/PluginExampleConfiguration.cs
Normal file
40
PluginExample/PluginExampleConfiguration.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* 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.IO;
|
||||
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// Description of PluginExampleConfiguration.
|
||||
/// </summary>
|
||||
[IniSection("PluginExample", Description="Plugin Example configuration")]
|
||||
public class PluginExampleConfiguration : IniSection {
|
||||
[IniProperty("GreyScaleProcessor", Description="Enable or disable the greyscale processor.", DefaultValue="False")]
|
||||
public bool GreyscaleProcessor;
|
||||
|
||||
[IniProperty("AnnotationProcessor", Description="Enable or disable the annotation processor.", DefaultValue="False")]
|
||||
public bool AnnotationProcessor;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* 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/
|
||||
|
@ -38,6 +38,7 @@ using Greenshot.Plugin;
|
|||
[assembly: AssemblyCopyright("Copyright 2010")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The PluginAttribute describes the "entryType" and if the plugin is configurable
|
||||
[assembly: PluginAttribute("PluginExample.PluginExample", true)]
|
||||
|
||||
|
|
24
PluginExample/SettingsForm.Designer.cs
generated
24
PluginExample/SettingsForm.Designer.cs
generated
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* 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/
|
||||
|
@ -51,6 +51,7 @@ namespace PluginExample
|
|||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.button2 = new System.Windows.Forms.Button();
|
||||
this.checkBox2 = new System.Windows.Forms.CheckBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkBox1
|
||||
|
@ -59,12 +60,12 @@ namespace PluginExample
|
|||
this.checkBox1.Name = "checkBox1";
|
||||
this.checkBox1.Size = new System.Drawing.Size(152, 24);
|
||||
this.checkBox1.TabIndex = 0;
|
||||
this.checkBox1.Text = "Test Annotations";
|
||||
this.checkBox1.Text = "Annotation processor";
|
||||
this.checkBox1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Location = new System.Drawing.Point(12, 52);
|
||||
this.button1.Location = new System.Drawing.Point(12, 72);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||||
this.button1.TabIndex = 1;
|
||||
|
@ -74,7 +75,7 @@ namespace PluginExample
|
|||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(93, 52);
|
||||
this.button2.Location = new System.Drawing.Point(100, 72);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(75, 23);
|
||||
this.button2.TabIndex = 2;
|
||||
|
@ -82,18 +83,29 @@ namespace PluginExample
|
|||
this.button2.UseVisualStyleBackColor = true;
|
||||
this.button2.Click += new System.EventHandler(this.Button2Click);
|
||||
//
|
||||
// checkBox2
|
||||
//
|
||||
this.checkBox2.Location = new System.Drawing.Point(12, 42);
|
||||
this.checkBox2.Name = "checkBox2";
|
||||
this.checkBox2.Size = new System.Drawing.Size(152, 24);
|
||||
this.checkBox2.TabIndex = 3;
|
||||
this.checkBox2.Text = "Greyscale processor";
|
||||
this.checkBox2.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(187, 105);
|
||||
this.ClientSize = new System.Drawing.Size(187, 106);
|
||||
this.Controls.Add(this.checkBox2);
|
||||
this.Controls.Add(this.button2);
|
||||
this.Controls.Add(this.button1);
|
||||
this.Controls.Add(this.checkBox1);
|
||||
this.Name = "SettingsForm";
|
||||
this.Text = "SettingsForm";
|
||||
this.Text = "Plugin example settings";
|
||||
this.ResumeLayout(false);
|
||||
}
|
||||
private System.Windows.Forms.CheckBox checkBox2;
|
||||
private System.Windows.Forms.Button button2;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.CheckBox checkBox1;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2010 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* 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/
|
||||
|
@ -22,29 +22,30 @@ using System;
|
|||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// Description of SettingsForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : Form {
|
||||
public SettingsForm(bool testAnnotations) {
|
||||
private static PluginExampleConfiguration conf = IniConfig.GetIniSection<PluginExampleConfiguration>();
|
||||
|
||||
public SettingsForm() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent();
|
||||
checkBox1.Checked = testAnnotations;
|
||||
checkBox1.Checked = conf.AnnotationProcessor;
|
||||
checkBox2.Checked = conf.GreyscaleProcessor;
|
||||
}
|
||||
|
||||
void Button1Click(object sender, EventArgs e) {
|
||||
conf.AnnotationProcessor = checkBox1.Checked;
|
||||
conf.GreyscaleProcessor = checkBox2.Checked;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
public bool TestAnnotations {
|
||||
get {
|
||||
return checkBox1.Checked;
|
||||
}
|
||||
}
|
||||
|
||||
void Button2Click(object sender, EventArgs e) {
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
77
PluginExample/SimpleOutputDestination.cs
Normal file
77
PluginExample/SimpleOutputDestination.cs
Normal file
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* 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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using IniFile;
|
||||
|
||||
namespace PluginExample {
|
||||
/// <summary>
|
||||
/// This destination shows a simple save to...
|
||||
/// </summary>
|
||||
public class SimpleOutputDestination : AbstractDestination {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SimpleOutputDestination));
|
||||
private IGreenshotHost host;
|
||||
|
||||
public SimpleOutputDestination(IGreenshotHost host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "SimpleOutput";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Designation;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool isActive {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ExportCapture(ISurface surface, ICaptureDetails captureDetails) {
|
||||
CoreConfiguration config = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
string file = host.GetFilename(OutputFormat.png, null);
|
||||
string filePath = Path.Combine(config.OutputFilePath, file);
|
||||
using (FileStream stream = new FileStream(filePath, FileMode.Create)) {
|
||||
using (Image image = surface.GetImageForExport()) {
|
||||
host.SaveToStream(image, stream, OutputFormat.png, 100);
|
||||
}
|
||||
}
|
||||
MessageBox.Show("Saved test file to: " + filePath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue