Ejemplo n.º 1
0
        public TextStyleUserControl(IconTextStyle style, StyleBuilderArguments requiredValues)
        {
            InitializeComponent();
            StyleBuilderArguments = requiredValues;
            viewModel             = new TextStyleViewModel(style, StyleBuilderArguments);
            DataContext           = viewModel;
            cm.DataContext        = viewModel;
            iconTextStyle         = style;
            if (requiredValues.FeatureLayer is InMemoryFeatureLayer)
            {
                ViewDataButton.IsEnabled = false;
            }

            var image = viewModel.ActualObject.GetPreviewImage();

            previewImage.Width  = image.Width > fixedSize ? fixedSize : image.Width;
            previewImage.Height = image.Height > fixedSize ? fixedSize : image.Height;

            string helpUri = GisEditor.LanguageManager.GetStringResource("LabelStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }
        }
Ejemplo n.º 2
0
        public DotDensityAreaStyleUserControl(DotDensityStyle style, StyleBuilderArguments requiredValues)
        {
            InitializeComponent();
            this.style          = style;
            this.RequiredValues = requiredValues;

            if (RequiredValues.FeatureLayer == null || RequiredValues.FeatureLayer is InMemoryFeatureLayer)
            {
                viewDataButton.IsEnabled = false;
            }
            var ratio = Math.Round(1 / style.PointToValueRatio);

            dotDensityStyleViewModel = new DotDensityStyleViewModel(style, requiredValues);
            if (ratio != 1)
            {
                dotDensityStyleViewModel.PointValueRatioY = ratio;
            }
            DataContext = dotDensityStyleViewModel;

            string helpUri = GisEditor.LanguageManager.GetStringResource("DotDensityAreaStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }
        }
        protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments)
        {
            if (userControl == null)
            {
                StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments);
                userControl = new FilterStyleUserControl(ConcreteObject as TextFilterStyle, styleArguments);

                if (Children.Count == 0)
                {
                    var textStylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(StyleCategories.Label);
                    if (textStylePlugin != null)
                    {
                        var textStyle = textStylePlugin.GetDefaultStyle() as TextStyle;
                        if (textStyle != null)
                        {
                            textStyle.TextColumnName = styleArguments.ColumnNames.FirstOrDefault();
                            var styleItem = GisEditor.StyleManager.GetStyleLayerListItem(textStyle);
                            Children.Add(styleItem);
                            UpdateConcreteObject();
                        }
                    }
                }
            }
            return(userControl);
        }
        public ValueStyleViewModel(ValueStyle style, StyleBuilderArguments requiredValues)
            : base(style)
        {
            HelpKey               = "ValueStyleHelp";
            this.valueItems       = new ObservableCollection <ValueItemEntity>();
            this.ActualObject     = style;
            this.actualValueStyle = style;
            this.requiredValues   = requiredValues;
            this.columnNames      = new Dictionary <string, string>();
            foreach (var columnName in requiredValues.ColumnNames)
            {
                string alias = requiredValues.FeatureLayer.FeatureSource.GetColumnAlias(columnName);
                this.columnNames[columnName] = alias;
            }

            if (string.IsNullOrEmpty(actualValueStyle.ColumnName))
            {
                SelectedColumnName = columnNames.FirstOrDefault();
            }

            InitializeValueItems();

            if (requiredValues.FeatureLayer != null)
            {
                AnalyzeCount(requiredValues.FeatureLayer);
            }
        }
