public static System.Windows.Controls.Image GetImageFromStyle(IEnumerable <Style> styles) { if (styles.Count() > 1) { CompositeStyle componentStyle = new CompositeStyle(styles) { Name = GisEditor.LanguageManager.GetStringResource("SampleStyleName") }; BitmapImage imageSource = componentStyle.GetPreviewImage(34, 34); System.Windows.Controls.Image image = new System.Windows.Controls.Image(); image.Source = imageSource; return(image); } else if (styles.Count() == 0) { return(new System.Windows.Controls.Image()); } else { return(GetImageFromStyle(styles.FirstOrDefault())); } }
private void InitializeStyleIcons() { var styles = CurrentAnnotationOverlay.TrackShapeLayer.ZoomLevelSet .ZoomLevel01.CustomStyles.OfType <ValueStyle>().First() .ValueItems.Take(1).SelectMany(valueItem => { return(new Styles.Style[] { valueItem.DefaultAreaStyle, valueItem.DefaultLineStyle, valueItem.DefaultPointStyle, valueItem.DefaultTextStyle }); }); CompositeStyle style = new CompositeStyle(); foreach (var item in styles) { style.Styles.Add(item); } AnnotationPreview = style.GetPreviewImage(32, 32); }