public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { if (context == null) { return(new TypeConverter.StandardValuesCollection(new ArrayList())); } Control instance = context.Instance as Control; ArrayList values = new ArrayList(); if ((instance != null) && (instance.Site != null)) { IThemeResolutionService service = (IThemeResolutionService)instance.Site.GetService(typeof(IThemeResolutionService)); ThemeProvider stylesheetThemeProvider = service.GetStylesheetThemeProvider(); ThemeProvider themeProvider = service.GetThemeProvider(); if (stylesheetThemeProvider != null) { values.AddRange(stylesheetThemeProvider.GetSkinsForControl(instance.GetType())); values.Remove(string.Empty); } if (themeProvider != null) { foreach (string str in themeProvider.GetSkinsForControl(instance.GetType())) { if (!values.Contains(str)) { values.Add(str); } } values.Remove(string.Empty); } values.Sort(); } return(new TypeConverter.StandardValuesCollection(values)); }
public override bool GetStandardValuesSupported(ITypeDescriptorContext context) { ThemeProvider themeProvider = null; if (context != null) { Control instance = context.Instance as Control; if ((instance != null) && (instance.Site != null)) { IThemeResolutionService service = (IThemeResolutionService)instance.Site.GetService(typeof(IThemeResolutionService)); if (service != null) { themeProvider = service.GetThemeProvider(); if (themeProvider == null) { themeProvider = service.GetStylesheetThemeProvider(); } } } } return(themeProvider != null); }