Ejemplo n.º 5
0
        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) + 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.FindMapElementInLayerList <FeatureLayer>(GisEditor.LayerListManager.SelectedLayerListItem);
            }

            arguments.AvailableStyleCategories = StylePluginHelper.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 (!styleResults.Canceled)
            {
                ZoomLevelHelper.ApplyStyle(styleResults.CompositeStyle, currentFeatureLayer, styleResults.FromZoomLevelIndex, styleResults.ToZoomLevelIndex);
            }
        }
        public static StyleBuilderResult EditCompondStyle <T>(T style, StyleBuilderArguments styleArguments) where T : Style
        {
            CompositeStyle compositeStyle = new CompositeStyle();

            compositeStyle.Styles.Add(style);
            styleArguments.StyleToEdit = compositeStyle;
            return(GisEditor.StyleManager.EditStyle(styleArguments));
        }
 protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments)
 {
     if (userControl == null)
     {
         userControl = new FontPointStyleUserControl(ConcreteObject as FontPointStyle);
     }
     return(userControl);
 }
 protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments)
 {
     if (userControl == null)
     {
         StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments);
         userControl = new TextStyleUserControl(ConcreteObject as IconTextStyle, styleArguments);
     }
     return(userControl);
 }
        public FilterConditionViewModel(StyleBuilderArguments requiredValues, FilterCondition condition)
        {
            columnNameTypes = new Dictionary <string, IntermediateColumnType>();

            basedOnVisibility = Visibility.Collapsed;
            if (requiredValues.FeatureLayer != null)
            {
                var layerPlugin = GisEditor.LayerManager.GetLayerPlugins(requiredValues.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                if (layerPlugin != null)
                {
                    var shapeType = layerPlugin.GetFeatureSimpleShapeType(requiredValues.FeatureLayer);
                    basedOnVisibility = shapeType == SimpleShapeType.Area ? Visibility.Visible : Visibility.Collapsed;
                }
            }

            areaUnits = new Collection <AreaUnit>(Enum.GetValues(typeof(AreaUnit)).OfType <AreaUnit>().ToList());
            AreaFilterCondition calculatedAreaFilterCondition = condition as AreaFilterCondition;

            if (calculatedAreaFilterCondition != null)
            {
                columnNamesVisibility = Visibility.Collapsed;
                areaUnitsVisibility   = Visibility.Visible;
                this.filterMode       = FilterMode.Area;
                this.selectedAreaUnit = calculatedAreaFilterCondition.AreaUnit;
            }
            else
            {
                columnNamesVisibility = Visibility.Visible;
                areaUnitsVisibility   = Visibility.Collapsed;
            }

            if (condition == null)
            {
                condition            = new FilterCondition();
                condition.Expression = ".*.*";
                condition.Logical    = true;
            }
            this.validStatus = true;
            this.matchExpressionIsEnabled = true;
            this.isIgnoreCase             = condition.RegexOptions == System.Text.RegularExpressions.RegexOptions.IgnoreCase;
            this.condition      = condition;
            this.columnNames    = new Dictionary <string, string>();
            this.requiredValues = requiredValues;
            foreach (var item in requiredValues.ColumnNames)
            {
                string alias = requiredValues.FeatureLayer.FeatureSource.GetColumnAlias(item);
                this.columnNames[item] = alias;
            }
            if (!string.IsNullOrEmpty(condition.ColumnName) && columnNames.Values.Contains(condition.ColumnName, StringComparer.OrdinalIgnoreCase))
            {
                condition.ColumnName = columnNames.FirstOrDefault(c => c.Value.Equals(condition.ColumnName, StringComparison.InvariantCultureIgnoreCase)).Key;
            }
            this.filterConditionTemplates = FilterHelper.GetFilterConditionTemplates(filterMode);
            this.InitializeCommands();
            this.InitializeProperties();
        }
 protected override StyleUserControl GetUICore(StyleBuilderArguments styleArguments)
 {
     styleUI = CreateUI(styleArguments);
     if (styleUI.DataContext is StyleViewModel)
     {
         styleViewModel = (StyleViewModel)styleUI.DataContext;
         styleViewModel.PropertyChanged -= StyleViewModel_PropertyChanged;
         styleViewModel.PropertyChanged += StyleViewModel_PropertyChanged;
     }
     return(styleUI);
 }
Ejemplo n.º 11
0
        internal static void AddStyle(Styles.Style style, FeatureLayer layer)
        {
            var styleProvider = GisEditor.StyleManager.GetStylePluginByStyle(style);

            if (styleProvider == null)
            {
                return;
            }
            Styles.Style          csvStyle  = styleProvider.GetDefaultStyle();
            StyleBuilderArguments arguments = new StyleBuilderArguments();

            arguments.AvailableUIElements = StyleBuilderUIElements.ZoomLevelPicker | StyleBuilderUIElements.StyleList;
            arguments.FeatureLayer        = layer;
            var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(layer.GetType()).FirstOrDefault() as FeatureLayerPlugin;

            if (featureLayerPlugin != null)
            {
                switch (featureLayerPlugin.GetFeatureSimpleShapeType(layer))
                {
                case SimpleShapeType.Point:
                    arguments.AvailableStyleCategories = StyleCategories.Point | StyleCategories.Label | StyleCategories.Composite;
                    break;

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

                case SimpleShapeType.Area:
                    arguments.AvailableStyleCategories = StyleCategories.Area | StyleCategories.Label | StyleCategories.Composite;
                    break;
                }
            }
            arguments.AppliedCallback = args =>
            {
                if (args.CompositeStyle != null)
                {
                    ZoomLevelHelper.ApplyStyle(args.CompositeStyle, layer, args.FromZoomLevelIndex, args.ToZoomLevelIndex);
                }
            };

            arguments.StyleToEdit = new CompositeStyle(new Styles.Style[] { csvStyle })
            {
                Name = styleProvider.Name
            };
            arguments.FillRequiredColumnNames();
            var resultStyle = GisEditor.StyleManager.EditStyle(arguments);

            if (!resultStyle.Canceled)
            {
                ZoomLevelHelper.ApplyStyle(resultStyle.CompositeStyle, layer, resultStyle.FromZoomLevelIndex, resultStyle.ToZoomLevelIndex);
            }
        }
Ejemplo n.º 12
0
        private void InitRequiredColumnNames(StyleBuilderArguments requiredValues)
        {
            requiredColumnNames = new Dictionary <string, string>();

            if (requiredValues != null && requiredValues.FeatureLayer != null)
            {
                foreach (var columnName in CollectNumberColumnNamesFromFeatureLayer(requiredValues.FeatureLayer))
                {
                    string alias = requiredValues.FeatureLayer.FeatureSource.GetColumnAlias(columnName);
                    requiredColumnNames.Add(columnName, alias);
                }
            }
        }
Ejemplo n.º 13
0
        protected override StyleUserControl GetUICore(StyleBuilderArguments styleArguments)
        {
            var parent = Parent as StyleLayerListItem;

            if (parent != null)
            {
                return(parent.GetUI(styleArguments));
            }
            else
            {
                return(null);
            }
        }
 public static void FillRequiredValueForStyleArguments(StyleBuilderArguments styleArguments)
 {
     if (styleArguments.ColumnNames.Count == 0 && styleArguments.FeatureLayer != null)
     {
         styleArguments.FeatureLayer.SafeProcess(() =>
         {
             styleArguments.ColumnNames.Clear();
             foreach (var columnName in styleArguments.FeatureLayer.QueryTools.GetColumns().Select(column => column.ColumnName))
             {
                 styleArguments.ColumnNames.Add(columnName);
             }
         });
     }
 }
        public ValueStyleUserControl(ValueStyle style, StyleBuilderArguments requiredValues)
        {
            InitializeComponent();
            StyleBuilderArguments = requiredValues;
            valueStyle            = style;
            viewModel             = new ValueStyleViewModel(style, requiredValues);
            DataContext           = viewModel;

            string helpUri = GisEditor.LanguageManager.GetStringResource("ValueStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }
        }
 public FilterStyleViewModel(FilterStyle filterStyle, StyleBuilderArguments requiredValues)
     : base(filterStyle)
 {
     filterStyleMatchTypeToStringConverter = new FilterStyleMatchTypeToStringConverter();
     HelpKey = "FilterStyleHelp";
     this.actualFilterStyle = filterStyle;
     this.requiredValues    = requiredValues;
     this.filterConditions  = new ObservableCollection <FilterConditionViewModel>();
     this.filterConditions.CollectionChanged += FilterConditions_CollectionChanged;
     this.availableStylePlugins = new Dictionary <StylePlugin, Style>();
     this.InitializeConditions(filterStyle.Conditions);
     this.InitializeAvailablePlugins(requiredValues.FeatureLayer);
     this.InitializeCommands();
     FilterConditions_CollectionChanged(null, null);
     InitializeColumnNameTypes(requiredValues);
 }
Ejemplo n.º 17
0
        private static T EditStyles <T>(StylePluginManager styleManager, StyleBuilderArguments styleArguments, T editingStyle, Func <T, Collection <T> > fetchInnerStyles) where T : Style, new()
        {
            CompositeStyle compositeStyle = new CompositeStyle();

            compositeStyle.Name = editingStyle.Name;

            if (fetchInnerStyles(editingStyle).Count > 0)
            {
                foreach (var style in fetchInnerStyles(editingStyle))
                {
                    compositeStyle.Styles.Add(style);
                }
            }
            else
            {
                compositeStyle.Styles.Add(editingStyle);
            }

            styleArguments.StyleToEdit = compositeStyle;
            var result = styleManager.EditStyle(styleArguments);

            if (result.Canceled)
            {
                return(null);
            }
            else
            {
                T resultAreaStyle = new T();
                resultAreaStyle.Name = compositeStyle.Name;
                PointStyle pointStyle = resultAreaStyle as PointStyle;
                if (pointStyle != null)
                {
                    foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <PointStyle>())
                    {
                        pointStyle.CustomPointStyles.Add(tmpAreaStyle);
                    }
                }
                else
                {
                    foreach (var tmpAreaStyle in compositeStyle.Styles.OfType <T>())
                    {
                        fetchInnerStyles(resultAreaStyle).Add(tmpAreaStyle);
                    }
                }
                return(resultAreaStyle);
            }
        }
        private void InitializeColumnNameTypes(StyleBuilderArguments requiredValues)
        {
            columnNameTypes = new Dictionary <string, IntermediateColumnType>();
            if (RequiredValues.FeatureLayer != null)
            {
                FeatureLayerPlugin resultLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(RequiredValues.FeatureLayer.GetType()).LastOrDefault() as FeatureLayerPlugin;

                if (resultLayerPlugin != null)
                {
                    Collection <IntermediateColumn> columns = resultLayerPlugin.GetIntermediateColumns(requiredValues.FeatureLayer.FeatureSource);
                    foreach (var item in columns)
                    {
                        columnNameTypes[item.ColumnName] = item.IntermediateColumnType;
                    }
                }
            }
        }
Ejemplo n.º 19
0
        public static IconTextStyle EditStyles(this StylePluginManager styleManager, StyleBuilderArguments styleArguments, IconTextStyle textStyle)
        {
            TextStyle resultTextStyle = EditStyles <TextStyle>(styleManager, styleArguments, textStyle, s => s.CustomTextStyles);

            if (resultTextStyle == null)
            {
                return(null);
            }

            IconTextStyle iconTextStyle = new IconTextStyle();

            iconTextStyle.Name = resultTextStyle.Name;
            foreach (var tmpStyle in resultTextStyle.CustomTextStyles)
            {
                iconTextStyle.CustomTextStyles.Add(tmpStyle);
            }

            return(iconTextStyle);
        }
Ejemplo n.º 20
0
        public DotDensityStyleViewModel(DotDensityStyle style, StyleBuilderArguments requiredValues)
            : base(style)
        {
            HelpKey = "DotDensityAreaStyleHelp";

            ActualObject          = style;
            actualDotDensityStyle = style;
            if (style.PointToValueRatio == 1.0)
            {
                RecommendPointValueRatio = 0.00001;
            }
            else
            {
                recommendPointValueRatio = style.PointToValueRatio;
            }
            SelectedPointStyleType = GetPointStyleType(style.CustomPointStyle);
            InitRequiredColumnNames(requiredValues);
            InitializeWarningTimer();
            InitializePointValueRatio();
        }
Ejemplo n.º 21
0
        private void ConfigureBackgroundStyleClick(object sender, RoutedEventArgs e)
        {
            if (viewModel.BackgroundStyle != null)
            {
                viewModel.BackgroundStyle.Name = GisEditor.StyleManager.GetStylePluginByStyle(viewModel.BackgroundStyle).Name;
            }

            if (viewModel.BackgroundStyle != null &&
                viewModel.BackgroundStyle.CustomAreaStyles.Count == 0)
            {
                var tempStyle = new AreaStyle();
                tempStyle.Name = viewModel.BackgroundStyle.Name;
                tempStyle      = (AreaStyle)viewModel.BackgroundStyle.CloneDeep();
                viewModel.BackgroundStyle.CustomAreaStyles.Add(tempStyle);
            }

            StyleBuilderArguments styleArguments = new StyleBuilderArguments();

            styleArguments.AvailableStyleCategories = StyleCategories.Area;
            styleArguments.AvailableUIElements      = StyleBuilderUIElements.StyleList;
            styleArguments.AppliedCallback          = (result) =>
            {
                AreaStyle areaStyle = new AreaStyle();
                foreach (var item in result.CompositeStyle.Styles.OfType <AreaStyle>())
                {
                    areaStyle.CustomAreaStyles.Add(item);
                }
                viewModel.BackgroundStyle = areaStyle;
            };

            AreaStyle style = (AreaStyle)viewModel.BackgroundStyle.CloneDeep();

            style.Name = viewModel.BackgroundStyle.Name;
            var resultStyle = GisEditor.StyleManager.EditStyles(styleArguments, style);

            if (resultStyle != null)
            {
                resultStyle.SetDrawingLevel();
                viewModel.BackgroundStyle = resultStyle;
            }
        }
Ejemplo n.º 22
0
        protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments)
        {
            if (userControl == null)
            {
                StylePluginHelper.FillRequiredValueForStyleArguments(styleArguments);
                userControl = new FilterStyleUserControl(ConcreteObject as FilterStyle, styleArguments);

                if (Children.Count == 0)
                {
                    var pointStylePlugin = GisEditor.StyleManager.GetDefaultStylePlugin(styleArguments.AvailableStyleCategories);
                    if (pointStylePlugin != null)
                    {
                        var style = pointStylePlugin.GetDefaultStyle();
                        style.Name = pointStylePlugin.Name;
                        var styleItem = GisEditor.StyleManager.GetStyleLayerListItem(style);
                        Children.Add(styleItem);
                        UpdateConcreteObject();
                    }
                }
            }
            return(userControl);
        }
