private static Style GetStyleByPlugin(StylePlugin styleProvider)
        {
            Style style       = null;
            bool  needRestore = false;

            if (!styleProvider.UseRandomColor)
            {
                styleProvider.UseRandomColor = true;
                needRestore = true;
            }

            // Apply more colors to avoid duplicated colors.
            GeoColorHelper.RandomColorType = RandomColorType.All;
            Style tmpStyle = styleProvider.GetDefaultStyle();

            GeoColorHelper.RandomColorType = RandomColorType.Pastel;

            if (needRestore)
            {
                styleProvider.UseRandomColor = false;
            }
            if (tmpStyle != null)
            {
                style      = tmpStyle.CloneDeep();
                style.Name = GisEditor.StyleManager.GetStylePluginByStyle(style).Name;
            }
            return(style);
        }
        protected override StyleLayerListItem GetStyleLayerListItemCore(Style style)
        {
            var filterStyle = style as FilterStyle;

            if (filterStyle != null)
            {
                return(new FilterStyleItem(filterStyle));
            }
            return(null);
        }
        private void InitValueItem <T>(StyleCategories styleProviderType, DistinctColumnValue columnValueGroup, string columnName) where T : Style
        {
            Collection <Style> styles = new Collection <Style>();

            if (styleProviderType == StyleCategories.Composite)
            {
                Collection <StylePlugin> plugins = new Collection <StylePlugin>();
                var areaPlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Area);
                if (areaPlugin != null)
                {
                    plugins.Add(areaPlugin);
                }
                var linePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Line);
                if (linePlugin != null)
                {
                    plugins.Add(linePlugin);
                }
                var pointPlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Point);
                if (pointPlugin != null)
                {
                    plugins.Add(pointPlugin);
                }
                foreach (var item in plugins)
                {
                    Style style = GetStyleByPlugin(item);
                    if (style != null)
                    {
                        styles.Add(style);
                    }
                }
            }
            else
            {
                var styleProvider = GisEditor.StyleManager.GetDefaultStylePlugin(styleProviderType);
                if (styleProvider != null)
                {
                    Style style = GetStyleByPlugin(styleProvider);
                    if (style != null)
                    {
                        styles.Add(style);
                    }
                }
            }

            if (styles.Count > 0)
            {
                ValueItem valueItem = new ValueItem();
                valueItem.Value = columnValueGroup.ColumnValue;
                styles.ForEach(s => valueItem.CustomStyles.Add(s));

                ValueItemEntity valueItemEntity = ValueItems.FirstOrDefault(tmpItem
                                                                            => tmpItem.MatchedValue.Equals(columnValueGroup.ColumnValue, StringComparison.Ordinal));

                if (valueItemEntity == null)
                {
                    valueItem       = new ValueItem();
                    valueItem.Value = columnValueGroup.ColumnValue;
                    styles.ForEach(s => valueItem.CustomStyles.Add(s));

                    var image = StyleHelper.GetImageFromStyle(styles);
                    var newValueItemEntity = GetValueItemEntity(image, columnValueGroup.ColumnValue, valueItem);
                    newValueItemEntity.Count = columnValueGroup.ColumnValueCount;
                    ValueItems.Add(newValueItemEntity);
                }
                else
                {
                    //valueItemEntity.Update(valueItem);
                    valueItemEntity.Count = columnValueGroup.ColumnValueCount;
                }
            }
        }