예제 #1
0
파일: Program.cs 프로젝트: runt18/GitForce
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Upgrade application settings across the version increment
            ClassUtils.UpgradeApplicationSettingsIfNecessary();

            // Make sure the application data folder directory exists
            Directory.CreateDirectory(AppHome);

            // Get and process command line arguments
            Arguments commandLine = new Arguments(args);

            // If the processing requested program termination,
            // return using the error code created by that class
            if (ClassCommandLine.Execute(commandLine) == false)
                return ClassCommandLine.ReturnCode;

            // Check that only one application instance is running
            bool mAcquired;
            Mutex mAppMutex = new Mutex(true, "gitforce", out mAcquired);
            if (!mAcquired && Properties.Settings.Default.WarnMultipleInstances)
            {
                if (MessageBox.Show("GitForce is already running.\nDo you want to open a new instance?", "Warning",
                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                    return -1;
            }

            // Initialize logging and git execute support
            Log = new FormLog();
            Log.ShowWindow(Properties.Settings.Default.ShowLogWindow);

            Git = new ClassGit();

            // Before we can start, we need to have a functional git executable);
            if (Git.Initialize())
            {
                // Initialize external diff program
                Diff = new ClassDiff();
                if( Diff.Initialize())
                {
                    Merge = new ClassMerge();
                    // Initialize external Merge program
                    if (Merge.Initialize())
                    {
                        // Add known text editors
                        Settings.Panels.ControlViewEdit.AddKnownEditors();

                        // Instantiate PuTTY support only on Windows OS
                        if (!ClassUtils.IsMono())
                            Putty = new ClassPutty();

                        GitPasswd = new ClassGitPasswd();   // Create HTTPS password helper file
                        Repos = new ClassRepos();           // Create repository canvas
                        Version = new ClassVersion();       // Start the new version check process
                        MainForm = new FormMain();          // Create the main form
                        MainForm.Show();                    // Show the main window so the handles get created
                        MainForm.Initialize();              // Load repos, custom tools etc.
                        DoRefresh();                        // Initial global refresh
                        Application.Run(MainForm);          // Run the main form

                        Properties.Settings.Default.Save();

                        GC.KeepAlive(mAppMutex);
                        return 0;
                    }
                }
            }
            return -1;
        }
예제 #2
0
        static int Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Upgrade application settings across the version increment
            ClassUtils.UpgradeApplicationSettingsIfNecessary();

            // Make sure the application data folder directory exists
            Directory.CreateDirectory(AppHome);

            // Get and process command line arguments
            Arguments commandLine = new Arguments(args);

            // If the processing requested program termination,
            // return using the error code created by that class
            if (ClassCommandLine.Execute(commandLine) == false)
            {
                return(ClassCommandLine.ReturnCode);
            }

            // Check that only one application instance is running
            bool  mAcquired;
            Mutex mAppMutex = new Mutex(true, "gitforce", out mAcquired);

            if (!mAcquired && Properties.Settings.Default.WarnMultipleInstances)
            {
                if (MessageBox.Show("GitForce is already running.\nDo you want to open a new instance?", "Warning",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.No)
                {
                    return(-1);
                }
            }

            // Initialize logging and git execute support
            Log = new FormLog();
            Log.ShowWindow(Properties.Settings.Default.ShowLogWindow);

            Git = new ClassGit();

            // Before we can start, we need to have a functional git executable);
            if (Git.Initialize())
            {
                // Initialize external diff program
                Diff = new ClassDiff();
                if (Diff.Initialize())
                {
                    Merge = new ClassMerge();
                    // Initialize external Merge program
                    if (Merge.Initialize())
                    {
                        // Add known text editors
                        Settings.Panels.ControlViewEdit.AddKnownEditors();

                        if (ClassUtils.IsMono())
                        {
                            Ssh = new ClassSSH();           // Instantiate SSH support only on Linux (Mono)
                        }
                        else
                        {
                            Putty = new ClassPutty();       // Instantiate PuTTY support only on Windows
                        }
                        GitPasswd = new ClassGitPasswd();   // Create HTTPS password helper file
                        Repos     = new ClassRepos();       // Create repository canvas
                        Version   = new ClassVersion();     // Start the new version check process
                        MainForm  = new FormMain();         // Create the main form
                        MainForm.Show();                    // Show the main window so the handles get created
                        MainForm.Initialize();              // Load repos, custom tools etc.
                        DoRefresh();                        // Initial global refresh
                        Application.Run(MainForm);          // Run the main form

                        Properties.Settings.Default.Save();

                        GC.KeepAlive(mAppMutex);
                        return(0);
                    }
                }
            }
            return(-1);
        }