// 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; }
/*=== utility ===*/ // This method refreshes the property grid. public void RefreshGrid() { bag.Properties.Clear(); /*=== 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 global options dialog. if (!info.IsGlobal) { continue; } OptionBase aOption = (OptionBase)oFields[i].GetValue(aOptions); OptionBase gOption = (OptionBase)oFields[i].GetValue(gOptions); PropertySpec ps = new PropertySpec(info.Name, gOption.GetOptionType()); ps.Category = info.Category; ps.Description = info.Description; ps.EditorTypeName = info.EditorType; ps.ConverterTypeName = info.GlobalTypeConverter; ps.DefaultValue = aOption; bag.Properties.Add(ps); } // Set the selected object to be the bag. this.SelectedObject = bag; }