Beispiel #1
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);
        }