private Tuple <PropertyInfo, object, Font> GetPropertyInfoAndValue(IAppearanceFormat appearanceFormat, string propertyName) { var type = appearanceFormat.GetType(); object obj = appearanceFormat; while (propertyName.Contains(".")) { var name = propertyName.Substring(0, propertyName.IndexOf(".", StringComparison.Ordinal)); PropertyInfo propertyInfo; try{ propertyInfo = type.PropertyX(name, Flags.ExcludeHiddenMembers | Flags.InstancePublic); } catch (AmbiguousMatchException e) { throw new AmbiguousMatchException(type.FullName + ", " + propertyName, e); } if (propertyInfo == null) { return(null); } propertyName = propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1); type = propertyInfo.PropertyType; obj = propertyInfo.Get(obj); } var property = type.Property(propertyName); return(obj != null? (property != null? new Tuple <PropertyInfo, object, Font>(property, obj, (Font)property.Get(obj)): null): null); }
void appearanceController_AppearanceApplied(object sender, ApplyAppearanceEventArgs e) { if ((View is ListView) && (e.ItemType == AppearanceItemType.ViewItem.ToString()) && (e.ItemName == "Category") && (e.ContextObjects.Length > 0)) { if (View.SelectedObjects.Contains(e.ContextObjects[0])) { IAppearanceFormat formattedItem = e.Item as IAppearanceFormat; if (formattedItem != null) { //Reset the font color of the Category property for selected objects formattedItem.ResetFontColor(); } } } }
void appearanceController_CustomApplyAppearance(object sender, ApplyAppearanceEventArgs e) { if ((e.ContextObjects == null) || (e.ContextObjects.Length != 1)) { return; } if (View is DetailView) { PropertyEditor prop = e.Item as PropertyEditor; if (prop != null) { IAppearanceFormat formattedItem = e.Item as IAppearanceFormat; if (formattedItem != null) { if (prop.PropertyValue != null && prop.PropertyValue is IColor) { formattedItem.BackColor = ((IColor)prop.PropertyValue).BackColor; formattedItem.FontColor = ((IColor)prop.PropertyValue).ForeColor; formattedItem.FontStyle = ((IColor)prop.PropertyValue).FontStyle; } else { formattedItem.ResetBackColor(); formattedItem.ResetFontColor(); formattedItem.ResetFontStyle(); } } } } if ((View is ListView)) { GridViewRowCellStyleEventArgsAppearanceAdapter gridViewRowCellStyleAdapter = e.Item as GridViewRowCellStyleEventArgsAppearanceAdapter; if (gridViewRowCellStyleAdapter != null) { if (gridViewRowCellStyleAdapter.Args.CellValue != null && gridViewRowCellStyleAdapter.Args.CellValue is IColor) { e.AppearanceObject.BackColor = ((IColor)gridViewRowCellStyleAdapter.Args.CellValue).BackColor; e.AppearanceObject.FontColor = ((IColor)gridViewRowCellStyleAdapter.Args.CellValue).ForeColor; e.AppearanceObject.FontStyle = ((IColor)gridViewRowCellStyleAdapter.Args.CellValue).FontStyle; } } } }
private Tuple<PropertyInfo, object, Font> GetPropertyInfoAndValue(IAppearanceFormat appearanceFormat, string propertyName) { var type = appearanceFormat.GetType(); object obj = appearanceFormat; while (propertyName.Contains(".")) { var name = propertyName.Substring(0, propertyName.IndexOf(".", StringComparison.Ordinal)); PropertyInfo propertyInfo; try{ propertyInfo = type.PropertyX(name, Flags.ExcludeHiddenMembers|Flags.InstancePublic); } catch (AmbiguousMatchException e){ throw new AmbiguousMatchException(type.FullName+", "+propertyName,e); } if (propertyInfo == null) return null; propertyName = propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1); type = propertyInfo.PropertyType; obj = propertyInfo.Get(obj); } var property = type.Property(propertyName); return obj != null? (property != null? new Tuple<PropertyInfo, object, Font>(property, obj, (Font) property.Get(obj)): null): null; }
private static Tuple<PropertyInfo, object, Font> GetPropertyInfoAndValue(IAppearanceFormat appearanceFormat, string propertyName) { var type = appearanceFormat.GetType(); object obj = appearanceFormat; while (propertyName.Contains(".")) { var propertyInfo = type.Property(propertyName.Substring(0, propertyName.IndexOf(".", StringComparison.Ordinal))); if (propertyInfo == null) return null; propertyName = propertyName.Substring(propertyName.IndexOf(".", StringComparison.Ordinal) + 1); type = propertyInfo.PropertyType; obj = propertyInfo.Get(obj); } var property = type.Property(propertyName); return new Tuple<PropertyInfo, object, Font>(property, obj, (Font)property.Get(obj)); }