Пример #1
0
        private void LoadAndParseSettingsFiles()
        {
            SettingsSection userLevelToAddTo = null;
            Category        categoryToAddTo  = null;
            Group           groupToAddTo     = null;
            SubGroup        subGroupToAddTo  = null;

            foreach (string line in AggContext.StaticData.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    switch (CountLeadingSpaces(line))
                    {
                    case 0:
                        userLevelToAddTo = new SettingsSection(sanitizedLine);
                        UserLevels.Add(sanitizedLine, userLevelToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new Category(sanitizedLine, userLevelToAddTo);
                        userLevelToAddTo.Categories.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new Group(sanitizedLine, categoryToAddTo);
                        categoryToAddTo.Groups.Add(groupToAddTo);
                        break;

                    case 6:
                        subGroupToAddTo = new SubGroup(sanitizedLine, groupToAddTo);
                        groupToAddTo.SubGroups.Add(subGroupToAddTo);
                        break;

                    case 8:
                        SliceSettingData data = GetSettingsData(sanitizedLine);
                        if (data != null)
                        {
                            subGroupToAddTo.Settings.Add(data);
                            data.OrganizerSubGroup = subGroupToAddTo;
                            userLevelToAddTo.AddSetting(data.SlicerConfigName, subGroupToAddTo);
                        }

                        break;

                    default:
                        throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Пример #2
0
        private void LoadAndParseLayoutFile()
        {
            SettingsSection sectionToAddTo  = null;
            Category        categoryToAddTo = null;
            Group           groupToAddTo    = null;

            foreach (string line in AggContext.StaticData.ReadAllLines(Path.Combine("SliceSettings", "Layouts.txt")))
            {
                if (line.Length > 0)
                {
                    string sanitizedLine = line.Replace('"', ' ').Trim();
                    var    leadingSpaces = CountLeadingSpaces(line);
                    switch (leadingSpaces)
                    {
                    case 0:
                        sectionToAddTo = new SettingsSection(sanitizedLine);
                        Sections.Add(sanitizedLine, sectionToAddTo);
                        break;

                    case 2:
                        categoryToAddTo = new Category(sanitizedLine, sectionToAddTo);
                        sectionToAddTo.Categories.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new Group(sanitizedLine, categoryToAddTo);
                        categoryToAddTo.Groups.Add(groupToAddTo);
                        break;

                    case 6:
                        if (PrinterSettings.SettingsData.TryGetValue(sanitizedLine, out SliceSettingData data))
                        {
                            groupToAddTo.Settings.Add(data);
                            data.OrganizerGroup = groupToAddTo;
                            sectionToAddTo.AddSetting(data.SlicerConfigName, groupToAddTo);
                        }

                        break;

                    default:
                        throw new Exception($"Bad file, too many spaces - {leadingSpaces} (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }