mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Optimizing the windows logic, as far as was possible without LINQ. Added a check to try to fix BUG-2017.
This commit is contained in:
parent
68f0926b4d
commit
d446127e19
5 changed files with 316 additions and 315 deletions
|
@ -488,7 +488,7 @@ namespace Greenshot {
|
|||
{
|
||||
return;
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
#region hotkeys
|
||||
|
@ -726,7 +726,7 @@ namespace Greenshot {
|
|||
|
||||
var now = DateTime.Now;
|
||||
if ((now.Month == 12 && now.Day > 19 && now.Day < 27) || // christmas
|
||||
(now.Month == 3 && now.Day > 13 && now.Day < 21)) { // birthday
|
||||
(now.Month == 3 && now.Day > 13 && now.Day < 21)) { // birthday
|
||||
var resources = new ComponentResourceManager(typeof(MainForm));
|
||||
contextmenu_donate.Image = (Image)resources.GetObject("contextmenu_present.Image");
|
||||
}
|
||||
|
@ -814,7 +814,7 @@ namespace Greenshot {
|
|||
} else if(screen.Bounds.Left != allScreensBounds.Left && screen.Bounds.Right == allScreensBounds.Right) {
|
||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_right);
|
||||
}
|
||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||
captureScreenItem.Click += delegate {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureRegion(false, screenToCapture.Bounds);
|
||||
|
@ -879,8 +879,7 @@ namespace Greenshot {
|
|||
// check if thumbnailPreview is enabled and DWM is enabled
|
||||
bool thumbnailPreview = _conf.ThumnailPreview && DWM.IsDwmEnabled();
|
||||
|
||||
List<WindowDetails> windows = WindowDetails.GetTopLevelWindows();
|
||||
foreach(WindowDetails window in windows) {
|
||||
foreach(WindowDetails window in WindowDetails.GetTopLevelWindows()) {
|
||||
|
||||
string title = window.Text;
|
||||
if (title != null) {
|
||||
|
@ -1203,7 +1202,7 @@ namespace Greenshot {
|
|||
LOG.Error("Exception caught in the UnhandledException handler.");
|
||||
LOG.Error(exceptionText);
|
||||
if (exceptionText != null && exceptionText.Contains("InputLanguageChangedEventArgs"))
|
||||
{
|
||||
{
|
||||
// Ignore for BUG-1809
|
||||
return;
|
||||
}
|
||||
|
@ -1214,7 +1213,7 @@ namespace Greenshot {
|
|||
Exception exceptionToLog = e.Exception;
|
||||
string exceptionText = EnvironmentInfo.BuildReport(exceptionToLog);
|
||||
LOG.Error("Exception caught in the ThreadException handler.");
|
||||
LOG.Error(exceptionText);
|
||||
LOG.Error(exceptionText);
|
||||
if (exceptionText != null && exceptionText.Contains("InputLanguageChangedEventArgs"))
|
||||
{
|
||||
// Ignore for BUG-1809
|
||||
|
@ -1275,18 +1274,18 @@ namespace Greenshot {
|
|||
switch (clickAction) {
|
||||
case ClickActions.OPEN_LAST_IN_EXPLORER:
|
||||
string path = null;
|
||||
if (!string.IsNullOrEmpty(_conf.OutputFileAsFullpath)) {
|
||||
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
||||
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
||||
path = lastFilePath;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false);
|
||||
if (Directory.Exists(configPath)) {
|
||||
path = configPath;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(_conf.OutputFileAsFullpath)) {
|
||||
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
||||
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
||||
path = lastFilePath;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false);
|
||||
if (Directory.Exists(configPath)) {
|
||||
path = configPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
try {
|
||||
|
|
|
@ -471,7 +471,7 @@ namespace Greenshot.Helpers {
|
|||
private void RetrieveWindowDetails() {
|
||||
LOG.Debug("start RetrieveWindowDetails");
|
||||
// Start Enumeration of "active" windows
|
||||
List<WindowDetails> allWindows = WindowDetails.GetMetroApps();
|
||||
List<WindowDetails> allWindows = new List<WindowDetails>(WindowDetails.GetMetroApps());
|
||||
allWindows.AddRange(WindowDetails.GetAllWindows());
|
||||
foreach (WindowDetails window in allWindows) {
|
||||
// Window should be visible and not ourselves
|
||||
|
|
|
@ -71,19 +71,19 @@ namespace Greenshot.Helpers {
|
|||
/// <summary>
|
||||
/// Helper Method for creating an Email with Image Attachment
|
||||
/// </summary>
|
||||
/// <param name="image">The image to send</param>
|
||||
/// <param name="surface">The image to send</param>
|
||||
/// <param name="captureDetails">ICaptureDetails</param>
|
||||
public static void SendImage(ISurface surface, ICaptureDetails captureDetails) {
|
||||
string tmpFile = ImageOutput.SaveNamedTmpFile(surface, captureDetails, new SurfaceOutputSettings());
|
||||
|
||||
if (tmpFile != null) {
|
||||
// Store the list of currently active windows, so we can make sure we show the email window later!
|
||||
List<WindowDetails> windowsBefore = WindowDetails.GetVisibleWindows();
|
||||
bool isEmailSend = false;
|
||||
var windowsBefore = WindowDetails.GetVisibleWindows();
|
||||
//bool isEmailSend = false;
|
||||
//if (EmailConfigHelper.HasOutlook() && (conf.OutputEMailFormat == EmailFormat.OUTLOOK_HTML || conf.OutputEMailFormat == EmailFormat.OUTLOOK_TXT)) {
|
||||
// isEmailSend = OutlookExporter.ExportToOutlook(tmpFile, captureDetails);
|
||||
//}
|
||||
if (!isEmailSend && EmailConfigHelper.HasMAPI()) {
|
||||
if (/*!isEmailSend &&*/ EmailConfigHelper.HasMAPI()) {
|
||||
// Fallback to MAPI
|
||||
// Send the email
|
||||
SendImage(tmpFile, captureDetails.Title);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -82,19 +82,19 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
public enum ExtendedWindowStyleFlags : uint {
|
||||
WS_EX_DLGMODALFRAME = 0x00000001,
|
||||
WS_EX_NOPARENTNOTIFY = 0x00000004,
|
||||
WS_EX_TOPMOST = 0x00000008,
|
||||
WS_EX_TOPMOST = 0x00000008,
|
||||
WS_EX_ACCEPTFILES = 0x00000010,
|
||||
WS_EX_TRANSPARENT = 0x00000020,
|
||||
|
||||
//#if(WINVER >= 0x0400)
|
||||
WS_EX_MDICHILD = 0x00000040,
|
||||
WS_EX_MDICHILD = 0x00000040,
|
||||
WS_EX_TOOLWINDOW = 0x00000080,
|
||||
WS_EX_WINDOWEDGE = 0x00000100,
|
||||
WS_EX_CLIENTEDGE = 0x00000200,
|
||||
WS_EX_CONTEXTHELP = 0x00000400,
|
||||
|
||||
WS_EX_RIGHT = 0x00001000,
|
||||
WS_EX_LEFT = 0x00000000,
|
||||
WS_EX_RIGHT = 0x00001000,
|
||||
WS_EX_LEFT = 0x00000000,
|
||||
WS_EX_RTLREADING = 0x00002000,
|
||||
WS_EX_LTRREADING = 0x00000000,
|
||||
WS_EX_LEFTSCROLLBAR = 0x00004000,
|
||||
|
@ -102,16 +102,17 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
|
||||
WS_EX_CONTROLPARENT = 0x00010000,
|
||||
WS_EX_STATICEDGE = 0x00020000,
|
||||
WS_EX_APPWINDOW = 0x00040000,
|
||||
WS_EX_APPWINDOW = 0x00040000,
|
||||
|
||||
//WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE),
|
||||
//WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST),
|
||||
|
||||
WS_EX_LAYERED = 0x00080000,
|
||||
WS_EX_LAYERED = 0x00080000,
|
||||
WS_EX_NOINHERITLAYOUT = 0x00100000, // Disable inheritence of mirroring by children
|
||||
WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring
|
||||
WS_EX_NOREDIRECTIONBITMAP = 0x00200000, //The window does not render to a redirection surface. This is for windows that do not have visible content or that use mechanisms other than surfaces to provide their visual.
|
||||
WS_EX_LAYOUTRTL = 0x00400000, // Right to left mirroring
|
||||
WS_EX_COMPOSITED = 0x02000000,
|
||||
WS_EX_NOACTIVATE = 0x08000000
|
||||
WS_EX_NOACTIVATE = 0x08000000 // A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue