Example #1
0
        private static void Main()
        {
            // parsing command line
            string[] args = Environment.GetCommandLineArgs();


            var options = new CmdLineOptions();

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                if (options.Reset)
                {
                    IsolatedStorageFile isoStore =
                        IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null,
                                                     null);
                    isoStore.DeleteFile("Pass4Win.json");
                }

                NoGit = false || options.NoGit;
            }

            // setting up logging
            LoggingBootstrap.Configure();

            log.Debug(() => "Application started");

            var handler = new AppExceptionHandler();

            Application.ThreadException += handler.Application_ThreadException;

            RegisterTypes();
            bool createdNew = true;

            log.Debug(() => "Checking if not already loaded");
            using (Mutex mutex = new Mutex(true, "Pass4Win", out createdNew))
            {
                if (createdNew)
                {
                    if (Environment.OSVersion.Version.Major >= 6)
                    {
                        NativeMethods.SetProcessDPIAware();
                    }
                    log.Debug(() => "Load main form");
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    try
                    {
                        Application.Run(Scope.Resolve <FrmMain>());
                    }
                    catch (Exception message)
                    {
                        if (log.IsDebugEnabled())
                        {
                            log.DebugException("MutexError", message);
                        }
                    }
                }
                else
                {
                    NativeMethods.PostMessage(
                        (IntPtr)NativeMethods.HWND_BROADCAST,
                        NativeMethods.WM_SHOWME,
                        IntPtr.Zero,
                        IntPtr.Zero);
                }
            }
        }
Example #2
0
        private static void Main()
        {
            // parsing command line
            string[] args = Environment.GetCommandLineArgs();
            string PersonalFolder = Path.GetTempPath() + "Pass4Win.log";

            var options = new CmdLineOptions();
            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                // consume Options instance properties
                if (options.Debug)
                {
                    PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Pass4Win.log";
                }
                if (options.Reset)
                {
                    IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
                    isoStore.DeleteFile("Pass4Win.json");
                }
                NoGit = false;
                if (options.NoGit)
                {
                    NoGit = true;
                }
            }

            // setting up logging

            Environment.SetEnvironmentVariable("log4netFileName", PersonalFolder + "\\Pass4Win.log");

            XmlConfigurator.Configure();
            log.Debug("Application started");

            ThreadExceptionHandler handler = new ThreadExceptionHandler();

            Application.ThreadException +=
                new ThreadExceptionEventHandler(
                    handler.Application_ThreadException);
            RegisterTypes();
            bool createdNew = true;
            log.Debug("Checking if not already loaded");
            using (Mutex mutex = new Mutex(true, "Pass4Win", out createdNew))
            {
                if (createdNew)
                {

                    if (Environment.OSVersion.Version.Major >= 6)
                    {
                        NativeMethods.SetProcessDPIAware();
                    }
                    log.Debug("Load main form");
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    try {

                        Application.Run(Scope.Resolve<FrmMain>());
                    }
                    catch (Exception message)
                    {
                        log.Debug(message);
                    }

                }
                else
                {
                    NativeMethods.PostMessage(
                                    (IntPtr)NativeMethods.HWND_BROADCAST,
                                    NativeMethods.WM_SHOWME,
                                    IntPtr.Zero,
                                    IntPtr.Zero);
                }
            }
        }
Example #3
0
        private static void Main()
        {
            // parsing command line
            string[] args           = Environment.GetCommandLineArgs();
            string   PersonalFolder = Path.GetTempPath() + "Pass4Win.log";

            var options = new CmdLineOptions();

            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                // consume Options instance properties
                if (options.Debug)
                {
                    PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Pass4Win.log";
                }
                if (options.Reset)
                {
                    IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
                    isoStore.DeleteFile("Pass4Win.json");
                }
                NoGit = false;
                if (options.NoGit)
                {
                    NoGit = true;
                }
            }

            // setting up logging

            Environment.SetEnvironmentVariable("log4netFileName", PersonalFolder + "\\Pass4Win.log");

            XmlConfigurator.Configure();
            log.Debug("Application started");

            ThreadExceptionHandler handler = new ThreadExceptionHandler();

            Application.ThreadException +=
                new ThreadExceptionEventHandler(
                    handler.Application_ThreadException);
            RegisterTypes();
            bool createdNew = true;

            log.Debug("Checking if not already loaded");
            using (Mutex mutex = new Mutex(true, "Pass4Win", out createdNew))
            {
                if (createdNew)
                {
                    if (Environment.OSVersion.Version.Major >= 6)
                    {
                        NativeMethods.SetProcessDPIAware();
                    }
                    log.Debug("Load main form");
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    try {
                        Application.Run(Scope.Resolve <FrmMain>());
                    }
                    catch (Exception message)
                    {
                        log.Debug(message);
                    }
                }
                else
                {
                    NativeMethods.PostMessage(
                        (IntPtr)NativeMethods.HWND_BROADCAST,
                        NativeMethods.WM_SHOWME,
                        IntPtr.Zero,
                        IntPtr.Zero);
                }
            }
        }