public RasterDefinitionCtrl(WmsConfigurationDocument config, RasterWmsItem item, IEditorService edsvc) { InitializeComponent(); cmbBackground.ResetColors(); _config = config; _fs = (IFeatureSource)edsvc.GetEditedResource(); _item = item; _edsvc = edsvc; txtImageFormat.Text = item.ImageFormat; chkTransparent.Checked = item.IsTransparent; cmbBackground.CurrentColor = item.BackgroundColor; txtElevation.Text = item.ElevationDimension; txtEpsg.Text = item.SpatialContextName; txtTime.Text = item.Time; txtImageFormat.TextChanged += (s, e) => { item.ImageFormat = txtImageFormat.Text; }; chkTransparent.CheckedChanged += (s, e) => { item.IsTransparent = chkTransparent.Checked; }; cmbBackground.SelectedIndexChanged += (s, e) => { item.BackgroundColor = cmbBackground.CurrentColor; }; txtElevation.TextChanged += (s, e) => { item.ElevationDimension = txtElevation.Text; }; txtEpsg.TextChanged += (s, e) => { item.SpatialContextName = txtEpsg.Text; }; txtTime.TextChanged += (s, e) => { item.Time = txtTime.Text; }; List<string> names = new List<string>(); foreach (var layer in item.Layers) { names.Add(layer.Name); } txtLayers.Lines = names.ToArray(); lnkUpdate.Enabled = false; }
/// <summary> /// Write this document's schema mappings from the given XML document /// </summary> /// <param name="node">The node.</param> /// <param name="mgr">The namespace manager.</param> protected override void ReadSchemaMappings(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { foreach (XmlNode map in node.ChildNodes) { if (map.Name != "SchemaMapping") //NOXLATE { continue; } var prv = map.Attributes["provider"]; //NOXLATE if (prv == null) { throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "provider")); } var sn = map.Attributes["name"]; if (sn == null) { throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); } foreach (XmlNode clsMap in map.ChildNodes) { if (clsMap.Name != "complexType") //NOXLATE { continue; } var cn = clsMap.Attributes["name"]; //NOXLATE if (cn == null) { throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); } var rdf = clsMap.FirstChild; if (rdf == null || rdf.Name != "RasterDefinition") { throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedElement, "RasterDefinition")); } RasterWmsItem item = new RasterWmsItem(); item.SchemaName = sn.Value; item.ReadXml(rdf, mgr); this.AddRasterItem(item); } } }
private static RasterWmsItem CreateDefaultItem(string schemaName, string clsName, string rasName, IFdoSpatialContext defaultSc) { var item = new RasterWmsItem(schemaName, clsName, rasName); item.ImageFormat = "PNG"; //NOXLATE item.IsTransparent = true; item.BackgroundColor = Color.White; item.SpatialContextName = defaultSc.Name; item.UseTileCache = false; item.AddLayer(new WmsLayerDefinition(clsName) { Style = "default" }); //NOXLATE return item; }
/// <summary> /// Removes the specified override item /// </summary> /// <param name="item"></param> public void RemoveRasterItem(RasterWmsItem item) => _rasterItems.Remove(item);
/// <summary> /// Adds the specified override item /// </summary> /// <param name="item"></param> public void AddRasterItem(RasterWmsItem item) => _rasterItems.Add(item);
/// <summary> /// Adds the specified override item /// </summary> /// <param name="item"></param> public void AddRasterItem(RasterWmsItem item) { _rasterItems.Add(item); }
/// <summary> /// Write this document's schema mappings from the given XML document /// </summary> /// <param name="node">The node.</param> /// <param name="mgr">The namespace manager.</param> protected override void ReadSchemaMappings(System.Xml.XmlNode node, System.Xml.XmlNamespaceManager mgr) { foreach (XmlNode map in node.ChildNodes) { if (map.Name != "SchemaMapping") //NOXLATE continue; var prv = map.Attributes["provider"]; //NOXLATE if (prv == null) throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "provider")); var sn = map.Attributes["name"]; if (sn == null) throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); foreach (XmlNode clsMap in map.ChildNodes) { if (clsMap.Name != "complexType") //NOXLATE continue; var cn = clsMap.Attributes["name"]; //NOXLATE if (cn == null) throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedAttribute, "name")); var rdf = clsMap.FirstChild; if (rdf == null || rdf.Name != "RasterDefinition") throw new Exception(string.Format(Strings.ErrorBadDocumentExpectedElement, "RasterDefinition")); RasterWmsItem item = new RasterWmsItem(); item.SchemaName = sn.Value; item.ReadXml(rdf, mgr); this.AddRasterItem(item); } } }
/// <summary> /// Removes the specified override item /// </summary> /// <param name="item"></param> public void RemoveRasterItem(RasterWmsItem item) { _rasterItems.Remove(item); }
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"; File.WriteAllText(path, conf.ToXml()); conf = null; string xml = File.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); }