コード例 #1
0
 private static void RemoveStyle()
 {
     if (GisEditor.LayerListManager.SelectedLayerListItem == null)
     {
         return;
     }
     //var styleItem = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as StyleItem;
     //if (styleItem != null)
     {
         var featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer;
         if (featureLayer != null)
         {
             var style = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style;
             foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels)
             {
                 if (zoomLevel.CustomStyles.Contains(style))
                 {
                     zoomLevel.CustomStyles.Remove(style);
                 }
             }
         }
         else
         {
             var parent = GisEditor.LayerListManager.SelectedLayerListItem.Parent as StyleLayerListItem;
             if (parent != null)
             {
                 parent.Children.Remove(GisEditor.LayerListManager.SelectedLayerListItem);
                 parent.UpdateConcreteObject();
             }
         }
         LayerListHelper.InvalidateTileOverlay();
         GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.RemoveStyleDescription));
     }
 }
コード例 #2
0
        public static void ApplyStyle(Style newStyle, FeatureLayer currentFeatureLayer, int fromZoomLevel, int toZoomLevel, bool needsRefresh = true)
        {
            currentFeatureLayer.ZoomLevelSet
            .CustomZoomLevels
            .Where(tmpLevel => tmpLevel.CustomStyles.Contains(newStyle))
            .ForEach(tmpLevel => tmpLevel.CustomStyles.Remove(newStyle));

            if (GisEditor.LayerListManager.SelectedLayerListItem != null && GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject != null)
            {
                FeatureLayer featureLayer = null;
                ZoomLevel    zoomLevel    = null;
                Style        currentStyle = null;
                if ((featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer) != null)
                {
                    AddStyleToZoomLevels(newStyle, fromZoomLevel, toZoomLevel, featureLayer.ZoomLevelSet.CustomZoomLevels);
                }
                else if ((zoomLevel = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as ZoomLevel) != null)
                {
                    var customZoomLevels = (GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer).ZoomLevelSet.CustomZoomLevels;
                    AddStyleToZoomLevels(newStyle, fromZoomLevel, toZoomLevel, customZoomLevels);
                }
                else if ((currentStyle = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Style) != null)
                {
                    featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.Parent.ConcreteObject as FeatureLayer;
                    ReplaceStyle(featureLayer, currentStyle, newStyle);
                }

                if (needsRefresh)
                {
                    LayerListHelper.InvalidateTileOverlay();
                    GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.ApplyStyleDescription));
                }
            }
        }
コード例 #3
0
        public static void ResetZoomLevelRange(ZoomLevel selectedZoomLevel, FeatureLayer featureLayer, int from, int to)
        {
            for (int i = 0; i < featureLayer.ZoomLevelSet.CustomZoomLevels.Count; i++)
            {
                var zoomLevel = featureLayer.ZoomLevelSet.CustomZoomLevels[i];
                if (i >= from - 1 && i <= to - 1)
                {
                    foreach (var style in selectedZoomLevel.CustomStyles)
                    {
                        if (!zoomLevel.CustomStyles.Contains(style))
                        {
                            zoomLevel.CustomStyles.Add(style);
                        }
                    }
                }
                else
                {
                    foreach (var style in selectedZoomLevel.CustomStyles)
                    {
                        if (zoomLevel.CustomStyles.Contains(style))
                        {
                            zoomLevel.CustomStyles.Remove(style);
                        }
                    }
                }
            }

            LayerListHelper.InvalidateTileOverlay();
            GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(selectedZoomLevel, RefreshArgsDescriptions.ResetZoomLevelRangeDescription));
        }
