mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
Removed some unused code, and fixed a Editor-reuse issue. (No focus, and resize issues)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2106 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
336518f5f9
commit
f7782299cd
7 changed files with 105 additions and 96 deletions
|
@ -96,6 +96,7 @@ namespace Greenshot.Destinations {
|
|||
GC.Collect();
|
||||
GC.WaitForPendingFinalizers();
|
||||
|
||||
bool modified = surface.Modified;
|
||||
if (editor == null) {
|
||||
if (editorConfiguration.ReuseEditor) {
|
||||
foreach(IImageEditor openedEditor in ImageEditorForm.Editors) {
|
||||
|
@ -134,6 +135,8 @@ namespace Greenshot.Destinations {
|
|||
}
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
// Workaround for the modified flag when using the editor.
|
||||
surface.Modified = modified;
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,6 +108,9 @@ namespace Greenshot {
|
|||
hideToolstripItems();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove the current surface
|
||||
/// </summary>
|
||||
private void RemoveSurface() {
|
||||
if (surface != null) {
|
||||
panel1.Controls.Remove(surface as Control);
|
||||
|
@ -116,6 +119,10 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Change the surface
|
||||
/// </summary>
|
||||
/// <param name="newSurface"></param>
|
||||
private void SetSurface(ISurface newSurface) {
|
||||
if (this.Surface != null && this.Surface.Modified) {
|
||||
throw new ApplicationException("Surface modified");
|
||||
|
@ -123,6 +130,8 @@ namespace Greenshot {
|
|||
|
||||
RemoveSurface();
|
||||
|
||||
panel1.Height = 10;
|
||||
panel1.Width = 10;
|
||||
this.surface = newSurface as Surface;
|
||||
panel1.Controls.Add(surface as Surface);
|
||||
Image backgroundForTransparency = GreenshotPlugin.Core.GreenshotResources.getImage("Checkerboard.Image");
|
||||
|
@ -135,7 +144,6 @@ namespace Greenshot {
|
|||
surface.SurfaceSizeChanged += new SurfaceSizeChangeEventHandler(SurfaceSizeChanged);
|
||||
surface.SurfaceMessage += new SurfaceMessageEventHandler(SurfaceMessageReceived);
|
||||
surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler(FieldAggregatorFieldChanged);
|
||||
|
||||
SurfaceSizeChanged(this.Surface);
|
||||
|
||||
bindFieldControls();
|
||||
|
@ -144,6 +152,7 @@ namespace Greenshot {
|
|||
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
|
||||
this.Text = surface.CaptureDetails.Title + " - " + Language.GetString(LangKey.editor_title);
|
||||
}
|
||||
WindowDetails.ToForeground(this.Handle);
|
||||
}
|
||||
|
||||
private void updateUI() {
|
||||
|
|
|
@ -372,7 +372,7 @@ namespace Greenshot.Helpers {
|
|||
}
|
||||
// Move cursor, fixing bug #3569703
|
||||
capture.MoveMouseLocation(capture.ScreenBounds.Location.X - capture.Location.X, capture.ScreenBounds.Location.Y - capture.Location.Y);
|
||||
capture.MoveElements(capture.ScreenBounds.Location.X - capture.Location.X, capture.ScreenBounds.Location.Y - capture.Location.Y);
|
||||
//capture.MoveElements(capture.ScreenBounds.Location.X - capture.Location.X, capture.ScreenBounds.Location.Y - capture.Location.Y);
|
||||
|
||||
capture.CaptureDetails.AddMetaData("source", "screen");
|
||||
HandleCapture();
|
||||
|
|
|
@ -131,14 +131,7 @@ namespace Greenshot.Helpers {
|
|||
public static ExportInformation ExportCapture(bool manuallyInitiated, string designation, ISurface surface, ICaptureDetails captureDetails) {
|
||||
IDestination destination = GetDestination(designation);
|
||||
if (destination != null && destination.isActive) {
|
||||
ExportInformation exportInformation = destination.ExportCapture(manuallyInitiated, surface, captureDetails);
|
||||
if (exportInformation != null && exportInformation.ExportMade) {
|
||||
// Export worked, set the modified flag to false if the export wasn't to the editor or picker
|
||||
if (!EditorDestination.DESIGNATION.Equals(designation) && !PickerDestination.DESIGNATION.Equals(designation)) {
|
||||
surface.Modified = false;
|
||||
}
|
||||
}
|
||||
return exportInformation;
|
||||
return destination.ExportCapture(manuallyInitiated, surface, captureDetails);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -372,30 +372,31 @@ namespace Greenshot.Helpers {
|
|||
} catch (Exception captureException) {
|
||||
LOG.Error("Exception found, ignoring and returning nothing! Error was: ", captureException);
|
||||
}
|
||||
// TODO: Enable when the elements are usable again.
|
||||
// Capture the element on the page
|
||||
try {
|
||||
if (configuration.IEFieldCapture && capture.CaptureDetails.HasDestination("Editor")) {
|
||||
// clear the current elements, as they are for the window itself
|
||||
capture.Elements.Clear();
|
||||
CaptureElement documentCaptureElement = documentContainer.CreateCaptureElements(pageSize);
|
||||
foreach(DocumentContainer frameDocument in documentContainer.Frames) {
|
||||
try {
|
||||
CaptureElement frameCaptureElement = frameDocument.CreateCaptureElements(Size.Empty);
|
||||
if (frameCaptureElement != null) {
|
||||
documentCaptureElement.Children.Add(frameCaptureElement);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.Warn("An error occurred while creating the capture elements: ", ex);
|
||||
}
|
||||
}
|
||||
capture.AddElement(documentCaptureElement);
|
||||
// Offset the elements, as they are "back offseted" later...
|
||||
Point windowLocation = documentContainer.ContentWindow.WindowRectangle.Location;
|
||||
capture.MoveElements(-(capture.ScreenBounds.Location.X-windowLocation.X), -(capture.ScreenBounds.Location.Y-windowLocation.Y));
|
||||
}
|
||||
} catch (Exception elementsException) {
|
||||
LOG.Warn("An error occurred while creating the capture elements: ", elementsException);
|
||||
}
|
||||
//try {
|
||||
// if (configuration.IEFieldCapture && capture.CaptureDetails.HasDestination("Editor")) {
|
||||
// // clear the current elements, as they are for the window itself
|
||||
// capture.Elements.Clear();
|
||||
// CaptureElement documentCaptureElement = documentContainer.CreateCaptureElements(pageSize);
|
||||
// foreach(DocumentContainer frameDocument in documentContainer.Frames) {
|
||||
// try {
|
||||
// CaptureElement frameCaptureElement = frameDocument.CreateCaptureElements(Size.Empty);
|
||||
// if (frameCaptureElement != null) {
|
||||
// documentCaptureElement.Children.Add(frameCaptureElement);
|
||||
// }
|
||||
// } catch (Exception ex) {
|
||||
// LOG.Warn("An error occurred while creating the capture elements: ", ex);
|
||||
// }
|
||||
// }
|
||||
// capture.AddElement(documentCaptureElement);
|
||||
// // Offset the elements, as they are "back offseted" later...
|
||||
// Point windowLocation = documentContainer.ContentWindow.WindowRectangle.Location;
|
||||
// capture.MoveElements(-(capture.ScreenBounds.Location.X-windowLocation.X), -(capture.ScreenBounds.Location.Y-windowLocation.Y));
|
||||
// }
|
||||
//} catch (Exception elementsException) {
|
||||
// LOG.Warn("An error occurred while creating the capture elements: ", elementsException);
|
||||
//}
|
||||
|
||||
|
||||
if (returnBitmap == null) {
|
||||
|
|
|
@ -295,7 +295,8 @@ namespace GreenshotPlugin.Core {
|
|||
// Change mouse location according to the cropRegtangle (including screenbounds) offset
|
||||
MoveMouseLocation(-cropRectangle.Location.X, -cropRectangle.Location.Y);
|
||||
// Move all the elements
|
||||
MoveElements(-cropRectangle.Location.X, -cropRectangle.Location.Y);
|
||||
// TODO: Enable when the elements are usable again.
|
||||
// MoveElements(-cropRectangle.Location.X, -cropRectangle.Location.Y);
|
||||
|
||||
// Remove invisible elements
|
||||
List <ICaptureElement> newElements = new List<ICaptureElement>();
|
||||
|
@ -321,52 +322,53 @@ namespace GreenshotPlugin.Core {
|
|||
cursorLocation.Offset(x, y);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Apply a translate to the elements
|
||||
/// e.g. needed for crop
|
||||
/// </summary>
|
||||
/// <param name="x">x coordinates to move the elements</param>
|
||||
/// <param name="y">y coordinates to move the elements</param>
|
||||
public void MoveElements(int x, int y) {
|
||||
MoveElements(elements, x, y);
|
||||
}
|
||||
// TODO: Enable when the elements are usable again.
|
||||
///// <summary>
|
||||
///// Apply a translate to the elements
|
||||
///// e.g. needed for crop
|
||||
///// </summary>
|
||||
///// <param name="x">x coordinates to move the elements</param>
|
||||
///// <param name="y">y coordinates to move the elements</param>
|
||||
//public void MoveElements(int x, int y) {
|
||||
// MoveElements(elements, x, y);
|
||||
//}
|
||||
|
||||
private void MoveElements(List<ICaptureElement> listOfElements, int x, int y) {
|
||||
foreach(ICaptureElement childElement in listOfElements) {
|
||||
Rectangle bounds = childElement.Bounds;
|
||||
bounds.Offset(x, y);
|
||||
childElement.Bounds = bounds;
|
||||
MoveElements(childElement.Children, x, y);
|
||||
}
|
||||
}
|
||||
//private void MoveElements(List<ICaptureElement> listOfElements, int x, int y) {
|
||||
// foreach(ICaptureElement childElement in listOfElements) {
|
||||
// Rectangle bounds = childElement.Bounds;
|
||||
// bounds.Offset(x, y);
|
||||
// childElement.Bounds = bounds;
|
||||
// MoveElements(childElement.Children, x, y);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Add a new element to the capture
|
||||
/// </summary>
|
||||
/// <param name="element">CaptureElement</param>
|
||||
public void AddElement(ICaptureElement element) {
|
||||
int match = elements.IndexOf(element);
|
||||
if (match >= 0) {
|
||||
if (elements[match].Children.Count < element.Children.Count) {
|
||||
elements.RemoveAt(match);
|
||||
elements.Add(element);
|
||||
}
|
||||
} else {
|
||||
elements.Add(element);
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
///// Add a new element to the capture
|
||||
///// </summary>
|
||||
///// <param name="element">CaptureElement</param>
|
||||
//public void AddElement(ICaptureElement element) {
|
||||
// int match = elements.IndexOf(element);
|
||||
// if (match >= 0) {
|
||||
// if (elements[match].Children.Count < element.Children.Count) {
|
||||
// elements.RemoveAt(match);
|
||||
// elements.Add(element);
|
||||
// }
|
||||
// } else {
|
||||
// elements.Add(element);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of rectangles which represent object that are on the capture
|
||||
/// </summary>
|
||||
public List<ICaptureElement> Elements {
|
||||
get {
|
||||
return elements;
|
||||
}
|
||||
set {
|
||||
elements = value;
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
///// Returns a list of rectangles which represent object that are on the capture
|
||||
///// </summary>
|
||||
//public List<ICaptureElement> Elements {
|
||||
// get {
|
||||
// return elements;
|
||||
// }
|
||||
// set {
|
||||
// elements = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -153,26 +153,27 @@ namespace Greenshot.Plugin {
|
|||
/// <param name="y">y coordinates to move the mouse</param>
|
||||
void MoveMouseLocation(int x, int y);
|
||||
|
||||
/// <summary>
|
||||
/// Apply a translate to the elements e.g. needed for crop
|
||||
/// </summary>
|
||||
/// <param name="x">x coordinates to move the elements</param>
|
||||
/// <param name="y">y coordinates to move the elements</param>
|
||||
void MoveElements(int x, int y);
|
||||
// / TODO: Enable when the elements are usable again.
|
||||
///// <summary>
|
||||
///// Apply a translate to the elements e.g. needed for crop
|
||||
///// </summary>
|
||||
///// <param name="x">x coordinates to move the elements</param>
|
||||
///// <param name="y">y coordinates to move the elements</param>
|
||||
//void MoveElements(int x, int y);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new element to the capture
|
||||
/// </summary>
|
||||
/// <param name="element">Rectangle</param>
|
||||
void AddElement(ICaptureElement element);
|
||||
///// <summary>
|
||||
///// Add a new element to the capture
|
||||
///// </summary>
|
||||
///// <param name="element">Rectangle</param>
|
||||
//void AddElement(ICaptureElement element);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of rectangles which represent objects that are "on" the capture
|
||||
/// </summary>
|
||||
List<ICaptureElement> Elements {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
///// <summary>
|
||||
///// Returns a list of rectangles which represent objects that are "on" the capture
|
||||
///// </summary>
|
||||
//List<ICaptureElement> Elements {
|
||||
// get;
|
||||
// set;
|
||||
//}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue