Пример #1
0
 private void InitFormOptions()
 {
     if (mOptions.SectionExist("Builds"))
     {
         for (int i = 0; i < mOptions.CountKeys("Builds"); i++)
         {
             string command = mOptions.GetKeyNameByIndexSLOW("Builds", i);
             BuildsListBox.Items.Add(command);
         }
     }
 }
Пример #2
0
        private int AppendSummaryNonExistant(string section, string comment, Color nodeColor)
        {
            // Get all the file copies
            if (mSummary.SectionExist(section))
            {
                for (int i = 0; i < mSummary.CountKeys(section); i++)
                {
                    ListViewItem item = new ListViewItem();

                    // Get classification name
                    string assetName = mSummary.GetKeyByIndexSLOW(section, i);

                    // Get file name
                    string fileName = mSummary.GetKeyNameByIndexSLOW(section, i);

                    // Trim any starting '\'
                    if (fileName != null && fileName.Length > 0)
                    {
                        fileName = fileName.TrimStart("\\".ToCharArray());
                    }

                    item.Text      = fileName;
                    item.ForeColor = nodeColor;

                    item.SubItems.Add("");
                    item.SubItems.Add(comment);

                    SummaryListView.Items.Add(item);
                }

                return(mSummary.CountKeys(section));
            }

            return(0);
        }
Пример #3
0
        public void InitializeItems(MenuItem menu)
        {
            string dir      = mCustomToolsInfo.Substring(0, mCustomToolsInfo.LastIndexOf("\\"));
            string wildcard = mCustomToolsInfo.Substring(mCustomToolsInfo.LastIndexOf("\\") + 1, (mCustomToolsInfo.Length - mCustomToolsInfo.LastIndexOf("\\")) - 1);

            foreach (FileInfo file in DosUtils.FileGetList(dir, wildcard))
            {
                MOG_Ini customTools = new MOG_Ini(file.FullName);

                // Remove the beginning of the info name
                string tmp  = wildcard.Substring(0, wildcard.IndexOf("*"));
                string name = file.Name.Replace(tmp, "");

                // Remove the .info
                name = name.Replace(".info", "");

                // Create the main Item
                MenuItem parent = new MenuItem(name);

                if (customTools.SectionExist("USER_TOOLS"))
                {
                    mClickHandlers = new ArrayList();
                    for (int i = 0; i < customTools.CountKeys("USER_TOOLS"); i++)
                    {
                        parent.MenuItems.Add(CreateItem(customTools.GetKeyNameByIndexSLOW("USER_TOOLS", i), new MogMenuItem_Click(CustomToolMenuItem_Click)));
                    }
                }

                menu.MenuItems.Add(parent);
            }
        }
Пример #4
0
        /// <summary>
        /// Load our RadioButtons, given a section and a MOG_Ini
        /// </summary>
        /// <param name="section"></param>
        /// <param name="ini"></param>
        /// <returns></returns>
        private static SortedList LoadRadioButtons(string section, MOG_Ini ini)
        {
            ini.Load(ini.GetFilename());
            int        count        = ini.CountKeys(section);
            SortedList radioButtons = new SortedList();

            for (int i = 0; i < count; ++i)
            {
                radioButtons.Add(ini.GetKeyNameByIndexSLOW(section, i), ini.GetKeyByIndexSLOW(section, i));
            }
            return(radioButtons);
        }
Пример #5
0
        private string ExtractRepositoryLocation(string iniFilename)
        {
            string  path     = this.mRepositoryPath;
            MOG_Ini reposIni = new MOG_Ini(iniFilename);

            if (reposIni.SectionExist("MOG_REPOSITORIES") && reposIni.CountKeys("MOG_REPOSITORIES") > 0)
            {
                string firstReposName = reposIni.GetKeyNameByIndexSLOW("MOG_REPOSITORIES", 0);
                if (reposIni.SectionExist(firstReposName))
                {
                    path = reposIni.GetString(firstReposName, "SystemRepositoryPath");
                }
            }
            reposIni.Close();

            return(path);
        }
Пример #6
0
        private int CreateComboControls(int startY, MOG_Ini dialogInfo, string section)
        {
            int x = 8;
            int y = startY;

            SuspendLayout();
            for (int i = 0; i < dialogInfo.CountKeys(section); i++)
            {
                string key        = dialogInfo.GetKeyNameByIndexSLOW(section, i);
                string keySection = section + "." + key;

                if (dialogInfo.SectionExist(keySection))
                {
                    if (dialogInfo.KeyExist(keySection, "Description"))
                    {
                        y = CreateLabelControl(x, y, dialogInfo.GetString(keySection, "Description"));
                    }
                    else
                    {
                        MOG_Prompt.PromptMessage("Custom Tool", "Cound not correctly create ComboControl due to missing (Description) field in info", Environment.StackTrace);
                    }

                    if (dialogInfo.KeyExist(keySection, "range"))
                    {
                        if (dialogInfo.KeyExist(keySection, "defaultValue"))
                        {
                            y = CreateComboBoxControl(x, y, dialogInfo.GetString(keySection, "range"), dialogInfo.GetString(keySection, "defaultValue"));
                        }
                        else
                        {
                            y = CreateComboBoxControl(x, y, dialogInfo.GetString(keySection, "range"), "0");
                        }
                    }
                    else
                    {
                        MOG_Prompt.PromptMessage("Custom Tool", "Cound not correctly create ComboControl due to missing (Range) field in info", Environment.StackTrace);
                    }
                }
            }

            ResumeLayout(false);

            return(y);
        }
Пример #7
0
        private void InitializeDialog()
        {
            if (DosUtils.FileExist(mDialogInfoFilename))
            {
                MOG_Ini dialogInfo = new MOG_Ini(mDialogInfoFilename);

                // Init the controls
                if (dialogInfo.SectionExist("Controls"))
                {
                    int Y = 8;

                    for (int i = 0; i < dialogInfo.CountKeys("Controls"); i++)
                    {
                        string control        = dialogInfo.GetKeyNameByIndexSLOW("Controls", i);
                        string controlSection = dialogInfo.GetKeyByIndexSLOW("Controls", i);
                        switch (control.ToLower())
                        {
                        case "toggleoptions":
                            Y = CreateToggleCroupControl(Y, dialogInfo, controlSection);
                            break;

                        case "combooptions":
                            Y = CreateComboControls(Y, dialogInfo, controlSection);
                            break;

                        case "editoptions":
                            Y = CreateEditControls(Y, dialogInfo, controlSection);
                            break;
                        }
                    }

                    // Make sure our form is tall enough to handle the new controls
                    if (Height < Y)
                    {
                        Height = Y + 80;
                    }
                }
            }
        }
Пример #8
0
        public bool LoadRepositories(string iniFilename)
        {
            if (!Directory.Exists(Path.GetDirectoryName(iniFilename)))
            {
                return(false);
            }

            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini == null)
            {
                return(false);
            }

            if (ini.SectionExist("REPOSITORIES"))
            {
                for (int i = 0; i < ini.CountKeys("REPOSITORIES"); i++)
                {
                    string key = ini.GetKeyNameByIndexSLOW("REPOSITORIES", i);
                    if (key.ToLower() == "default")
                    {
                        continue;
                    }

                    if (!ini.SectionExist("REPOSITORIES." + key))
                    {
                        continue;
                    }

                    string name = ini.GetString("REPOSITORIES." + key, "name");
                    string path = ini.GetString("REPOSITORIES." + key, "path");
                    AddRepository(name, path);
                }
            }

            ini.Close();
            return(true);
        }
Пример #9
0
        public void AddShallowRepositories()
        {
            this.lvIniFile.Items.Clear();

            foreach (string drive in Directory.GetLogicalDrives())
            {
                int type = (int)GetDriveType(drive);
                if (type == DRIVE_TYPE_HD || type == DRIVE_TYPE_NETWORK)
                {
                    if (Directory.Exists(drive))
                    {
                        // look for a repository marker
                        if (File.Exists(drive + "MogRepository.ini"))
                        {
                            // repository exists, open it up
                            MOG_Ini ini = new MOG_Ini(drive + "MogRepository.ini");
                            if (!ini.SectionExist("MOG_REPOSITORIES"))
                            {
                                continue;
                            }

                            for (int sectionIndex = 0; sectionIndex < ini.CountKeys("MOG_REPOSITORIES"); sectionIndex++)
                            {
                                string sectionName = ini.GetKeyNameByIndexSLOW("MOG_REPOSITORIES", sectionIndex);
                                if (ini.SectionExist(sectionName) && ini.KeyExist(sectionName, "SystemRepositoryPath"))
                                {
                                    ListViewItem item = new ListViewItem(sectionName + " on " + drive.Trim("\\".ToCharArray()));
                                    item.SubItems.Add(ini.GetString(sectionName, "SystemRepositoryPath"));
                                    this.lvRepositories.Items.Add(item);
                                }
                            }

                            ini.Close();
                        }
                    }
                }
            }
        }
Пример #10
0
        private void LoadIniFile(string iniFilePath)
        {
            if (!File.Exists(iniFilePath))
            {
                return;
            }

            // setup list view and ini reader
            this.lvRemovedProjects.Items.Clear();
            MOG_Ini ini = new MOG_Ini(iniFilePath);

            // Make sure the section exists?
            if (ini.SectionExist("Projects.Deleted"))
            {
                // for each "deleted" project listed
                for (int i = 0; i < ini.CountKeys("Projects.Deleted"); i++)
                {
                    string projName = ini.GetKeyNameByIndexSLOW("Projects.Deleted", i);

                    // Check if the deleted project's directory is missing?
                    if (!DosUtils.DirectoryExistFast(MOG_ControllerSystem.GetSystemDeletedProjectsPath() + "\\" + projName))
                    {
                        // Auto clean this deleted project from the ini
                        ini.RemoveSection(projName + ".Deleted");
                        ini.RemoveString("projects.deleted", projName);
                        continue;
                    }

                    ListViewItem item = new ListViewItem();
                    item.Text = projName;
//					item.Tag = new RemovedProjectInfo( configFile );
                    this.lvRemovedProjects.Items.Add(item);
                }
            }

            ini.Close();
        }
