private void lstFeatureClasses_SelectedIndexChanged(object sender, EventArgs e)
        {
            var item = (RasterWmsItem)lstFeatureClasses.SelectedItem;

            grpRaster.Controls.Clear();
            _updatingLogicalClassUI = true;
            try
            {
                if (item != null)
                {
                    var ctrl = new RasterDefinitionCtrl(_config, item, _service);
                    ctrl.Dock = DockStyle.Fill;
                    grpRaster.Controls.Add(ctrl);

                    btnRemove.Enabled = true;

                    //Get logical class
                    string schemaName = item.SchemaName;
                    string className  = item.FeatureClass;

                    if (!string.IsNullOrEmpty(schemaName) && !string.IsNullOrEmpty(className))
                    {
                        _logicalClass = _config.GetClass(schemaName, className);
                        if (_logicalClass != null)
                        {
                            txtClassName.Text        = _logicalClass.Name;
                            txtClassDescription.Text = _logicalClass.Description;
                        }
                        else
                        {
                            txtClassName.Text        = string.Empty;
                            txtClassDescription.Text = string.Empty;
                        }
                    }
                    else
                    {
                        _logicalClass            = null;
                        txtClassName.Text        = string.Empty;
                        txtClassDescription.Text = string.Empty;
                    }
                }
                else
                {
                    _logicalClass            = null;
                    txtClassName.Text        = string.Empty;
                    txtClassDescription.Text = string.Empty;
                }
            }
            finally
            {
                _updatingLogicalClassUI = false;
            }
            grpLogicalClass.Enabled = (_logicalClass != null);
        }
Exemple #2
0
        public void TestWmsSaveLoad()
        {
            var conf = new WmsConfigurationDocument();

            var schema = new FeatureSchema("WMS", "WMS Test Schema");
            var cls    = new ClassDefinition("NASAWMSGlobalPan", "WMS Test Class");

            cls.AddProperty(new DataPropertyDefinition("Id", "ID Property")
            {
                DataType   = DataPropertyType.String,
                Length     = 256,
                IsNullable = false
            }, true);
            cls.AddProperty(new RasterPropertyDefinition("Image", "Raster Property")
            {
                DefaultImageXSize = 800,
                DefaultImageYSize = 800
            });

            schema.AddClass(cls);
            conf.AddSchema(schema);

            var item = new RasterWmsItem(schema.Name, cls.Name, "Image");

            item.ImageFormat        = RasterWmsItem.WmsImageFormat.PNG;
            item.IsTransparent      = true;
            item.BackgroundColor    = ColorTranslator.FromHtml("#FFFFFF");
            item.Time               = "current";
            item.ElevationDimension = "0";
            item.SpatialContextName = "EPSG:4326";

            for (int i = 0; i < 5; i++)
            {
                item.AddLayer(new WmsLayerDefinition("Layer" + i));
            }

            conf.AddRasterItem(item);

            string path = "WmsConfigTest.xml";

            Utils.WriteAllText(path, conf.ToXml());

            conf = null;
            string xml = Utils.ReadAllText(path);

            conf = ConfigurationDocument.LoadXml(xml) as WmsConfigurationDocument;
            Assert.NotNull(conf);

            Assert.AreEqual(1, conf.RasterOverrides.Length);

            var ritem = conf.RasterOverrides[0];

            cls = conf.GetClass("WMS", "NASAWMSGlobalPan");

            Assert.NotNull(cls);
            Assert.NotNull(cls.Parent);
            Assert.AreEqual("WMS", cls.Parent.Name);
            Assert.AreEqual("WMS Test Schema", cls.Parent.Description);
            Assert.AreEqual("NASAWMSGlobalPan", cls.Name);
            Assert.AreEqual("WMS Test Class", cls.Description);
            var prop = cls.FindProperty("Id");

            Assert.NotNull(prop);
            Assert.AreEqual("Id", prop.Name);
            Assert.AreEqual("ID Property", prop.Description);
            prop = cls.FindProperty("Image");
            Assert.NotNull(prop);
            Assert.AreEqual("Image", prop.Name);
            Assert.AreEqual("Raster Property", prop.Description);

            Assert.AreEqual(item.ImageFormat, ritem.ImageFormat);
            Assert.AreEqual(item.IsTransparent, ritem.IsTransparent);
            Assert.AreEqual(item.BackgroundColor, ritem.BackgroundColor);
            Assert.AreEqual(item.Time, ritem.Time);
            Assert.AreEqual(item.ElevationDimension, ritem.ElevationDimension);
            Assert.AreEqual(item.SpatialContextName, ritem.SpatialContextName);

            Assert.AreEqual(5, item.Layers.Length);
        }