public static void InsertFromLibrary()
        {
            StyleLibraryWindow library = new StyleLibraryWindow();

            if (library.ShowDialog().GetValueOrDefault())
            {
                var styleItem = GisEditor.LayerListManager.SelectedLayerListItem as StyleLayerListItem;
                if (styleItem != null)
                {
                    TileOverlay containingOverlay  = null;
                    var         compositeStyle     = styleItem.ConcreteObject as CompositeStyle;
                    var         compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(library.Result.CompositeStyle);
                    if (compositeStyle != null)
                    {
                        foreach (var item in compositeStyleItem.Children.Reverse())
                        {
                            styleItem.Children.Insert(0, item);
                        }
                        styleItem.UpdateConcreteObject();
                        containingOverlay = GisEditor.LayerListManager.SelectedLayerListItem.Parent.Parent.ConcreteObject as TileOverlay;
                    }
                    else if (styleItem.ConcreteObject is Styles.Style && styleItem.Parent.ConcreteObject is Styles.Style)
                    {
                        var index = styleItem.Parent.Children.IndexOf(styleItem);
                        foreach (var item in compositeStyleItem.Children)
                        {
                            index++;
                            styleItem.Parent.Children.Insert(index, item);
                        }
                        ((StyleLayerListItem)styleItem.Parent).UpdateConcreteObject();
                        containingOverlay = LayerListHelper.FindMapElementInLayerList <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                    }
                    else
                    {
                        foreach (var item in compositeStyleItem.Children.Reverse())
                        {
                            styleItem.Children.Insert(0, item);
                        }
                        styleItem.UpdateConcreteObject();
                        containingOverlay = LayerListHelper.FindMapElementInLayerList <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                    }
                    if (containingOverlay != null)
                    {
                        containingOverlay.Invalidate();
                        GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(containingOverlay, RefreshArgsDescription.InsertFromLibraryDescription));
                    }
                }
            }
        }
        private static void LoadFromLibrary()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            StyleLibraryWindow library = new StyleLibraryWindow();

            if (library.ShowDialog().GetValueOrDefault())
            {
                FeatureLayer currentFeatureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer;
                if (currentFeatureLayer != null)
                {
                    ZoomLevelHelper.ApplyStyle(library.Result.CompositeStyle, currentFeatureLayer, library.Result.FromZoomLevelIndex, library.Result.ToZoomLevelIndex);
                }
            }
        }
        public static void ReplaceFromLibrary()
        {
            StyleLibraryWindow library = new StyleLibraryWindow();

            if (library.ShowDialog().GetValueOrDefault())
            {
                if (GisEditor.LayerListManager.SelectedLayerListItem == null)
                {
                    return;
                }
                var         styleItem         = GisEditor.LayerListManager.SelectedLayerListItem;
                TileOverlay containingOverlay = null;
                var         compositeStyle    = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as CompositeStyle;
                if (compositeStyle != null)
                {
                    FeatureLayer currentFeatureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer;
                    if (currentFeatureLayer != null)
                    {
                        foreach (var zoomLevel in currentFeatureLayer.ZoomLevelSet.CustomZoomLevels)
                        {
                            var index = zoomLevel.CustomStyles.IndexOf(compositeStyle);
                            if (index >= 0)
                            {
                                zoomLevel.CustomStyles.RemoveAt(index);
                                zoomLevel.CustomStyles.Insert(index, library.Result.CompositeStyle);
                            }
                        }
                        containingOverlay = GisEditor.LayerListManager.SelectedLayerListItem.Parent.Parent.ConcreteObject as TileOverlay;
                    }
                }
                else if (styleItem.ConcreteObject is Styles.Style && styleItem.Parent.ConcreteObject is Styles.Style)
                {
                    var index = styleItem.Parent.Children.IndexOf(styleItem);
                    styleItem.Parent.Children.RemoveAt(index);
                    var compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(library.Result.CompositeStyle);
                    foreach (var item in compositeStyleItem.Children)
                    {
                        styleItem.Parent.Children.Insert(index, item);
                        index++;
                    }
                    ((StyleLayerListItem)styleItem.Parent).UpdateConcreteObject();
                    containingOverlay = LayerListHelper.FindMapElementInLayerList <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                }
                else
                {
                    styleItem.Children.Clear();
                    var compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(library.Result.CompositeStyle);
                    foreach (var item in compositeStyleItem.Children)
                    {
                        styleItem.Children.Add(item);
                    }
                    ((StyleLayerListItem)styleItem).UpdateConcreteObject();
                    containingOverlay = LayerListHelper.FindMapElementInLayerList <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                }
                if (containingOverlay != null)
                {
                    containingOverlay.Invalidate();
                    GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(containingOverlay, RefreshArgsDescription.ReplaceFromLibraryDescription));
                }
            }
        }