Пример #11
0
        /// <summary>
        /// Load a report form from a file and populate it
        /// </summary>
        /// <param name="filename"></param>
        public void LoadReportList(string filename)
        {
            MOG_Ini report = new MOG_Ini(filename);

            // Set the form title
            Text = Path.GetFileName(filename);

            if (report.SectionExist("ASSETS"))
            {
                ListListView.Items.Clear();

                ListListView.BeginUpdate();

                ProgressMax(report.CountKeys("ASSETS"));

                for (int x = 0; x < report.CountKeys("ASSETS"); x++)
                {
                    MOG_Filename mogAsset  = new MOG_Filename(report.GetKeyNameByIndexSLOW("ASSETS", x));
                    string       extraInfo = report.GetKeyByIndexSLOW("ASSETS", x);

                    MOG_Properties pProperties = new MOG_Properties(mogAsset);

                    string version        = mogAsset.GetVersionTimeStamp();
                    string currentVersion = MOG_DBAssetAPI.GetAssetVersion(mogAsset);                    //mCurrentInfo.GetString("ASSETS", mogAsset.GetAssetName());

                    MOG_Time assetTime        = new MOG_Time(version);
                    MOG_Time currentAssetTime = new MOG_Time(currentVersion);

                    ListViewItem item = new ListViewItem();

                    // We have support for the old lists as well as the new ones that have extra information stored.
                    if (string.Compare(extraInfo, "ReportList", true) != 0)
                    {
                        string [] extraItems = extraInfo.Split(",".ToCharArray());
                        foreach (string extra in extraItems)
                        {
                            if (item.Text.Length == 0)
                            {
                                item.Text = extra;
                            }
                            else
                            {
                                item.SubItems.Add(extra);
                            }
                        }

                        // Update the version
                        if (assetTime.Compare(currentAssetTime) != 0)
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                        }
                    }
                    else
                    {
                        item = AddItemToListView(mogAsset, pProperties, MOG_ControllerRepository.GetAssetBlessedVersionPath(mogAsset, version).GetEncodedFilename());

                        // Get version
                        if (assetTime.Compare(currentAssetTime) != 0)                                                                                           // Version
                        {
                            item.SubItems[FindColumn("Version")].Text      = currentAssetTime.FormatString("");
                            item.SubItems[FindColumn("Version")].ForeColor = Color.Red;
                            version = currentVersion;
                        }
                        else
                        {
                            item.SubItems[FindColumn("Version")].Text = assetTime.FormatString("");
                        }
                    }

                    // Icon
                    item.ImageIndex = MogUtil_AssetIcons.GetAssetIconIndex(mogAsset.GetAssetFullName());

                    ListListView.Items.Add(item);

                    ProgressStep();
                }

                UpdateAssetTotals();
                ListListView.EndUpdate();
                ProgressReset();
            }
        }
Пример #12
0
        private int CreateToggleCroupControl(int startY, MOG_Ini dialogInfo, string section)
        {
            SuspendLayout();

            GroupBox groupBox = new System.Windows.Forms.GroupBox();

            groupBox.Location = new System.Drawing.Point(8, startY);
            groupBox.Name     = section;
            groupBox.TabIndex = 2;
            groupBox.TabStop  = false;
            groupBox.Text     = section;
            groupBox.Visible  = true;
            groupBox.Parent   = ControlsPanel;

            groupBox.SuspendLayout();

            int X = 5;
            int Y = 12;

            //Graphics Gdi = Graphics.FromImage(pictureBox1.Image);

            for (int i = 0; i < dialogInfo.CountKeys(section); i++)
            {
                RadioButton radioButton = new System.Windows.Forms.RadioButton();

                string option  = dialogInfo.GetKeyNameByIndexSLOW(section, i);
                string command = dialogInfo.GetKeyByIndexSLOW(section, i);

                radioButton.Location  = new System.Drawing.Point(X, Y);
                radioButton.Name      = command;
                radioButton.TabIndex  = 0;
                radioButton.FlatStyle = FlatStyle.System;
                radioButton.Text      = option;
                radioButton.Visible   = true;
                radioButton.Parent    = groupBox;

                // Measure string.
                radioButton.Width = MeasureString(option, radioButton.Font);
                if (radioButton.Width > groupBox.Width)
                {
                    groupBox.Width = radioButton.Width + 10;
                }

                if (groupBox.Width > Width)
                {
                    Width = groupBox.Width + 10;
                }

                groupBox.Controls.Add(radioButton);
                mDynamicControls.Add(radioButton);

                Y += radioButton.Height;
            }

            groupBox.Height = Y + 5;
            groupBox.ResumeLayout(false);
            ResumeLayout(false);
            mDynamicControls.Add(groupBox);

            return(startY + groupBox.Height);
        }
