Ejemplo n.º 1
0
        private void CreateDefaultSettings(Setting setting)
        {
            Menu menu = new Menu("Graphics");

            setting.Add(menu);

            MenuEntryBool entry = new MenuEntryBool("Fullscreen", false);

            menu.Add(entry);

            MenuEntryNumber entry1 = new MenuEntryNumber("Height", 10.00);

            menu.Add(entry1);
        }
Ejemplo n.º 2
0
        public Boolean Load(string fileName, string path)
        {
            var FileParser = new FileIniDataParser();

            Boolean isExist = FileParser.IsFileExists(fileName, path);

            if (!isExist)
            {
                return(false);
            }

            IniData data = FileParser.ReadIniFile(fileName, path, Encoding.ASCII);

            bool  bresult;
            float fresult;
            Menu  menu;

            SectionCollection sections = data.Sections;

            foreach (Section section in sections)
            {
                menu = new Menu(section.Name);

                foreach (Property property in section.Properties)
                {
                    if (Boolean.TryParse(property.Value, out bresult))
                    {
                        MenuEntryBool entry = new MenuEntryBool(property.Key, bresult);
                        menu.Add(entry);
                    }
                    else if (float.TryParse(property.Value, out fresult))
                    {
                        MenuEntryNumber entry = new MenuEntryNumber(property.Key, fresult);
                        menu.Add(entry);
                    }
                    else
                    {
                        MenuEntryString entry = new MenuEntryString(property.Key, property.Value);
                        menu.Add(entry);
                    }
                }

                Add(menu);
            }

            return(true);
        }
Ejemplo n.º 3
0
        public Boolean Save(string fileName, string path)
        {
            IniData data = new IniData();

            Section  section;
            Property property;

            foreach (Menu menu in _menuList)
            {
                section = new Section(menu.Name);

                foreach (MenuEntry entry in menu.List)
                {
                    if (entry is MenuEntryNumber)
                    {
                        MenuEntryNumber fentry = (MenuEntryNumber)entry;
                        property = new Property(fentry.Name, fentry.Value.ToString());
                        section.Properties.Add(property);
                    }
                    else if (entry is MenuEntryBool)
                    {
                        MenuEntryBool bentry = (MenuEntryBool)entry;
                        property = new Property(bentry.Name, bentry.Value.ToString());
                        section.Properties.Add(property);
                    }
                    else if (entry is MenuEntryString)
                    {
                        MenuEntryString sentry = (MenuEntryString)entry;
                        property = new Property(sentry.Name, sentry.Value);
                        section.Properties.Add(property);
                    }
                }

                data.Sections.Add(section);
            }

            var FileParser = new FileIniDataParser();

            FileParser.WriteIniFile(fileName, path, data);

            return(true);
        }