private void InsertFromLibrary(object sender, RoutedEventArgs e)
        {
            var styleLibraryWindow = new StyleLibraryWindow();

            if (styleLibraryWindow.ShowDialog().GetValueOrDefault())
            {
                var compositeStyle     = styleItem.ConcreteObject as CompositeStyle;
                var compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(styleLibraryWindow.Result.CompositeStyle);
                if (compositeStyle != null)
                {
                    foreach (var item in compositeStyleItem.Children.Reverse())
                    {
                        styleItem.Children.Insert(0, item);
                    }
                }
                else
                {
                    var index = styleItem.Parent.Children.IndexOf(styleItem);
                    foreach (var item in compositeStyleItem.Children)
                    {
                        index++;
                        styleItem.Parent.Children.Insert(index, item);
                    }
                }
            }
        }
        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));
                    }
                }
            }
        }
        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);
                }
            }
        }
        private void ReplaceFromLibrary(object sender, RoutedEventArgs e)
        {
            var styleLibraryWindow = new StyleLibraryWindow();

            if (styleLibraryWindow.ShowDialog().GetValueOrDefault())
            {
                var compositeStyle = styleItem.ConcreteObject as CompositeStyle;

                //styleLibraryWindow.Result.CompositeStyle
                var compositeStyleItem = GisEditor.StyleManager.GetStyleLayerListItem(styleLibraryWindow.Result.CompositeStyle);
                if (compositeStyle != null)
                {
                    styleItem.Children.Clear();
                    styleItem.Name = compositeStyleItem.Name;
                    foreach (var item in compositeStyleItem.Children)
                    {
                        styleItem.Children.Add(item);
                    }
                    styleItem.UpdateConcreteObject();
                }
                else
                {
                    var parentStyleitem = styleItem.Parent as StyleLayerListItem;
                    if (parentStyleitem != null)
                    {
                        var index = parentStyleitem.Children.IndexOf(styleItem);
                        parentStyleitem.Children.RemoveAt(index);
                        foreach (var item in compositeStyleItem.Children)
                        {
                            parentStyleitem.Children.Insert(index, item);
                            index++;
                        }
                        parentStyleitem.UpdateConcreteObject();
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void InitializeCommands()
        {
            #region load from lib

            loadFromLibraryCommand = new RelayCommand(() =>
            {
                StyleLibraryWindow libraryWindow = new StyleLibraryWindow();
                if (libraryWindow.ShowDialog().Value)
                {
                    var componentStyle = libraryWindow.Result.CompositeStyle;
                    if (componentStyle != null)
                    {
                        FromZoomLevelIndex = libraryWindow.Result.FromZoomLevelIndex;
                        ToZoomLevelIndex   = libraryWindow.Result.ToZoomLevelIndex;
                        RootStyleItem.StyleItem.Children.Clear();
                        componentStyle.Styles.Reverse().ForEach(s => LoadStyle(s));
                        RootStyleItem.StyleItem.Name = componentStyle.Name;
                        RootStyleItem.StyleItem.UpdateConcreteObject();
                        UpdatePreviewSource();
                        SelectedStyleItem = RootStyleItem.StyleItemViewModels.FirstOrDefault();
                        if (SelectedStyleItem != null)
                        {
                            SelectedStyleItem.IsSelected = true;
                        }
                    }
                }
            }, () => !styleArguments.IsSubStyleReadonly);

            #endregion load from lib

            #region save to lib

            saveToLibraryCommand = new RelayCommand(() =>
            {
                var innerStyles = StyleItems.Select(s => s.StyleItem.ConcreteObject).Reverse().OfType <Styles.Style>();
                CompositeStyle componentStyle = new CompositeStyle(innerStyles)
                {
                    Name = Name
                };
                GisEditor.StyleManager.SaveStyleToLibrary(componentStyle, SelectedToZoomLevelModel.Scale, SelectedFromZoomLevelModel.Scale);
            });

            #endregion save to lib

            #region clear styles

            clearStylesCommand = new RelayCommand(() =>
            {
                System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("StyleBuilderViewModelEraseAllStylesText")
                                                                                                , GisEditor.LanguageManager.GetStringResource("StyleBuilderViewModelClearStylesCaption")
                                                                                                , System.Windows.Forms.MessageBoxButtons.YesNo
                                                                                                , System.Windows.Forms.MessageBoxIcon.Warning);

                if (result == System.Windows.Forms.DialogResult.Yes)
                {
                    RootStyleItem.StyleItem.Children.Clear();
                    RootStyleItem.StyleItem.UpdateConcreteObject();
                    UpdatePreviewSource();
                    SelectRootNodeIfEmpty();
                }
            }, () => !styleArguments.IsSubStyleReadonly);

            #endregion clear styles

            #region duplicate style

            duplicateCommand = new RelayCommand(() =>
            {
                StyleLayerListItem duplicateStyleItem = SelectedStyleItem.StyleItem.CloneDeep();
                if (duplicateStyleItem != null)
                {
                    var parent = SelectedStyleItem.StyleItem.Parent as StyleLayerListItem;
                    if (parent != null)
                    {
                        parent.Children.Insert(0, duplicateStyleItem);
                        parent.UpdateConcreteObject();
                        if (StyleItems.Count > 0)
                        {
                            StyleItems.FirstOrDefault().IsSelected = true;
                        }
                        UpdatePreviewSource();
                    }
                }
            }, () => !styleArguments.IsSubStyleReadonly && SelectedStyleItem != null && SelectedStyleItem.StyleItem.Parent != null);

            #endregion duplicate style

            #region delete style

            deleteStyleCommand = new RelayCommand(() =>
            {
                var parentItem = SelectedStyleItem.StyleItem.Parent as StyleLayerListItem;
                if (parentItem != null && parentItem.Children.Contains(SelectedStyleItem.StyleItem))
                {
                    parentItem.Children.Remove(SelectedStyleItem.StyleItem);
                    parentItem.UpdateConcreteObject();
                    UpdatePreviewSource();
                    SelectRootNodeIfEmpty();
                }
            }, () => !styleArguments.IsSubStyleReadonly && SelectedStyleItem != null && SelectedStyleItem.StyleItem.Parent != null && SelectedStyleItem.StyleItem.ConcreteObject is Styles.Style);

            #endregion delete style

            #region rename

            renameCommand = new RelayCommand(() =>
            {
                if (IsRootNodeSelected)
                {
                    RootStyleItem.IsRenaming = true;
                }
                else
                {
                    SelectedStyleItem.IsRenaming = true;
                }
            }, () => !styleArguments.IsSubStyleReadonly && (IsRootNodeSelected || (SelectedStyleItem != null && SelectedStyleItem.StyleItem.CanRename)));

            #endregion rename
        }
Exemplo n.º 6
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));
                    }
                }
            }
        }