mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 01:23:47 -07:00
Fixed some interface usage, also cleanup of the surface & editor code. This should theoretically allow usage of home made IDrawableContainer objects, which plug-ins supply.
Also made it possible to reuse the editor, currently only available editors which have a non modified surface can be reused. And only than if the configuration is set to do so. git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2100 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
7bb187ce71
commit
f9abcac063
13 changed files with 233 additions and 154 deletions
|
@ -50,6 +50,8 @@ namespace Greenshot.Configuration {
|
||||||
public Point WindowMaxPosition;
|
public Point WindowMaxPosition;
|
||||||
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
|
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
|
||||||
public Rectangle WindowNormalPosition;
|
public Rectangle WindowNormalPosition;
|
||||||
|
[IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")]
|
||||||
|
public bool ReuseEditor;
|
||||||
|
|
||||||
[IniProperty("SuppressSaveDialogAtClose", Description="Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue="False")]
|
[IniProperty("SuppressSaveDialogAtClose", Description="Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue="False")]
|
||||||
public bool SuppressSaveDialogAtClose;
|
public bool SuppressSaveDialogAtClose;
|
||||||
|
|
|
@ -38,7 +38,7 @@ namespace Greenshot.Destinations {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorDestination : AbstractDestination {
|
public class EditorDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(EditorDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(EditorDestination));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||||
public const string DESIGNATION = "Editor";
|
public const string DESIGNATION = "Editor";
|
||||||
private IImageEditor editor = null;
|
private IImageEditor editor = null;
|
||||||
private static Image greenshotIcon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon().ToBitmap();
|
private static Image greenshotIcon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon().ToBitmap();
|
||||||
|
@ -92,35 +92,46 @@ namespace Greenshot.Destinations {
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||||
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
||||||
|
// Make sure we collect the garbage before opening the screenshot
|
||||||
|
GC.Collect();
|
||||||
|
GC.WaitForPendingFinalizers();
|
||||||
|
|
||||||
if (editor == null) {
|
if (editor == null) {
|
||||||
// Make sure we collect the garbage before opening the screenshot
|
if (editorConfiguration.ReuseEditor) {
|
||||||
GC.Collect();
|
foreach(IImageEditor openedEditor in ImageEditorForm.Editors) {
|
||||||
GC.WaitForPendingFinalizers();
|
if (!openedEditor.Surface.Modified) {
|
||||||
|
openedEditor.Surface = surface;
|
||||||
try {
|
exportInformation.ExportMade = true;
|
||||||
ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??
|
break;
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(captureDetails.Filename)) {
|
}
|
||||||
editorForm.SetImagePath(captureDetails.Filename);
|
}
|
||||||
|
if (!exportInformation.ExportMade) {
|
||||||
|
try {
|
||||||
|
ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(captureDetails.Filename)) {
|
||||||
|
editorForm.SetImagePath(captureDetails.Filename);
|
||||||
|
}
|
||||||
|
editorForm.Show();
|
||||||
|
editorForm.Activate();
|
||||||
|
LOG.Debug("Finished opening Editor");
|
||||||
|
exportInformation.ExportMade = true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LOG.Error(e);
|
||||||
|
exportInformation.ErrorMessage = e.Message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
using (Bitmap image = (Bitmap)surface.GetImageForExport()) {
|
||||||
|
editor.Surface.AddBitmapContainer(image, 10, 10);
|
||||||
}
|
}
|
||||||
editorForm.Show();
|
|
||||||
editorForm.Activate();
|
|
||||||
LOG.Debug("Finished opening Editor");
|
|
||||||
exportInformation.ExportMade = true;
|
exportInformation.ExportMade = true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.Error(e);
|
LOG.Error(e);
|
||||||
exportInformation.ErrorMessage = e.Message;
|
exportInformation.ErrorMessage = e.Message;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
using (Bitmap image = (Bitmap)surface.GetImageForExport()) {
|
|
||||||
editor.Surface.AddBitmapContainer(image, 10, 10);
|
|
||||||
}
|
|
||||||
exportInformation.ExportMade = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
LOG.Error(e);
|
|
||||||
exportInformation.ErrorMessage = e.Message;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ProcessExport(exportInformation, surface);
|
ProcessExport(exportInformation, surface);
|
||||||
return exportInformation;
|
return exportInformation;
|
||||||
|
|
|
@ -24,12 +24,10 @@ using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Configuration;
|
|
||||||
using Greenshot.Drawing.Fields;
|
using Greenshot.Drawing.Fields;
|
||||||
using Greenshot.Drawing.Filters;
|
using Greenshot.Drawing.Filters;
|
||||||
using Greenshot.Helpers;
|
using Greenshot.Helpers;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
using Greenshot.Memento;
|
using Greenshot.Memento;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
|
@ -87,7 +85,16 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
public EditStatus Status = EditStatus.UNDRAWN;
|
private EditStatus status = EditStatus.UNDRAWN;
|
||||||
|
public EditStatus Status {
|
||||||
|
get {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
status = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private int left = 0;
|
private int left = 0;
|
||||||
public int Left {
|
public int Left {
|
||||||
|
|
|
@ -35,8 +35,8 @@ namespace Greenshot.Drawing {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dispatches most of a DrawableContainer's public properties and methods to a list of DrawableContainers.
|
/// Dispatches most of a DrawableContainer's public properties and methods to a list of DrawableContainers.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Serializable()]
|
[Serializable()]
|
||||||
public class DrawableContainerList : List<DrawableContainer> {
|
public class DrawableContainerList : List<IDrawableContainer> {
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static System.ComponentModel.ComponentResourceManager editorFormResources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
|
private static System.ComponentModel.ComponentResourceManager editorFormResources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
|
||||||
|
|
||||||
|
@ -48,7 +48,9 @@ namespace Greenshot.Drawing {
|
||||||
return this[Count-1].Status;
|
return this[Count-1].Status;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
foreach(DrawableContainer dc in this) dc.Status = value;
|
foreach (DrawableContainer dc in this) {
|
||||||
|
dc.Status = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,9 +180,9 @@ namespace Greenshot.Drawing {
|
||||||
/// <param name="x">x coordinate to be checked</param>
|
/// <param name="x">x coordinate to be checked</param>
|
||||||
/// <param name="y">y coordinate to be checked</param>
|
/// <param name="y">y coordinate to be checked</param>
|
||||||
/// <returns>the topmost element from the list being clickable at the given location, null if there is no clickable element</returns>
|
/// <returns>the topmost element from the list being clickable at the given location, null if there is no clickable element</returns>
|
||||||
public DrawableContainer ClickableElementAt(int x, int y) {
|
public IDrawableContainer ClickableElementAt(int x, int y) {
|
||||||
for(int i=Count-1; i>=0; i--) {
|
for (int i=Count-1; i>=0; i--) {
|
||||||
if(this[i].ClickableAt(x,y)) {
|
if (this[i].ClickableAt(x,y)) {
|
||||||
return this[i];
|
return this[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -280,7 +282,7 @@ namespace Greenshot.Drawing {
|
||||||
/// <param name="elements">list of elements to pull up</param>
|
/// <param name="elements">list of elements to pull up</param>
|
||||||
public void PullElementsUp(DrawableContainerList elements) {
|
public void PullElementsUp(DrawableContainerList elements) {
|
||||||
for(int i=this.Count-1; i>=0; i--) {
|
for(int i=this.Count-1; i>=0; i--) {
|
||||||
DrawableContainer dc = this[i];
|
IDrawableContainer dc = this[i];
|
||||||
if (elements.Contains(dc)) {
|
if (elements.Contains(dc)) {
|
||||||
if (Count > (i+1) && !elements.Contains(this[i+1])) {
|
if (Count > (i+1) && !elements.Contains(this[i+1])) {
|
||||||
SwapElements(i,i+1);
|
SwapElements(i,i+1);
|
||||||
|
@ -294,9 +296,9 @@ namespace Greenshot.Drawing {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elements">of elements to pull to top</param>
|
/// <param name="elements">of elements to pull to top</param>
|
||||||
public void PullElementsToTop(DrawableContainerList elements) {
|
public void PullElementsToTop(DrawableContainerList elements) {
|
||||||
DrawableContainer[] dcs = this.ToArray();
|
IDrawableContainer[] dcs = this.ToArray();
|
||||||
for(int i=0; i<dcs.Length; i++) {
|
for(int i=0; i<dcs.Length; i++) {
|
||||||
DrawableContainer dc = dcs[i];
|
IDrawableContainer dc = dcs[i];
|
||||||
if (elements.Contains(dc)) {
|
if (elements.Contains(dc)) {
|
||||||
this.Remove(dc);
|
this.Remove(dc);
|
||||||
this.Add(dc);
|
this.Add(dc);
|
||||||
|
@ -329,7 +331,7 @@ namespace Greenshot.Drawing {
|
||||||
/// <param name="elements">list of elements to push down</param>
|
/// <param name="elements">list of elements to push down</param>
|
||||||
public void PushElementsDown(DrawableContainerList elements) {
|
public void PushElementsDown(DrawableContainerList elements) {
|
||||||
for(int i=0; i<Count; i++) {
|
for(int i=0; i<Count; i++) {
|
||||||
DrawableContainer dc = this[i];
|
IDrawableContainer dc = this[i];
|
||||||
if(elements.Contains(dc)) {
|
if(elements.Contains(dc)) {
|
||||||
if((i>0) && !elements.Contains(this[i-1])) {
|
if((i>0) && !elements.Contains(this[i-1])) {
|
||||||
SwapElements(i,i-1);
|
SwapElements(i,i-1);
|
||||||
|
@ -343,9 +345,9 @@ namespace Greenshot.Drawing {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="elements">of elements to push to bottom</param>
|
/// <param name="elements">of elements to push to bottom</param>
|
||||||
public void PushElementsToBottom(DrawableContainerList elements) {
|
public void PushElementsToBottom(DrawableContainerList elements) {
|
||||||
DrawableContainer[] dcs = this.ToArray();
|
IDrawableContainer[] dcs = this.ToArray();
|
||||||
for(int i=dcs.Length-1; i>=0; i--) {
|
for(int i=dcs.Length-1; i>=0; i--) {
|
||||||
DrawableContainer dc = dcs[i];
|
IDrawableContainer dc = dcs[i];
|
||||||
if(elements.Contains(dc)) {
|
if(elements.Contains(dc)) {
|
||||||
this.Remove(dc);
|
this.Remove(dc);
|
||||||
this.Insert(0, dc);
|
this.Insert(0, dc);
|
||||||
|
@ -362,7 +364,7 @@ namespace Greenshot.Drawing {
|
||||||
/// <param name="index2">index of the 2nd element</param>
|
/// <param name="index2">index of the 2nd element</param>
|
||||||
private void SwapElements(int index1, int index2) {
|
private void SwapElements(int index1, int index2) {
|
||||||
if(index1 >= 0 && index1 < Count && index2 >= 0 && index2 < Count && index1 != index2) {
|
if(index1 >= 0 && index1 < Count && index2 >= 0 && index2 < Count && index1 != index2) {
|
||||||
DrawableContainer dc = this[index1];
|
IDrawableContainer dc = this[index1];
|
||||||
this[index1] = this[index2];
|
this[index1] = this[index2];
|
||||||
this[index2] = dc;
|
this[index2] = dc;
|
||||||
Parent.Modified = true;
|
Parent.Modified = true;
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.ComponentModel;
|
||||||
|
|
||||||
using Greenshot.Configuration;
|
using Greenshot.Configuration;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
using Greenshot.Plugin.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Drawing.Fields {
|
namespace Greenshot.Drawing.Fields {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -39,7 +40,7 @@ namespace Greenshot.Drawing.Fields {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FieldAggregator : AbstractFieldHolder {
|
public class FieldAggregator : AbstractFieldHolder {
|
||||||
|
|
||||||
private List<DrawableContainer> boundContainers;
|
private List<IDrawableContainer> boundContainers;
|
||||||
private bool internalUpdateRunning = false;
|
private bool internalUpdateRunning = false;
|
||||||
|
|
||||||
enum Status {IDLE, BINDING, UPDATING};
|
enum Status {IDLE, BINDING, UPDATING};
|
||||||
|
@ -52,7 +53,7 @@ namespace Greenshot.Drawing.Fields {
|
||||||
Field field = new Field(fieldType, GetType());
|
Field field = new Field(fieldType, GetType());
|
||||||
AddField(field);
|
AddField(field);
|
||||||
}
|
}
|
||||||
boundContainers = new List<DrawableContainer>();
|
boundContainers = new List<IDrawableContainer>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void AddField(Field field) {
|
public override void AddField(Field field) {
|
||||||
|
@ -66,31 +67,38 @@ namespace Greenshot.Drawing.Fields {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindElement(DrawableContainer dc) {
|
public void BindElement(IDrawableContainer dc) {
|
||||||
if (!boundContainers.Contains(dc)) {
|
DrawableContainer container = dc as DrawableContainer;
|
||||||
boundContainers.Add(dc);
|
if (container != null && !boundContainers.Contains(container)) {
|
||||||
dc.ChildrenChanged += delegate { UpdateFromBoundElements(); };
|
boundContainers.Add(container);
|
||||||
|
container.ChildrenChanged += delegate {
|
||||||
|
UpdateFromBoundElements();
|
||||||
|
};
|
||||||
UpdateFromBoundElements();
|
UpdateFromBoundElements();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BindAndUpdateElement(DrawableContainer dc) {
|
public void BindAndUpdateElement(IDrawableContainer dc) {
|
||||||
UpdateElement(dc);
|
UpdateElement(dc);
|
||||||
BindElement(dc);
|
BindElement(dc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateElement(DrawableContainer dc) {
|
public void UpdateElement(IDrawableContainer dc) {
|
||||||
|
DrawableContainer container = dc as DrawableContainer;
|
||||||
|
if (container == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
internalUpdateRunning = true;
|
internalUpdateRunning = true;
|
||||||
foreach(Field field in GetFields()) {
|
foreach(Field field in GetFields()) {
|
||||||
if (dc.HasField(field.FieldType) && field.HasValue) {
|
if (container.HasField(field.FieldType) && field.HasValue) {
|
||||||
//if(LOG.IsDebugEnabled) LOG.Debug(" "+field+ ": "+field.Value);
|
//if(LOG.IsDebugEnabled) LOG.Debug(" "+field+ ": "+field.Value);
|
||||||
dc.SetFieldValue(field.FieldType, field.Value);
|
container.SetFieldValue(field.FieldType, field.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internalUpdateRunning = false;
|
internalUpdateRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UnbindElement(DrawableContainer dc) {
|
public void UnbindElement(IDrawableContainer dc) {
|
||||||
if (boundContainers.Contains(dc)) {
|
if (boundContainers.Contains(dc)) {
|
||||||
boundContainers.Remove(dc);
|
boundContainers.Remove(dc);
|
||||||
UpdateFromBoundElements();
|
UpdateFromBoundElements();
|
||||||
|
@ -129,28 +137,33 @@ namespace Greenshot.Drawing.Fields {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Field> FindCommonFields() {
|
private List<Field> FindCommonFields() {
|
||||||
List<Field> ret = null;
|
List<Field> returnFields = null;
|
||||||
if (boundContainers.Count > 0) {
|
if (boundContainers.Count > 0) {
|
||||||
// take all fields from the least selected container...
|
// take all fields from the least selected container...
|
||||||
ret = boundContainers[boundContainers.Count-1].GetFields();
|
DrawableContainer leastSelectedContainer = boundContainers[boundContainers.Count - 1] as DrawableContainer;
|
||||||
for(int i=0;i<boundContainers.Count-1; i++) {
|
if (leastSelectedContainer != null) {
|
||||||
DrawableContainer dc = boundContainers[i];
|
returnFields = leastSelectedContainer.GetFields();
|
||||||
List<Field> fieldsToRemove = new List<Field>();
|
for (int i = 0; i < boundContainers.Count - 1; i++) {
|
||||||
foreach(Field f in ret) {
|
DrawableContainer dc = boundContainers[i] as DrawableContainer;
|
||||||
// ... throw out those that do not apply to one of the other containers
|
if (dc != null) {
|
||||||
if (!dc.HasField(f.FieldType)) {
|
List<Field> fieldsToRemove = new List<Field>();
|
||||||
fieldsToRemove.Add(f);
|
foreach (Field f in returnFields) {
|
||||||
|
// ... throw out those that do not apply to one of the other containers
|
||||||
|
if (!dc.HasField(f.FieldType)) {
|
||||||
|
fieldsToRemove.Add(f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (Field f in fieldsToRemove) {
|
||||||
|
returnFields.Remove(f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach(Field f in fieldsToRemove) {
|
|
||||||
ret.Remove(f);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ret == null) {
|
if (returnFields == null) {
|
||||||
ret = new List<Field>();
|
returnFields = new List<Field>();
|
||||||
}
|
}
|
||||||
return ret;
|
return returnFields;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea) {
|
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea) {
|
||||||
|
|
|
@ -39,10 +39,6 @@ using System.Drawing.Drawing2D;
|
||||||
using GreenshotPlugin.Controls;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace Greenshot.Drawing {
|
namespace Greenshot.Drawing {
|
||||||
public delegate void SurfaceElementEventHandler(object source, DrawableContainerList element);
|
|
||||||
public delegate void SurfaceDrawingModeEventHandler(object source, DrawingModes drawingMode);
|
|
||||||
|
|
||||||
public enum DrawingModes { None, Rect, Ellipse, Text, Line, Arrow, Crop, Highlight, Obfuscate, Bitmap, Path }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of Surface.
|
/// Description of Surface.
|
||||||
|
@ -155,7 +151,7 @@ namespace Greenshot.Drawing {
|
||||||
/// The selected element for the mouse down, do not serialize
|
/// The selected element for the mouse down, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DrawableContainer mouseDownElement = null;
|
private IDrawableContainer mouseDownElement = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// all selected elements, do not serialize
|
/// all selected elements, do not serialize
|
||||||
|
@ -167,19 +163,19 @@ namespace Greenshot.Drawing {
|
||||||
/// the element we are drawing with, do not serialize
|
/// the element we are drawing with, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DrawableContainer drawingElement = null;
|
private IDrawableContainer drawingElement = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the element we want to draw with (not yet drawn), do not serialize
|
/// the element we want to draw with (not yet drawn), do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DrawableContainer undrawnElement = null;
|
private IDrawableContainer undrawnElement = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the cropcontainer, when cropping this is set, do not serialize
|
/// the cropcontainer, when cropping this is set, do not serialize
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[NonSerialized]
|
[NonSerialized]
|
||||||
private DrawableContainer cropContainer = null;
|
private IDrawableContainer cropContainer = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// the brush which is used for transparent backgrounds, set by the editor, do not serialize
|
/// the brush which is used for transparent backgrounds, set by the editor, do not serialize
|
||||||
|
@ -319,8 +315,12 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICaptureDetails CaptureDetails {
|
public ICaptureDetails CaptureDetails {
|
||||||
get {return captureDetails;}
|
get {
|
||||||
set {captureDetails = value;}
|
return captureDetails;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
captureDetails = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Surface() : base(){
|
public Surface() : base(){
|
||||||
|
@ -338,6 +338,7 @@ namespace Greenshot.Drawing {
|
||||||
this.elements.Parent = this;
|
this.elements.Parent = this;
|
||||||
// Make sure we are visible
|
// Make sure we are visible
|
||||||
this.Visible = true;
|
this.Visible = true;
|
||||||
|
this.TabStop = false;
|
||||||
// Enable double buffering
|
// Enable double buffering
|
||||||
this.DoubleBuffered = true;
|
this.DoubleBuffered = true;
|
||||||
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.ContainerControl | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
|
this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw | ControlStyles.ContainerControl | ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor, true);
|
||||||
|
@ -447,6 +448,7 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public LangKey RedoActionKey {
|
public LangKey RedoActionKey {
|
||||||
get {
|
get {
|
||||||
if (CanRedo) {
|
if (CanRedo) {
|
||||||
|
@ -932,7 +934,7 @@ namespace Greenshot.Drawing {
|
||||||
selectedList = selectedElements;
|
selectedList = selectedElements;
|
||||||
} else {
|
} else {
|
||||||
// Single element
|
// Single element
|
||||||
DrawableContainer rightClickedContainer = elements.ClickableElementAt(mouseStart.X, mouseStart.Y);
|
IDrawableContainer rightClickedContainer = elements.ClickableElementAt(mouseStart.X, mouseStart.Y);
|
||||||
if (rightClickedContainer != null) {
|
if (rightClickedContainer != null) {
|
||||||
selectedList = new DrawableContainerList();
|
selectedList = new DrawableContainerList();
|
||||||
selectedList.Add(rightClickedContainer);
|
selectedList.Add(rightClickedContainer);
|
||||||
|
@ -996,7 +998,7 @@ namespace Greenshot.Drawing {
|
||||||
mouseDownElement = null;
|
mouseDownElement = null;
|
||||||
if (DrawingMode == DrawingModes.None) {
|
if (DrawingMode == DrawingModes.None) {
|
||||||
// check whether an existing element was clicked
|
// check whether an existing element was clicked
|
||||||
DrawableContainer element = elements.ClickableElementAt(currentMouse.X, currentMouse.Y);
|
IDrawableContainer element = elements.ClickableElementAt(currentMouse.X, currentMouse.Y);
|
||||||
bool shiftModifier = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
|
bool shiftModifier = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
|
||||||
if (element != null) {
|
if (element != null) {
|
||||||
element.Invalidate();
|
element.Invalidate();
|
||||||
|
@ -1166,7 +1168,7 @@ namespace Greenshot.Drawing {
|
||||||
/// Wrapper for makeUndoable flag which was introduced later, will call AddElement with makeundoable set to true
|
/// Wrapper for makeUndoable flag which was introduced later, will call AddElement with makeundoable set to true
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="element">the new element</param>
|
/// <param name="element">the new element</param>
|
||||||
public void AddElement(DrawableContainer element) {
|
public void AddElement(IDrawableContainer element) {
|
||||||
AddElement(element, true);
|
AddElement(element, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1175,11 +1177,14 @@ namespace Greenshot.Drawing {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="element">the new element</param>
|
/// <param name="element">the new element</param>
|
||||||
/// <param name="makeUndoable">true if the adding should be undoable</param>
|
/// <param name="makeUndoable">true if the adding should be undoable</param>
|
||||||
public void AddElement(DrawableContainer element, bool makeUndoable) {
|
public void AddElement(IDrawableContainer element, bool makeUndoable) {
|
||||||
elements.Add(element);
|
elements.Add(element);
|
||||||
element.FieldChanged += element_FieldChanged;
|
DrawableContainer container = element as DrawableContainer;
|
||||||
|
if (container != null) {
|
||||||
|
container.FieldChanged += element_FieldChanged;
|
||||||
|
}
|
||||||
element.PropertyChanged += ElementPropertyChanged;
|
element.PropertyChanged += ElementPropertyChanged;
|
||||||
if(element.Status == EditStatus.UNDRAWN) {
|
if (element.Status == EditStatus.UNDRAWN) {
|
||||||
element.Status = EditStatus.IDLE;
|
element.Status = EditStatus.IDLE;
|
||||||
}
|
}
|
||||||
element.Invalidate();
|
element.Invalidate();
|
||||||
|
@ -1190,21 +1195,23 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable) {
|
public void RemoveElement(IDrawableContainer elementToRemove, bool makeUndoable) {
|
||||||
|
DeselectElement(elementToRemove);
|
||||||
|
elements.Remove(elementToRemove);
|
||||||
DrawableContainer element = elementToRemove as DrawableContainer;
|
DrawableContainer element = elementToRemove as DrawableContainer;
|
||||||
DeselectElement(element);
|
if (element != null) {
|
||||||
elements.Remove(element);
|
element.FieldChanged -= element_FieldChanged;
|
||||||
element.FieldChanged -= element_FieldChanged;
|
}
|
||||||
element.PropertyChanged -= ElementPropertyChanged;
|
elementToRemove.PropertyChanged -= ElementPropertyChanged;
|
||||||
// Do not dispose, the memento should!! element.Dispose();
|
// Do not dispose, the memento should!! element.Dispose();
|
||||||
element.Invalidate();
|
elementToRemove.Invalidate();
|
||||||
if (makeUndoable) {
|
if (makeUndoable) {
|
||||||
MakeUndoable(new DeleteElementMemento(this, element), false);
|
MakeUndoable(new DeleteElementMemento(this, elementToRemove), false);
|
||||||
}
|
}
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddElements(DrawableContainerList elementsToAdd) {
|
public void AddElements(DrawableContainerList elementsToAdd) {
|
||||||
foreach(DrawableContainer element in elementsToAdd) {
|
foreach(IDrawableContainer element in elementsToAdd) {
|
||||||
AddElement(element, true);
|
AddElement(element, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1248,8 +1255,8 @@ namespace Greenshot.Drawing {
|
||||||
|
|
||||||
public void ConfirmSelectedConfirmableElements(bool confirm){
|
public void ConfirmSelectedConfirmableElements(bool confirm){
|
||||||
// create new collection so that we can iterate safely (selectedElements might change due with confirm/cancel)
|
// create new collection so that we can iterate safely (selectedElements might change due with confirm/cancel)
|
||||||
List<DrawableContainer> selectedDCs = new List<DrawableContainer>(selectedElements);
|
List<IDrawableContainer> selectedDCs = new List<IDrawableContainer>(selectedElements);
|
||||||
foreach(DrawableContainer dc in selectedDCs){
|
foreach(IDrawableContainer dc in selectedDCs){
|
||||||
if(dc.Equals(cropContainer)){
|
if(dc.Equals(cropContainer)){
|
||||||
DrawingMode = DrawingModes.None;
|
DrawingMode = DrawingModes.None;
|
||||||
// No undo memento for the cropcontainer itself, only for the effect
|
// No undo memento for the cropcontainer itself, only for the effect
|
||||||
|
@ -1314,11 +1321,10 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeselectElement(IDrawableContainer container) {
|
public void DeselectElement(IDrawableContainer container) {
|
||||||
DrawableContainer element = container as DrawableContainer;
|
container.HideGrippers();
|
||||||
element.HideGrippers();
|
container.Selected = false;
|
||||||
element.Selected = false;
|
selectedElements.Remove(container);
|
||||||
selectedElements.Remove(element);
|
FieldAggregator.UnbindElement(container);
|
||||||
FieldAggregator.UnbindElement(element);
|
|
||||||
if (movingElementChanged != null) {
|
if (movingElementChanged != null) {
|
||||||
movingElementChanged(this, selectedElements);
|
movingElementChanged(this, selectedElements);
|
||||||
}
|
}
|
||||||
|
@ -1327,7 +1333,7 @@ namespace Greenshot.Drawing {
|
||||||
public void DeselectAllElements() {
|
public void DeselectAllElements() {
|
||||||
if (HasSelectedElements()) {
|
if (HasSelectedElements()) {
|
||||||
while(selectedElements.Count > 0) {
|
while(selectedElements.Count > 0) {
|
||||||
DrawableContainer element = selectedElements[0];
|
IDrawableContainer element = selectedElements[0];
|
||||||
element.Invalidate();
|
element.Invalidate();
|
||||||
element.HideGrippers();
|
element.HideGrippers();
|
||||||
element.Selected = false;
|
element.Selected = false;
|
||||||
|
@ -1341,16 +1347,15 @@ namespace Greenshot.Drawing {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectElement(IDrawableContainer container) {
|
public void SelectElement(IDrawableContainer container) {
|
||||||
DrawableContainer element = container as DrawableContainer;
|
if (!selectedElements.Contains(container)) {
|
||||||
if(!selectedElements.Contains(element)) {
|
selectedElements.Add(container);
|
||||||
selectedElements.Add(element);
|
container.ShowGrippers();
|
||||||
element.ShowGrippers();
|
container.Selected = true;
|
||||||
element.Selected = true;
|
FieldAggregator.BindElement(container);
|
||||||
FieldAggregator.BindElement(element);
|
|
||||||
if (movingElementChanged != null) {
|
if (movingElementChanged != null) {
|
||||||
movingElementChanged(this, selectedElements);
|
movingElementChanged(this, selectedElements);
|
||||||
}
|
}
|
||||||
element.Invalidate();
|
container.Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using Greenshot.Plugin.Drawing;
|
||||||
|
|
||||||
namespace Greenshot {
|
namespace Greenshot {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -71,12 +72,6 @@ namespace Greenshot {
|
||||||
get { return this; }
|
get { return this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Surface EditorSurface {
|
|
||||||
get {
|
|
||||||
return surface;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<IImageEditor> Editors {
|
public static List<IImageEditor> Editors {
|
||||||
get {
|
get {
|
||||||
return editorList;
|
return editorList;
|
||||||
|
@ -84,19 +79,13 @@ namespace Greenshot {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImageEditorForm(ISurface iSurface, bool outputMade) {
|
public ImageEditorForm(ISurface iSurface, bool outputMade) {
|
||||||
// init surface
|
|
||||||
this.surface = iSurface as Surface;
|
|
||||||
editorList.Add(this);
|
editorList.Add(this);
|
||||||
|
|
||||||
// Intial "saved" flag for asking if the image needs to be save
|
|
||||||
surface.Modified = !outputMade;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||||
//
|
//
|
||||||
this.ManualLanguageApply = true;
|
this.ManualLanguageApply = true;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
updateUI();
|
|
||||||
|
|
||||||
this.Load += delegate {
|
this.Load += delegate {
|
||||||
new Thread(delegate() {AddDestinations();}).Start();
|
new Thread(delegate() {AddDestinations();}).Start();
|
||||||
|
@ -104,18 +93,58 @@ namespace Greenshot {
|
||||||
|
|
||||||
IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);
|
IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);
|
||||||
|
|
||||||
|
|
||||||
|
// init surface
|
||||||
|
Surface = iSurface;
|
||||||
|
// Intial "saved" flag for asking if the image needs to be save
|
||||||
|
surface.Modified = !outputMade;
|
||||||
|
updateUI();
|
||||||
|
|
||||||
// Make sure the editor is placed on the same location as the last editor was on close
|
// Make sure the editor is placed on the same location as the last editor was on close
|
||||||
WindowDetails thisForm = new WindowDetails(this.Handle);
|
WindowDetails thisForm = new WindowDetails(this.Handle);
|
||||||
thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());
|
thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());
|
||||||
|
|
||||||
SurfaceSizeChanged(this.Surface);
|
|
||||||
|
|
||||||
bindFieldControls();
|
|
||||||
refreshEditorControls();
|
|
||||||
// Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
|
// Workaround: As the cursor is (mostly) selected on the surface a funny artifact is visible, this fixes it.
|
||||||
hideToolstripItems();
|
hideToolstripItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RemoveSurface() {
|
||||||
|
if (surface != null) {
|
||||||
|
panel1.Controls.Remove(surface as Control);
|
||||||
|
this.surface.Dispose();
|
||||||
|
this.surface = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetSurface(ISurface newSurface) {
|
||||||
|
if (this.Surface != null && this.Surface.Modified) {
|
||||||
|
throw new ApplicationException("Surface modified");
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveSurface();
|
||||||
|
|
||||||
|
this.surface = newSurface as Surface;
|
||||||
|
panel1.Controls.Add(surface as Surface);
|
||||||
|
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
||||||
|
this.surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
|
||||||
|
|
||||||
|
surface.MovingElementChanged += delegate {
|
||||||
|
refreshEditorControls();
|
||||||
|
};
|
||||||
|
surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
|
||||||
|
surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);
|
||||||
|
surface.SurfaceMessage += new SurfaceMessageEventHandler(SurfaceMessageReceived);
|
||||||
|
surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler(FieldAggregatorFieldChanged);
|
||||||
|
|
||||||
|
SurfaceSizeChanged(this.Surface);
|
||||||
|
|
||||||
|
bindFieldControls();
|
||||||
|
refreshEditorControls();
|
||||||
|
// Fix title
|
||||||
|
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
|
||||||
|
this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
||||||
|
@ -126,9 +155,6 @@ namespace Greenshot {
|
||||||
toolStripSeparator11.Visible = !coreConf.DisableSettings;
|
toolStripSeparator11.Visible = !coreConf.DisableSettings;
|
||||||
btnSettings.Visible = !coreConf.DisableSettings;
|
btnSettings.Visible = !coreConf.DisableSettings;
|
||||||
|
|
||||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
|
|
||||||
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
|
||||||
surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
|
|
||||||
// Make sure Double-buffer is enabled
|
// Make sure Double-buffer is enabled
|
||||||
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
|
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
|
||||||
|
|
||||||
|
@ -136,22 +162,12 @@ namespace Greenshot {
|
||||||
// to fix the bug (?) with the vscrollbar not being able to shrink to
|
// to fix the bug (?) with the vscrollbar not being able to shrink to
|
||||||
// a smaller size than the initial panel size (as set by the forms designer)
|
// a smaller size than the initial panel size (as set by the forms designer)
|
||||||
panel1.Height = 10;
|
panel1.Height = 10;
|
||||||
|
|
||||||
surface.TabStop = false;
|
|
||||||
|
|
||||||
surface.MovingElementChanged += delegate { refreshEditorControls(); };
|
|
||||||
surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
|
|
||||||
surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);
|
|
||||||
surface.SurfaceMessage += new SurfaceMessageEventHandler(SurfaceMessageReceived);
|
|
||||||
|
|
||||||
this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);
|
this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);
|
||||||
|
|
||||||
surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler( FieldAggregatorFieldChanged );
|
|
||||||
obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
||||||
highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
|
||||||
|
|
||||||
panel1.Controls.Add(surface);
|
|
||||||
|
|
||||||
toolbarButtons = new GreenshotPlugin.Controls.GreenshotToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
|
toolbarButtons = new GreenshotPlugin.Controls.GreenshotToolStripButton[] { btnCursor, btnRect, btnEllipse, btnText, btnLine, btnArrow, btnFreehand, btnHighlight, btnObfuscate, btnCrop };
|
||||||
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
|
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
|
||||||
|
|
||||||
|
@ -161,11 +177,6 @@ namespace Greenshot {
|
||||||
this.MouseWheel += new MouseEventHandler( PanelMouseWheel);
|
this.MouseWheel += new MouseEventHandler( PanelMouseWheel);
|
||||||
|
|
||||||
ApplyLanguage();
|
ApplyLanguage();
|
||||||
|
|
||||||
// Fix title
|
|
||||||
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
|
|
||||||
this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -329,15 +340,20 @@ namespace Greenshot {
|
||||||
// Even update language when needed
|
// Even update language when needed
|
||||||
ApplyLanguage();
|
ApplyLanguage();
|
||||||
|
|
||||||
// Fix title
|
// Fix title
|
||||||
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
|
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
|
||||||
this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public ISurface Surface {
|
public ISurface Surface {
|
||||||
get {return surface;}
|
get {
|
||||||
|
return surface;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
SetSurface(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetImagePath(string fullpath) {
|
public void SetImagePath(string fullpath) {
|
||||||
|
@ -648,7 +664,7 @@ namespace Greenshot {
|
||||||
updateClipboardSurfaceDependencies();
|
updateClipboardSurfaceDependencies();
|
||||||
updateUndoRedoSurfaceDependencies();
|
updateUndoRedoSurfaceDependencies();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageEditorFormFormClosing(object sender, FormClosingEventArgs e) {
|
void ImageEditorFormFormClosing(object sender, FormClosingEventArgs e) {
|
||||||
IniConfig.IniChanged -= new FileSystemEventHandler(ReloadConfiguration);
|
IniConfig.IniChanged -= new FileSystemEventHandler(ReloadConfiguration);
|
||||||
if (surface.Modified && !editorConfiguration.SuppressSaveDialogAtClose) {
|
if (surface.Modified && !editorConfiguration.SuppressSaveDialogAtClose) {
|
||||||
|
|
|
@ -21,16 +21,17 @@
|
||||||
using System;
|
using System;
|
||||||
using Greenshot.Configuration;
|
using Greenshot.Configuration;
|
||||||
using Greenshot.Drawing;
|
using Greenshot.Drawing;
|
||||||
|
using Greenshot.Plugin.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Memento {
|
namespace Greenshot.Memento {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The AddElementMemento makes it possible to undo adding an element
|
/// The AddElementMemento makes it possible to undo adding an element
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class AddElementMemento : IMemento {
|
public class AddElementMemento : IMemento {
|
||||||
private DrawableContainer drawableContainer;
|
private IDrawableContainer drawableContainer;
|
||||||
private Surface surface;
|
private Surface surface;
|
||||||
|
|
||||||
public AddElementMemento(Surface surface, DrawableContainer drawableContainer) {
|
public AddElementMemento(Surface surface, IDrawableContainer drawableContainer) {
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
this.drawableContainer = drawableContainer;
|
this.drawableContainer = drawableContainer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,17 @@
|
||||||
using System;
|
using System;
|
||||||
using Greenshot.Configuration;
|
using Greenshot.Configuration;
|
||||||
using Greenshot.Drawing;
|
using Greenshot.Drawing;
|
||||||
|
using Greenshot.Plugin.Drawing;
|
||||||
|
|
||||||
namespace Greenshot.Memento {
|
namespace Greenshot.Memento {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The DeleteElementMemento makes it possible to undo deleting an element
|
/// The DeleteElementMemento makes it possible to undo deleting an element
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DeleteElementMemento : IMemento {
|
public class DeleteElementMemento : IMemento {
|
||||||
private DrawableContainer drawableContainer;
|
private IDrawableContainer drawableContainer;
|
||||||
private Surface surface;
|
private Surface surface;
|
||||||
|
|
||||||
public DeleteElementMemento(Surface surface, DrawableContainer drawableContainer) {
|
public DeleteElementMemento(Surface surface, IDrawableContainer drawableContainer) {
|
||||||
this.surface = surface;
|
this.surface = surface;
|
||||||
this.drawableContainer = drawableContainer;
|
this.drawableContainer = drawableContainer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -745,7 +745,7 @@ namespace GreenshotPlugin.Core {
|
||||||
cm.Matrix22 = 0;
|
cm.Matrix22 = 0;
|
||||||
cm.Matrix33 = darkness;
|
cm.Matrix33 = darkness;
|
||||||
ia.SetColorMatrix(cm);
|
ia.SetColorMatrix(cm);
|
||||||
Rectangle shadowRectangle = new Rectangle(new Point(shadowSize - 1, shadowSize - 1), sourceBitmap.Size);
|
Rectangle shadowRectangle = new Rectangle(new Point(shadowSize, shadowSize), sourceBitmap.Size);
|
||||||
graphics.DrawImage(sourceBitmap, shadowRectangle, 0, 0, sourceBitmap.Width, sourceBitmap.Height, GraphicsUnit.Pixel, ia);
|
graphics.DrawImage(sourceBitmap, shadowRectangle, 0, 0, sourceBitmap.Width, sourceBitmap.Height, GraphicsUnit.Pixel, ia);
|
||||||
}
|
}
|
||||||
// blur "shadow", apply to whole new image
|
// blur "shadow", apply to whole new image
|
||||||
|
|
|
@ -22,12 +22,13 @@ using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace Greenshot.Plugin.Drawing {
|
namespace Greenshot.Plugin.Drawing {
|
||||||
public enum RenderMode {EDIT, EXPORT};
|
public enum RenderMode {EDIT, EXPORT};
|
||||||
public enum EditStatus {UNDRAWN, DRAWING, MOVING, RESIZING, IDLE};
|
public enum EditStatus {UNDRAWN, DRAWING, MOVING, RESIZING, IDLE};
|
||||||
|
|
||||||
public interface IDrawableContainer {
|
public interface IDrawableContainer : INotifyPropertyChanged {
|
||||||
ISurface Parent {
|
ISurface Parent {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
@ -76,9 +77,22 @@ namespace Greenshot.Plugin.Drawing {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditStatus Status {
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
}
|
||||||
void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment);
|
void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment);
|
||||||
void Invalidate();
|
void Invalidate();
|
||||||
void Dispose();
|
void Dispose();
|
||||||
|
bool ClickableAt(int x, int y);
|
||||||
|
void HideGrippers();
|
||||||
|
void ShowGrippers();
|
||||||
|
void MoveBy(int x, int y);
|
||||||
|
bool HandleMouseDown(int x, int y);
|
||||||
|
void HandleMouseUp(int x, int y);
|
||||||
|
bool HandleMouseMove(int x, int y);
|
||||||
|
bool InitContent();
|
||||||
|
void MakeBoundsChangeUndoable(bool allowMerge);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITextContainer: IDrawableContainer {
|
public interface ITextContainer: IDrawableContainer {
|
||||||
|
|
|
@ -70,9 +70,10 @@ namespace Greenshot.Plugin {
|
||||||
ICaptureDetails CaptureDetails {
|
ICaptureDetails CaptureDetails {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
ISurface Surface {
|
ISurface Surface {
|
||||||
get;
|
get;
|
||||||
|
set;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Greenshot.Plugin {
|
namespace Greenshot.Plugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -58,13 +59,18 @@ namespace Greenshot.Plugin {
|
||||||
|
|
||||||
public delegate void SurfaceSizeChangeEventHandler(object source);
|
public delegate void SurfaceSizeChangeEventHandler(object source);
|
||||||
public delegate void SurfaceMessageEventHandler(object source, SurfaceMessageEventArgs eventArgs);
|
public delegate void SurfaceMessageEventHandler(object source, SurfaceMessageEventArgs eventArgs);
|
||||||
|
public delegate void SurfaceElementEventHandler(object source, IList<IDrawableContainer> element);
|
||||||
|
public delegate void SurfaceDrawingModeEventHandler(object source, DrawingModes drawingMode);
|
||||||
|
public enum DrawingModes { None, Rect, Ellipse, Text, Line, Arrow, Crop, Highlight, Obfuscate, Bitmap, Path }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The interface to the Surface object, so Plugins can use it.
|
/// The interface to the Surface object, so Plugins can use it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ISurface : IDisposable {
|
public interface ISurface : IDisposable {
|
||||||
event SurfaceSizeChangeEventHandler SurfaceSizeChanged;
|
event SurfaceSizeChangeEventHandler SurfaceSizeChanged;
|
||||||
event SurfaceMessageEventHandler SurfaceMessage;
|
event SurfaceMessageEventHandler SurfaceMessage;
|
||||||
|
event SurfaceDrawingModeEventHandler DrawingModeChanged;
|
||||||
|
event SurfaceElementEventHandler MovingElementChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get/Set the image to the Surface
|
/// Get/Set the image to the Surface
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue