public ShapeToKMLForm(IApplication application) { layers = new List <LayerProperties>(); InitializeComponent(); this.m_application = application; chkLayers.Items.Clear(); IMxDocument activeDoc = application.Document as IMxDocument; IMap activeMap = activeDoc.FocusMap; layers.Clear(); for (int i = 0; i < activeMap.LayerCount; i++) { //if it's a raster or a feature layer. Other supported layers will be added later if ((activeMap.get_Layer(i) is IFeatureLayer) || (activeMap.get_Layer(i) is IRasterLayer)) { //chkLayers.Items.Add(activeMap.get_Layer(i).Name, false); LayerProperties lp = new LayerProperties(); lp.Layeru = activeMap.get_Layer(i); lp.Tesselate = false; lp.AltitudeMode = AltitudeMode.clampToGround; lp.Extrude = false; lp.Color = Color.Black; lp.name = lp.Layeru.Name; chkLayers.Items.Add(lp, false); } } }
public ShapeToKMLForm(IApplication application) { layers = new List<LayerProperties>(); InitializeComponent(); this.m_application = application; chkLayers.Items.Clear(); IMxDocument activeDoc = application.Document as IMxDocument; IMap activeMap = activeDoc.FocusMap; layers.Clear(); for (int i = 0; i < activeMap.LayerCount; i++) { //if it's a raster or a feature layer. Other supported layers will be added later if ((activeMap.get_Layer(i) is IFeatureLayer) || (activeMap.get_Layer(i) is IRasterLayer)) { //chkLayers.Items.Add(activeMap.get_Layer(i).Name, false); LayerProperties lp = new LayerProperties(); lp.Layeru = activeMap.get_Layer(i); lp.Tesselate = false; lp.AltitudeMode = AltitudeMode.clampToGround; lp.Extrude = false; lp.Color = Color.Black; lp.name = lp.Layeru.Name; chkLayers.Items.Add(lp, false); } } }
private void cmbName_SelectedIndexChanged(object sender, EventArgs e) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; if (cmbName.SelectedItem != null) { selected.NameField = cmbName.SelectedItem as string; } }
private void rbRelative_CheckedChanged(object sender, EventArgs e) { if (rbRelative.Checked) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.AltitudeMode = AltitudeMode.relativeToGround; grpSelAltitude.Visible = true; chkExtrude.Visible = true; chkTesselate.Visible = false; } }
private void rbSelManualAltitude_CheckedChanged(object sender, EventArgs e) { //enable or disable correspondent controls numAltitude.Enabled = rbSelManualAltitude.Checked; numMultiplier.Enabled = rbSelAttrib.Checked; cmbAttribute.Enabled = rbSelAttrib.Checked; lblX.Enabled = rbSelAttrib.Checked; if (rbSelManualAltitude.Checked) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.Field = ""; selected.Altitude = (int)numAltitude.Value; } }
private void rbSelAttrib_CheckedChanged(object sender, EventArgs e) { //enable or disable correspondent controls numMultiplier.Enabled = rbSelAttrib.Checked; cmbAttribute.Enabled = rbSelAttrib.Checked; lblX.Enabled = rbSelAttrib.Checked; numAltitude.Enabled = rbSelManualAltitude.Checked; if (rbSelAttrib.Checked) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; if (cmbAttribute.SelectedItem != null) { selected.Field = cmbAttribute.SelectedItem.ToString(); } selected.Altitude = 0; } }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (rbAbsolute.Checked) { //if its checked enable list of attributes to choose from: grpSelAltitude.Visible = true; rbSelAttrib.Checked = true; LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.AltitudeMode = AltitudeMode.absolute; numAltitude.Value = selected.Altitude; numMultiplier.Value = selected.Multiplier; chkExtrude.Visible = true; chkTesselate.Visible = false; } else { //if its unchecked disable list of attributes to choose from: grpSelAltitude.Visible = false; } }
private void processLayerProperties(LayerProperties lp, geFolder folder) { if (lp.Layeru is IFeatureLayer) { if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { processPolyLineLayer(lp, folder); } if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) { processPointLayer(lp, folder); } if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { processPolygonLayer(lp, folder); } } if (lp.Layeru is IRasterLayer) { processRasterLayer(lp, folder); } }
private void processPolygonLayer(LayerProperties layerProps, geFolder folder) { //I have a polygon layer, and a kml folder :) IFeatureClass clasa = (layerProps.Layeru as IFeatureLayer).FeatureClass; //get acces to features IFeatureCursor featurele = clasa.Search(null, true); int nrFeature = clasa.FeatureCount(null); //if I have any features Polygon poligon; IFeature currentFeature; while ((currentFeature = featurele.NextFeature()) != null) { poligon = currentFeature.Shape as Polygon; //coordinates and vertices double coordLat; double coordLong; IEnumVertex colection = poligon.EnumVertices; IPoint polyVertex; //create coord system WGS 84 (Google earth) IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //create spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; #region add points to polygon //create a placemark for the line gePlacemark pmPolygon = new gePlacemark(); pmPolygon.StyleUrl = "#Shape2KMLGeneratedStyle"; List <geCoordinates> polyCoords = new List <geCoordinates>(); int index1, index2; //iterate points... while (!colection.IsLastInPart()) { //create polygon from vertices colection.Next(out polyVertex, out index1, out index2); //project point and get coordinates polyVertex.Project(pointToSpatialReference); polyVertex.QueryCoords(out coordLong, out coordLat); //add point to line try { //create points for polygon based on altitude mode. switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: if (layerProps.Field == "") { //add point to line polyCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude)); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point to line polyCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude)); } break; case AltitudeMode.clampToGround: //add point to line polyCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong))); break; case AltitudeMode.relativeToGround: if (layerProps.Field == "") { //add point to line polyCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude)); } else { float altitude; //if altitude is integer, this should work altitude = (float)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point to line polyCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude)); } break; default: break; } } catch (Exception) { MessageBox.Show("Altitude field is not a number value"); break; } } //create line from list of coords geOuterBoundaryIs outer = new geOuterBoundaryIs(new geLinearRing(polyCoords)); gePolygon poly = new gePolygon(outer); //and add it to document switch (layerProps.AltitudeMode) { //set altitude mode... case AltitudeMode.absolute: poly.AltitudeMode = geAltitudeModeEnum.absolute; break; case AltitudeMode.clampToGround: poly.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: poly.AltitudeMode = geAltitudeModeEnum.relativeToGround; break; default: break; } if (layerProps.DescField != "") { pmPolygon.Description = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.DescField)).ToString(); } if (layerProps.NameField != "") { pmPolygon.Name = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.NameField)).ToString(); } pmPolygon.Geometry = poly; folder.Features.Add(pmPolygon); #endregion } }
private void processPointLayer(LayerProperties layerProps, geFolder folder) { //I have a point layer, and a kml folder :) IFeatureClass clasa = (layerProps.Layeru as IFeatureLayer).FeatureClass; //get acces to features IFeatureCursor featurele = clasa.Search(null, true); //if I have any features Point punct; IFeature currentFeature; //create coord system WGS 84 (Google earth) IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //create spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; #region add points while ((currentFeature = featurele.NextFeature()) != null) { punct = currentFeature.Shape as Point; //coordinates and vertices double coordLat; double coordLong; //create a placemark for the point gePlacemark pmPoint = new gePlacemark(); pmPoint.StyleUrl = "#Shape2KMLGeneratedStyle"; //project point and get coordinates punct.Project(pointToSpatialReference); punct.QueryCoords(out coordLong, out coordLat); //add point geCoordinates coords; gePoint point; switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: if (layerProps.Field == "") { //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude); } point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.absolute; break; case AltitudeMode.clampToGround: coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong)); point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: if (layerProps.Field == "") { //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude); } point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.relativeToGround; break; default: point = null; break; } if (layerProps.DescField != "") { pmPoint.Description = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.DescField)).ToString(); } if (layerProps.NameField != "") { pmPoint.Name = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.NameField)).ToString(); } pmPoint.Geometry = point; folder.Features.Add(pmPoint); #endregion } }
private void processPolyLineLayer(LayerProperties layerProps, geFolder folder) { //I have a polyline layer, and a kml folder :) IFeatureClass clasa = (layerProps.Layeru as IFeatureLayer).FeatureClass; //get acces to features IFeatureCursor featurele = clasa.Search(null, true); int nrFeature = clasa.FeatureCount(null); //if I have any features Polyline curba; IFeature currentFeature; while ((currentFeature = featurele.NextFeature()) != null) { curba = currentFeature.Shape as Polyline; //coordinates and vertices double coordLat; double coordLong; IEnumVertex colection = curba.EnumVertices; IPoint lineVertex; //create coord system WGS 84 (Google earth) IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //create spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; #region add points to polyline //create a placemark for the line gePlacemark pmLine = new gePlacemark(); pmLine.StyleUrl = "#Shape2KMLGeneratedStyle"; List<geCoordinates> lineCoords = new List<geCoordinates>(); int index1, index2; //iterate points... geLineString line = null; while (!colection.IsLastInPart()) { colection.Next(out lineVertex, out index1, out index2); //project point and get coordinates lineVertex.Project(pointToSpatialReference); lineVertex.QueryCoords(out coordLong, out coordLat); try { switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: if (layerProps.Field == "") { //add point to line lineCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude)); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point to line lineCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude)); } break; case AltitudeMode.clampToGround: //add point to line lineCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong))); break; case AltitudeMode.relativeToGround: if (layerProps.Field == "") { //add point to line lineCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude)); } else { float altitude; //if altitude is integer, this should work altitude = (float)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point to line lineCoords.Add(new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude)); } break; default: break; } } catch (Exception) { MessageBox.Show("Altitude field is not a number value"); break; } } //create line from list of coords line = new geLineString(lineCoords); switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: line.AltitudeMode = geAltitudeModeEnum.absolute; break; case AltitudeMode.clampToGround: line.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: line.AltitudeMode = geAltitudeModeEnum.relativeToGround; break; default: break; } if (layerProps.DescField != "") pmLine.Description = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.DescField)).ToString(); if (layerProps.NameField != "") pmLine.Name = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.NameField)).ToString(); //and add it to document pmLine.Geometry = line; folder.Features.Add(pmLine); #endregion } }
private void chkExtrude_CheckedChanged(object sender, EventArgs e) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.Extrude = chkExtrude.Checked; }
private void numAltitude_ValueChanged(object sender, EventArgs e) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.Altitude = (int)numAltitude.Value; }
private void cmbAttribute_SelectedIndexChanged(object sender, EventArgs e) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.Field = cmbAttribute.SelectedItem as string; }
private void processPointLayer(LayerProperties layerProps, geFolder folder) { //I have a point layer, and a kml folder :) IFeatureClass clasa = (layerProps.Layeru as IFeatureLayer).FeatureClass; //get acces to features IFeatureCursor featurele = clasa.Search(null, true); //if I have any features Point punct; IFeature currentFeature; //create coord system WGS 84 (Google earth) IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //create spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; #region add points while ((currentFeature = featurele.NextFeature()) != null) { punct = currentFeature.Shape as Point; //coordinates and vertices double coordLat; double coordLong; //create a placemark for the point gePlacemark pmPoint = new gePlacemark(); pmPoint.StyleUrl = "#Shape2KMLGeneratedStyle"; //project point and get coordinates punct.Project(pointToSpatialReference); punct.QueryCoords(out coordLong, out coordLat); //add point geCoordinates coords; gePoint point; switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: if (layerProps.Field == "") { //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude); } point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.absolute; break; case AltitudeMode.clampToGround: coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong)); point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: if (layerProps.Field == "") { //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Altitude); } else { int altitude; //if altitude is integer, this should work altitude = (int)currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.Field)); //add point coords = new geCoordinates(new geAngle90(coordLat), new geAngle180(coordLong), layerProps.Multiplier * altitude); } point = new gePoint(coords); point.AltitudeMode = geAltitudeModeEnum.relativeToGround; break; default: point = null; break; } if (layerProps.DescField != "") pmPoint.Description = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.DescField)).ToString(); if (layerProps.NameField != "") pmPoint.Name = currentFeature.get_Value(currentFeature.Fields.FindField(layerProps.NameField)).ToString(); pmPoint.Geometry = point; folder.Features.Add(pmPoint); #endregion } }
private void processRasterLayer(LayerProperties layerProps, geFolder folder) { IRasterLayer currentLayer = layerProps.Layeru as IRasterLayer; //get coordinates for image :D geAngle90 north; geAngle90 south; geAngle180 east; geAngle180 west; Double coordlat, coordlong; IPoint refPoint; refPoint = currentLayer.AreaOfInterest.LowerLeft; //coordinate system. IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); //create coordinate system for WGS 84 (Google earth) gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; //project point to google earth projection refPoint.Project(pointToSpatialReference); //and get coordinates refPoint.QueryCoords(out coordlong, out coordlat); //left = west point and lower = south west = new geAngle180(coordlong); south = new geAngle90(coordlat); //and upper right refPoint = currentLayer.AreaOfInterest.UpperRight; //project point to google earth projection refPoint.Project(pointToSpatialReference); //x.ToString("{0:0.00}"); //and get coordinates refPoint.QueryCoords(out coordlong, out coordlat); //north and east north = new geAngle90(coordlat); east = new geAngle180(coordlong); //so I have all coordinates, now I create the overlay. geGroundOverlay.geLatLonBox latlonbox = new geGroundOverlay.geLatLonBox(north, south, east, west); geGroundOverlay overlay = new geGroundOverlay(latlonbox); //copy image to current folder... string name = System.IO.Path.GetDirectoryName(Path); name = System.IO.Path.Combine(name, currentLayer.Name); File.Copy(currentLayer.FilePath, name, true); // overlay.Icon.Href = currentLayer.FilePath; overlay.Icon = new geIcon(System.IO.Path.GetFileName(name)); overlay.Name = currentLayer.Name; overlay.Description = currentLayer.FilePath; overlay.StyleUrl = "#Shape2KMLGeneratedStyle"; switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: overlay.AltitudeMode = geAltitudeModeEnum.absolute; overlay.Altitude = layerProps.Altitude; //use altitude from field , do that later... break; case AltitudeMode.clampToGround: overlay.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: overlay.AltitudeMode = geAltitudeModeEnum.relativeToGround; overlay.Altitude = layerProps.Altitude; //use altitude from field , do that later... break; default: break; } //and add overlay to folder. THAT "simple" folder.Features.Add(overlay); }
private void processRasterLayer(LayerProperties layerProps, geFolder folder) { IRasterLayer currentLayer = layerProps.Layeru as IRasterLayer; //get coordinates for image :D geAngle90 north; geAngle90 south; geAngle180 east; geAngle180 west; Double coordlat, coordlong; IPoint refPoint; refPoint = currentLayer.AreaOfInterest.LowerLeft; //coordinate system. IGeographicCoordinateSystem gcs; SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment(); //create coordinate system for WGS 84 (Google earth) gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984); //spatial reference ISpatialReference pointToSpatialReference; pointToSpatialReference = gcs; //project point to google earth projection refPoint.Project(pointToSpatialReference); //and get coordinates refPoint.QueryCoords(out coordlong, out coordlat); //left = west point and lower = south west= new geAngle180(coordlong); south = new geAngle90(coordlat); //and upper right refPoint = currentLayer.AreaOfInterest.UpperRight; //project point to google earth projection refPoint.Project(pointToSpatialReference); //x.ToString("{0:0.00}"); //and get coordinates refPoint.QueryCoords(out coordlong, out coordlat); //north and east north = new geAngle90(coordlat); east = new geAngle180(coordlong); //so I have all coordinates, now I create the overlay. geGroundOverlay.geLatLonBox latlonbox = new geGroundOverlay.geLatLonBox(north,south,east,west); geGroundOverlay overlay = new geGroundOverlay(latlonbox); //copy image to current folder... string name = System.IO.Path.GetDirectoryName(Path); name = System.IO.Path.Combine(name, currentLayer.Name); File.Copy(currentLayer.FilePath, name,true); // overlay.Icon.Href = currentLayer.FilePath; overlay.Icon = new geIcon(System.IO.Path.GetFileName(name)); overlay.Name = currentLayer.Name; overlay.Description = currentLayer.FilePath; overlay.StyleUrl = "#Shape2KMLGeneratedStyle"; switch (layerProps.AltitudeMode) { case AltitudeMode.absolute: overlay.AltitudeMode = geAltitudeModeEnum.absolute; overlay.Altitude = layerProps.Altitude; //use altitude from field , do that later... break; case AltitudeMode.clampToGround: overlay.AltitudeMode = geAltitudeModeEnum.clampToGround; break; case AltitudeMode.relativeToGround: overlay.AltitudeMode = geAltitudeModeEnum.relativeToGround; overlay.Altitude = layerProps.Altitude; //use altitude from field , do that later... break; default: break; } //and add overlay to folder. THAT "simple" folder.Features.Add(overlay); }
private void cmbLayers_SelectedIndexChanged(object sender, EventArgs e) { //get selected layer LayerProperties selectedLayer = ((cmbLayers.Items[cmbLayers.SelectedIndex]) as LayerProperties); //if it's a known type, enable altitude group to be able to select altitude if (selectedLayer.Layeru is IRasterLayer || selectedLayer.Layeru is IFeatureLayer) { grpAltitude.Enabled = true; } //if it's Raster altitude cannot be relative. if (selectedLayer.Layeru is IRasterLayer) { rbRelative.Enabled = false; } else { rbRelative.Enabled = true; //get fields and add them to combobox. IFeatureLayer sel = selectedLayer.Layeru as IFeatureLayer; cmbAttribute.Items.Clear(); cmbAttribute.Text = ""; cmbDesc.Items.Clear(); cmbDesc.Text = ""; cmbName.Items.Clear(); cmbName.Text = ""; for (int i = 0; i < sel.FeatureClass.Fields.FieldCount; i++) { //get name for every field. string fieldName = sel.FeatureClass.Fields.get_Field(i).Name; //and add it to the combobox. Keep the selected one correct if recorded. cmbAttribute.Items.Add(fieldName); cmbDesc.Items.Add(fieldName); cmbName.Items.Add(fieldName); //field name is unique for a table, so this is ok. if (selectedLayer.Field == fieldName) { cmbAttribute.SelectedIndex = i; } if (selectedLayer.DescField == fieldName) { cmbDesc.SelectedIndex = i; } if (selectedLayer.NameField == fieldName) { cmbName.SelectedIndex = i; } } } //check correct button from the properties. switch (selectedLayer.AltitudeMode) { case AltitudeMode.absolute: rbAbsolute.Checked = true; numMultiplier.Value = selectedLayer.Multiplier; numAltitude.Value = selectedLayer.Altitude; break; case AltitudeMode.clampToGround: grpSelAltitude.Visible = false; rbClamp.Checked = true; break; case AltitudeMode.relativeToGround: rbRelative.Checked = true; numAltitude.Value = selectedLayer.Altitude; break; default: break; } }
private void numMultiplier_ValueChanged(object sender, EventArgs e) { LayerProperties selected = cmbLayers.SelectedItem as LayerProperties; selected.Multiplier = (int)numMultiplier.Value; }
private void processLayerProperties(LayerProperties lp, geFolder folder) { if (lp.Layeru is IFeatureLayer) { if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) processPolyLineLayer(lp,folder); if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint) processPointLayer(lp,folder); if ((lp.Layeru as IFeatureLayer).FeatureClass.ShapeType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) processPolygonLayer(lp,folder); } if (lp.Layeru is IRasterLayer) processRasterLayer(lp,folder); }