Ejemplo n.º 23
0
        public ClassBreakStyleViewModel(ClassBreakStyle style, StyleBuilderArguments requiredValues)
            : base(style)
        {
            this.HelpKey         = "ClassBreakStyleHelp";
            this.classBreakItems = new ObservableCollection <ClassBreakItem>();
            foreach (var item in style.ClassBreaks)
            {
                classBreakItems.Add(GetClassBreakItem(item));
            }
            this.ActualObject          = style;
            this.actualClassBreakStyle = style;
            this.requiredValues        = requiredValues;

            this.columns = new Dictionary <string, string>();
            foreach (var columnName in requiredValues.ColumnNames)
            {
                string alias = requiredValues.FeatureLayer.FeatureSource.GetColumnAlias(columnName);
                this.columns[columnName] = alias;
            }

            this.SelectedColumnName = this.columns.FirstOrDefault(c => c.Key == style.ColumnName);
        }
Ejemplo n.º 24
0
        private void LayerListManager_SelectedLayerListItemChanged(object sender, SelectedLayerListItemChangedLayerListManagerEventArgs e)
        {
            StyleUserControl   currentStyleUI     = null;
            StyleLayerListItem styleLayerListItem = e.NewValue as StyleLayerListItem;

            if (styleLayerListItem != null)
            {
                Style        style        = styleLayerListItem.ConcreteObject as Style;
                FeatureLayer featureLayer = GetConcreteObjectContaining <FeatureLayer>(styleLayerListItem);
                if (featureLayer != null && featureLayer.IsVisible && style != null)
                {
                    StyleBuilderArguments argument = new StyleBuilderArguments();
                    argument.FeatureLayer = featureLayer;
                    argument.StyleToEdit  = new CompositeStyle(style);
                    argument.FillRequiredColumnNames();

                    currentStyleUI = styleLayerListItem.GetUI(argument);
                    stylePropertyViewModel.FeatureLayer = featureLayer;
                }
            }

            stylePropertyViewModel.StylePropertyContent = currentStyleUI;
        }
