protected override LayerListItem GetLayerListItemCore(Layer layer)
        {
            LayerListItem layerListItem = base.GetLayerListItemCore(layer);

            if (layerListItem != null)
            {
                Image image = new Image();
                image.Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/Noaa/noaa_radar_ui_icon.png", UriKind.Relative));
                image.Width  = 16;
                image.Height = 16;
                layerListItem.PreviewImage = image;
            }

            return(layerListItem);
        }
        public static bool CheckIsVisibleZoomLevel(LayerListItem zoomLevelEntity)
        {
            ZoomLevel zoomLevel = zoomLevelEntity.ConcreteObject as ZoomLevel;

            if (zoomLevel != null && GisEditor.ActiveMap != null)
            {
                int    applyToZoomLevelIndex = (int)zoomLevel.ApplyUntilZoomLevel;
                double upperScale            = zoomLevel.Scale;
                double lowerScale            = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels()[applyToZoomLevelIndex - 1].Scale;
                return(GisEditor.ActiveMap.CurrentScale <= upperScale && GisEditor.ActiveMap.CurrentScale >= lowerScale);
            }
            else
            {
                return(false);
            }
        }
        private void TreeNode_DragOver(object sender, DragEventArgs e)
        {
            LayerListItem targetEntity = sender.GetDataContext <LayerListItem>();
            var           dragWrapper  = e.Data.GetData(typeof(DragWrapper)) as DragWrapper;

            if (dragWrapper != null)
            {
                LayerListItem dragedEntity = dragWrapper.Object;
                if (targetEntity == null)
                {
                    e.Effects = DragDropEffects.None;
                }
                else if (targetEntity.Parent != dragedEntity.Parent)
                {
                    e.Effects = DragDropEffects.None;
                }
            }
        }
        private static void RearrangeStylesInZoomLevel(LayerListItem dragedEntity, LayerListItem targetEntity)
        {
            var featureLayer     = dragedEntity.Parent.Parent.ConcreteObject as FeatureLayer;
            var currentZoomLevel = dragedEntity.Parent.ConcreteObject as ZoomLevel;

            if (currentZoomLevel != null && featureLayer != null)
            {
                var from = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(currentZoomLevel.Scale, false) + 1;
                var to   = (int)currentZoomLevel.ApplyUntilZoomLevel;
                for (int i = from - 1; i < to; i++)
                {
                    var tmpZoomLevel = featureLayer.ZoomLevelSet.CustomZoomLevels[i];
                    int index        = tmpZoomLevel.CustomStyles.IndexOf(GetStyleFromObject(targetEntity.ConcreteObject));
                    tmpZoomLevel.CustomStyles.Remove(GetStyleFromObject(dragedEntity.ConcreteObject));
                    tmpZoomLevel.CustomStyles.Insert(index, GetStyleFromObject(dragedEntity.ConcreteObject));
                }
            }
        }
