/// <summary> /// Gets the style plugins core. /// </summary> /// <param name="styleCategories">The style categories.</param> /// <returns></returns> protected virtual Collection <StylePlugin> GetStylePluginsCore(StyleCategories styleCategories) { Collection <StylePlugin> stylePlugins = new Collection <StylePlugin>(); var activeStylePlugins = GetActiveStylePlugins(); foreach (var stylePlugin in activeStylePlugins.Where(p => styleCategories.HasFlag(p.StyleCategories)).OrderBy(p => p.Index)) { stylePlugins.Add(stylePlugin); } return(stylePlugins); }
private static void AddSubMenuItemsForStyle(StyleBuilderArguments styleArguments, StyleCategories styleCategories , string categoryName , MenuItem rootMenuItem , StyleItemViewModel currentStyleItemViewModel , bool hasCompositedStyle) { if (hasCompositedStyle && styleCategories != StyleCategories.None && !styleCategories.HasFlag(StyleCategories.Label)) { styleCategories = styleCategories | StyleCategories.Composite; } var plugins = GisEditor.StyleManager.GetStylePlugins(styleCategories); if (plugins.Count > 0) { var menuItems = plugins.Select(plugin => { if (plugin.RequireColumnNames && styleArguments.ColumnNames.Count == 0) { return(null); } MenuItem subMenuItem = new MenuItem(); subMenuItem.Header = plugin.Name; subMenuItem.Icon = new Image { Source = plugin.SmallIcon, Width = 16, Height = 16 }; subMenuItem.CommandParameter = new Tuple <StylePlugin, StyleCategories>(plugin, styleCategories); subMenuItem.Command = new RelayCommand <Tuple <StylePlugin, StyleCategories> >(commandParameter => { StylePlugin tmpStylePlugin = commandParameter.Item1; Styles.Style style = tmpStylePlugin.GetDefaultStyle(); style.Name = tmpStylePlugin.Name; StyleLayerListItem styleItem = GisEditor.StyleManager.GetStyleLayerListItem(style); if (styleItem != null) { currentStyleItemViewModel.StyleItem.Children.Insert(0, styleItem); currentStyleItemViewModel.StyleItem.UpdateConcreteObject(); var styleItemUI = currentStyleItemViewModel.StyleItem.GetUI(GetDuplicateStyleArguments(styleCategories, styleArguments)); if (styleItemUI != null) { currentStyleItemViewModel.StyleItem.UpdateUI(styleItemUI); } var addedStyleItemViewModel = currentStyleItemViewModel.StyleItemViewModels.FirstOrDefault(vm => vm.StyleItem == styleItem); if (addedStyleItemViewModel != null) { if (commandParameter.Item2 == StyleCategories.Label) { addedStyleItemViewModel.IsSelected = true; } else { StyleItemViewModel rootStyleItemViewModel = GetRootViewModel(currentStyleItemViewModel); tmpStyleCategories = commandParameter.Item2; var tmpStyleArguments = rootStyleItemViewModel.StyleBuilder.StyleArguments; rootStyleItemViewModel.StyleBuilder.PropertyChanged -= StyleBuilder_PropertyChanged; rootStyleItemViewModel.StyleBuilder.PropertyChanged += StyleBuilder_PropertyChanged; addedStyleItemViewModel.IsSelected = true; rootStyleItemViewModel.StyleBuilder.PropertyChanged -= StyleBuilder_PropertyChanged; rootStyleItemViewModel.StyleBuilder.StyleArguments = tmpStyleArguments; } } } }); return(subMenuItem); }).Where(i => i != null).ToArray(); foreach (var item in menuItems) { rootMenuItem.Items.Add(item); } } }