Ejemplo n.º 25
0
        public FilterStyleUserControl(FilterStyle style, StyleBuilderArguments requiredValues)
        {
            StyleBuilderArguments = requiredValues;
            InitializeComponent();

            filterStyle = style;

            viewModel   = new FilterStyleViewModel(style, requiredValues);
            DataContext = viewModel;
            textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("C#");

            string helpUri = GisEditor.LanguageManager.GetStringResource("FilterStyleHelp");

            if (!string.IsNullOrEmpty(helpUri))
            {
                HelpUri = new Uri(helpUri);
            }


            ScriptComboBox.ItemsSource        = Enum.GetNames(typeof(FilterStyleScriptType)).Where(e => e != "None");
            textEditor.TextArea.TextEntering += new TextCompositionEventHandler(TextArea_TextEntering);
            textEditor.TextArea.TextEntered  += new TextCompositionEventHandler(TextArea_TextEntered);
        }
Ejemplo n.º 26
0
        public static void FillRequiredColumnNames(this StyleBuilderArguments arguments)
        {
            if (arguments.ColumnNames.Count == 0 && arguments.FeatureLayer != null)
            {
                arguments.FeatureLayer.SafeProcess(() =>
                {
                    arguments.ColumnNames.Clear();
                    foreach (var columnName in arguments.FeatureLayer.QueryTools.GetColumns().Select(column => column.ColumnName))
                    {
                        arguments.ColumnNames.Add(columnName);
                    }

                    if (CalculatedDbfColumn.CalculatedColumns.ContainsKey(arguments.FeatureLayer.FeatureSource.Id) &&
                        CalculatedDbfColumn.CalculatedColumns[arguments.FeatureLayer.FeatureSource.Id].Count > 0)
                    {
                        foreach (var item in CalculatedDbfColumn.CalculatedColumns[arguments.FeatureLayer.FeatureSource.Id])
                        {
                            arguments.ColumnNames.Add(item.ColumnName);
                        }
                    }
                });
            }
        }