コード例 #4
0
        public static void AddStyle()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            var featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer;

            if (featureLayer == null)
            {
                featureLayer = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject as FeatureLayer;
            }
            if (featureLayer != null)
            {
                var styleArguments     = new StyleBuilderArguments();
                var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(featureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                switch (featureLayerPlugin.GetFeatureSimpleShapeType(featureLayer))
                {
                case SimpleShapeType.Point:
                    styleArguments.AvailableStyleCategories = StyleCategories.Point | StyleCategories.Label | StyleCategories.Composite;
                    break;

                case SimpleShapeType.Line:
                    styleArguments.AvailableStyleCategories = StyleCategories.Line | StyleCategories.Label | StyleCategories.Composite;
                    break;

                case SimpleShapeType.Area:
                    styleArguments.AvailableStyleCategories = StyleCategories.Area | StyleCategories.Label | StyleCategories.Composite;
                    break;
                }
                var componentStyle = new CompositeStyle();
                styleArguments.StyleToEdit        = componentStyle;
                styleArguments.FeatureLayer       = featureLayer;
                styleArguments.FromZoomLevelIndex = 1;
                styleArguments.ToZoomLevelIndex   = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels().Where(z => z.GetType() == typeof(ZoomLevel)).Count();
                styleArguments.AppliedCallback    = new Action <StyleBuilderResult>((styleResult) =>
                {
                    if (!styleResult.Canceled)
                    {
                        foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels)
                        {
                            zoomLevel.CustomStyles.Remove(componentStyle);
                        }

                        for (int i = styleResult.FromZoomLevelIndex - 1; i < styleResult.ToZoomLevelIndex; i++)
                        {
                            featureLayer.ZoomLevelSet.CustomZoomLevels[i].CustomStyles.Add(styleResult.CompositeStyle);
                        }

                        LayerListHelper.InvalidateTileOverlay();
                        GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(featureLayer, RefreshArgsDescriptions.AddStyleCommandDescription));
                        componentStyle = styleResult.CompositeStyle as CompositeStyle;
                    }
                });

                styleArguments.FillRequiredColumnNames();
                var styleResults = GisEditor.StyleManager.EditStyle(styleArguments);
                styleArguments.AppliedCallback(styleResults);
            }
        }
コード例 #5
0
        private static void RemoveZoomLevel()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            ZoomLevel selectedZoomLevel = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as ZoomLevel;

            if (selectedZoomLevel != null)
            {
                FeatureLayer featureLayer = (FeatureLayer)GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject;
                foreach (var zoomLevel in featureLayer.ZoomLevelSet.CustomZoomLevels)
                {
                    foreach (var style in selectedZoomLevel.CustomStyles)
                    {
                        if (zoomLevel.CustomStyles.Contains(style))
                        {
                            zoomLevel.CustomStyles.Remove(style);
                        }
                    }
                }

                LayerListHelper.InvalidateTileOverlay();
                GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.RemoveZoomLevelDescription));
            }
        }
コード例 #6
0
        //public static MenuItem GetRemoveSubStyleMenuItem()
        //{
        //    var command = new ObservedCommand(RemoveSubStyle, () => true);
        //    return GetMenuItem("Remove", "/GisEditorPluginCore;component/Images/unload.png", command);
        //}

        private static void RemoveSubStyle()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            Styles.Style style = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as Styles.Style;
            object       parentActualObject = GisEditor.LayerListManager.SelectedLayerListItem.Parent.ConcreteObject;

            if (style != null)
            {
                if (parentActualObject is ValueStyle)
                {
                    var valueStyle      = (ValueStyle)parentActualObject;
                    var resultValueItem = valueStyle.ValueItems.Where(valueItem => valueItem.CustomStyles.Contains(style)).FirstOrDefault();
                    valueStyle.ValueItems.Remove(resultValueItem);
                }
                else if (parentActualObject is ClassBreakStyle)
                {
                    var classBreakStyle  = (ClassBreakStyle)parentActualObject;
                    var resultClassBreak = classBreakStyle.ClassBreaks.Where(classBreak => classBreak.CustomStyles.Contains(style)).FirstOrDefault();
                    classBreakStyle.ClassBreaks.Remove(resultClassBreak);
                }
                else if (parentActualObject is RegexStyle)
                {
                    var regexStyle      = (RegexStyle)parentActualObject;
                    var resultRegexItem = regexStyle.RegexItems.Where(regexItem => regexItem.CustomStyles.Contains(style)).FirstOrDefault();
                    regexStyle.RegexItems.Remove(resultRegexItem);
                }

                LayerListHelper.InvalidateTileOverlay();
                GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescriptions.RemoveSubStyleDescription));
            }
        }
コード例 #7
0
        public static MenuItem GetAddStyleWizardMenuItem(FeatureLayer featureLayer)
        {
            var command = new ObservedCommand(() =>
            {
                if (AddStyleToLayerWithStyleWizard(new Layer[] { featureLayer }))
                {
                    LayerListHelper.InvalidateTileOverlay();
                    GisEditor.UIManager.InvokeRefreshPlugins(new RefreshArgs(featureLayer, RefreshArgsDescriptions.GetAddStyleWizardMenuItemDescription));
                }
            }, () => true);

            return(GetMenuItem("Style Wizard", "/GisEditorInfrastructure;component/Images/addstyle.png", command));
        }
コード例 #8
0
        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));
            }
        }