Beispiel #1
0
        private void LoadAndParseSettingsFiles()
        {
            string propertiesFileContents = StaticData.Instance.ReadAllText(Path.Combine("SliceSettings", "Properties.json"));

            settingsData = JsonConvert.DeserializeObject <List <OrganizerSettingsData> >(propertiesFileContents) as List <OrganizerSettingsData>;

            OrganizerUserLevel userLevelToAddTo = null;
            OrganizerCategory  categoryToAddTo  = null;
            OrganizerGroup     groupToAddTo     = null;
            OrganizerSubGroup  subGroupToAddTo  = null;

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

                    case 2:
                        categoryToAddTo = new OrganizerCategory(sanitizedLine);
                        userLevelToAddTo.CategoriesList.Add(categoryToAddTo);
                        break;

                    case 4:
                        groupToAddTo = new OrganizerGroup(sanitizedLine);
                        categoryToAddTo.GroupsList.Add(groupToAddTo);
                        break;

                    case 6:
                        subGroupToAddTo = new OrganizerSubGroup(sanitizedLine);
                        groupToAddTo.SubGroupsList.Add(subGroupToAddTo);
                        break;

                    case 8:
                        OrganizerSettingsData data = GetSettingsData(sanitizedLine);
                        if (data != null)
                        {
                            subGroupToAddTo.SettingDataList.Add(data);
                        }

                        break;

                    default:
                        throw new Exception("Bad file, too many spaces (must be 0, 2, 4 or 6).");
                    }
                }
            }
        }
Beispiel #2
0
        private void LoadAndParseSettingsFiles()
        {
            UserLevel 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 UserLevel(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).");
                    }
                }
            }
        }
Beispiel #3
0
        void LoadAndParseSettingsFiles(string properties, string layout)
        {
            {
                string propertiesFileContents = "";
                using (FileStream fileStream = new FileStream(properties, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader propertiesReader = new StreamReader(fileStream))
                    {
                        propertiesFileContents = propertiesReader.ReadToEnd();
                    }
                }

                string[] lines = propertiesFileContents.Split('\n');
                foreach (string line in lines)
                {
                    if (line.Trim().Length > 0)
                    {
                        settingsData.Add(OrganizerSettingsData.NewOrganizerSettingData(line));
                    }
                }
            }

            {
                string layoutFileContents = "";
                using (FileStream fileStream = new FileStream(layout, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    using (StreamReader layoutReader = new StreamReader(fileStream))
                    {
                        layoutFileContents = layoutReader.ReadToEnd();
                    }
                }

                OrganizerUserLevel userLevelToAddTo = null;
                OrganizerCategory  categoryToAddTo  = null;
                OrganizerGroup     groupToAddTo     = null;
                OrganizerSubGroup  subGroupToAddTo  = null;
                string[]           lines            = layoutFileContents.Split('\n');
                foreach (string line in lines)
                {
                    if (line.Length > 0)
                    {
                        switch (CountLeadingSpaces(line))
                        {
                        case 0:
                            string userLevelText = line.Replace('"', ' ').Trim();
                            userLevelToAddTo = new OrganizerUserLevel(userLevelText);
                            UserLevels.Add(userLevelText, userLevelToAddTo);
                            break;

                        case 2:
                            categoryToAddTo = new OrganizerCategory(line.Replace('"', ' ').Trim());
                            userLevelToAddTo.CategoriesList.Add(categoryToAddTo);
                            break;

                        case 4:
                            groupToAddTo = new OrganizerGroup(line.Replace('"', ' ').Trim());
                            categoryToAddTo.GroupsList.Add(groupToAddTo);
                            break;

                        case 6:
                            subGroupToAddTo = new OrganizerSubGroup(line.Replace('"', ' ').Trim());
                            groupToAddTo.SubGroupsList.Add(subGroupToAddTo);
                            break;

                        case 8:
                            subGroupToAddTo.SettingDataList.Add(GetSettingsData(line.Replace('"', ' ').Trim()));
                            break;

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