public static void InvalidateTileOverlay()
        {
            TileOverlay tileOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);

            if (tileOverlay != null)
            {
                tileOverlay.Invalidate();
            }
        }
Esempio n. 2
0
        private static void Duplicate()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            var  compositeStyle = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as CompositeStyle;
            bool needRefersh    = false;

            if (compositeStyle != null)
            {
                var newStyle     = compositeStyle.CloneDeep();
                var featureLayer = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem);
                if (newStyle != null && featureLayer != null)
                {
                    foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels)
                    {
                        var index = zoomLevel.CustomStyles.IndexOf(compositeStyle);
                        if (index >= 0)
                        {
                            zoomLevel.CustomStyles.Insert(index, newStyle);
                        }
                    }
                    needRefersh = true;
                }
            }
            else
            {
                var newStyle = (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style).CloneDeep();
                if (newStyle != null)
                {
                    var newStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(newStyle);
                    if (newStyleItem != null)
                    {
                        var parent = GisEditor.LayerListManager.SelectedLayerListItem.Parent as StyleLayerListItem;
                        if (parent != null)
                        {
                            parent.Children.Insert(0, newStyleItem);
                            parent.UpdateConcreteObject();
                            needRefersh = true;
                        }
                    }
                }
            }
            if (needRefersh)
            {
                var tileOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                if (tileOverlay != null)
                {
                    tileOverlay.Invalidate();
                    GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.DuplicateDescription));
                }
            }
        }
        public static void ModifySelectedStyle(Style selectedStyle, Style newStyle, int from, int to)
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem != null && GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style)
            {
                if (selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject)
                {
                    //The following check is for issue-7208 and issue-7213.
                    //When we double click on a RegexItem, we actually mean to edit the RegextItem's parent - the RegexStyle.
                    //But the SelectedEntity matches up with the RegextItem, not the RegextStyle, so we need to have this check.
                    //Anyways, this is quite complicated, jsut reconsider before you modify the following code.
                    if (!IsSubStyleSelected(selectedStyle) && selectedStyle != GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject)
                    {
                        selectedStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject;
                    }
                }

                FeatureLayer currentLayer     = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem);
                ZoomLevel    currentZoomLevel = LayerListHelper.FindMapElementInTree <ZoomLevel>(GisEditor.LayerListManager.SelectedLayerListItem);
                int          originalFrom     = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(currentZoomLevel.Scale, false) + 1;
                int          originalTo       = (int)currentZoomLevel.ApplyUntilZoomLevel;

                Style nextSelectedStyle = newStyle.CloneDeep();
                ReplaceStyle(currentLayer, selectedStyle, newStyle);

                if (originalFrom != from || originalTo != to)
                {
                    for (int i = 0; i < currentLayer.ZoomLevelSet.CustomZoomLevels.Count; i++)
                    {
                        var zoomLevel = currentLayer.ZoomLevelSet.CustomZoomLevels[i];
                        if (i >= from - 1 && i <= to - 1)
                        {
                            if (!zoomLevel.CustomStyles.Contains(newStyle))
                            {
                                zoomLevel.CustomStyles.Add(newStyle);
                            }
                        }
                        else
                        {
                            if (zoomLevel.CustomStyles.Contains(newStyle))
                            {
                                zoomLevel.CustomStyles.Remove(newStyle);
                            }
                        }
                    }
                }
                GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject = newStyle;
                LayerListHelper.InvalidateTileOverlay();
                GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.ModifySelectedStyleDescription));
            }
        }
        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.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                    }
                    else
                    {
                        foreach (var item in compositeStyleItem.Children.Reverse())
                        {
                            styleItem.Children.Insert(0, item);
                        }
                        styleItem.UpdateConcreteObject();
                        containingOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                    }
                    if (containingOverlay != null)
                    {
                        containingOverlay.Invalidate();
                        GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(containingOverlay, RefreshArgsDescriptions.InsertFromLibraryDescription));
                    }
                }
            }
        }
