public void TargetXboxDeepSynch()
        {
            string userName   = mMog.GetUser().GetUserName();
            bool   useDefault = false;

            // Use 'default' as user, if the Default checkbox is checked.  This is used for the programmers who debug their code using the default.xbe
            if (mainForm.AssetManagerLocalDataXboxDefaultCheckBox.Checked)
            {
                userName   = "******";
                useDefault = true;
            }

            guiPlatformSinc sinc = new guiPlatformSinc(mTargetXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, true);

            sinc.mProjectSyncFile = mProjectSyncFile;
            sinc.mUserSyncFile    = mUserSyncFile;
            sinc.TargetConsoleRemoveSync();
        }
        public void TargetXboxSynch(bool force, bool runAfterComplete)
        {
            string userName   = mMog.GetUser().GetUserName();
            bool   useDefault = false;

            // Use 'default' as user, if the Default checkbox is checked.  This is used for the programmers who debug their code using the default.xbe
            if (mainForm.AssetManagerLocalDataXboxDefaultCheckBox.Checked)
            {
                userName   = "******";
                useDefault = true;
            }

            // No reset for PC targets
            if (mTargetXbox.IndexOf(":") == -1)
            {
                TargetXboxReset();
            }

            guiPlatformSinc sinc = new guiPlatformSinc(mTargetXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, force, runAfterComplete, true);

            sinc.mProjectSyncFile = mProjectSyncFile;
            sinc.mUserSyncFile    = mUserSyncFile;

            if (mPlatformSyncThread == null)
            {
                mPlatformSyncThread = new Thread(new ThreadStart(sinc.TargetConsoleSync));
            }
            else
            {
                mPlatformSyncThread.Abort();
                mPlatformSyncThread = null;
                mPlatformSyncThread = new Thread(new ThreadStart(sinc.TargetConsoleSync));
            }

            mPlatformSyncThread.Start();
        }
        public void TargetXboxMakeLinearLoadIso()
        {
            // Optimize all the data
            string output    = "";
            string sourceDir = mainForm.mAssetManager.GetTargetPath();

            string userName   = mMog.GetUser().GetUserName();
            bool   useDefault = false;

            CallbackDialogForm bigProgress = new CallbackDialogForm();

            bigProgress.DialogInitialize("Make Linear Load Build", "Creating linear maps...\nThis could take many hours", "Cancel");

            // Use 'default' as user, if the Default checkbox is checked.  This is used for the programmers who debug their code using the default.xbe
            if (mainForm.AssetManagerLocalDataXboxDefaultCheckBox.Checked)
            {
                userName   = "******";
                useDefault = true;
            }

            // Check for user cancel
            Application.DoEvents();
            if (bigProgress.DialogProcess())
            {
                bigProgress.DialogKill();
                return;
            }

            // Get the tool listed on the startup page
            string command = "[ProjectPath]\\Mog\\Tools\\Xbox\\Optimize\\Optimize.bat";

            if (command.IndexOf("[ProjectPath]") != -1)
            {
                command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1));
            }

            bigProgress.DialogUpdate(10, "Optimizing the newly merged data");

            // Make sure the tool we need exits
            if (DosUtils.FileExist(command))
            {
                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                if (guiCommandLine.ShellExecute(command, mainForm.mAssetManager.GetTargetPath() + "\\System", ProcessWindowStyle.Normal, ref output) != 0)
                {
                    MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK);
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(20, "Syncing to Build Xbox for linear load tool execution...");

                // Sync to the Linear Build xbox
                string buildXbox = "LinearBuild";

                // Logon to correct xbox
                XboxUtils.SetXboxName(buildXbox, false);

                guiPlatformSinc sinc = new guiPlatformSinc(buildXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false);
                sinc.mProjectSyncFile = "xbox.opt.ls.sync";
                sinc.mUserSyncFile    = "";
                sinc.TargetConsoleSync();

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                // Run the linear load tool
                string xboxExe = "xE:\\" + mMog.GetProject().GetProjectName() + "\\defaultls.xbe";

                bigProgress.DialogUpdate(30, "Preparing for linear load tool execution...");

                // Kill the Linear load complete file in the root before we call the tool
                if (XboxUtils.FileExist("xQ:\\LoadComplete.sys"))
                {
                    XboxUtils.FileDelete("xQ:\\LoadComplete.sys");
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }


                // Kill all previous linear files
                string LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\");
                if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1)
                {
                    CallbackDialogForm progress1 = new CallbackDialogForm();
                    progress1.DialogInitialize("Make Linear Load Build", "Deleting previous linear load maps...", "Cancel");

                    string [] files = LinearLoadFiles.Split(",".ToCharArray());
                    foreach (string file in files)
                    {
                        if (string.Compare(Path.GetExtension(file), ".lin", true) == 0)
                        {
                            progress1.DialogUpdate(0, file);
                            XboxUtils.FileDelete(file);

                            // Check for user cancel
                            Application.DoEvents();
                            if (bigProgress.DialogProcess())
                            {
                                progress1.DialogKill();
                                bigProgress.DialogKill();
                                return;
                            }

                            if (progress1.DialogProcess())
                            {
                                progress1.DialogKill();
                                return;
                            }
                        }
                    }

                    progress1.DialogKill();
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                MOG_Ini buttonDefaults = null;
                if (mMog.IsProject())
                {
                    // Get the project defaults
                    string projectDefaultButtonsFile = mMog.GetProject().GetProjectToolsPath() + "\\" + mMog.GetProject().GetProjectName() + ".Client.Buttons.Default.info";
                    if (DosUtils.FileExist(projectDefaultButtonsFile))
                    {
                        buttonDefaults = new MOG_Ini(projectDefaultButtonsFile);
                    }
                }

                // Get the tool listed on the startup page
                if (buttonDefaults != null)
                {
                    if (buttonDefaults.SectionExist(mMog.GetProject().GetProjectName() + ".Buttons"))
                    {
                        if (buttonDefaults.KeyExist(mMog.GetProject().GetProjectName() + ".Buttons", "Run"))
                        {
                            command = buttonDefaults.GetString(mMog.GetProject().GetProjectName() + ".Buttons", "Run");
                        }
                    }
                }

                if (command.IndexOf("[ProjectPath]") != -1)
                {
                    command = string.Concat(command.Substring(0, command.IndexOf("[")), mainForm.mAssetManager.GetTargetPath(), command.Substring(command.IndexOf("]") + 1));
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(50, "Starting the linear load creation tool...");

                // Make sure the tool we need exits
                if (DosUtils.FileExist(command))
                {
                    if (guiCommandLine.ShellExecute(command, string.Concat("/x ", buildXbox, " ", xboxExe), ProcessWindowStyle.Hidden, ref output) != 0)
                    {
                        MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat(output), MessageBoxButtons.OK);
                    }

                    // Wait till the LinearLoad.sys file exists before continuing...
                    while (XboxUtils.FileExist("Q:\\LoadComplete.sys") == false)
                    {
                        Application.DoEvents();
                        if (bigProgress.DialogProcess())
                        {
                            bigProgress.DialogKill();
                            return;
                        }

                        Thread.Sleep(500);
                    }
                }
                else
                {
                    MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK);
                }

                // Kill the Linear load complete file once we are done
                if (XboxUtils.FileExist("xQ:\\LoadComplete.sys"))
                {
                    XboxUtils.FileDelete("xQ:\\LoadComplete.sys");
                }

                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(80, "Retrieving linear load maps from Build Xbox...");

                // Copy off the data
                LinearLoadFiles = XboxUtils.GetFiles("xE:\\" + mMog.GetProject().GetProjectName() + "\\System\\");

                if (LinearLoadFiles.Length != 0 && LinearLoadFiles.IndexOf(",") != -1)
                {
                    CallbackDialogForm progress = new CallbackDialogForm();
                    progress.DialogInitialize("Make Linear Load Build", "Copying completed linear load maps...", "Cancel");

                    string [] files = LinearLoadFiles.Split(",".ToCharArray());
                    foreach (string file in files)
                    {
                        if (string.Compare(Path.GetExtension(file), ".lin", true) == 0)
                        {
                            string target = mMog.GetActivePlatform().mPlatformTargetPath + "\\xboxdata\\maps\\" + Path.GetFileName(file);

                            progress.DialogUpdate(0, target);

                            // Check for user cancel
                            Application.DoEvents();
                            if (bigProgress.DialogProcess())
                            {
                                progress.DialogKill();
                                bigProgress.DialogKill();
                                return;
                            }

                            if (progress.DialogProcess())
                            {
                                progress.DialogKill();
                                break;
                            }

                            if (!XboxUtils.FileGet(file, target, false))
                            {
                                MOG_REPORT.ShowMessageBox("Make Linear Load Build", "Error copying file(" + file + ") from build xbox!", MessageBoxButtons.OK);
                            }
                        }
                    }

                    progress.DialogKill();
                }
                else
                {
                    MOG_REPORT.ShowMessageBox("Make Linear Load Build", "There were no Linear Load files found on the Xbox Build machine(" + buildXbox + ")", MessageBoxButtons.OK);
                    return;
                }


                // Check for user cancel
                Application.DoEvents();
                if (bigProgress.DialogProcess())
                {
                    bigProgress.DialogKill();
                    return;
                }

                bigProgress.DialogUpdate(90, "Syncing to target Xbox...");

                // Sync
                sinc = new guiPlatformSinc(mTargetXbox, mainForm.mAssetManager.GetTargetPath(), mainForm, userName, useDefault, false, false, false);
                sinc.mProjectSyncFile = "xbox.opt.ll.sync";
                sinc.mUserSyncFile    = "";
                sinc.TargetConsoleSync();
            }
            else
            {
                MOG_REPORT.ShowMessageBox("XBox Tools", string.Concat("This tool is missing, have you updated to the latest version?"), MessageBoxButtons.OK);
            }

            bigProgress.DialogUpdate(100, "Done!");
            bigProgress.DialogKill();
        }