From d60952599977b3c10fa2d9de9e355440ef9d75f8 Mon Sep 17 00:00:00 2001 From: RKrom Date: Tue, 17 Aug 2010 19:21:45 +0000 Subject: [PATCH] Added initial "ini" code git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@808 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4 --- Greenshot/Forms/MainForm.cs | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index bf0fe9680..9b939a211 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -33,12 +33,13 @@ using System.Windows.Forms; using Greenshot.Capturing; using Greenshot.Configuration; +using Greenshot.Core; using Greenshot.Drawing; using Greenshot.Forms; using Greenshot.Helpers; using Greenshot.Plugin; using Greenshot.UnmanagedHelpers; -using Greenshot.Core; +using GreenshotCore.Configuration; namespace Greenshot { /// @@ -48,20 +49,10 @@ namespace Greenshot { private const string LOG4NET_FILE = "log4net.xml"; private static log4net.ILog LOG = null; private static AppConfig conf; - private static Mutex applicationMutex = null; + private static CoreConfiguration coreConfiguration; - [STAThread] - public static void Main(string[] args) { - bool isAlreadyRunning = false; - List filesToOpen = new List(); - - // Set the Thread name, is better than "1" - Thread.CurrentThread.Name = Application.ProductName; - - Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); - AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); - + private static void InitializeLog4NET() { // Setup log4j, currently the file is called log4net.xml string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE); if (File.Exists(log4netFilename)) { @@ -72,10 +63,30 @@ namespace Greenshot { // Setup the LOG LOG = log4net.LogManager.GetLogger(typeof(MainForm)); + } + [STAThread] + public static void Main(string[] args) { + bool isAlreadyRunning = false; + Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); + AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); + + List filesToOpen = new List(); + + // Init Log4NET + InitializeLog4NET(); + // Log the startup LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false)); + // Set the Thread name, is better than "1" + Thread.CurrentThread.Name = Application.ProductName; + + // Read configuration + coreConfiguration = IniConfig.GetInstance().GetSection(); + IniConfig.GetInstance().Save(); + LOG.Info(coreConfiguration.IsFirstLaunch); + try { // Fix for Bug 2495900, Multi-user Environment // check whether there's an local instance running already