// This method refreshes the property grid. public void RefreshGrid(string configuration, string platform) { // If we don't have a project yet, don't run this method. if (project == null) { return; } bag.Properties.Clear(); Configuration = configuration; Platform = platform; // Setup the new configuration. If it doesn't exist, add it. pOptions = ProjectOptions.GetNewConfiguration(Configuration, Platform).Options; /*=== Setup the property bag. ===*/ FieldInfo[] oFields; Type oType = typeof(Options); oFields = oType.GetFields(BindingFlags.Public | BindingFlags.Instance); // Loop through all the fields in the 'Options' class. for (int i = 0; i < oFields.Length; i++) { // If the current field is not an option, ignore it. if (!oFields[i].FieldType.IsSubclassOf(typeof(OptionBase))) { continue; } List <Attribute> attrs = AttributeUtility.GetAllAttributes(oFields[i], false); OptionInfo info = new OptionInfo(attrs); // Ignore options that shouldn't show up in the project options dialog. if (!info.IsProject) { continue; } OptionBase gOption = (OptionBase)oFields[i].GetValue(gOptions); OptionBase pOption = (OptionBase)oFields[i].GetValue(pOptions); PropertySpec ps = new PropertySpec(info.Name, pOption.GetOptionType()); ps.Category = info.Category; ps.Description = info.Description; ps.EditorTypeName = info.EditorType; ps.ConverterTypeName = info.ProjectTypeConverter; ps.DefaultValue = gOption; bag.Properties.Add(ps); } // Set the selected object to be the bag. this.SelectedObject = bag; }
// Override this method to save options. public override void Save() { /*=== update the global project options, then save ===*/ List <OptionsElement> options = ProjectOptions.Options; ProjectOptionsSet optionsSet = OptionsManager.GetProjectOptions(project); foreach (OptionsElement oe in options) { optionsSet.GetNewConfiguration(oe.Configuration, oe.Platform).Options = new Options(oe.Options); } optionsSet.Save(); }