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); }
private 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]; if (setting.DataEditType != OrganizerSettingsData.DataEditTypes.HARDWARE_PRESENT) { 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", " ")); } if (ActivePrinterProfile.Instance.ActiveSliceEngine.MapContains(setting.SlicerConfigName)) { 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); }