Skip to content

Commit

Permalink
[Fix]: fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
EliotVU committed Nov 20, 2012
1 parent 04c65d0 commit 5f0bd12
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
48 changes: 25 additions & 23 deletions UE Explorer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ namespace UEExplorer

public static class Program
{
private static readonly string LogFilePath = Path.Combine( Application.StartupPath, "Log.txt" );
private static FileStream _LogStream;

[STAThread]
static void Main( string[] args )
{
Expand All @@ -34,27 +31,8 @@ static void Main( string[] args )
return;
}

StartLogStream();
var app = new SingleInstanceApplication();
app.Run( Environment.GetCommandLineArgs() );
EndLogStream();
}

private static void StartLogStream()
{
_LogStream = new FileStream( LogFilePath, FileMode.Create, FileAccess.Write );
Console.SetOut( new StreamWriter( _LogStream ) );
}

private static void EndLogStream()
{
if( _LogStream == null )
return;

_LogStream.Flush();
_LogStream.Close();
_LogStream.Dispose();
_LogStream = null;
}

public class SingleInstanceApplication : WindowsFormsApplicationBase
Expand Down Expand Up @@ -88,6 +66,30 @@ protected override void OnStartupNextInstance( StartupNextInstanceEventArgs even
}
}

public static class LogManager
{
private const string LogFileName = "Log.txt";
private static readonly string LogFilePath = Path.Combine( Application.StartupPath, LogFileName );
private static FileStream _LogStream;

public static void StartLogStream()
{
_LogStream = new FileStream( LogFilePath, FileMode.Create, FileAccess.Write );
Console.SetOut( new StreamWriter( _LogStream ) );
}

public static void EndLogStream()
{
if( _LogStream == null )
return;

_LogStream.Flush();
_LogStream.Close();
_LogStream.Dispose();
_LogStream = null;
}
}

#region Options
private static readonly string SettingsPath = Path.Combine(
Application.StartupPath,
Expand Down Expand Up @@ -313,7 +315,7 @@ private static void ToggleFileProperties( Microsoft.Win32.RegistryKey key, bool

[System.Reflection.ObfuscationAttribute(Exclude = true)]
public class XMLSettings
{
{
#region Unreal Packages Decompiler Related Members
public string NTLPath = "NativesTableList_UT2004";

Expand Down
1 change: 1 addition & 0 deletions UE Explorer/UI/Main/ProgramForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions UE Explorer/UI/Main/ProgramForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace UEExplorer.UI
{
using UEExplorer.Development;
using UEExplorer.UI.Dialogs;
using UEExplorer.UI.Tabs;
using Development;
using Dialogs;
using Tabs;

using UELib;

Expand Down Expand Up @@ -144,6 +144,7 @@ public static string Version

internal ProgramForm()
{
Program.LogManager.StartLogStream();
Text = string.Format( "{0} {1}", Application.ProductName, Version );

InitializeComponent();
Expand Down Expand Up @@ -464,6 +465,11 @@ private void menuItem4_Click( object sender, EventArgs e )
{
System.Diagnostics.Process.Start( Program.Contact_URL );
}

private void ProgramForm_FormClosed( object sender, FormClosedEventArgs e )
{
Program.LogManager.EndLogStream();
}
}

public static class ProgressStatus
Expand Down

0 comments on commit 5f0bd12

Please sign in to comment.