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

            if (tileOverlay != null && tileOverlay.TileCache != null)
            {
                tileOverlay.Invalidate();
            }
        }
        public static void InvalidateTileOverlay()
        {
            TileOverlay tileOverlay = LayerListHelper.FindMapElementInTree <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);

            if (tileOverlay != null)
            {
                tileOverlay.Invalidate();
            }
        }
        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 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();
                }
            }
        }
        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));
                }
            }
        }
Пример #6
0
        public void AddQuickFilterStyle(string columnName, string columnValue)
        {
            var styleProvider  = GisEditor.StyleManager.GetActiveStylePlugins <FilterStylePlugin>().FirstOrDefault();
            var styleArguments = new StyleBuilderArguments();

            styleArguments.FeatureLayer = ViewModel.SelectedEntity.OwnerFeatureLayer;
            var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(styleArguments.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;

            if (featureLayerPlugin != null)
            {
                styleArguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(styleArguments.FeatureLayer);
                styleArguments.FromZoomLevelIndex       = 1;
                styleArguments.ToZoomLevelIndex         = GisEditor.ActiveMap.ZoomLevelSet.CustomZoomLevels.Count(z => z.GetType() == typeof(ZoomLevel));
                styleArguments.FillRequiredColumnNames();
                styleArguments.AppliedCallback = styleResults =>
                {
                    if (styleResults.CompositeStyle != null)
                    {
                        ZoomLevelHelper.AddStyleToZoomLevels(styleResults.CompositeStyle, styleResults.FromZoomLevelIndex, styleResults.ToZoomLevelIndex, styleArguments.FeatureLayer.ZoomLevelSet.CustomZoomLevels);
                        TileOverlay tileOverlay = GisEditor.ActiveMap.GetOverlaysContaining(styleArguments.FeatureLayer).FirstOrDefault();
                        if (tileOverlay != null)
                        {
                            tileOverlay.Invalidate();
                        }
                        GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(GisEditor.LayerListManager.SelectedLayerListItem, RefreshArgsDescription.ApplyStyleDescription));
                    }
                };
                var defaultFilterStyle = styleProvider.GetDefaultStyle() as FilterStyle;
                defaultFilterStyle.Name = string.Format(filterStyleNameFormat, columnName, columnValue);
                FilterCondition filterCondition = new FilterCondition();
                filterCondition.ColumnName = columnName;
                filterCondition.Name       = defaultFilterStyle.Name;
                bool isNumericColumn = false;
                styleArguments.FeatureLayer.SafeProcess(() =>
                {
                    Collection <FeatureSourceColumn> columns = styleArguments.FeatureLayer.FeatureSource.GetColumns();
                    var resultColumn = columns.FirstOrDefault(c => c.ColumnName.Equals(columnName, StringComparison.InvariantCultureIgnoreCase));
                    if (resultColumn != null)
                    {
                        isNumericColumn = resultColumn.TypeName.Equals("DOUBLE", StringComparison.InvariantCultureIgnoreCase) || resultColumn.TypeName.Equals("INTEGER", StringComparison.InvariantCultureIgnoreCase) || resultColumn.TypeName.Equals("FLOAT", StringComparison.InvariantCultureIgnoreCase);
                    }
                });

                //filterCondition.Expression = string.Format(isNumericColumn ? numericEqualConditionFormat : textContainsConditionFormat, columnValue.ToLowerInvariant());

                filterCondition.RegexOptions = System.Text.RegularExpressions.RegexOptions.IgnoreCase;
                filterCondition.Expression   = string.Format(isNumericColumn ? numericEqualConditionFormat : textContainsConditionFormat, columnValue);

                defaultFilterStyle.Conditions.Add(filterCondition);
                var componentStyle = new CompositeStyle(defaultFilterStyle)
                {
                    Name = styleArguments.FeatureLayer.Name
                };
                styleArguments.StyleToEdit = componentStyle;
                var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(styleArguments);
                if (styleBuilder.ShowDialog().GetValueOrDefault())
                {
                    styleArguments.AppliedCallback(styleBuilder.StyleBuilderResult);
                }
            }
        }
        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.FindMapElementInLayerList <TileOverlay>(GisEditor.LayerListManager.SelectedLayerListItem);
                if (overlay != null)
                {
                    overlay.Invalidate();
                }
            }
            return(needRefresh);
        }
Пример #8
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);
                    }
                }
            }
        }