Esempio n. 5
0
        private static void SetDrawingMargin(MenuItem menuItem, int marginValue)
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            var featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer;

            if (featureLayer != null)
            {
                featureLayer.DrawingMarginInPixel = marginValue;
                var parentOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                parentOverlay.Invalidate();

                foreach (MenuItem item in ((MenuItem)menuItem.Parent).Items)
                {
                    item.IsChecked = item.Header.Equals(marginValue.ToString() + "%");
                }
            }
        }
Esempio n. 6
0
        private void VisibilityChanged(bool value)
        {
            if (ConcreteObject is LayerOverlay && needRefresh)
            {
                foreach (var subEntity in Children)
                {
                    subEntity.needRefresh = false;
                    LayerPlugin layerPlugin = GisEditor.LayerManager.GetLayerPlugins(subEntity.ConcreteObject.GetType()).FirstOrDefault();
                    if (layerPlugin != null)
                    {
                        bool isDataSourceAvailable = layerPlugin.DataSourceResolveTool.IsDataSourceAvailable((Layer)subEntity.ConcreteObject);
                        if (isDataSourceAvailable)
                        {
                            subEntity.IsChecked = IsChecked;
                            ((Layer)subEntity.ConcreteObject).IsVisible = IsChecked;
                        }
                    }
                    subEntity.needRefresh = true;
                }
                var tileOverlay = (TileOverlay)ConcreteObject;
                tileOverlay.IsVisible = isChecked;
                if (!isChecked)
                {
                    RefreshOverlay(tileOverlay);
                }
                GisEditor.UIManager.InvokeRefreshPlugins();
            }
            else if (ConcreteObject is Layer && needRefresh)
            {
                LayerPlugin layerPlugin = GisEditor.LayerManager.GetLayerPlugins(ConcreteObject.GetType()).FirstOrDefault();
                if (layerPlugin != null)
                {
                    bool isDataSourceAvailable = layerPlugin.DataSourceResolveTool.IsDataSourceAvailable((Layer)ConcreteObject);
                    if (!isDataSourceAvailable)
                    {
                        ((Layer)ConcreteObject).IsVisible = false;
                        isChecked = false;
                        OnPropertyChanged("IsChecked");
                        return;
                    }
                }

                if (!isChecked)
                {
                    Image image = warningImages.FirstOrDefault(i => i.Name.Equals("InEditing", StringComparison.InvariantCultureIgnoreCase));
                    if (image != null)
                    {
                        warningImages.Remove(image);
                    }
                }
                ((Layer)ConcreteObject).IsVisible = isChecked;
                Parent.needRefresh = false;
                Parent.IsChecked   = Parent.Children.Any(m => m.IsChecked);
                Parent.needRefresh = true;
                TileOverlay tileOverlay = Parent.ConcreteObject as TileOverlay;
                if (tileOverlay != null)
                {
                    //In this case, tileOverlay will execute Refresh() in default.
                    if (!tileOverlay.IsVisible && Parent.IsChecked)
                    {
                        tileOverlay.IsVisible = Parent.IsChecked;
                    }
                    else
                    {
                        tileOverlay.IsVisible = Parent.IsChecked;
                        tileOverlay.Invalidate();
                        RefreshOverlay(tileOverlay);
                    }
                }
                GisEditor.UIManager.InvokeRefreshPlugins();
            }

            if (!(ConcreteObject is Layer) && !(ConcreteObject is LayerOverlay))
            {
                TryChangeIsVisiblePropertyOfMapElement();
            }

            if (ConcreteObject is Styles.Style)
            {
                Styles.Style concreteStyle = (Styles.Style)ConcreteObject;
                concreteStyle.IsActive = value;
                Layer layer = LayerListHelper.FindMapElementInTree <Layer>(this);
                if (layer != null && layer.IsVisible)
                {
                    LayerOverlay layerOverlay = LayerListHelper.FindMapElementInTree <LayerOverlay>(this);
                    if (layerOverlay != null && layerOverlay.IsVisible)
                    {
                        layerOverlay.Invalidate();
                        RefreshOverlay(layerOverlay);
                    }
                }
            }
        }
        private static void ZoomToExtent()
        {
            RectangleShape resultExtent = null;

            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Overlay && GisEditor.LayerListManager.SelectedLayerListItems.Count > 0)
            {
                Collection <RectangleShape> extents = new Collection <RectangleShape>();
                foreach (var item in GisEditor.LayerListManager.SelectedLayerListItems)
                {
                    var tmpOverlay = item.ConcreteObject as Overlay;
                    if (tmpOverlay != null)
                    {
                        extents.Add(tmpOverlay.GetBoundingBox());
                    }
                }
                resultExtent = ExtentHelper.GetBoundingBoxOfItems(extents);
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItems.Count > 0)
            {
                Collection <RectangleShape> extents = new Collection <RectangleShape>();
                foreach (var item in GisEditor.LayerListManager.SelectedLayerListItems)
                {
                    Layer tmpLayer = item.ConcreteObject as Layer;
                    if (tmpLayer != null && tmpLayer.HasBoundingBox)
                    {
                        tmpLayer.SafeProcess(() =>
                        {
                            extents.Add(tmpLayer.GetBoundingBox());
                        });

                        //tmpLayer.Open();
                        //extents.Add(tmpLayer.GetBoundingBox());
                        //tmpLayer.Close();
                    }
                }
                resultExtent = ExtentHelper.GetBoundingBoxOfItems(extents);
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Overlay)
            {
                resultExtent = (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Overlay).GetBoundingBox();
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Layer)
            {
                Layer layer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Layer;
                if (layer.HasBoundingBox)
                {
                    layer.SafeProcess(() =>
                    {
                        resultExtent = layer.GetBoundingBox();
                    });
                }
            }
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is ValueItem)
            {
                string       value        = ((ValueItem)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject).Value;
                string       columnName   = ((ValueStyle)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject).ColumnName;
                FeatureLayer featureLayer = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem);
                if (featureLayer != null)
                {
                    System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.DialogResult.Yes;
                    FeatureLayerPlugin[] layerPlugins = GisEditor.LayerManager.GetLayerPlugins(featureLayer.GetType()).OfType <FeatureLayerPlugin>().ToArray();
                    if (layerPlugins.Length > 0 && !layerPlugins[0].CanQueryFeaturesEfficiently)
                    {
                        dialogResult = System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ZoomToExtentWarning"), GisEditor.LanguageManager.GetStringResource("MapElementsListPluginZoomToExtent"), System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Information);
                    }
                    if (dialogResult == System.Windows.Forms.DialogResult.Yes)
                    {
                        Collection <Feature> features = new Collection <Feature>();
                        featureLayer.SafeProcess(() =>
                        {
                            features     = featureLayer.QueryTools.GetFeaturesByColumnValue(columnName, value);
                            resultExtent = ExtentHelper.GetBoundingBoxOfItems(features);
                        });
                        if (features.Count == 0)
                        {
                            MessageBoxHelper.ShowMessage("No features matched.", "Zoom to extent", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                        }
                    }
                }
            }

            if (resultExtent != null)
            {
                GisEditor.ActiveMap.CurrentExtent = resultExtent;
                GisEditor.ActiveMap.Refresh();
            }
        }
