refactoring: moved interfaces from GreenshotPlugin to GreenshotCore

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@704 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
JKlingen 2010-07-25 18:20:18 +00:00
commit 01d843e8cf
46 changed files with 80 additions and 103 deletions

View file

@ -0,0 +1,81 @@
/*
* 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.ComponentModel;
namespace Greenshot.Drawing.Fields {
public interface IField : INotifyPropertyChanged
{
object Value { get; set; }
FieldType FieldType { get; set; }
string Scope { get; set; }
bool HasValue { get; }
}
/// <summary>
/// EventHandler to be used when a field value changes
/// </summary>
public delegate void FieldChangedEventHandler(object sender, FieldChangedEventArgs e);
/// <summary>
/// EventArgs to be used with FieldChangedEventHandler
/// </summary>
public class FieldChangedEventArgs : EventArgs {
public readonly IField Field;
public FieldChangedEventArgs(IField field) {
this.Field = field;
}
}
/// <summary>
/// All types of fields
/// </summary>
public enum FieldType {
ARROWHEADS,
BLUR_RADIUS,
BRIGHTNESS,
FILL_COLOR,
FONT_BOLD,
FONT_FAMILY,
FONT_ITALIC,
FONT_SIZE,
HIGHLIGHT_COLOR,
LINE_COLOR,
LINE_THICKNESS,
MAGNIFICATION_FACTOR,
PIXEL_SIZE,
PREVIEW_QUALITY,
SHADOW,
PREPARED_FILTER_OBFUSCATE,
PREPARED_FILTER_HIGHLIGHT,
FLAGS
}
/// <summary>
/// This enum provides values for FieldType.FLAGS
/// </summary>
[Flags]
public enum FieldFlag {
NONE = 0,
CONFIRMABLE = 1
}
}

View file

@ -0,0 +1,53 @@
/*
* 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.Collections.Generic;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Any element holding Fields must provide access to it.
/// AbstractFieldHolder is the basic implementation.
/// If you need the fieldHolder to have child fieldHolders,
/// you should consider using IFieldHolderWithChildren.
/// </summary>
public interface IFieldHolder {
event FieldChangedEventHandler FieldChanged;
void AddField(IField field);
void RemoveField(IField field);
List<IField> GetFields();
IField GetField(FieldType fieldType);
bool HasField(FieldType fieldType);
void SetFieldValue(FieldType fieldType, object value);
}
/// <summary>
/// Extended fieldHolder which has fieldHolder children.
/// Implementations should pass field values to and from
/// their children.
/// AbstractFieldHolderWithChildren is the basic implementation.
/// </summary>
public interface IFieldHolderWithChildren : IFieldHolder {
void AddChild(IFieldHolder fieldHolder);
void RemoveChild(IFieldHolder fieldHolder);
}
}

View file

@ -0,0 +1,105 @@
/*
* 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.IO;
using System.Windows.Forms;
namespace Greenshot.Drawing {
public enum RenderMode {EDIT, EXPORT};
public enum EditStatus {UNDRAWN, DRAWING, MOVING, RESIZING, IDLE};
public interface IDrawableContainer {
ISurface Parent {
get;
}
bool Selected {
get;
set;
}
int Left {
get;
set;
}
int Top {
get;
set;
}
int Width {
get;
set;
}
int Height {
get;
set;
}
Rectangle Bounds {
get;
}
void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment);
void Dispose();
}
public interface ITextContainer: IDrawableContainer {
string Text {
get;
set;
}
void FitToText();
}
public interface IBitmapContainer: IDrawableContainer {
Bitmap Bitmap {
get;
set;
}
void Load(string filename);
}
public interface ICursorContainer: IDrawableContainer {
Cursor Cursor {
get;
set;
}
void Load(string filename);
}
public interface IIconContainer: IDrawableContainer {
Icon Icon {
get;
set;
}
void Load(string filename);
}
public interface IMetafileContainer: IDrawableContainer {
Metafile Metafile {
get;
set;
}
void Load(string filename);
}
}

View file

@ -0,0 +1,101 @@
/*
* 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.Windows.Forms;
namespace Greenshot.Drawing {
/// <summary>
/// Alignment Enums for positioning
/// </summary>
//public enum HorizontalAlignment {LEFT, CENTER, RIGHT};
public enum VerticalAlignment {TOP, CENTER, BOTTOM};
/// <summary>
/// The interface to the Surface object, so Plugins can use it.
/// </summary>
public interface ISurface {
/// <summary>
/// Get/Set the original image from the Surface, use this if you need the captured image without anything on it!
/// </summary>
Image OriginalImage {
get;
}
/// <summary>
/// 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!)
/// </summary>
Image Image {
get;
set;
}
/// <summary>
/// Get the current Image from the Editor for Exporting (save/upload etc)
/// Don't forget to call image.Dispose() when finished!!!
/// </summary>
/// <returns>Bitmap</returns>
Image GetImageForExport();
/// <summary>
/// Add a TextContainer, at the given location, to the Surface.
/// The TextContainer will be "re"sized to the text size.
/// </summary>
/// <param name="text">String to show</param>
/// <param name="horizontalAlignment">Left, Center, Right</param>
/// <param name="verticalAlignment">TOP, CENTER, BOTTOM</param>
/// <param name="family">FontFamily</param>
/// <param name="size">Font Size in float</param>
/// <param name="italic">bool true if italic</param>
/// <param name="bold">bool true if bold</param>
/// <param name="shadow">bool true if shadow</param>
/// <param name="borderSize">size of border (0 for none)</param>
/// <param name="color">Color of string</param>
/// <param name="fillColor">Color of background (e.g. Color.Transparent)</param>
ITextContainer AddTextContainer(string text, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, FontFamily family, float size, bool italic, bool bold, bool shadow, int borderSize, Color color, Color fillColor);
IBitmapContainer AddBitmapContainer(Bitmap bitmap, int x, int y);
ICursorContainer AddCursorContainer(Cursor cursor, int x, int y);
IIconContainer AddIconContainer(Icon icon, int x, int y);
IMetafileContainer AddMetafileContainer(Metafile metafile, int x, int y);
IBitmapContainer AddBitmapContainer(string filename, int x, int y);
ICursorContainer AddCursorContainer(string filename, int x, int y);
IIconContainer AddIconContainer(string filename, int x, int y);
IMetafileContainer AddMetafileContainer(string filename, int x, int y);
bool HasSelectedElements();
void RemoveSelectedElements();
void CutSelectedElements();
void CopySelectedElements();
void PasteElementFromClipboard();
void DuplicateSelectedElements();
void DeselectElement(IDrawableContainer container);
void DeselectAllElements();
void SelectElement(IDrawableContainer container);
}
}