Пример #1
0
        private void AssignLayerSymbologies(IMapFrame mapFrame)
        {
            foreach (ILayer layer in mapFrame.GetAllLayers())
            {
                IMapLineLayer lineLayer = layer as IMapLineLayer;
                if (lineLayer != null)
                {
                    ILineScheme original = lineLayer.Symbology;
                    if (original != null)
                    {
                        ILineScheme newScheme = original.Clone() as ILineScheme;
                        original.CopyProperties(newScheme);
                        original.ResumeEvents();
                    }
                }

                //to correctly draw categories:
                IMapFeatureLayer featureLayer = layer as IMapFeatureLayer;
                if (featureLayer != null)
                {
                    if (featureLayer.Symbology.NumCategories > 1)
                    {
                        featureLayer.DataSet.FillAttributes();
                        featureLayer.ApplyScheme(featureLayer.Symbology);
                    }
                }
            }
        }
Пример #2
0
        private void Configure(IFeatureSet inFeatureSet)
        {
            if (inFeatureSet.FeatureType != FeatureType.Line)
            {
                throw new LineFeatureTypeException();
            }

            Symbology = new LineScheme();
        }
Пример #3
0
        private void Configure(IFeatureSet inFeatureSet)
        {
            if (inFeatureSet.FeatureType != FeatureType.Line /*CGX*/ && inFeatureSet.FeatureType != FeatureType.Unspecified /*CGX END*/)
            {
                throw new LineFeatureTypeException();
            }

            Symbology = new LineScheme();
        }
 /// <summary>
 /// This should launch an open file dialog instead of the usual thing.
 /// </summary>
 /// <param name="context">System.ComponentModel.ITypeDescriptorContext</param>
 /// <param name="provider">IServiceProvider</param>
 /// <param name="value">The object being displayed</param>
 /// <returns>A new version of the object if the dialog was ok.</returns>
 public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
 {
     _original = value as ILineScheme;
     _editCopy = _original.Copy();
    
     IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
     NamedList<ILineCategory> cats = new NamedList<ILineCategory>(_editCopy.Categories, "Category");
     CollectionPropertyGrid frm = new CollectionPropertyGrid(cats);
     frm.ChangesApplied += frm_ChangesApplied;
     frm.AddItemClicked += frm_AddItemClicked;
     dialogProvider.ShowDialog(frm);
     return _original; // don't bother swapping out the edit copy, just store copies of the categories when changes are applied.
 }
Пример #5
0
        /// <summary>
        /// This should launch an open file dialog instead of the usual thing.
        /// </summary>
        /// <param name="context">ITypeDescriptorContext</param>
        /// <param name="provider">IServiceProvider</param>
        /// <param name="value">The object being displayed</param>
        /// <returns>A new version of the object if the dialog was ok.</returns>
        public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            _original = value as ILineScheme;
            _editCopy = _original.Copy();

            IWindowsFormsEditorService dialogProvider = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            NamedList <ILineCategory>  cats           = new NamedList <ILineCategory>(_editCopy.Categories, "Category");
            CollectionPropertyGrid     frm            = new CollectionPropertyGrid(cats);

            frm.ChangesApplied += FrmChangesApplied;
            frm.AddItemClicked += FrmAddItemClicked;
            dialogProvider.ShowDialog(frm);
            return(_original); // don't bother swapping out the edit copy, just store copies of the categories when changes are applied.
        }
Пример #6
0
        public void ConvertLayerProperties_MapLineDataWithThemeAndMetaDataNameNotInFeatures_OnlyAddsDefaultCategory()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);
            var          theme             = new MapTheme <LineCategoryTheme>("Other Meta", new[]
            {
                new LineCategoryTheme(ValueCriterionTestFactory.CreateValueCriterion(),
                                      new LineStyle
                {
                    Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Width     = random.Next(1, 48),
                    DashStyle = random.NextEnum <LineDashStyle>()
                })
            });

            var lineStyle = new LineStyle
            {
                Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Width     = random.Next(1, 48),
                DashStyle = random.NextEnum <LineDashStyle>()
            };
            var mapLineData = new MapLineData("test", lineStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapLineLayer = new MapLineLayer();

            var converter = new MapLineDataConverter();

            // Call
            converter.ConvertLayerProperties(mapLineData, mapLineLayer);

            // Assert
            ILineSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(lineStyle);

            ILineScheme appliedScheme = mapLineLayer.Symbology;

            Assert.AreEqual(1, appliedScheme.Categories.Count);

            ILineCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);
        }
Пример #7
0
        public void ConvertLayerProperties_MapLineDataWithThemeAndMetaDataNameInFeatures_ConvertDataToMapLineLayer()
        {
            // Setup
            const string metadataAttribute = "Meta";
            var          random            = new Random(21);

            var unequalCriterion = new ValueCriterion(ValueCriterionOperator.UnequalValue,
                                                      "unequal value");
            var equalCriterion = new ValueCriterion(ValueCriterionOperator.EqualValue,
                                                    "equal value");
            var theme = new MapTheme <LineCategoryTheme>(metadataAttribute, new[]
            {
                new LineCategoryTheme(equalCriterion, new LineStyle
                {
                    Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Width     = random.Next(1, 48),
                    DashStyle = random.NextEnum <LineDashStyle>()
                }),
                new LineCategoryTheme(unequalCriterion, new LineStyle
                {
                    Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                    Width     = random.Next(1, 48),
                    DashStyle = random.NextEnum <LineDashStyle>()
                })
            });

            var lineStyle = new LineStyle
            {
                Color     = Color.FromKnownColor(random.NextEnum <KnownColor>()),
                Width     = random.Next(1, 48),
                DashStyle = random.NextEnum <LineDashStyle>()
            };
            var mapLineData = new MapLineData("test", lineStyle, theme)
            {
                Features = new[]
                {
                    CreateMapFeatureWithMetaData(metadataAttribute)
                }
            };

            var mapLineLayer = new MapLineLayer();

            var converter = new MapLineDataConverter();

            // Call
            converter.ConvertLayerProperties(mapLineData, mapLineLayer);

            // Assert
            ILineSymbolizer expectedSymbolizer = CreateExpectedSymbolizer(lineStyle);

            ILineScheme appliedScheme = mapLineLayer.Symbology;

            Assert.AreEqual(3, appliedScheme.Categories.Count);

            ILineCategory baseCategory = appliedScheme.Categories[0];

            AssertAreEqual(expectedSymbolizer, baseCategory.Symbolizer);
            Assert.IsNull(baseCategory.FilterExpression);

            ILineCategory equalSchemeCategory = appliedScheme.Categories[1];
            string        expectedFilter      = $"[1] = '{equalCriterion.Value}'";

            Assert.AreEqual(expectedFilter, equalSchemeCategory.FilterExpression);
            LineStyle expectedCategoryStyle = theme.CategoryThemes.ElementAt(0).Style;

            expectedSymbolizer = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, equalSchemeCategory.Symbolizer);

            ILineCategory unEqualSchemeCategory = appliedScheme.Categories[2];

            expectedFilter = $"NOT [1] = '{unequalCriterion.Value}'";
            Assert.AreEqual(expectedFilter, unEqualSchemeCategory.FilterExpression);
            expectedCategoryStyle = theme.CategoryThemes.ElementAt(1).Style;
            expectedSymbolizer    = CreateExpectedSymbolizer(expectedCategoryStyle);
            AssertAreEqual(expectedSymbolizer, unEqualSchemeCategory.Symbolizer);
        }