public static void Add(string style, StyleWidgetHandler handler) { var list = GetStyleList(style); list.Add(delegate(InstanceWidget widget) { handler(widget); }); }
/// <summary> /// Adds a style for a widget /// </summary> /// <remarks> /// Styling a widget allows you to access the widget, but not the platform-specific controls (in a type-safe way). /// /// Typically, you'd use Style.Add<H>(string, StyleHandler<H>) instead, which will add a style based on the widget handler, which /// will give you direct and type safe access to platform-specifics of the widget. /// </remarks> /// <typeparam name="T">Type of the widget to style</typeparam> /// <param name="style">Identifier of the style</param> /// <param name="handler">Delegate with your logic to style the widget</param> public static void Add <T> (string style, StyleWidgetHandler <T> handler) where T : InstanceWidget { var list = GetStyleList((object)style ?? typeof(T)); list.Add(delegate(InstanceWidget widget) { var control = widget as T; if (control != null) { handler(control); } }); }
/// <summary> /// Adds a style for a widget /// </summary> /// <remarks> /// Styling a widget allows you to access the widget, but not the platform-specific controls (in a type-safe way). /// /// Typically, you'd use Style.Add<H>(string, StyleHandler<H>) instead, which will add a style based on the widget handler, which /// will give you direct and type safe access to platform-specifics of the widget. /// </remarks> /// <typeparam name="TWidget">Type of the widget to style</typeparam> /// <param name="style">Identifier of the style</param> /// <param name="handler">Delegate with your logic to style the widget</param> public static void Add <TWidget>(string style, StyleWidgetHandler <TWidget> handler) where TWidget : Widget { var list = GetStyleList((object)style ?? typeof(TWidget)); list.Add(widget => { var control = widget as TWidget; if (control != null) { handler(control); } }); }
/// <summary> /// Adds a style for a widget /// </summary> /// <remarks> /// Styling a widget allows you to access the widget, but not the platform-specific controls (in a type-safe way). /// /// Typically, you'd use Style.Add<H>(string, StyleHandler<H>) instead, which will add a style based on the widget handler, which /// will give you direct and type safe access to platform-specifics of the widget. /// </remarks> /// <typeparam name="TWidget">Type of the widget to style</typeparam> /// <param name="style">Identifier of the style</param> /// <param name="handler">Delegate with your logic to style the widget</param> public static void Add <TWidget>(string style, StyleWidgetHandler <TWidget> handler) where TWidget : Widget { Styles.Add <TWidget>(style, w => handler(w)); }