void PopulateLayoutDictionary()
        {
            string UserLevel = "Advanced"; //Show all settings

            for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++)
            {
                OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex];

                for (int groupIndex = 0; groupIndex < category.GroupsList.Count; groupIndex++)
                {
                    OrganizerGroup group = category.GroupsList[groupIndex];

                    for (int subGroupIndex = 0; subGroupIndex < group.SubGroupsList.Count; subGroupIndex++)
                    {
                        OrganizerSubGroup subgroup = group.SubGroupsList[subGroupIndex];
                        for (int settingIndex = 0; settingIndex < subgroup.SettingDataList.Count; settingIndex++)
                        {
                            OrganizerSettingsData setting = subgroup.SettingDataList[settingIndex];
                            string settingDisplayName     = "{0} > {1} > {2}".FormatWith(category.Name, group.Name, setting.PresentationName).Replace("\\n", "").Replace(":", "");
                            settingLayoutData[setting.SlicerConfigName] = settingDisplayName;
                        }
                    }
                }
            }
        }
示例#2
0
        internal OrganizerSubGroup NewAndAddSettingsSubGroup(string subGroupName)
        {
            OrganizerSubGroup newSettingsSubGroup = new OrganizerSubGroup(subGroupName);

            SubGroupsList.Add(newSettingsSubGroup);
            return(newSettingsSubGroup);
        }
示例#3
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).");
                    }
                }
            }
        }
		private void LoadAndParseSettingsFiles()
		{
			string propertiesFileContents = StaticData.Instance.ReadAllText(Path.Combine("SliceSettings", "Properties.json"));
			SettingsData = JsonConvert.DeserializeObject<List<SliceSettingData>>(propertiesFileContents) as List<SliceSettingData>;

			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:
							SliceSettingData 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).");
					}
				}
			}
		}
		internal OrganizerSubGroup NewAndAddSettingsSubGroup(string subGroupName)
		{
			OrganizerSubGroup newSettingsSubGroup = new OrganizerSubGroup(subGroupName);
			SubGroupsList.Add(newSettingsSubGroup);
			return newSettingsSubGroup;
		}
        void PopulateAddSettingRow(int categoryDefaultIndex = -1, int groupDefaultIndex = -1, string settingDefaultConfigName = "-1")
        {
            errorMessageContainer.Visible = false;

            categoryDropDownList             = new SettingsDropDownList("- Select Category -");
            categoryDropDownList.Margin      = new BorderDouble(right: 3);
            categoryDropDownList.MinimumSize = new Vector2(categoryDropDownList.LocalBounds.Width, categoryDropDownList.LocalBounds.Height);
            categoryDropDownList.VAnchor     = Agg.UI.VAnchor.ParentCenter;
            categoryDropDownList.Height      = 24;

            groupDropDownList             = new SettingsDropDownList("- Select Group -");
            groupDropDownList.Margin      = new BorderDouble(right: 3);
            groupDropDownList.MinimumSize = new Vector2(groupDropDownList.LocalBounds.Width, groupDropDownList.LocalBounds.Height);
            groupDropDownList.VAnchor     = Agg.UI.VAnchor.ParentCenter;
            groupDropDownList.Height      = 24;

            settingDropDownList                  = new SettingsDropDownList("- Select Setting -");
            settingDropDownList.Margin           = new BorderDouble(right: 3);
            settingDropDownList.MinimumSize      = new Vector2(settingDropDownList.LocalBounds.Width, settingDropDownList.LocalBounds.Height);
            settingDropDownList.VAnchor          = Agg.UI.VAnchor.ParentCenter;
            settingDropDownList.HAnchor          = Agg.UI.HAnchor.ParentLeftRight;
            settingDropDownList.AlignToRightEdge = true;
            settingDropDownList.Height           = 24;

            string selectedCategoryValue = "{0}:-1:-1".FormatWith(categoryDefaultIndex);
            string selectedGroupValue    = "{0}:{1}:-1".FormatWith(categoryDefaultIndex, groupDefaultIndex);
            string selectedSettingValue  = "{0}:{1}:{2}".FormatWith(categoryDefaultIndex, groupDefaultIndex, settingDefaultConfigName);

            string UserLevel = "Advanced"; //Show all settings

            for (int categoryIndex = 0; categoryIndex < SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList.Count; categoryIndex++)
            {
                OrganizerCategory category = SliceSettingsOrganizer.Instance.UserLevels[UserLevel].CategoriesList[categoryIndex];

                //Always add all categories
                MenuItem categoryMenuItem = categoryDropDownList.AddItem(category.Name, "{0}:-1:-1".FormatWith(categoryIndex));
                categoryMenuItem.Selected += new EventHandler(OnItemSelected);

                for (int groupIndex = 0; groupIndex < category.GroupsList.Count; groupIndex++)
                {
                    OrganizerGroup group      = category.GroupsList[groupIndex];
                    string         groupValue = "{0}:{1}:-1".FormatWith(categoryIndex, groupIndex);

                    //Add groups if within selected category or no category selected
                    if (categoryIndex == categoryDefaultIndex || categoryDefaultIndex == -1)
                    {
                        MenuItem groupMenuItem = groupDropDownList.AddItem(group.Name, groupValue);
                        groupMenuItem.Selected += new EventHandler(OnItemSelected);
                    }

                    for (int subGroupIndex = 0; subGroupIndex < group.SubGroupsList.Count; subGroupIndex++)
                    {
                        OrganizerSubGroup subgroup = group.SubGroupsList[subGroupIndex];
                        for (int settingIndex = 0; settingIndex < subgroup.SettingDataList.Count; settingIndex++)
                        {
                            //Add settings if within selected category and group or no category selected
                            if (selectedGroupValue == groupValue || (groupDefaultIndex == -1 && categoryIndex == categoryDefaultIndex) || categoryDefaultIndex == -1)
                            {
                                OrganizerSettingsData setting = subgroup.SettingDataList[settingIndex];
                                string itemValue = "{0}:{1}:{2}".FormatWith(categoryIndex, groupIndex, setting.SlicerConfigName);
                                string itemName  = setting.PresentationName.Replace("\\n", "").Replace(":", "");
                                if (setting.ExtraSettings.Trim() != "" && setting.DataEditType != OrganizerSettingsData.DataEditTypes.LIST)
                                {
                                    itemName = "{0} ({1})".FormatWith(itemName, setting.ExtraSettings.Replace("\\n", " "));
                                }

                                MenuItem settingMenuItem = settingDropDownList.AddItem(itemName, itemValue);
                                settingMenuItem.Selected += new EventHandler(OnItemSelected);
                                settingMenuItem.Selected += new EventHandler(OnSettingSelected);
                            }
                        }
                    }
                }
            }

            if (categoryDefaultIndex != -1)
            {
                categoryDropDownList.SelectedValue = selectedCategoryValue;
            }
            if (groupDefaultIndex != -1)
            {
                groupDropDownList.SelectedValue = selectedGroupValue;
            }
            if (settingDefaultConfigName != "-1")
            {
                settingDropDownList.SelectedValue = selectedSettingValue;
            }

            addSettingsContainer.RemoveAllChildren();
            addSettingsContainer.AddChild(categoryDropDownList);
            addSettingsContainer.AddChild(groupDropDownList);
            addSettingsContainer.AddChild(settingDropDownList);
            //addSettingsContainer.AddChild(addButton);
        }
示例#7
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).");
                        }
                    }
                }
            }
        }
		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).");
                        }
                    }
                }
            }
        }