Skip to content

Commit ea81fb3

Browse files
author
Alex Camilleri
committed
Added Exception log saving to Logs folder.
1 parent 3d1a92a commit ea81fb3

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

App.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
<configuration>
33
<startup>
44

5-
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
5+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
66
</startup>
77
</configuration>

BorderlessGaming.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
<AssemblyName>BorderlessGaming</AssemblyName>
1212
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
1313
<FileAlignment>512</FileAlignment>
14-
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
14+
<TargetFrameworkProfile>
15+
</TargetFrameworkProfile>
1516
<PublishUrl>publish\</PublishUrl>
1617
<Install>true</Install>
1718
<InstallFrom>Disk</InstallFrom>

Forms/CompactWindow.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,11 @@ private void RemoveBorder(String procName) //actually make it frameless
147147
//force a redraw
148148
Native.DrawMenuBar(proc.MainWindowHandle);
149149
Native.SetWindowLong(pFoundWindow, WindowLongIndex.Style, (style & ~(WindowStyleFlags.ExtendedDlgmodalframe | WindowStyleFlags.Caption | WindowStyleFlags.ThickFrame | WindowStyleFlags.Minimize | WindowStyleFlags.Maximize | WindowStyleFlags.SystemMenu | WindowStyleFlags.MaximizeBox | WindowStyleFlags.MinimizeBox | WindowStyleFlags.Border | WindowStyleFlags.ExtendedComposited)));
150-
151-
var bounds = Screen.FromHandle(pFoundWindow).Bounds;
152-
Native.SetWindowPos(pFoundWindow, 0, bounds.X, bounds.Y, bounds.Width, bounds.Height, SetWindowPosFlags.NoZOrder | SetWindowPosFlags.ShowWindow);
150+
if (!_borderlessWindows.Contains(pFoundWindow.ToInt32().ToString()))
151+
{
152+
var bounds = Screen.FromHandle(pFoundWindow).Bounds;
153+
Native.SetWindowPos(pFoundWindow, 0, bounds.X, bounds.Y, bounds.Width, bounds.Height, SetWindowPosFlags.NoZOrder | SetWindowPosFlags.ShowWindow);
154+
}
153155
_gameFound = true;
154156
}
155157

Utilities/ExceptionHandler.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@ public static void AddHandlers()
1515
{
1616
AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
1717
{
18-
var filePath = string.Format("./UnhandledException{0}.json", DateTime.Now.ToShortDateString());
19-
File.WriteAllText(filePath, JsonConvert.SerializeObject(args.ExceptionObject));
20-
MessageBox.Show(string.Format("An Unhandled Exception was Caught and Logged to:\r\n{0}", filePath), "Exception Caught");
18+
Directory.CreateDirectory("./Logs");
19+
var filePath = string.Format("Logs/UnhandledException{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"));
20+
File.WriteAllText("./" + filePath, JsonConvert.SerializeObject(args.ExceptionObject, Formatting.Indented));
21+
MessageBox.Show(string.Format("An Unhandled Exception was Caught and Logged to:\r\n{0}", filePath), "Exception Caught", MessageBoxButtons.OK, MessageBoxIcon.Error);
2122
};
2223

2324

2425
Application.ThreadException += (sender, args) =>
2526
{
26-
var filePath = string.Format("./ThreadException{0}.json", DateTime.Now.ToShortDateString());
27-
File.WriteAllText(string.Format("./ThreadException{0}.json", DateTime.Now.ToShortDateString()), JsonConvert.SerializeObject(args.Exception));
28-
MessageBox.Show(string.Format("An Unhandled Thread Exception was Caught and Logged to:\r\n{0}", filePath), "Thread Exception Caught");
27+
Directory.CreateDirectory("./Logs");
28+
var filePath = string.Format("Logs/ThreadException{0}.json", DateTime.Now.ToShortDateString().Replace("/", "-"));
29+
File.WriteAllText("./" + filePath, JsonConvert.SerializeObject(args.Exception, Formatting.Indented));
30+
MessageBox.Show(string.Format("An Unhandled Thread Exception was Caught and Logged to:\r\n{0}", filePath), "Thread Exception Caught", MessageBoxButtons.OK, MessageBoxIcon.Error);
2931
};
3032
}
3133
}

0 commit comments

Comments
 (0)