Пример #13
0
        public bool InitializeMogRepository()
        {
            // First we are going to attempt to load our loader.ini and check if a Repository path was saved froma previous load
            // Load system Ini
            MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

            if (loader != null && loader.CountSections() > 0)
            {
                if (loader.SectionExist("Loader"))
                {
                    if (loader.KeyExist("Loader", "SystemRepositoryPath"))
                    {
                        // Now double check that the path specified actually has a Repository.ini at that location
                        // Lets verify if the repository that was saved is really still a repository?
                        if (Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Tools") &&
                            Directory.Exists(loader.GetString("Loader", "SystemRepositoryPath") + "\\Updates"))
                        {
                            mRepositoryPath = loader.GetString("Loader", "SystemRepositoryPath");

                            // SECOND make sure that we have the mog.ini saved correctly in the current directory
                            if (File.Exists(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini"))
                            {
                                // Also make sure it has a valid repository
                                MOG_Ini targetLoader = new MOG_Ini(Environment.CurrentDirectory + "\\" + LoaderTargetDirectory + "\\MOG.ini");
                                if (targetLoader != null && targetLoader.CountSections() > 0)
                                {
                                    if (targetLoader.SectionExist("MOG"))
                                    {
                                        if (targetLoader.KeyExist("MOG", "SystemRepositoryPath"))
                                        {
                                            // Lets verify if the repository that was saved is really still a repository?
                                            if (Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Tools") &&
                                                Directory.Exists(targetLoader.GetString("MOG", "SystemRepositoryPath") + "\\Updates"))
                                            {
                                                return(true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            // If any of the above conditions fail, have the user locate our repository path for us
            MogForm_RepositoryBrowser_ServerLoader form = new MogForm_RepositoryBrowser_ServerLoader();

            form.ForceRepositorySelection = true;
            form.RepositoryViewVisible    = false;
            form.RepositoryViewVisible    = false;

LocateRepository:

            try
            {
                mSplash.Opacity  = 0;
                this.WindowState = FormWindowState.Minimized;
                if (form.ShowDialog() == DialogResult.OK)
                {
                    // Determine if the path selected is valid
                    if (!File.Exists(form.SelectedPath + "\\MogRepository.ini"))
                    {
                        MessageBox.Show(this, "The selected path is not a valid MOG repository.", "Invalid repository");
                        goto LocateRepository;
                    }
                    else
                    {
                        // Load the MogRepository.ini file found at the location specified by the user
                        MOG_Ini repository = new MOG_Ini(form.SelectedPath + "\\MogRepository.ini");

                        // Does this MogRepository have at least one valid repository path
                        if (repository.SectionExist("Mog_Repositories"))
                        {
                            // If there is only one specified repository, choose that one
                            if (repository.CountKeys("Mog_Repositories") == 1)
                            {
                                // Get the section
                                string section = repository.GetKeyNameByIndexSLOW("Mog_Repositories", 0);

                                // Get the path from that section
                                if (repository.SectionExist(section) && repository.KeyExist(section, "SystemRepositoryPath"))
                                {
                                    mRepositoryPath = repository.GetString(section, "SystemRepositoryPath");
                                }
                                else
                                {
                                    MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                    goto LocateRepository;
                                }
                            }
                            else if (repository.CountKeys("Mog_Repositories") > 1)
                            {
                                // The user must now choose which repository to use
                                MogForm_MultiRepository multiRep = new MogForm_MultiRepository();
                                for (int i = 0; i < repository.CountKeys("Mog_Repositories"); i++)
                                {
                                    multiRep.RepositoryComboBox.Items.Add(repository.GetKeyNameByIndexSLOW("Mog_Repositories", i));
                                }
                                multiRep.RepositoryComboBox.SelectedIndex = 0;

                                // Show the form to the user and have him select between the repository sections found
                                if (multiRep.ShowDialog() == DialogResult.OK)
                                {
                                    // Get the section
                                    string userSection = multiRep.RepositoryComboBox.Text;

                                    // Get the path from that section
                                    if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemRepositoryPath"))
                                    {
                                        mRepositoryPath = repository.GetString(userSection, "SystemRepositoryPath");
                                    }
                                    else
                                    {
                                        MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                        goto LocateRepository;
                                    }
                                }
                                else
                                {
                                    goto LocateRepository;
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                goto LocateRepository;
                            }
                        }
                    }
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Invalid repository");
                goto LocateRepository;
            }


            // Double check that we got a valid mog repository path
            if (mRepositoryPath.Length == 0)
            {
                goto LocateRepository;
            }
            else
            {
                //Warn the user if the repository was on a local drive
                string drive = Path.GetPathRoot(mRepositoryPath);
                int    type  = (int)GetDriveType(drive);
                if (type != DRIVE_TYPE_NETWORK)
                {
                    if (MessageBox.Show(this, "It is not recommended to place a MOG Repository on a local drive because it will not be accessible to other users on the network.", "Local Drive Warning", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                    {
                        goto LocateRepository;
                    }
                }

                // Yup, all is well save it out
                loader.PutString("Loader", "SystemRepositoryPath", mRepositoryPath);
                loader.Save();

                // Save out our MOG.ini
                SaveMOGConfiguration();

                this.Opacity     = 0;
                mSplash.Opacity  = 1;
                this.WindowState = FormWindowState.Normal;
                return(true);
            }
        }
Пример #14
0
        public guiSound(MogMainForm handle, SplashForm SplashScreen, string configFilename, string soundClass)
        {
            mTheme          = soundClass;
            mHandle         = handle;
            mSoundAvailable = true;

            InitializeSoundEngine();

            // Load the sound ini
            string iniPath    = Application.StartupPath;
            string configFile = string.Concat(iniPath, "\\", configFilename);

            if (DosUtils.FileExist(configFile))
            {
                mConfig    = new MOG_Ini(configFile);
                mSoundPath = string.Concat(iniPath, "\\ClientSounds");

                // Update the sound menu with the scheme choices
                if (mConfig.SectionExist("Themes"))
                {
                    // Add a menuItem for each them found in the ini
                    for (int i = 0; i < mConfig.CountKeys("Themes"); i++)
                    {
                        // Assign the click event to each menu item
                        ToolStripMenuItem item = new ToolStripMenuItem(mConfig.GetKeyNameByIndexSLOW("Themes", i));
                        item.Click += new System.EventHandler(this.SoundMenu_OnClick);

                        // Set the check mark on the theme that pass passed in to the constructor
                        if (string.Compare(item.Text, mTheme, true) == 0)
                        {
                            item.Checked = true;
                        }

                        // Add th menu item
                        mHandle.themeToolStripMenuItem.DropDownItems.Add(item);
                    }

                    // Setup default theme
                    if (mTheme == null)
                    {
                        if (mHandle.themeToolStripMenuItem.DropDownItems.Count > 0)
                        {
                            mTheme = mHandle.themeToolStripMenuItem.DropDownItems[0].Text;
                            ToolStripMenuItem defaultTheme = mHandle.themeToolStripMenuItem.DropDownItems[0] as ToolStripMenuItem;
                            defaultTheme.Checked = true;
                        }
                    }
                }

                // Get our current sounds version
                if (mConfig.SectionExist("Version"))
                {
                    mVersion = Convert.ToInt32(mConfig.GetString("SoundsVersion", "Version"));
                }
                else
                {
                    mVersion = 0;
                }

                // Get all default sounds
                if (mConfig.SectionExist("SOUNDS"))
                {
                    string SourceSoundPath = MOG_ControllerSystem.GetSystemRepositoryPath() + "\\" + mConfig.GetString("Sounds", "Root");
                    // Make sure we have a current sound directory
                    if (!DosUtils.DirectoryExist(mSoundPath))
                    {
                        DosUtils.DirectoryCreate(mSoundPath);
                    }

                    // Make sure we have all the needed sounds
                    if (DosUtils.FileExist(string.Concat(SourceSoundPath, "\\version.ini")))
                    {
                        MOG_Ini soundVersion = new MOG_Ini(string.Concat(SourceSoundPath, "\\version.ini"));

                        int sourceVersion = Convert.ToInt32(soundVersion.GetString("SoundsVersion", "Version"));

                        if (sourceVersion > mVersion)
                        {
                            // Update all our sounds
                            foreach (FileInfo file in DosUtils.FileGetList(SourceSoundPath, "*.wav"))
                            {
                                string target = string.Concat(mSoundPath, "\\", file.Name);
                                if (DosUtils.FileCopyModified(file.FullName, target))
                                {
                                    SplashScreen.updateSplashNoStep("UPDATING: " + file.Name, 0);
                                }
                            }

                            // Update our version number
                            mConfig.PutString("SoundsVersion", "Version", sourceVersion.ToString());
                            mConfig.Save();
                        }
                    }
                }
            }

            // Set the main theme to be the same as this private version
            mHandle.mSoundScheme = mTheme;
        }
Пример #15
0
        private void PopulateSyncTree(MOG_Ini ProjectPlatfromSinc, MOG_Ini userPlatfromSinc)
        {
            // Clear our list
            XboxSincTreeView.Nodes.Clear();

            #region Project platform defaults
            // Load the project platform defaults
            TreeNode parentPlatform = new TreeNode(MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName());
            if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("xbox")))
            {
                for (int x = 0; x < ProjectPlatfromSinc.CountKeys("Xbox"); x++)
                {
                    TreeNode node  = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("Xbox", x)));
                    TreeNode child = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("Xbox", x)));
                    node.Checked = true;
                    node.Nodes.Add(child);

                    parentPlatform.Nodes.Add(node);
                }
            }

            // Add user nodes
            if (userPlatfromSinc != null)
            {
                if (userPlatfromSinc.SectionExist("xbox"))
                {
                    for (int x = 0; x < userPlatfromSinc.CountKeys("Xbox"); x++)
                    {
                        TreeNode node  = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("Xbox", x)));
                        TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("Xbox", x)));
                        node.Checked   = true;
                        node.ForeColor = Color.Blue;
                        node.Nodes.Add(child);

                        parentPlatform.Nodes.Add(node);
                    }
                }
            }
            XboxSincTreeView.Nodes.Add(parentPlatform);
            #endregion

            #region Filemaps
            // Load project Filemaps
            TreeNode parentFileMaps = new TreeNode("FileMap");
            if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("FileMap")))
            {
                for (int x = 0; x < ProjectPlatfromSinc.CountKeys("FileMap"); x++)
                {
                    TreeNode node  = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("FileMap", x)));
                    TreeNode child = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("FileMap", x)));
                    node.Checked = true;
                    node.Nodes.Add(child);

                    parentFileMaps.Nodes.Add(node);
                }
            }

            // Add user nodes
            if (userPlatfromSinc != null)
            {
                if (userPlatfromSinc.SectionExist("FileMap"))
                {
                    for (int x = 0; x < userPlatfromSinc.CountKeys("FileMap"); x++)
                    {
                        TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("FileMap", x)));
                        node.ForeColor = Color.Blue;
                        node.Checked   = true;

                        TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("FileMap", x)));
                        node.ForeColor = Color.Blue;
                        node.Nodes.Add(child);

                        parentFileMaps.Nodes.Add(node);
                    }
                }
            }

            XboxSincTreeView.Nodes.Add(parentFileMaps);
            #endregion

            #region Remaps
            // Load Remaps
            TreeNode parentRemaps = new TreeNode("ReMap");
            if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("ReMap")))
            {
                for (int x = 0; x < ProjectPlatfromSinc.CountKeys("ReMap"); x++)
                {
                    TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("ReMap", x)));
                    node.Checked = true;
                    node.Nodes.Add(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("ReMap", x)));

                    parentRemaps.Nodes.Add(node);
                }
            }

            if ((userPlatfromSinc != null) && (userPlatfromSinc.SectionExist("ReMap")))
            {
                for (int x = 0; x < userPlatfromSinc.CountKeys("ReMap"); x++)
                {
                    TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("ReMap", x)));
                    node.Checked   = true;
                    node.ForeColor = Color.Blue;
                    node.Nodes.Add(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("ReMap", x)));

                    parentRemaps.Nodes.Add(node);
                }
            }

            XboxSincTreeView.Nodes.Add(parentRemaps);
            #endregion

            #region Exclusions
            // Load Exclusions
            TreeNode parentExclusions = new TreeNode("Exclusion");

            if ((ProjectPlatfromSinc != null) && (ProjectPlatfromSinc.SectionExist("Exclusion")))
            {
                for (int x = 0; x < ProjectPlatfromSinc.CountKeys("Exclusion"); x++)
                {
                    TreeNode node = new TreeNode(FormatString(ProjectPlatfromSinc.GetKeyNameByIndexSLOW("Exclusion", x)));
                    node.Checked = true;
                    node.Nodes.Add(FormatString(ProjectPlatfromSinc.GetKeyByIndexSLOW("Exclusion", x)));

                    parentExclusions.Nodes.Add(node);
                }
            }

            // Add user nodes
            if (userPlatfromSinc != null)
            {
                if (userPlatfromSinc.SectionExist("Exclusion"))
                {
                    for (int x = 0; x < userPlatfromSinc.CountKeys("Exclusion"); x++)
                    {
                        TreeNode node = new TreeNode(FormatString(userPlatfromSinc.GetKeyNameByIndexSLOW("Exclusion", x)));
                        node.ForeColor = Color.Blue;
                        node.Checked   = true;

                        TreeNode child = new TreeNode(FormatString(userPlatfromSinc.GetKeyByIndexSLOW("Exclusion", x)));
                        node.ForeColor = Color.Blue;
                        node.Nodes.Add(child);

                        parentExclusions.Nodes.Add(node);
                    }
                }
            }

            XboxSincTreeView.Nodes.Add(parentExclusions);
            #endregion
        }