Ejemplo n.º 27
0
        private void ConfigureBackgroundMaskMode()
        {
            LazyPreviewSourceChanged();

            if (BackMask == null)
            {
                SetDefaultStyles();
            }
            AreaStyle editingStyle = (AreaStyle)BackMask.CloneDeep();

            editingStyle.Name = GisEditor.StyleManager.GetStylePluginByStyle(editingStyle).Name;
            if (editingStyle.CustomAreaStyles.Count == 0)
            {
                var tempStyle = new AreaStyle();
                tempStyle.Name = editingStyle.Name;
                tempStyle.CustomAreaStyles.Add(editingStyle);
                editingStyle = tempStyle;
            }

            StyleBuilderArguments args = new StyleBuilderArguments();

            args.AvailableUIElements      = StyleBuilderUIElements.StyleList;
            args.AvailableStyleCategories = StyleCategories.Area;
            args.AppliedCallback          = (editResult) =>
            {
                editingStyle.Name = editResult.CompositeStyle.Name;
                editingStyle.CustomAreaStyles.Clear();
                ((CompositeStyle)editResult.CompositeStyle).Styles.OfType <AreaStyle>().ForEach(s => editingStyle.CustomAreaStyles.Add(s));
                BackMask = (AreaStyle)editingStyle;
            };
            var resultStyle = GisEditor.StyleManager.EditStyles(args, editingStyle);

            if (resultStyle != null)
            {
                BackMask = resultStyle;
            }
        }