Beispiel #5
0
        private void ViewDataMenuItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem      menuItem      = (MenuItem)sender;
            LayerListItem layerListItem = (LayerListItem)menuItem.Tag;
            LayerListItem tempItem      = layerListItem;

            while (!(tempItem.ConcreteObject is FeatureLayer))
            {
                tempItem = tempItem.Parent;
            }
            FeatureLayer selectedLayer = tempItem.ConcreteObject as FeatureLayer;

            if (selectedLayer != null)
            {
                FilterStyle filterStyle = (FilterStyle)layerListItem.ConcreteObject;
                FilterStyleViewModel.ShowFilteredData(selectedLayer, filterStyle.Conditions, layerListItem.Name);
            }
        }
        private static IEnumerable <LayerListItem> CollectSubEntities(MeasureTrackInteractiveOverlay trackOverlay)
        {
            foreach (var item in trackOverlay.ShapeLayer.MapShapes)
            {
                var mapShape = item.Value;
                if (!mapShape.Feature.ColumnValues.ContainsKey("DisplayName"))
                {
                    mapShape.Feature.ColumnValues["DisplayName"] = mapShape.Feature.Id;
                }
                var subEntity = new LayerListItem
                {
                    Name                     = mapShape.Feature.ColumnValues["DisplayName"],
                    ConcreteObject           = mapShape,
                    ExpandButtonVisibility   = Visibility.Collapsed,
                    HighlightBackgroundBrush = new SolidColorBrush(Colors.White)
                };

                subEntity.ContextMenuItems.Add(LayerListMenuItemHelper.GetRenameMenuItem());
                subEntity.ContextMenuItems.Add(LayerListMenuItemHelper.GetRemoveFeatureMenuItem());
                StopRefreshProcess(() =>
                {
                    subEntity.IsChecked = mapShape.ZoomLevels.ZoomLevel01.IsActive;
                });

                var          wkt          = mapShape.Feature.GetWellKnownType();
                Styles.Style drawingStyle = null;
                if (wkt == WellKnownType.Line || wkt == WellKnownType.Multiline)
                {
                    drawingStyle = mapShape.ZoomLevels.ZoomLevel01.CustomStyles.OfType <LineStyle>().FirstOrDefault();
                }
                else
                {
                    drawingStyle = mapShape.ZoomLevels.ZoomLevel01.CustomStyles.OfType <AreaStyle>().FirstOrDefault();
                }
                subEntity.PreviewImage = new Image {
                    Source = drawingStyle.GetPreviewImage(26, 26)
                };

                subEntity.PropertyChanged += new PropertyChangedEventHandler(SubEntity_PropertyChanged);

                yield return(subEntity);
            }
        }
        private void ExchangeElement(LayerListItem dragedEntity, LayerListItem targetEntity)
        {
            var dragEntityParent   = dragedEntity.Parent;
            var targetEntityParent = targetEntity.Parent;

            if (dragEntityParent == targetEntityParent)
            {
                var targetStyleItem = targetEntityParent as StyleLayerListItem;
                if (targetStyleItem != null)
                {
                    var targetStyle = ((StyleLayerListItem)targetEntity);
                    var dragedStyle = ((StyleLayerListItem)dragedEntity);
                    if (targetStyle != null && dragedStyle != null)
                    {
                        int targetStyleIndex = targetStyleItem.Children.IndexOf(targetStyle);
                        int dragedStyleIndex = targetStyleItem.Children.IndexOf(dragedStyle);

                        targetStyleItem.Children[targetStyleIndex] = dragedStyle;
                        targetStyleItem.Children[dragedStyleIndex] = targetStyle;
                        targetStyleItem.UpdateConcreteObject();
                    }
                }
                RearrangeStylesInZoomLevel(dragedEntity, targetEntity);

                var componentStyleEntity = LayerListHelper.FindItemInLayerList <CompositeStyle>(dragedEntity);

                if (componentStyleEntity != null)
                {
                    var bitmapSource = new BitmapImage();
                    bitmapSource = ((StyleLayerListItem)componentStyleEntity).GetPreviewSource(23, 23) as BitmapImage;
                    componentStyleEntity.PreviewImage = new Image {
                        Source = bitmapSource
                    };
                    var featureLayer = componentStyleEntity.Parent.ConcreteObject as FeatureLayer;
                }
                dragedEntity.IsSelected = true;
                TileOverlay overlay = LayerListHelper.FindMapElementInLayerList <TileOverlay>(dragedEntity);
                if (overlay != null)
                {
                    overlay.Invalidate();
                }
            }
        }
        private LegendImporterItemViewModel GenerateComponentSytleItem(LayerListItem layerListItem)
        {
            var style = layerListItem.ConcreteObject as CompositeStyle;
            var zoomLevelImporterItem = new LegendImporterItemViewModel();

            zoomLevelImporterItem.PropertyChanged += LayerLegendImporterItemPropertyChanged;
            zoomLevelImporterItem.Text             = layerListItem.Name;
            var styleItem = layerListItem as StyleLayerListItem;

            if (styleItem != null)
            {
                zoomLevelImporterItem.Text += styleItem.ZoomLevelRange;
            }

            zoomLevelImporterItem.IconSource         = layerListItem.PreviewImage.Source;
            zoomLevelImporterItem.CheckBoxVisibility = Visibility.Visible;
            zoomLevelImporterItem.Style = style;
            zoomLevelImporterItem.Level = 1;
            return(zoomLevelImporterItem);
        }
        private void ExportItem_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            MenuItem      menuItem         = (MenuItem)sender;
            LayerListItem layerListItem    = (LayerListItem)menuItem.Tag;
            LayerListItem featureLayerItem = layerListItem;

            while (!(featureLayerItem.ConcreteObject is FeatureLayer))
            {
                featureLayerItem = featureLayerItem.Parent;
            }
            GisEditor.LayerListManager.SelectedLayerListItem = featureLayerItem;
            FeatureLayer selectedLayer = featureLayerItem.ConcreteObject as FeatureLayer;

            if (selectedLayer != null)
            {
                Collection <Feature> resultFeatures = new Collection <Feature>();
                selectedLayer.SafeProcess(() =>
                {
                    resultFeatures = selectedLayer.QueryTools.GetAllFeatures(ReturningColumnsType.AllColumns);
                });

                FilterStyle filterStyle = (FilterStyle)layerListItem.ConcreteObject;
                foreach (var condition in filterStyle.Conditions)
                {
                    resultFeatures = condition.GetMatchingFeatures(resultFeatures);
                }

                if (resultFeatures.Count > 0)
                {
                    Collection <FeatureSourceColumn> columns = selectedLayer.FeatureSource.GetColumns();

                    FeatureLayerPlugin sourcePlugin = GisEditor.LayerManager.GetLayerPlugins(selectedLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                    if (sourcePlugin != null)
                    {
                        WellKnownType type = selectedLayer.FeatureSource.GetFirstFeaturesWellKnownType();
                        ExportToShapeFile(resultFeatures, columns, sourcePlugin, type);
                    }
                }
            }
        }
        private void Tree_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            LayerListItem selectedItem = tree.SelectedItem as LayerListItem;

            if (selectedItem != null)
            {
                GisEditor.LayerListManager.SelectedLayerListItem = selectedItem;
                var overlay = LayerListHelper.FindMapElementInLayerList <Overlay>(selectedItem);
                var layer   = LayerListHelper.FindMapElementInLayerList <Layer>(selectedItem);

                if (GisEditor.ActiveMap != null)
                {
                    if (overlay != null)
                    {
                        GisEditor.ActiveMap.ActiveOverlay = overlay;
                    }
                    if (layer != null)
                    {
                        GisEditor.ActiveMap.ActiveLayer = layer;
                    }
                }
            }
        }
 private void UpdateTreeViewExpandStatus(LayerListItem oldEntity, LayerListItem newEntity)
 {
     foreach (var zoomLevelEntity in newEntity.Children)
     {
         var matchedZoomLevelEntity = oldEntity.Children
                                      .FirstOrDefault(subEntity => subEntity.Name.Equals(zoomLevelEntity.Name));
         if (matchedZoomLevelEntity != null)
         {
             zoomLevelEntity.IsExpanded = matchedZoomLevelEntity.IsExpanded;
             foreach (var styleEntity in zoomLevelEntity.Children)
             {
                 var styleItem = styleEntity as StyleLayerListItem;
                 if (styleItem != null)
                 {
                     var matchedStyleEntity = matchedZoomLevelEntity.Children
                                              .FirstOrDefault(subEntity =>
                     {
                         var tmpStyleItem = subEntity as StyleLayerListItem;
                         if (tmpStyleItem != null)
                         {
                             return(tmpStyleItem.ConcreteObject == styleItem.ConcreteObject);
                         }
                         else
                         {
                             return(false);
                         }
                     });
                     if (matchedStyleEntity != null)
                     {
                         styleEntity.IsExpanded = matchedStyleEntity.IsExpanded;
                     }
                 }
             }
         }
     }
 }
        public static void EditStyle(LayerListItem selectedLayerListItem)
        {
            var componentStyleItem = LayerListHelper.FindItemInLayerList <CompositeStyle>(selectedLayerListItem) as StyleLayerListItem;

            if (componentStyleItem != null)
            {
                var componentStyle = componentStyleItem.ConcreteObject as CompositeStyle;
                var styleArguments = new StyleBuilderArguments();
                styleArguments.FeatureLayer = componentStyleItem.Parent.ConcreteObject as FeatureLayer;
                var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(styleArguments.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                if (featureLayerPlugin != null)
                {
                    styleArguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(styleArguments.FeatureLayer);
                    int from = 0;
                    int to   = GisEditor.ActiveMap.ZoomLevelSet.CustomZoomLevels.Count;
                    if (!string.IsNullOrEmpty(componentStyleItem.ZoomLevelRange))
                    {
                        var array = componentStyleItem.ZoomLevelRange.Split(" to ".ToArray(), StringSplitOptions.RemoveEmptyEntries);
                        if (array.Length == 2)
                        {
                            int.TryParse(array[0].Replace("(", "").Trim(), out from);
                            int.TryParse(array[1].Replace(")", "").Trim(), out to);
                        }
                    }

                    styleArguments.FromZoomLevelIndex = from;
                    styleArguments.ToZoomLevelIndex   = to;
                    styleArguments.AppliedCallback    = new Action <StyleBuilderResult>((styleResults) =>
                    {
                        if (!styleResults.Canceled)
                        {
                            var resultStyle = styleResults.CompositeStyle as CompositeStyle;
                            var count       = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels().Count;
                            for (int i = 0; i < count; i++)
                            {
                                var customStyles = styleArguments.FeatureLayer.ZoomLevelSet.CustomZoomLevels[i].CustomStyles;
                                if (i >= styleResults.FromZoomLevelIndex - 1 && i < styleResults.ToZoomLevelIndex)
                                {
                                    if (!customStyles.Contains(componentStyle))
                                    {
                                        customStyles.Add(componentStyle);
                                    }
                                    componentStyle.Styles.Clear();
                                    componentStyle.Name = resultStyle.Name;
                                    foreach (var item in resultStyle.Styles)
                                    {
                                        componentStyle.Styles.Add(item);
                                    }
                                }
                                else
                                {
                                    customStyles.Remove(componentStyle);
                                }
                            }
                            foreach (var overlay in GisEditor.ActiveMap.GetOverlaysContaining(styleArguments.FeatureLayer))
                            {
                                if (overlay.MapArguments != null)
                                {
                                    overlay.Invalidate();
                                }
                            }
                            GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(styleResults, RefreshArgsDescription.EditStyleDescription));
                        }
                    });
                    var styleItems = new Collection <StyleLayerListItem>();
                    foreach (var style in componentStyle.Styles)
                    {
                        var item = GisEditor.StyleManager.GetStyleLayerListItem(style);
                        if (item != null)
                        {
                            styleItems.Add(item);
                        }
                    }

                    var clonedStyleItems     = new Collection <StyleLayerListItem>();
                    var clonedCompositeStyle = componentStyle.CloneDeep() as CompositeStyle;
                    styleArguments.StyleToEdit = clonedCompositeStyle;

                    foreach (var style in clonedCompositeStyle.Styles)
                    {
                        var item = GisEditor.StyleManager.GetStyleLayerListItem(style);
                        if (item != null)
                        {
                            clonedStyleItems.Add(item);
                        }
                    }

                    object selectedClonedObject = FindSelectedObject(styleItems.ToList(), clonedStyleItems.ToList(), selectedLayerListItem.ConcreteObject);
                    styleArguments.FillRequiredColumnNames();
                    styleArguments.SelectedConcreteObject = selectedClonedObject;
                    var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(styleArguments);
                    if (styleBuilder.ShowDialog().GetValueOrDefault())
                    {
                        styleArguments.AppliedCallback(styleBuilder.StyleBuilderResult);
                    }
                }
            }
        }
 public static LayerListItem FindItemInLayerList <T>(LayerListItem layerListItem) where T : class
 {
     return(FindViewModelInTree(layerListItem, new Func <object, bool>((actualMapElement) => actualMapElement is T)));
 }
        private void MapCurrentScaleChanged(object sender, CurrentScaleChangedWpfMapEventArgs e)
        {
            GisEditorWpfMap map       = sender as GisEditorWpfMap;
            LayerListItem   viewModel = null;

            if (map != null && (viewModel = layerListUserControl.DataContext as LayerListItem) != null)
            {
                var layerEntities = viewModel.Children.SelectMany(overlayEntity =>
                                                                  overlayEntity.Children.ToDictionary(layerEntity => layerEntity, layerEntity =>
                {
                    var featureLayer = layerEntity.ConcreteObject as FeatureLayer;
                    if (featureLayer != null)
                    {
                        e.CurrentExtent = GisEditor.ActiveMap.GetSnappedExtent(e.CurrentExtent);
                        var zoomLevel   = featureLayer.ZoomLevelSet.GetZoomLevelForDrawing(e.CurrentExtent, map.ActualWidth, map.MapUnit);
                        return(zoomLevel == null);
                    }
                    else
                    {
                        return(false);
                    }
                }));
                BitmapImage bitmapImage = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/Unavailable.png", UriKind.RelativeOrAbsolute));
                foreach (var item in layerEntities)
                {
                    //No style available
                    if (item.Value)
                    {
                        Image image = new Image();
                        image.BeginInit();
                        image.Source = bitmapImage;
                        image.EndInit();
                        item.Key.PreviewImage = image;
                        foreach (var styleItem in item.Key.Children)
                        {
                            styleItem.FontWeight = FontWeights.Normal;
                        }

                        //item.Key.TextStyleLabelVisibility = Visibility.Collapsed;
                    }
                    else
                    {
                        var currentZoomLevelIndex = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(GisEditor.ActiveMap.CurrentScale, false) + 1;
                        foreach (var styleItemEntity in item.Key.Children.OfType <StyleLayerListItem>())
                        {
                            //var match = Regex.Match(styleItem.Text, MapElementViewModel.ZoomLevelPattern);
                            if (!string.IsNullOrEmpty(styleItemEntity.ZoomLevelRange))
                            {
                                int from  = 0;
                                int to    = 0;
                                var array = styleItemEntity.ZoomLevelRange.Split(" to ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                                if (array.Length == 2)
                                {
                                    int.TryParse(array[0].Replace("(", "").Trim(), out from);
                                    int.TryParse(array[1].Replace(")", "").Trim(), out to);
                                    if (from <= currentZoomLevelIndex && to >= currentZoomLevelIndex)
                                    {
                                        styleItemEntity.FontWeight = FontWeights.Bold;
                                    }
                                    else
                                    {
                                        styleItemEntity.FontWeight = FontWeights.Normal;
                                    }
                                }
                            }
                        }

                        FeatureLayer featureLayer = item.Key.ConcreteObject as FeatureLayer;
                        if (featureLayer != null)
                        {
                            var zoomLevel = featureLayer.ZoomLevelSet.GetZoomLevelForDrawing(e.CurrentExtent, map.ActualWidth, map.MapUnit);
                            if (zoomLevel == null)
                            {
                                break;
                            }
                            if (zoomLevel.CustomStyles.Count > 0)
                            {
                                BitmapSource bitmapSource = new BitmapImage();
                                var          styleItem    = GisEditor.StyleManager.GetStyleLayerListItem(zoomLevel.CustomStyles.LastOrDefault());
                                if (styleItem != null)
                                {
                                    bitmapSource = styleItem.GetPreviewSource(23, 23);
                                }
                                var img = new Image();
                                img.Source            = bitmapSource;
                                item.Key.PreviewImage = img;
                            }
                            else
                            {
                                var disableIconSource = new BitmapImage(new Uri("pack://application:,,,/GisEditorPluginCore;component/Images/Unavailable.png", UriKind.RelativeOrAbsolute));
                                viewModel.PreviewImage = new Image()
                                {
                                    Source = disableIconSource
                                };
                            }
                            var textStyleCount = zoomLevel.CustomStyles
                                                 .Count(style => style is IconTextStyle);
                        }
                    }
                }
            }
        }
        protected override LayerListItem GetLayerListItemCore(object concreteObject)
        {
            if (concreteObject is Overlay)
            {
                var overlay         = (Overlay)concreteObject;
                var overlayListItem = new LayerListItem();
                overlayListItem.ConcreteObject              = concreteObject;
                overlayListItem.CheckBoxVisibility          = Visibility.Visible;
                overlayListItem.ChildrenContainerVisibility = Visibility.Visible;
                overlayListItem.IsChecked = overlay.IsVisible;
                overlayListItem.Name      = overlay.Name;
                overlayListItem.HighlightBackgroundBrush = GetDefaultLayerGroupBackground();
                overlayListItem.PropertyChanged         += OverlayItemPropertyChanged;
                if (GisEditor.LayerListManager.SelectedLayerListItem != null && overlay == GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject)
                {
                    overlayListItem.HighlightBackgroundBrush         = new SolidColorBrush(Colors.LightBlue);
                    GisEditor.LayerListManager.SelectedLayerListItem = overlayListItem;
                }
                MenuItem toTopMenuItem    = LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.ToTop);
                MenuItem toBottomMenuItem = LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.ToBottom);
                MenuItem upMenuItem       = LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.Up);
                MenuItem downMenuItem     = LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.Down);

                overlayListItem.ContextMenuItems.Add(toTopMenuItem);
                overlayListItem.ContextMenuItems.Add(toBottomMenuItem);
                overlayListItem.ContextMenuItems.Add(upMenuItem);
                overlayListItem.ContextMenuItems.Add(downMenuItem);
                overlayListItem.ContextMenuItems.Add(new MenuItem()
                {
                    Header = "--"
                });
                overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetZoomToExtentMenuItem());
                overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetRenameMenuItem());
                overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetRemoveOverlayMenuItem());
                overlayListItem.ContextMenuItems.Add(new MenuItem()
                {
                    Header = "--"
                });
                if (concreteObject is LayerOverlay)
                {
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetAddLayerMenuItem());
                    MenuItem newLayerItem = LayerListMenuItemHelper.GetNewLayerMenuItem();
                    if (newLayerItem != null)
                    {
                        overlayListItem.ContextMenuItems.Add(newLayerItem);
                    }
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetRefreshLayersMenuItem((LayerOverlay)concreteObject));
                    //overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetCloneLayerCountMenuItem((LayerOverlay)concreteObject));
                }
                if (concreteObject is TileOverlay)
                {
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetTileTypeMenuItem((TileOverlay)concreteObject));
                }

                //overlayListItem.ContextMenuItems.Add(new MenuItem() { Header = "--" });
                //overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetSetExceptionModeMenuItem());

                if (overlayListItem.ConcreteObject is BingMapsOverlay)
                {
                    //e.LayerListItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/BingMaps.png", UriKind.Relative)) };
                    overlayListItem.SideImage = new Image {
                        Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/dr_base_maps.png", UriKind.Relative)), Width = 16, Height = 16
                    };
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetBingMapStyleMenuItem());
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetBaseMapsCacheMenuItem());
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetTransparencyMenuItem(((BingMapsOverlay)overlayListItem.ConcreteObject).OverlayCanvas.Opacity));
                }
                else if (overlayListItem.ConcreteObject is OpenStreetMapOverlay)
                {
                    //e.LayerListItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/osm_logo.png", UriKind.Relative)) };
                    overlayListItem.SideImage = new Image {
                        Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/dr_base_maps.png", UriKind.Relative)), Width = 16, Height = 16
                    };
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetBaseMapsCacheMenuItem());
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetTransparencyMenuItem(((OpenStreetMapOverlay)overlayListItem.ConcreteObject).OverlayCanvas.Opacity));
                }
                else if (overlayListItem.ConcreteObject is WorldMapKitMapOverlay)
                {
                    overlayListItem.SideImage = new Image {
                        Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/dr_base_maps.png", UriKind.Relative)), Width = 16, Height = 16
                    };
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetWorldMapKitStyleMenuItem());
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetBaseMapsCacheMenuItem());

                    //e.LayerListItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/WMKOverlay.png", UriKind.Relative)) };
                    overlayListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetTransparencyMenuItem(((WorldMapKitMapOverlay)overlayListItem.ConcreteObject).OverlayCanvas.Opacity));
                }
                else if (overlayListItem.ConcreteObject is DynamicLayerOverlay)
                {
                    overlayListItem.Name       = string.IsNullOrEmpty(overlay.Name) ? "Dynamic Layer Group" : overlay.Name;
                    toTopMenuItem.IsEnabled    = false;
                    toBottomMenuItem.IsEnabled = false;
                    upMenuItem.IsEnabled       = false;
                    downMenuItem.IsEnabled     = false;
                    InMemoryFeatureLayer[] featureLayersToDelete = ((DynamicLayerOverlay)overlay).Layers.OfType <InMemoryFeatureLayer>().Where(l => l.InternalFeatures.Count == 0).ToArray();
                    foreach (var item in featureLayersToDelete)
                    {
                        ((DynamicLayerOverlay)overlay).Layers.Remove(item);
                    }

                    //overlayListItem = null;
                }
                else if (overlayListItem.ConcreteObject is MeasureTrackInteractiveOverlay)
                {
                    if (Singleton <MeasureSetting> .Instance.AllowCollectFixedElements)
                    {
                        overlayListItem = LayerListHelper.CreateLayerListItemForMeasureOverlay(overlayListItem);
                    }
                    else
                    {
                        overlayListItem = null;
                    }
                }
                else if (overlayListItem.ConcreteObject is LayerOverlay)
                {
                    var layerOverlay = (LayerOverlay)overlay;

                    //e.LayerListItem.Icon = new Image { Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/LayerOverlay.png", UriKind.Relative)) };
                    overlayListItem.Name = string.IsNullOrEmpty(layerOverlay.Name) ? "Layer Group" : layerOverlay.Name;
                    overlayListItem.ChildrenContainerVisibility = Visibility.Visible;
                    overlayListItem.SideImage = new Image {
                        Source = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/up.png", UriKind.Relative))
                    };

                    //Dictionary<Layer, bool> elementVisibleDictionary = new Dictionary<Layer, bool>();
                    //layerOverlay.Layers.ForEach(layer => { elementVisibleDictionary.Add(layer, layer.IsVisible); });
                    overlayListItem.IsChecked = layerOverlay.Layers.Any(layer => layer.IsVisible);

                    //entity.SubEntities.ForEach(mapEntity => { mapEntity.IsVisible = elementVisibleDictionary[mapEntity]; });
                }
                else
                {
                    overlayListItem = null;
                }
                return(overlayListItem);
            }
            else if (concreteObject is Layer)
            {
                GdiPlusRasterLayerPlugin gdiPlusRasterLayerPlugin = new GdiPlusRasterLayerPlugin();
                LayerListItem            layerListItem            = gdiPlusRasterLayerPlugin.GetLayerListItem(concreteObject as Layer);
                if (string.IsNullOrEmpty(layerListItem.Name))
                {
                    layerListItem.Name = concreteObject.GetType().Name;
                }
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.ToTop));
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.ToBottom));
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.Up));
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetMovementMenuItem(MovementAction.Down));
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetZoomToExtentMenuItem());
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetRenameMenuItem());
                layerListItem.ContextMenuItems.Add(LayerListMenuItemHelper.GetRemoveLayerMenuItem());
                return(layerListItem);
            }
            else
            {
                return(null);
            }
        }