diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs
index b26372e85..6dfc64e47 100644
--- a/Greenshot/Forms/MainForm.cs
+++ b/Greenshot/Forms/MainForm.cs
@@ -294,7 +294,7 @@ namespace Greenshot {
private CopyData copyData = null;
// Thumbnail preview
- private FormWithoutActivation thumbnailForm = null;
+ private ThumbnailForm thumbnailForm = null;
private IntPtr thumbnailHandle = IntPtr.Zero;
private Rectangle parentMenuBounds = Rectangle.Empty;
// Make sure we have only one settings form
@@ -743,72 +743,17 @@ namespace Greenshot {
private void ShowThumbnailOnEnter(object sender, EventArgs e) {
ToolStripMenuItem captureWindowItem = sender as ToolStripMenuItem;
WindowDetails window = captureWindowItem.Tag as WindowDetails;
- parentMenuBounds = captureWindowItem.GetCurrentParent().TopLevelControl.Bounds;
if (thumbnailForm == null) {
- thumbnailForm = new FormWithoutActivation();
- thumbnailForm.ShowInTaskbar = false;
- thumbnailForm.FormBorderStyle = FormBorderStyle.None;
- thumbnailForm.TopMost = false;
- thumbnailForm.Enabled = false;
- if (conf.WindowCaptureMode == WindowCaptureMode.Auto || conf.WindowCaptureMode == WindowCaptureMode.Aero) {
- thumbnailForm.BackColor = Color.FromArgb(255, conf.DWMBackgroundColor.R, conf.DWMBackgroundColor.G, conf.DWMBackgroundColor.B);
- } else {
- thumbnailForm.BackColor = Color.White;
- }
- }
- if (thumbnailHandle != IntPtr.Zero) {
- DWM.DwmUnregisterThumbnail(thumbnailHandle);
- thumbnailHandle = IntPtr.Zero;
- }
- DWM.DwmRegisterThumbnail(thumbnailForm.Handle, window.Handle, out thumbnailHandle);
- if (thumbnailHandle != IntPtr.Zero) {
- Rectangle windowRectangle = window.WindowRectangle;
- int thumbnailHeight = 200;
- int thumbnailWidth = (int)(thumbnailHeight * ((float)windowRectangle.Width / (float)windowRectangle.Height));
- if (thumbnailWidth > parentMenuBounds.Width) {
- thumbnailWidth = parentMenuBounds.Width;
- thumbnailHeight = (int)(thumbnailWidth * ((float)windowRectangle.Height / (float)windowRectangle.Width));
- }
- thumbnailForm.Width = thumbnailWidth;
- thumbnailForm.Height = thumbnailHeight;
- // Prepare the displaying of the Thumbnail
- DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();
- props.Opacity = (byte)255;
- props.Visible = true;
- props.SourceClientAreaOnly = false;
- props.Destination = new RECT(0, 0, thumbnailWidth, thumbnailHeight);
- DWM.DwmUpdateThumbnailProperties(thumbnailHandle, ref props);
- if (!thumbnailForm.Visible) {
- thumbnailForm.Show();
- }
- // Make sure it's on "top"!
- User32.SetWindowPos(thumbnailForm.Handle,captureWindowItem.GetCurrentParent().TopLevelControl.Handle, 0,0,0,0, WindowPos.SWP_NOMOVE | WindowPos.SWP_NOSIZE | WindowPos.SWP_NOACTIVATE);
-
- // Align to menu
- Rectangle screenBounds = WindowCapture.GetScreenBounds();
- if (screenBounds.Contains(parentMenuBounds.Left, parentMenuBounds.Top - thumbnailHeight)) {
- thumbnailForm.Location = new Point(parentMenuBounds.Left + (parentMenuBounds.Width/2) - (thumbnailWidth/2), parentMenuBounds.Top - thumbnailHeight);
- } else {
- thumbnailForm.Location = new Point(parentMenuBounds.Left + (parentMenuBounds.Width/2) - (thumbnailWidth/2), parentMenuBounds.Bottom);
- }
+ thumbnailForm = new ThumbnailForm();
}
+ thumbnailForm.ShowThumbnail(window, captureWindowItem.GetCurrentParent().TopLevelControl);
}
private void HideThumbnailOnLeave(object sender, EventArgs e) {
- hideThumbnail();
- }
-
- private void hideThumbnail() {
- if (thumbnailHandle != IntPtr.Zero) {
- DWM.DwmUnregisterThumbnail(thumbnailHandle);
- thumbnailHandle = IntPtr.Zero;
- thumbnailForm.Hide();
- }
+ thumbnailForm.Hide();
}
private void cleanupThumbnail() {
- hideThumbnail();
-
if (thumbnailForm != null) {
thumbnailForm.Close();
thumbnailForm = null;
diff --git a/Greenshot/Greenshot.csproj b/Greenshot/Greenshot.csproj
index 819e5aa5f..c48188565 100644
--- a/Greenshot/Greenshot.csproj
+++ b/Greenshot/Greenshot.csproj
@@ -161,9 +161,6 @@
CaptureForm.cs
-
- Form
- Form
diff --git a/Greenshot/Languages/language-en-US.xml b/Greenshot/Languages/language-en-US.xml
index c4b8d5e05..849aec4c4 100644
--- a/Greenshot/Languages/language-en-US.xml
+++ b/Greenshot/Languages/language-en-US.xml
@@ -5,19 +5,19 @@
If you like Greenshot, you are welcome to support us:Greenshot is hosted by sourceforge.net atIcons from Yusuke Kamiyamane's Fugue icon set (Creative Commons Attribution 3.0 license)
- Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
-Greenshot comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
+ Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
+Greenshot comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions.
Details about the GNU General Public License:About GreenshotGreenshot - the revolutionary screenshot utilityClose
- Sorry, an unexpected error occured.
-
-The good news is: you can help us getting rid of it by filing a bug report.
-Please visit the URL below, create a new bug report and paste the contents from the text area into the description.
-
-Please add a meaningful summary and enclose any information you consider to be helpful for reproducing the issue.
+ Sorry, an unexpected error occured.
+
+The good news is: you can help us getting rid of it by filing a bug report.
+Please visit the URL below, create a new bug report and paste the contents from the text area into the description.
+
+Please add a meaningful summary and enclose any information you consider to be helpful for reproducing the issue.
Also, we would highly appreciate if you checked whether a tracker item already exists for this bug. (You can use the search to find those quickly.) Thank you :)ErrorCancel
@@ -51,6 +51,7 @@ Also, we would highly appreciate if you checked whether a tracker item already e
Open last capture locationQuick preferencesPreferences...
+ Error while exporting to {0}. Please try again.ArrangeArrow headsBoth
@@ -137,7 +138,7 @@ Also, we would highly appreciate if you checked whether a tracker item already e
Outlook with textErrorAn instance of Greenshot is already running.
- Cannot save file to {0}.
+ Cannot save file to {0}.
Please check write accessibility of the selected storage location.The file "{0}" could not be opened.Could not open link '{0}'.
@@ -201,22 +202,22 @@ Please check write accessibility of the selected storage location.JPEG qualityQuality settingsLanguage
- The following placeholders will be replaced automatically in the pattern defined:
-${YYYY} year, 4 digits
-${MM} month, 2 digits
-${DD} day, 2 digits
-${hh} hour, 2 digits
-${mm} minute, 2 digits
-${ss} second, 2 digits
-${NUM} incrementing number, 6 digits
-${title} Window title
-${user} Windows user
-${domain} Windows domain
-${hostname} PC name
-
-You can also have Greenshot create directories dynamically, simply use the backslash symbol (\) to separate folders and filename.
-Example: the pattern ${YYYY}-${MM}-${DD}\${hh}-${mm}-${ss}
-will generate a folder for the current day in your default storage location, e.g. 2008-06-29, the contained screenshot file's name will be based on the current
+ The following placeholders will be replaced automatically in the pattern defined:
+${YYYY} year, 4 digits
+${MM} month, 2 digits
+${DD} day, 2 digits
+${hh} hour, 2 digits
+${mm} minute, 2 digits
+${ss} second, 2 digits
+${NUM} incrementing number, 6 digits
+${title} Window title
+${user} Windows user
+${domain} Windows domain
+${hostname} PC name
+
+You can also have Greenshot create directories dynamically, simply use the backslash symbol (\) to separate folders and filename.
+Example: the pattern ${YYYY}-${MM}-${DD}\${hh}-${mm}-${ss}
+will generate a folder for the current day in your default storage location, e.g. 2008-06-29, the contained screenshot file's name will be based on the current
time, e.g. 11_58_32 (plus extension defined in the settings)Network and updatesOutput
@@ -246,8 +247,8 @@ time, e.g. 11_58_32 (plus extension defined in the settings)A newer version of Greenshot is available! Do you want to download Greenshot {0}?Please wait while the page in Internet Explorer is captured...Warning
- The hotkey(s) "{0}" could not be registered. This problem is probably caused by another tool claiming usage of the same hotkey(s)! You could either change your hotkey settings or deactivate/change the software making use of the hotkey(s).
-
+ The hotkey(s) "{0}" could not be registered. This problem is probably caused by another tool claiming usage of the same hotkey(s)! You could either change your hotkey settings or deactivate/change the software making use of the hotkey(s).
+
All Greenshot features still work directly from the tray icon context menu without hotkeys.Use custom colorPreserve transparency
diff --git a/GreenshotImgurPlugin/ImgurUtils.cs b/GreenshotImgurPlugin/ImgurUtils.cs
index 83d1fb407..1c3c96b12 100644
--- a/GreenshotImgurPlugin/ImgurUtils.cs
+++ b/GreenshotImgurPlugin/ImgurUtils.cs
@@ -156,8 +156,12 @@ namespace GreenshotImgurPlugin {
}
public static void RetrieveImgurThumbnail(ImgurInfo imgurInfo) {
- LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo);
- HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(imgurInfo.SmallSquare);
+ if (imgurInfo.SmallSquare == null) {
+ LOG.Warn("Imgur URL was null, not retrieving thumbnail.");
+ return;
+ }
+ LOG.InfoFormat("Retrieving Imgur image for {0} with url {1}", imgurInfo.Hash, imgurInfo);
+ HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest(imgurInfo.SmallSquare);
webRequest.Method = "GET";
webRequest.ServicePoint.Expect100Continue = false;
diff --git a/Greenshot/Forms/FormWithoutActivation.cs b/GreenshotPlugin/Controls/FormWithoutActivation.cs
similarity index 73%
rename from Greenshot/Forms/FormWithoutActivation.cs
rename to GreenshotPlugin/Controls/FormWithoutActivation.cs
index 737a84adb..ac53a73ac 100644
--- a/Greenshot/Forms/FormWithoutActivation.cs
+++ b/GreenshotPlugin/Controls/FormWithoutActivation.cs
@@ -21,13 +21,13 @@
using System;
using System.Windows.Forms;
-namespace Greenshot.Forms {
- ///
- /// FormWithoutActivation is exactly like a normal form, but doesn't activate (steal focus)
- ///
- public class FormWithoutActivation : Form {
- protected override bool ShowWithoutActivation {
- get { return true; }
- }
- }
+namespace GreenshotPlugin.Controls {
+ ///
+ /// FormWithoutActivation is exactly like a normal form, but doesn't activate (steal focus)
+ ///
+ public class FormWithoutActivation : Form {
+ protected override bool ShowWithoutActivation {
+ get { return true; }
+ }
+ }
}
diff --git a/GreenshotPlugin/Controls/ThumbnailForm.cs b/GreenshotPlugin/Controls/ThumbnailForm.cs
new file mode 100644
index 000000000..6d8987def
--- /dev/null
+++ b/GreenshotPlugin/Controls/ThumbnailForm.cs
@@ -0,0 +1,90 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using GreenshotPlugin.Core;
+using Greenshot.IniFile;
+using System.Drawing;
+using GreenshotPlugin.UnmanagedHelpers;
+
+namespace GreenshotPlugin.Controls {
+ public class ThumbnailForm : FormWithoutActivation {
+ private static CoreConfiguration conf = IniConfig.GetIniSection();
+
+ private IntPtr thumbnailHandle = IntPtr.Zero;
+ private Rectangle parentMenuBounds = Rectangle.Empty;
+
+ public ThumbnailForm() {
+ ShowInTaskbar = false;
+ FormBorderStyle = FormBorderStyle.None;
+ TopMost = false;
+ Enabled = false;
+ if (conf.WindowCaptureMode == WindowCaptureMode.Auto || conf.WindowCaptureMode == WindowCaptureMode.Aero) {
+ BackColor = Color.FromArgb(255, conf.DWMBackgroundColor.R, conf.DWMBackgroundColor.G, conf.DWMBackgroundColor.B);
+ } else {
+ BackColor = Color.White;
+ }
+
+ // cleanup at close
+ this.FormClosing += delegate {
+ UnregisterThumbnail();
+ };
+ }
+
+ public new void Hide() {
+ UnregisterThumbnail();
+ base.Hide();
+ }
+
+ private void UnregisterThumbnail() {
+ if (thumbnailHandle != IntPtr.Zero) {
+ DWM.DwmUnregisterThumbnail(thumbnailHandle);
+ thumbnailHandle = IntPtr.Zero;
+ }
+ }
+
+ public void ShowThumbnail(WindowDetails window, Control parentControl) {
+ UnregisterThumbnail();
+
+ DWM.DwmRegisterThumbnail(Handle, window.Handle, out thumbnailHandle);
+ if (thumbnailHandle != IntPtr.Zero) {
+ Rectangle windowRectangle = window.WindowRectangle;
+ int thumbnailHeight = 200;
+ int thumbnailWidth = (int)(thumbnailHeight * ((float)windowRectangle.Width / (float)windowRectangle.Height));
+ if (parentControl != null && thumbnailWidth > parentControl.Width) {
+ thumbnailWidth = parentControl.Width;
+ thumbnailHeight = (int)(thumbnailWidth * ((float)windowRectangle.Height / (float)windowRectangle.Width));
+ }
+ Width = thumbnailWidth;
+ Height = thumbnailHeight;
+ // Prepare the displaying of the Thumbnail
+ DWM_THUMBNAIL_PROPERTIES props = new DWM_THUMBNAIL_PROPERTIES();
+ props.Opacity = (byte)255;
+ props.Visible = true;
+ props.SourceClientAreaOnly = false;
+ props.Destination = new RECT(0, 0, thumbnailWidth, thumbnailHeight);
+ DWM.DwmUpdateThumbnailProperties(thumbnailHandle, ref props);
+ if (parentControl != null) {
+ AlignToControl(parentControl);
+ }
+
+ if (!Visible) {
+ Show();
+ }
+ // Make sure it's on "top"!
+ if (parentControl != null) {
+ User32.SetWindowPos(Handle, parentControl.Handle, 0, 0, 0, 0, WindowPos.SWP_NOMOVE | WindowPos.SWP_NOSIZE | WindowPos.SWP_NOACTIVATE);
+ }
+ }
+ }
+
+ public void AlignToControl(Control alignTo) {
+ Rectangle screenBounds = WindowCapture.GetScreenBounds();
+ if (screenBounds.Contains(alignTo.Left, alignTo.Top - Height)) {
+ Location = new Point(alignTo.Left + (alignTo.Width / 2) - (Width / 2), alignTo.Top - Height);
+ } else {
+ Location = new Point(alignTo.Left + (alignTo.Width / 2) - (Width / 2), alignTo.Bottom);
+ }
+ }
+ }
+}
diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj
index 96aef4a30..adbe868a6 100644
--- a/GreenshotPlugin/GreenshotPlugin.csproj
+++ b/GreenshotPlugin/GreenshotPlugin.csproj
@@ -175,6 +175,9 @@
Interop\WordInterop.cs
+
+ Form
+ Component
@@ -223,6 +226,9 @@
Component
+
+ Form
+