private static T EditStyles <T>(StylePluginManager styleManager, StyleBuilderArguments styleArguments, T editingStyle, Func <T, Collection <T> > fetchInnerStyles) where T : Style, new() { CompositeStyle compositeStyle = new CompositeStyle(); compositeStyle.Name = editingStyle.Name; if (fetchInnerStyles(editingStyle).Count > 0) { foreach (var style in fetchInnerStyles(editingStyle)) { compositeStyle.Styles.Add(style); } } else { compositeStyle.Styles.Add(editingStyle); } styleArguments.StyleToEdit = compositeStyle; var result = styleManager.EditStyle(styleArguments); if (result.Canceled) { return(null); } else { T resultAreaStyle = new T(); resultAreaStyle.Name = compositeStyle.Name; PointStyle pointStyle = resultAreaStyle as PointStyle; if (pointStyle != null) { foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <PointStyle>()) { pointStyle.CustomPointStyles.Add(tmpAreaStyle); } } else { foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <T>()) { fetchInnerStyles(resultAreaStyle).Add(tmpAreaStyle); } } return(resultAreaStyle); } }
public static IconTextStyle EditStyles(this StylePluginManager styleManager, StyleBuilderArguments styleArguments, IconTextStyle textStyle) { TextStyle resultTextStyle = EditStyles <TextStyle>(styleManager, styleArguments, textStyle, s => s.CustomTextStyles); if (resultTextStyle == null) { return(null); } IconTextStyle iconTextStyle = new IconTextStyle(); iconTextStyle.Name = resultTextStyle.Name; foreach (var tmpStyle in resultTextStyle.CustomTextStyles) { iconTextStyle.CustomTextStyles.Add(tmpStyle); } return(iconTextStyle); }
public static LineStyle EditStyles(this StylePluginManager styleManager, StyleBuilderArguments styleArguments, LineStyle lineStyle) { return(EditStyles <LineStyle>(styleManager, styleArguments, lineStyle, s => s.CustomLineStyles)); }
public static PointStyle EditStyles(this StylePluginManager styleManager, StyleBuilderArguments styleArguments, PointStyle pointStyle) { return(EditStyles <PointStyle>(styleManager, styleArguments, pointStyle, s => new Collection <PointStyle>(s.CustomPointStyles.OfType <PointStyle>().ToList()))); }
public static AreaStyle EditStyles(this StylePluginManager styleManager, StyleBuilderArguments styleArguments, AreaStyle areaStyle) { return(EditStyles <AreaStyle>(styleManager, styleArguments, areaStyle, s => s.CustomAreaStyles)); }