diff --git a/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs new file mode 100644 index 0000000..6489202 --- /dev/null +++ b/Eve-O-Preview/ApplicationBase/ExceptionHandler.cs @@ -0,0 +1,50 @@ +using System; +using System.IO; +using System.Threading; +using System.Windows.Forms; + +namespace EveOPreview +{ + // A really very primitive exception handler stuff here + // No IoC, no fancy DI containers - just a plain exception stacktrace dump + // If this code is called then something was gone really bad + // so even the DI infrastructure might be dead already. + // So this dumb and non elegant approach is used + sealed class ExceptionHandler + { + private const string ExceptionDumpFileName = "EVE-O Preview.log"; + private const string ExceptionMessage = "EVE-O Preview has encountered a problem and needs to close. Additional information has been saved in the crash log file."; + + public void SetupExceptionHandlers() + { + Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); + Application.ThreadException += delegate (Object sender, ThreadExceptionEventArgs e) + { + this.ExceptionEventHandler(e.Exception); + }; + + AppDomain.CurrentDomain.UnhandledException += delegate (Object sender, UnhandledExceptionEventArgs e) + { + this.ExceptionEventHandler(e.ExceptionObject as Exception); + }; + } + + private void ExceptionEventHandler(Exception exception) + { + try + { + String exceptionMessage = exception.ToString(); + File.WriteAllText(ExceptionHandler.ExceptionDumpFileName, exceptionMessage); + + MessageBox.Show(ExceptionHandler.ExceptionMessage, @"EVE-O Preview", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + catch + { + // We are in unstable state now so even this operation might fail + // Still we actually don't care anymore - anyway the application has been cashed + } + + System.Environment.Exit(1); + } + } +} \ No newline at end of file diff --git a/Eve-O-Preview/Configuration/IThumbnailConfig.cs b/Eve-O-Preview/Configuration/IThumbnailConfig.cs index d563629..f3571d7 100644 --- a/Eve-O-Preview/Configuration/IThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/IThumbnailConfig.cs @@ -34,6 +34,7 @@ public interface IThumbnailConfig Color ActiveClientHighlightColor { get; set; } int ActiveClientHighlightThickness { get; set; } + Point GetDefaultThumbnailLocation(); Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation); void SetThumbnailLocation(string currentClient, string activeClient, Point location); diff --git a/Eve-O-Preview/Configuration/ThumbnailConfig.cs b/Eve-O-Preview/Configuration/ThumbnailConfig.cs index 73b9104..24c71f2 100644 --- a/Eve-O-Preview/Configuration/ThumbnailConfig.cs +++ b/Eve-O-Preview/Configuration/ThumbnailConfig.cs @@ -80,6 +80,14 @@ public ThumbnailConfig() [JsonProperty] private Dictionary ClientHotkey { get; set; } + public Point GetDefaultThumbnailLocation() + { + // Returns default thumbnail location + // This location can be used for f.e. EVE clients sitting on the login screen + // Can be made configurable later (that's why it was moved out here) + return new Point(5, 5); + } + public Point GetThumbnailLocation(string currentClient, string activeClient, Point defaultLocation) { Point location; diff --git a/Eve-O-Preview/DwmAPI/WindowManagerNativeMethods.cs b/Eve-O-Preview/DwmAPI/WindowManagerNativeMethods.cs index 66899eb..6cf3f09 100644 --- a/Eve-O-Preview/DwmAPI/WindowManagerNativeMethods.cs +++ b/Eve-O-Preview/DwmAPI/WindowManagerNativeMethods.cs @@ -4,121 +4,125 @@ namespace EveOPreview { - // Desktop Windows Manager APIs - static class WindowManagerNativeMethods - { - [DllImport("user32.dll")] - public static extern IntPtr GetForegroundWindow(); - - [DllImport("user32.dll")] - public static extern bool SetForegroundWindow(IntPtr window); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern bool DwmIsCompositionEnabled(); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmGetColorizationColor( - out int pcrColorization, - [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmEnableComposition(bool bEnable); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmUnregisterThumbnail(IntPtr hThumbnail); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props); - - [DllImport("dwmapi.dll", PreserveSig = false)] - public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size); - - public const int SW_SHOWNORMAL = 1; - public const int SW_SHOWMINIMIZED = 2; - public const int SW_SHOWMAXIMIZED = 3; - - [DllImport("user32.dll")] - public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); - - public const int WM_NCLBUTTONDOWN = 0xA1; - public const int HTCAPTION = 0x2; - - [DllImport("User32.dll")] - public static extern bool ReleaseCapture(); - - [DllImport("User32.dll")] - public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); - - [DllImport("user32.dll", SetLastError = true)] - public static extern int GetWindowLong(IntPtr hWnd, int nIndex); - - public const int GWL_ID = (-12); - public const int GWL_STYLE = (-16); - public const int GWL_EXSTYLE = (-20); - - // Window Styles - public const UInt32 WS_OVERLAPPED = 0; - public const UInt32 WS_POPUP = 0x80000000; - public const UInt32 WS_CHILD = 0x40000000; - public const UInt32 WS_MINIMIZE = 0x20000000; - public const UInt32 WS_VISIBLE = 0x10000000; - public const UInt32 WS_DISABLED = 0x8000000; - public const UInt32 WS_CLIPSIBLINGS = 0x4000000; - public const UInt32 WS_CLIPCHILDREN = 0x2000000; - public const UInt32 WS_MAXIMIZE = 0x1000000; - public const UInt32 WS_CAPTION = 0xC00000; // WS_BORDER or WS_DLGFRAME - public const UInt32 WS_BORDER = 0x800000; - public const UInt32 WS_DLGFRAME = 0x400000; - public const UInt32 WS_VSCROLL = 0x200000; - public const UInt32 WS_HSCROLL = 0x100000; - public const UInt32 WS_SYSMENU = 0x80000; - public const UInt32 WS_THICKFRAME = 0x40000; - public const UInt32 WS_GROUP = 0x20000; - public const UInt32 WS_TABSTOP = 0x10000; - public const UInt32 WS_MINIMIZEBOX = 0x20000; - public const UInt32 WS_MAXIMIZEBOX = 0x10000; - public const UInt32 WS_TILED = WS_OVERLAPPED; - public const UInt32 WS_ICONIC = WS_MINIMIZE; - public const UInt32 WS_SIZEBOX = WS_THICKFRAME; - - // Extended Window Styles - public const UInt32 WS_EX_DLGMODALFRAME = 0x0001; - public const UInt32 WS_EX_NOPARENTNOTIFY = 0x0004; - public const UInt32 WS_EX_TOPMOST = 0x0008; - public const UInt32 WS_EX_ACCEPTFILES = 0x0010; - public const UInt32 WS_EX_TRANSPARENT = 0x0020; - public const UInt32 WS_EX_MDICHILD = 0x0040; - public const UInt32 WS_EX_TOOLWINDOW = 0x0080; - public const UInt32 WS_EX_WINDOWEDGE = 0x0100; - public const UInt32 WS_EX_CLIENTEDGE = 0x0200; - public const UInt32 WS_EX_CONTEXTHELP = 0x0400; - public const UInt32 WS_EX_RIGHT = 0x1000; - public const UInt32 WS_EX_LEFT = 0x0000; - public const UInt32 WS_EX_RTLREADING = 0x2000; - public const UInt32 WS_EX_LTRREADING = 0x0000; - public const UInt32 WS_EX_LEFTSCROLLBAR = 0x4000; - public const UInt32 WS_EX_RIGHTSCROLLBAR = 0x0000; - public const UInt32 WS_EX_CONTROLPARENT = 0x10000; - public const UInt32 WS_EX_STATICEDGE = 0x20000; - public const UInt32 WS_EX_APPWINDOW = 0x40000; - public const UInt32 WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE); - public const UInt32 WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); - public const UInt32 WS_EX_LAYERED = 0x00080000; - public const UInt32 WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritence of mirroring by children - public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring - public const UInt32 WS_EX_COMPOSITED = 0x02000000; - public const UInt32 WS_EX_NOACTIVATE = 0x08000000; + // Desktop Windows Manager APIs + static class WindowManagerNativeMethods + { + [DllImport("user32.dll")] + public static extern IntPtr GetForegroundWindow(); + + [DllImport("user32.dll")] + public static extern bool SetForegroundWindow(IntPtr window); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmEnableBlurBehindWindow(IntPtr hWnd, DWM_BLURBEHIND pBlurBehind); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, MARGINS pMargins); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern bool DwmIsCompositionEnabled(); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmGetColorizationColor( + out int pcrColorization, + [MarshalAs(UnmanagedType.Bool)]out bool pfOpaqueBlend); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmEnableComposition(bool bEnable); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern IntPtr DwmRegisterThumbnail(IntPtr dest, IntPtr source); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmUnregisterThumbnail(IntPtr hThumbnail); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmUpdateThumbnailProperties(IntPtr hThumbnail, DWM_THUMBNAIL_PROPERTIES props); + + [DllImport("dwmapi.dll", PreserveSig = false)] + public static extern void DwmQueryThumbnailSourceSize(IntPtr hThumbnail, out Size size); + + public const int SW_SHOWNORMAL = 1; + public const int SW_SHOWMINIMIZED = 2; + public const int SW_SHOWMAXIMIZED = 3; + + [DllImport("user32.dll")] + public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); + + public const int WM_NCLBUTTONDOWN = 0xA1; + public const int HTCAPTION = 0x2; + + [DllImport("User32.dll")] + public static extern bool ReleaseCapture(); + + [DllImport("User32.dll")] + public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); + + [DllImport("user32.dll", SetLastError = true)] + public static extern int GetWindowLong(IntPtr hWnd, int nIndex); + + public const int GWL_ID = (-12); + public const int GWL_STYLE = (-16); + public const int GWL_EXSTYLE = (-20); + + // Window Styles + public const UInt32 WS_OVERLAPPED = 0; + public const UInt32 WS_POPUP = 0x80000000; + public const UInt32 WS_CHILD = 0x40000000; + public const UInt32 WS_MINIMIZE = 0x20000000; + public const UInt32 WS_VISIBLE = 0x10000000; + public const UInt32 WS_DISABLED = 0x8000000; + public const UInt32 WS_CLIPSIBLINGS = 0x4000000; + public const UInt32 WS_CLIPCHILDREN = 0x2000000; + public const UInt32 WS_MAXIMIZE = 0x1000000; + public const UInt32 WS_CAPTION = 0xC00000; // WS_BORDER or WS_DLGFRAME + public const UInt32 WS_BORDER = 0x800000; + public const UInt32 WS_DLGFRAME = 0x400000; + public const UInt32 WS_VSCROLL = 0x200000; + public const UInt32 WS_HSCROLL = 0x100000; + public const UInt32 WS_SYSMENU = 0x80000; + public const UInt32 WS_THICKFRAME = 0x40000; + public const UInt32 WS_GROUP = 0x20000; + public const UInt32 WS_TABSTOP = 0x10000; + public const UInt32 WS_MINIMIZEBOX = 0x20000; + public const UInt32 WS_MAXIMIZEBOX = 0x10000; + public const UInt32 WS_TILED = WS_OVERLAPPED; + public const UInt32 WS_ICONIC = WS_MINIMIZE; + public const UInt32 WS_SIZEBOX = WS_THICKFRAME; + + // Extended Window Styles + public const UInt32 WS_EX_DLGMODALFRAME = 0x0001; + public const UInt32 WS_EX_NOPARENTNOTIFY = 0x0004; + public const UInt32 WS_EX_TOPMOST = 0x0008; + public const UInt32 WS_EX_ACCEPTFILES = 0x0010; + public const UInt32 WS_EX_TRANSPARENT = 0x0020; + public const UInt32 WS_EX_MDICHILD = 0x0040; + public const UInt32 WS_EX_TOOLWINDOW = 0x0080; + public const UInt32 WS_EX_WINDOWEDGE = 0x0100; + public const UInt32 WS_EX_CLIENTEDGE = 0x0200; + public const UInt32 WS_EX_CONTEXTHELP = 0x0400; + public const UInt32 WS_EX_RIGHT = 0x1000; + public const UInt32 WS_EX_LEFT = 0x0000; + public const UInt32 WS_EX_RTLREADING = 0x2000; + public const UInt32 WS_EX_LTRREADING = 0x0000; + public const UInt32 WS_EX_LEFTSCROLLBAR = 0x4000; + public const UInt32 WS_EX_RIGHTSCROLLBAR = 0x0000; + public const UInt32 WS_EX_CONTROLPARENT = 0x10000; + public const UInt32 WS_EX_STATICEDGE = 0x20000; + public const UInt32 WS_EX_APPWINDOW = 0x40000; + public const UInt32 WS_EX_OVERLAPPEDWINDOW = (WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE); + public const UInt32 WS_EX_PALETTEWINDOW = (WS_EX_WINDOWEDGE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); + public const UInt32 WS_EX_LAYERED = 0x00080000; + public const UInt32 WS_EX_NOINHERITLAYOUT = 0x00100000; // Disable inheritence of mirroring by children + public const UInt32 WS_EX_LAYOUTRTL = 0x00400000; // Right to left mirroring + public const UInt32 WS_EX_COMPOSITED = 0x02000000; + public const UInt32 WS_EX_NOACTIVATE = 0x08000000; public const int WM_SIZE = 5; + public const int WM_SYSCOMMAND = 0x0112; + + public const int SC_MINIMIZE = 0xf020; + public const int SIZE_RESTORED = 0; public const int SIZE_MINIMIZED = 1; public const int SIZE_MAXIMIZED = 2; diff --git a/Eve-O-Preview/Eve-O-Preview.csproj b/Eve-O-Preview/Eve-O-Preview.csproj index 59948ff..64f0ad2 100644 --- a/Eve-O-Preview/Eve-O-Preview.csproj +++ b/Eve-O-Preview/Eve-O-Preview.csproj @@ -71,13 +71,15 @@ - - ..\packages\LightInject.4.0.9\lib\net45\LightInject.dll - True + + ..\packages\Costura.Fody.1.6.2\lib\dotnet\Costura.dll + False - - ..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll - True + + ..\packages\LightInject.5.0.3\lib\net45\LightInject.dll + + + ..\packages\Newtonsoft.Json.10.0.2\lib\net45\Newtonsoft.Json.dll @@ -90,6 +92,7 @@ + @@ -162,7 +165,6 @@ Resources.resx True - Form @@ -172,21 +174,24 @@ + - + - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + + + +