Exemplo n.º 1
0
        private static void Main()
        {
            // parsing command line
            string[] args           = Environment.GetCommandLineArgs();
            string   PersonalFolder = Path.GetTempPath() + "Pass4Win.log";

            if (args.Length > 1 && args[1].Equals("debug"))
            {
                PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + "\\Pass4Win.log";
            }

            // 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);
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
                }
            }
        }