Пример #16
0
        public bool SaveRepositories(string iniFilename)
        {
            if (!Directory.Exists(Path.GetDirectoryName(iniFilename)))
            {
                return(false);
            }

            MOG_Ini ini = new MOG_Ini(iniFilename);

            if (ini == null)
            {
                return(false);
            }

            // remove all old repository data
            int i;

            if (ini.SectionExist("REPOSITORIES"))
            {
                for (i = 0; i < ini.CountKeys("REPOSITORIES"); i++)
                {
                    // skip default
                    if (ini.GetKeyNameByIndexSLOW("REPOSITORIES", i).ToLower() == "default")
                    {
                        continue;
                    }

                    ini.RemoveSection("REPOSITORIES." + ini.GetKeyNameByIndexSLOW("REPOSITORIES", i));
                }
                ini.RemoveSection("REPOSITORIES");
            }

            // and save the new data
            i = 0;
            foreach (ListViewItem item in this.lvRepositories.Items)
            {
                string mrString = "mr" + i.ToString();
                ini.PutString("REPOSITORIES", mrString, "");
                ini.PutString("REPOSITORIES." + mrString, "name", item.Text);
                ini.PutString("REPOSITORIES." + mrString, "path", item.SubItems[1].Text);

                if (item == this.lvRepositories.SelectedItems[0])
                {
                    // this one's the default
                    ini.PutString("REPOSITORIES", "default", mrString);

                    // is there an INI selected in lvIniFiles?
                    if (this.lvIniFile.SelectedItems.Count > 0)
                    {
                        ini.PutString("REPOSITORIES." + mrString, "ini", item.SubItems[1].Text + "\\Tools\\" + this.lvIniFile.SelectedItems[0].Text);
                    }
                    else
                    {
                        ini.PutString("REPOSITORIES." + mrString, "ini", item.SubItems[1].Text + "\\" + MOG_Main.GetDefaultSystemRelativeConfigFileDefine());
                    }
                }
                else
                {
                    ini.PutString("REPOSITORIES." + "mr" + i.ToString(), "ini", item.SubItems[1].Text + "\\" + MOG_Main.GetDefaultSystemRelativeConfigFileDefine());
                }

                ++i;
            }

            ini.Save();
            ini.Close();
            return(true);
        }
        private void CloseButton_Click(object sender, System.EventArgs e)
        {
LocateRepository:

            try
            {
                // Determine if the path selected is valid
                if (!File.Exists(MOGSelectedRepository + "\\MogRepository.ini"))
                {
                    MessageBox.Show(this, "The selected path is not a valid MOG repository.", "Invalid repository");
                    this.DialogResult = DialogResult.Retry;
                    return;
                }
                else
                {
                    // Load the MogRepository.ini file found at the location specified by the user
                    MOG_Ini repository = new MOG_Ini(MOGSelectedRepository + "\\MogRepository.ini");

                    // Does this MogRepository have at least one valid repository path
                    if (repository.SectionExist("Mog_Repositories"))
                    {
                        // If there is only one specified repository, choose that one
                        if (repository.CountKeys("Mog_Repositories") == 1)
                        {
                            // Get the section
                            string section = repository.GetKeyNameByIndexSLOW("Mog_Repositories", 0);

                            // Get the path from that section
                            if (repository.SectionExist(section) && repository.KeyExist(section, "SystemRepositoryPath"))
                            {
                                mRepositoryPath = repository.GetString(section, "SystemRepositoryPath");

                                // Now set the config
                                if (repository.SectionExist(section) && repository.KeyExist(section, "SystemConfiguration"))
                                {
                                    mConfigFile = repository.GetString(section, "SystemConfiguration");
                                }
                                else
                                {
                                    MessageBox.Show(this, "The selected path does not have or is missing a System Configuration file.", "Invalid repository");
                                    goto LocateRepository;
                                }
                            }
                            else
                            {
                                MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                goto LocateRepository;
                            }
                        }
                        else if (repository.CountKeys("Mog_Repositories") > 1)
                        {
                            // The user must now choose which repository to use
                            MogForm_MultiRepository multiRep = new MogForm_MultiRepository();
                            for (int i = 0; i < repository.CountKeys("Mog_Repositories"); i++)
                            {
                                multiRep.RepositoryComboBox.Items.Add(repository.GetKeyNameByIndexSLOW("Mog_Repositories", i));
                            }
                            multiRep.RepositoryComboBox.SelectedIndex = 0;

                            // Show the form to the user and have him select between the repository sections found
                            if (multiRep.ShowDialog() == DialogResult.OK)
                            {
                                // Get the section
                                string userSection = multiRep.RepositoryComboBox.Text;

                                // Get the path from that section
                                if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemRepositoryPath"))
                                {
                                    mRepositoryPath = repository.GetString(userSection, "SystemRepositoryPath");

                                    // Now set the config
                                    if (repository.SectionExist(userSection) && repository.KeyExist(userSection, "SystemConfiguration"))
                                    {
                                        mConfigFile = repository.GetString(userSection, "SystemConfiguration");
                                    }
                                    else
                                    {
                                        MessageBox.Show(this, "The selected path does not have or is missing a System Configuration file.", "Invalid repository");
                                        goto LocateRepository;
                                    }
                                }
                                else
                                {
                                    MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                                    goto LocateRepository;
                                }
                            }
                            else
                            {
                                goto LocateRepository;
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "The selected path does not have or is missing a repository path.", "Invalid repository");
                            goto LocateRepository;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Invalid repository");
                goto LocateRepository;
            }


            // Double check that we got a valid mog repository path
            if (mRepositoryPath.Length == 0)
            {
                goto LocateRepository;
            }
            else
            {
                // Save out our MOG.ini
                SaveMOGConfiguration();

                if (mForceRestart)
                {
                    // Close our application
                    MessageBox.Show(this, "Changing of the MOG repository requires MOG to restart.  We are now shutting down the client. When complete, restart MOG for changes to be effective.", "Shutting down MOG", MessageBoxButtons.OK);
                }
            }
        }
Пример #18
0
        public void LoadSysIni()
        {
            try
            {
                // Start the progressBar
                ZipProgressBar(10);

                // Load system Ini
                MOG_Ini loader = new MOG_Ini(LoaderConfigFile);

                // Clear our box
                CheckListBox.Items.Clear();

                // Locate the Master Archive drive
                for (int i = 0; i < loader.CountKeys("UPDATE"); i++)
                {
                    string SectionToBeUpdated = loader.GetKeyNameByIndexSLOW("UPDATE", i);

                    // Get bin locations
                    string gSourceLocation = mRepositoryPath + "\\" + loader.GetString(SectionToBeUpdated, "BINLOCATION");
                    string TargetLocation  = loader.GetString("LOADER", "BINLOCATION");

                    if (TargetLocation.CompareTo("NONE") == 0)
                    {
                        TargetLocation = String.Concat(Environment.CurrentDirectory, "\\" + LoaderTargetDirectory);

                        DirectoryInfo dir = new DirectoryInfo(TargetLocation);
                        if (dir.Exists != true)
                        {
                            dir.Create();
                        }
                    }


                    // Make sure we have a valid fileList in the target drive
                    if (!File.Exists(gSourceLocation + "\\FileList.ini"))
                    {
                        throw new Exception("Current version of (" + SectionToBeUpdated + ") does not exist at:\n\n " + gSourceLocation + "\n\n Aborting...");
                    }

                    // Load the filelist associated with this section
                    MOG_Ini files = new MOG_Ini(String.Concat(gSourceLocation, "\\FileList.ini"));


                    // Either update the directory box or the ini
                    if (TargetDir.Text == "")
                    {
                        if (gSourceLocation.CompareTo("") == 0)
                        {
                            TargetDir.Text = String.Concat(Environment.CurrentDirectory, "\\" + LoaderTargetDirectory);
                            gBinLocation   = TargetDir.Text;
                            loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                            loader.Save();
                        }
                        else
                        {
                            TargetDir.Text = TargetLocation;
                            gBinLocation   = TargetLocation;
                            loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                            loader.Save();
                        }
                    }
                    else
                    {
                        gBinLocation = TargetDir.Text;
                        loader.PutString("LOADER", "BINLOCATION", TargetDir.Text);
                        loader.Save();
                    }

                    // Get the executable to launch with the run button
                    string exeFile = files.GetString(SectionToBeUpdated, "EXE");

                    // Make sure the exe is not NONE
                    if (String.Compare(exeFile, "NONE", true) != 0)
                    {
                        gExeFile = exeFile;
                    }

                    // Walk thru all files
                    for (int x = 0; x < files.CountKeys("FILES"); x++)
                    {
                        ListViewItem item    = new ListViewItem();
                        string       curFile = String.Concat(TargetLocation, "\\", files.GetKeyNameByIndexSLOW("FILES", x));
                        string       newFile = String.Concat(gSourceLocation, "\\", files.GetKeyNameByIndexSLOW("FILES", x));

                        // Check current version against new version
                        FileInfo CurrentBin, NewBin;

                        // Check for special folders
                        if (curFile.IndexOf("<WIN_SYSTEM>") != -1)
                        {
                            // Fix path to reflect new dir
                            curFile = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.System), curFile.Substring(curFile.IndexOf(">") + 1));
                            newFile = string.Concat(newFile.Substring(0, newFile.IndexOf("<")), newFile.Substring(newFile.IndexOf(">") + 1));
                        }

                        CurrentBin = new FileInfo(curFile);
                        NewBin     = new FileInfo(newFile);

                        // Add file to the menu
                        item.Text = files.GetKeyNameByIndexSLOW("FILES", x);
                        item.SubItems.Add(newFile);
                        item.SubItems.Add(gSourceLocation);                          // Source directory

                        if ((CurrentBin.LastWriteTime.CompareTo(NewBin.LastWriteTime) != 0) || !(CurrentBin.Exists))
                        {
                            Debug.Write("Copy - " + curFile + " \tCurrent:" + CurrentBin.LastWriteTime.ToString() + " New:" + NewBin.LastWriteTime.ToString(), "\nNew Check");
                        }
                        else
                        {
                            Debug.Write("Skip - " + curFile + " \tCurrent:" + CurrentBin.LastWriteTime.ToString() + " New:" + NewBin.LastWriteTime.ToString(), "\nNew Check");
                        }

                        if ((CurrentBin.LastWriteTime.CompareTo(NewBin.LastWriteTime) != 0) || !(CurrentBin.Exists))
                        {
                            if (NewBin.Exists)
                            {
                                // Enable buttons
                                UpdateButton.Enabled    = true;
                                UpdateRunButton.Enabled = true;
                                RunButton.Enabled       = true;
                                allUpToDate             = false;

                                // Check the old file
                                item.Checked = true;
                            }
                            else
                            {
                                item.Remove();
                            }
                        }

                        // Make sure we don't add an asset twice to the list
                        bool alreadyExists = false;
                        foreach (ListViewItem lItem in CheckListBox.Items)
                        {
                            if (String.Compare(lItem.Text, item.Text) == 0)
                            {
                                alreadyExists = true;
                            }
                        }

                        if (alreadyExists == false)
                        {
                            CheckListBox.Items.Add(item);
                        }
                    }
                }

                if (loader.KeyExist("LOADER", "UpdateRun") && !allUpToDate)
                {
                    if (string.Compare(loader.GetString("LOADER", "UpdateRun"), "true", true) == 0)
                    {
                        mSplash.updateSplash("Auto Updating to current version...", 500);

                        if (!UserAbort)
                        {
                            if (UpdateBinary())
                            {
                                allUpToDate   = true;
                                DisableEvents = false;
                                RunBinary();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "Error updating to latest version");
                allUpToDate = false;
                Application.Exit();
            }
        }