Esempio n. 8
0
        public static void ReplaceFromLibrary()
        {
            StyleLibraryWindow library = new StyleLibraryWindow();

            if (library.ShowDialog().GetValueOrDefault())
            {
                if (GisEditor.LayerListManager.SelectedLayerListItem == null)
                {
                    return;
                }
                var styleItem = GisEditor.LayerListManager.SelectedLayerListItem;
                //var styleItem = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as StyleItem;
                //if (styleItem != null)
                {
                    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.FindMapElementInTree <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.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                    }
                    if (containingOverlay != null)
                    {
                        containingOverlay.Invalidate();
                        GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(containingOverlay, RefreshArgsDescriptions.ReplaceFromLibraryDescription));
                    }
                }
            }
        }
        private static void AddStyle(StylePlugin styleProvider)
        {
            Style style = null;
            StyleBuilderArguments arguments           = new StyleBuilderArguments();
            FeatureLayer          currentFeatureLayer = null;

            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }

            //add a new style by right-clicking on a layer node
            if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is FeatureLayer)
            {
                currentFeatureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject;
            }

            //add a new style by right-clicking on a zoomlevel node
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is ZoomLevel)
            {
                ZoomLevel editingZoomLevel = (ZoomLevel)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject;
                arguments.FromZoomLevelIndex = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(editingZoomLevel.Scale, false) + 1;
                arguments.ToZoomLevelIndex   = (int)editingZoomLevel.ApplyUntilZoomLevel;
                currentFeatureLayer          = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject;
            }

            //replace an existing style
            else if (GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject is Style)
            {
                Style currentStyle = (Style)GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject;
                currentFeatureLayer = LayerListHelper.FindMapElementInTree <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem);
            }

            arguments.AvailableStyleCategories = LayerListHelper.GetStyleCategoriesByFeatureLayer(currentFeatureLayer);
            arguments.FeatureLayer             = currentFeatureLayer;
            arguments.FillRequiredColumnNames();
            arguments.AppliedCallback = args =>
            {
                if (args.CompositeStyle != null)
                {
                    ZoomLevelHelper.ApplyStyle(args.CompositeStyle, currentFeatureLayer, args.FromZoomLevelIndex, args.ToZoomLevelIndex);
                }
            };

            style      = styleProvider.GetDefaultStyle();
            style.Name = styleProvider.Name;
            var componentStyle = new CompositeStyle(style)
            {
                Name = currentFeatureLayer.Name
            };

            arguments.StyleToEdit = componentStyle;
            //var styleResults = GisEditor.StyleManager.EditStyle(arguments);
            if (currentFeatureLayer != null)
            {
                var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(currentFeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                if (featureLayerPlugin != null)
                {
                    var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI();
                    if (styleBuilder != null)
                    {
                        styleBuilder.StyleBuilderArguments = arguments;
                        if (styleBuilder.ShowDialog().GetValueOrDefault())
                        {
                            arguments.AppliedCallback(styleBuilder.StyleBuilderResult);
                        }
                    }
                }
            }
        }
        private static void MoveItem(MovementAction movementAction)
        {
            var selectedItem = GisEditor.LayerListManager.SelectedLayerListItem;

            if (selectedItem != null && selectedItem.ConcreteObject != null)
            {
                Layer   layer       = selectedItem.ConcreteObject as Layer;
                Overlay overlay     = selectedItem.ConcreteObject as Overlay;
                Style   styleItem   = selectedItem.ConcreteObject as Style;
                bool    needRefresh = false;

                if (layer != null)
                {
                    Overlay parentOverlay = GisEditor.ActiveMap.GetOverlaysContaining(layer).FirstOrDefault();
                    if (parentOverlay is LayerOverlay)
                    {
                        LayerOverlay layerOverlay = (LayerOverlay)parentOverlay;
                        needRefresh = MoveLayerInLayerOverlay(layer, layerOverlay, movementAction);
                    }
                }
                else if (overlay != null)
                {
                    needRefresh = MoveOverlay(overlay, movementAction);
                }
                else if (styleItem != null)
                {
                    var featureLayer = selectedItem.Parent.ConcreteObject as FeatureLayer;
                    if (featureLayer != null && selectedItem is StyleLayerListItem)
                    {
                        int from = 0;
                        int to   = 0;

                        var       resultZoomLevels = LayerListHelper.GetZoomLevelsAccordingToSacle(featureLayer);
                        ZoomLevel zoomLevel        = resultZoomLevels.OrderByDescending(zl => zl.Scale).FirstOrDefault(z => z.CustomStyles.Contains(selectedItem.ConcreteObject));

                        if (zoomLevel != null)
                        {
                            from = GisEditor.ActiveMap.GetSnappedZoomLevelIndex(zoomLevel.Scale, false) + 1;
                            to   = (int)zoomLevel.ApplyUntilZoomLevel;
                        }

                        var array = ((StyleLayerListItem)selectedItem).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);
                        }
                        if (from < to)
                        {
                            needRefresh = MoveStyle(styleItem, featureLayer, from, to, movementAction);
                        }
                    }
                    else
                    {
                        var parent = selectedItem.Parent as StyleLayerListItem;
                        if (parent != null)
                        {
                            var currentIndex = parent.Children.IndexOf(selectedItem);
                            var styleCount   = parent.Children.Count;
                            switch (movementAction)
                            {
                            case MovementAction.Down:
                                if (currentIndex + 1 <= styleCount - 1)
                                {
                                    parent.Children.RemoveAt(currentIndex);
                                    parent.Children.Insert(currentIndex + 1, selectedItem);
                                    parent.UpdateConcreteObject();
                                    needRefresh = true;
                                }
                                break;

                            case MovementAction.Up:
                                if (currentIndex - 1 >= 0)
                                {
                                    parent.Children.RemoveAt(currentIndex);
                                    parent.Children.Insert(currentIndex - 1, selectedItem);
                                    parent.UpdateConcreteObject();
                                    needRefresh = true;
                                }
                                break;

                            case MovementAction.ToTop:
                                if (currentIndex != 0)
                                {
                                    parent.Children.RemoveAt(currentIndex);
                                    parent.Children.Insert(0, selectedItem);
                                    parent.UpdateConcreteObject();
                                    needRefresh = true;
                                }
                                break;

                            case MovementAction.ToBottom:
                                if (currentIndex != styleCount - 1)
                                {
                                    parent.Children.RemoveAt(currentIndex);
                                    parent.Children.Add(selectedItem);
                                    parent.UpdateConcreteObject();
                                    needRefresh = true;
                                }
                                break;
                            }
                        }
                    }
                    if (needRefresh)
                    {
                        var tileOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                        if (tileOverlay != null && tileOverlay.MapArguments != null)
                        {
                            tileOverlay.Invalidate();
                        }
                    }
                }
                if (needRefresh)
                {
                    GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(selectedItem, RefreshArgsDescriptions.MoveItemDescription));
                }
            }
        }
        private static bool MoveStyle(Style style, FeatureLayer featureLayer, int from, int to, MovementAction movementAction)
        {
            var  customZoomLevels = featureLayer.ZoomLevelSet.CustomZoomLevels;
            bool needRefresh      = false;

            for (int i = from - 1; i < to; i++)
            {
                var zoomLevel    = customZoomLevels[i];
                var currentIndex = zoomLevel.CustomStyles.IndexOf(style);
                var styleCount   = zoomLevel.CustomStyles.Count;
                switch (movementAction)
                {
                case MovementAction.Down:
                    if (currentIndex - 1 >= 0)
                    {
                        zoomLevel.CustomStyles.RemoveAt(currentIndex);
                        zoomLevel.CustomStyles.Insert(currentIndex - 1, style);
                        needRefresh = true;
                    }
                    break;

                case MovementAction.Up:
                    if (currentIndex + 1 <= styleCount - 1)
                    {
                        zoomLevel.CustomStyles.RemoveAt(currentIndex);
                        zoomLevel.CustomStyles.Insert(currentIndex + 1, style);
                        needRefresh = true;
                    }
                    break;

                case MovementAction.ToTop:
                    if (currentIndex != styleCount - 1)
                    {
                        zoomLevel.CustomStyles.RemoveAt(currentIndex);
                        zoomLevel.CustomStyles.Add(style);
                        needRefresh = true;
                    }
                    break;

                case MovementAction.ToBottom:
                    if (currentIndex != 0)
                    {
                        zoomLevel.CustomStyles.RemoveAt(currentIndex);
                        zoomLevel.CustomStyles.Insert(0, style);
                        needRefresh = true;
                    }
                    break;

                default:
                    break;
                }
            }
            if (needRefresh)
            {
                TileOverlay overlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                if (overlay != null)
                {
                    overlay.Invalidate();
                }
            }
            return(needRefresh);
        }