Ejemplo n.º 28
0
        public static void EditStyle(LayerListItem selectedLayerListItem)
        {
            var componentStyleItem = LayerListHelper.FindItemInLayerList <CompositeStyle>(selectedLayerListItem) as StyleLayerListItem;

            if (componentStyleItem != null)
            {
                var componentStyle = componentStyleItem.ConcreteObject as CompositeStyle;
                var styleArguments = new StyleBuilderArguments();
                styleArguments.FeatureLayer = componentStyleItem.Parent.ConcreteObject as FeatureLayer;
                var featureLayerPlugin = GisEditor.LayerManager.GetLayerPlugins(styleArguments.FeatureLayer.GetType()).FirstOrDefault() as FeatureLayerPlugin;
                if (featureLayerPlugin != null)
                {
                    styleArguments.AvailableStyleCategories = StylePluginHelper.GetStyleCategoriesByFeatureLayer(styleArguments.FeatureLayer);
                    int from = 0;
                    int to   = GisEditor.ActiveMap.ZoomLevelSet.CustomZoomLevels.Count;
                    if (!string.IsNullOrEmpty(componentStyleItem.ZoomLevelRange))
                    {
                        var array = componentStyleItem.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);
                        }
                    }

                    styleArguments.FromZoomLevelIndex = from;
                    styleArguments.ToZoomLevelIndex   = to;
                    styleArguments.AppliedCallback    = new Action <StyleBuilderResult>((styleResults) =>
                    {
                        if (!styleResults.Canceled)
                        {
                            var resultStyle = styleResults.CompositeStyle as CompositeStyle;
                            var count       = GisEditor.ActiveMap.ZoomLevelSet.GetZoomLevels().Count;
                            for (int i = 0; i < count; i++)
                            {
                                var customStyles = styleArguments.FeatureLayer.ZoomLevelSet.CustomZoomLevels[i].CustomStyles;
                                if (i >= styleResults.FromZoomLevelIndex - 1 && i < styleResults.ToZoomLevelIndex)
                                {
                                    if (!customStyles.Contains(componentStyle))
                                    {
                                        customStyles.Add(componentStyle);
                                    }
                                    componentStyle.Styles.Clear();
                                    componentStyle.Name = resultStyle.Name;
                                    foreach (var item in resultStyle.Styles)
                                    {
                                        componentStyle.Styles.Add(item);
                                    }
                                }
                                else
                                {
                                    customStyles.Remove(componentStyle);
                                }
                            }
                            foreach (var overlay in GisEditor.ActiveMap.GetOverlaysContaining(styleArguments.FeatureLayer))
                            {
                                if (overlay.MapArguments != null)
                                {
                                    overlay.Invalidate();
                                }
                            }
                            GisEditor.UIManager.BeginRefreshPlugins(new RefreshArgs(styleResults, RefreshArgsDescription.EditStyleDescription));
                        }
                    });
                    var styleItems = new Collection <StyleLayerListItem>();
                    foreach (var style in componentStyle.Styles)
                    {
                        var item = GisEditor.StyleManager.GetStyleLayerListItem(style);
                        if (item != null)
                        {
                            styleItems.Add(item);
                        }
                    }

                    var clonedStyleItems     = new Collection <StyleLayerListItem>();
                    var clonedCompositeStyle = componentStyle.CloneDeep() as CompositeStyle;
                    styleArguments.StyleToEdit = clonedCompositeStyle;

                    foreach (var style in clonedCompositeStyle.Styles)
                    {
                        var item = GisEditor.StyleManager.GetStyleLayerListItem(style);
                        if (item != null)
                        {
                            clonedStyleItems.Add(item);
                        }
                    }

                    object selectedClonedObject = FindSelectedObject(styleItems.ToList(), clonedStyleItems.ToList(), selectedLayerListItem.ConcreteObject);
                    styleArguments.FillRequiredColumnNames();
                    styleArguments.SelectedConcreteObject = selectedClonedObject;
                    var styleBuilder = GisEditor.StyleManager.GetStyleBuiderUI(styleArguments);
                    if (styleBuilder.ShowDialog().GetValueOrDefault())
                    {
                        styleArguments.AppliedCallback(styleBuilder.StyleBuilderResult);
                    }
                }
            }
        }
Ejemplo n.º 29
0
 protected override StyleUserControl CreateUI(StyleBuilderArguments styleArguments)
 {
     return(userControl ?? (userControl = new AdvancedAreaStyleUserControl(ConcreteObject as AreaStyle)));
 }
Ejemplo n.º 30
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);
                }
            }
        }