void IFeatureRenderer.Draw(ESRI.ArcGIS.Geodatabase.IFeatureCursor Cursor, ESRI.ArcGIS.esriSystem.esriDrawPhase DrawPhase, IDisplay Display, ESRI.ArcGIS.esriSystem.ITrackCancel TrackCancel) { // do not draw features if no display if (Display == null) { return; } else { clsSnippet pSnippet = new clsSnippet(); IFeature pFeat = null; intBrksCount = pCSMembers.ClassBrks.Length - 1; ISimpleFillSymbol pSFillSym = new SimpleFillSymbolClass(); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblLineWidth; pOutLines.Color = (IColor)pLineRgb; pFeat = Cursor.NextFeature(); IRgbColor pRGBColor = null; int i = 0; double dblValue = 0; //Start Loop while (pFeat != null) { dblValue = Convert.ToDouble(pFeat.get_Value(intEstIdx)); IFeatureDraw pFeatDraw = (IFeatureDraw)pFeat; pSFillSym = new SimpleFillSymbolClass(); pSFillSym.Outline = pOutLines; pRGBColor = null; for (int j = 0; j < intBrksCount; j++) { if (j == 0) { if (dblValue >= pCSMembers.ClassBrks[0] && dblValue <= pCSMembers.ClassBrks[1]) { pRGBColor = pSnippet.getRGB(pCSMembers.Colors[0, 0], pCSMembers.Colors[0, 1], pCSMembers.Colors[0, 2]); } } else { if (dblValue > pCSMembers.ClassBrks[j] && dblValue <= pCSMembers.ClassBrks[j + 1]) { pRGBColor = pSnippet.getRGB(pCSMembers.Colors[j, 0], pCSMembers.Colors[j, 1], pCSMembers.Colors[j, 2]); } } } pSFillSym.Color = (IColor)pRGBColor; Display.SetSymbol((ISymbol)pSFillSym); pFeatDraw.Draw(esriDrawPhase.esriDPGeography, Display, (ISymbol)pSFillSym, true, null, esriDrawStyle.esriDSNormal); i++; pFeat = Cursor.NextFeature(); } } }
public static CartographicLineSymbol CreateLineSymbol() { Brush b = new SolidColorBrush(Color.FromRgb(0, 150, 255)) { Opacity = 100 }; CartographicLineSymbol _symbol = new CartographicLineSymbol() { Color = b, Width = 4, }; return _symbol; }
private ICartographicLineSymbol CreateCartographicLineSymbol(IRgbColor rgbColor) { if (rgbColor == null) { return(null); } ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbol(); ILineProperties lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; // Here's how to do a template for the pattern of marks and gaps Double[] hpe = new Double[6]; hpe[0] = 0; hpe[1] = 7; hpe[2] = 1; hpe[3] = 1; hpe[4] = 1; hpe[5] = 0; /* hpe[0] = 1; * hpe[1] = 0; * hpe[2] = 1; * hpe[3] = 0; * hpe[4] = 1; * hpe[5] = 0; * hpe[6] = 1; * hpe[7] = 0; * hpe[11] = 0;*/ ITemplate template = new Template(); template.Interval = 1; /* for (Int32 i = 0; i < hpe.Length; i = i + 2) * { * template.AddPatternElement(hpe[i], hpe[i + 1]); * }*/ for (int i = 0; i < 4; i += 2) { template.AddPatternElement(i, 0); } lineProperties.Template = template; // Set the basic and cartographic line properties cartographicLineSymbol.Width = 1; cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSRound; cartographicLineSymbol.Color = rgbColor; return(cartographicLineSymbol); }
//MultilayerFillSymbol private void button17_Click(object sender, EventArgs e) { IMultiLayerFillSymbol multiLayerFillSymbol = new MultiLayerFillSymbolClass(); IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass(); IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass(); algorithcColorRamp.FromColor = getRGB(255, 0, 0); algorithcColorRamp.ToColor = getRGB(0, 255, 0); algorithcColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm; gradientFillSymbol.ColorRamp = algorithcColorRamp; gradientFillSymbol.GradientAngle = 45; gradientFillSymbol.GradientPercentage = 0.9; gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear; ICartographicLineSymbol cartoLine = new CartographicLineSymbol(); cartoLine.Cap = esriLineCapStyle.esriLCSButt; cartoLine.Join = esriLineJoinStyle.esriLJSMitre; cartoLine.Color = getRGB(255, 0, 0); cartoLine.Width = 2; //Create the LineFillSymbo ILineFillSymbol lineFill = new LineFillSymbol(); lineFill.Angle = 45; lineFill.Separation = 10; lineFill.Offset = 5; lineFill.LineSymbol = cartoLine; multiLayerFillSymbol.AddLayer(gradientFillSymbol); multiLayerFillSymbol.AddLayer(lineFill); object Missing = Type.Missing; IPolygon polygon = new PolygonClass(); IPointCollection pointCollection = polygon as IPointCollection; IPoint point = new PointClass(); point.PutCoords(5, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(5, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); polygon.SimplifyPreserveFromTo(); IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(multiLayerFillSymbol as ISymbol); activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry); activeView.ScreenDisplay.FinishDrawing(); }
public static CartographicLineSymbol CreateLineSymbol() { Brush b = new SolidColorBrush(Color.FromRgb(0, 150, 255)) { Opacity = 100 }; CartographicLineSymbol _symbol = new CartographicLineSymbol() { Color = b, Width = 4, }; return(_symbol); }
/// <summary> /// 闪烁地物 /// </summary> /// <param name="pMapControl"></param> /// <param name="pGeometry"></param> public static void FlashGeometry(IMapControl4 pMapControl, IGeometry pGeometry) { ICartographicLineSymbol ipCartographicLineSymbol; ISimpleFillSymbol ipSimpleFillSymbol; ISimpleMarkerSymbol ipSimpleMarkersymbol; ISymbol ipSymbol = null; IRgbColor ipColor; int Size; ipColor = new RgbColor(); ipColor.Blue = 255; Size = 2; esriGeometryType type = pGeometry.GeometryType; if (type == esriGeometryType.esriGeometryPolyline) { ipCartographicLineSymbol = new CartographicLineSymbol(); ipSymbol = (ISymbol)ipCartographicLineSymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipCartographicLineSymbol.Width = Size; ipCartographicLineSymbol.Color = ipColor; ipCartographicLineSymbol.Cap = esriLineCapStyle.esriLCSRound; } else if (type == esriGeometryType.esriGeometryPolygon) { ipSimpleFillSymbol = new SimpleFillSymbol(); ipSymbol = (ISymbol)ipSimpleFillSymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipColor.Red = 0; ipColor.Blue = 255; ipColor.Green = 0; ipSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; ipSimpleFillSymbol.Color = ipColor; } else if (type == esriGeometryType.esriGeometryPoint || type == esriGeometryType.esriGeometryMultipoint) { ipSimpleMarkersymbol = new SimpleMarkerSymbol(); ipSymbol = (ISymbol)ipSimpleMarkersymbol; ipSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ipSimpleMarkersymbol.Color = ipColor; ipSimpleMarkersymbol.Size = 8; } pMapControl.FlashShape(pGeometry, 2, 100, ipSymbol); }
public static ILineSymbol CreateLineDirectionSymbol() { ILineSymbol symbol = new CartographicLineSymbol(); symbol.Color = ColorHelper.CreateColor(0, 0, 200); LineDecoration class2 = new LineDecoration(); SimpleLineDecorationElement lineDecorationElement = new SimpleLineDecorationElement(); lineDecorationElement.AddPosition(0.3); lineDecorationElement.AddPosition(0.7); lineDecorationElement.PositionAsRatio = true; IMarkerSymbol symbol2 = (lineDecorationElement.MarkerSymbol as IClone).Clone() as IMarkerSymbol; symbol2.Size = 9.0; symbol2.Color = ColorHelper.CreateColor(0, 200, 0); lineDecorationElement.MarkerSymbol = symbol2; class2.AddElement(lineDecorationElement); (symbol as ILineProperties).LineDecoration = class2; return(symbol); }
/// <summary> /// Initializes tool with map control. /// </summary> /// <param name="mapControl">Parent map control.</param> public void Initialize(MapControl mapControl) { _mapControl = mapControl; _cursor = Cursors.Cross; CartographicLineSymbol simpleLineSymbol = new CartographicLineSymbol() { Color = new SolidColorBrush(Colors.Blue), Width = 2 }; SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol() { BorderThickness = 1, BorderBrush = new System.Windows.Media.SolidColorBrush(Colors.Black), Fill = new SolidColorBrush(Color.FromArgb(128, 128, 128, 128)) }; _polygonDrawObject = new Draw(mapControl.map); _polygonDrawObject.LineSymbol = simpleLineSymbol; _polygonDrawObject.FillSymbol = simpleFillSymbol; _polygonDrawObject.DrawComplete += _PolygonDrawComplete; _polygonDrawObject.DrawMode = DrawMode.Polygon; }
//LineFillSymbol private void button13_Click(object sender, EventArgs e) { ICartographicLineSymbol cartoLine = new CartographicLineSymbol(); cartoLine.Cap = esriLineCapStyle.esriLCSButt; cartoLine.Join = esriLineJoinStyle.esriLJSMitre; cartoLine.Color = getRGB(255, 0, 0); cartoLine.Width = 2; //Create the LineFillSymbo ILineFillSymbol lineFill = new LineFillSymbol(); lineFill.Angle = 45; lineFill.Separation = 10; lineFill.Offset = 5; lineFill.LineSymbol = cartoLine; object Missing = Type.Missing; IPolygon polygon = new PolygonClass(); IPointCollection pointCollection = polygon as IPointCollection; IPoint point = new PointClass(); point.PutCoords(5, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(5, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); polygon.SimplifyPreserveFromTo(); IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(lineFill as ISymbol); activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry); activeView.ScreenDisplay.FinishDrawing(); }
protected override void OnClick() { // Create two points. IPoint fromPoint = new Point(); fromPoint.PutCoords(1300757, 554219); IPoint toPoint = new Point(); toPoint.PutCoords(1300759, 554217); // Note: Spatial Reference = NAD_1983_StatePlane_Washington_North_FIPS_4601_Feet // ****** No Need to go through IPointCollection **** //// Add the points to a point collection //object missing = Type.Missing; //IPointCollection pointCollection = new Multipoint(); //pointCollection.AddPoint(fromPoint, ref missing, ref missing); //pointCollection.AddPoint(toPoint, ref missing, ref missing); // ****** No Need to go through IPointCollection **** // Get a reference to a feature class from ArcMap IMap map = ArcMap.Document.ActiveView as IMap; ILayer layer = map.get_Layer(0); IFeatureLayer featureLayer = layer as FeatureLayer; IFeatureClass featureClass = featureLayer.FeatureClass; IFeature feature = featureClass.CreateFeature(); IPolyline polyline = new PolylineClass(); polyline.FromPoint = fromPoint; polyline.ToPoint = toPoint; //IPolyline polyline = pointCollection as IPolyline; // This leads to a null polyline feature.Shape = polyline as IGeometry; feature.Store(); // ---- Symbolize the polyline with the ArrorMarker at both ends of the line ----------- // See: http://resources.arcgis.com/en/help/arcobjects-net/conceptualhelp/index.html#//0001000008w8000000 ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbol(); // the line color will be red IRgbColor ipRgbRedColor = new RgbColorClass(); ipRgbRedColor.Red = 192; // the arrow will be black IRgbColor ipRgbBlackColor = new RgbColorClass(); ipRgbBlackColor.RGB = 0; // set up the arrow that will be displayed along the line IArrowMarkerSymbol ipArrowMarker = new ArrowMarkerSymbolClass(); ipArrowMarker.Style = esriArrowMarkerStyle.esriAMSPlain; ipArrowMarker.Length = 18; ipArrowMarker.Width = 12; ipArrowMarker.Color = ipRgbBlackColor; // set up the line itself ipArrowLineSymbol.Width = 4; ipArrowLineSymbol.Color = ipRgbRedColor; // decorate the line with the arrow symbol ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass(); ipSimpleLineDecorationElement.Rotate = true; ipSimpleLineDecorationElement.PositionAsRatio = true; ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker; ipSimpleLineDecorationElement.AddPosition(0.0); ipSimpleLineDecorationElement.AddPosition(1.0); ipSimpleLineDecorationElement.FlipFirst = true; ILineDecoration ipLineDecoration = new LineDecorationClass(); ipLineDecoration.AddElement(ipSimpleLineDecorationElement); ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration; // Create renderer and apply it to the layer ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = ipArrowLineSymbol as ISymbol; IGeoFeatureLayer geoFeatureLayer = featureLayer as IGeoFeatureLayer; geoFeatureLayer.Renderer = simpleRenderer as IFeatureRenderer; IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument; mxDocument.ActiveView.Refresh(); mxDocument.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFeatureLayer, mxDocument.ActiveView.Extent); mxDocument.UpdateContents(); // ---- Symbolize the polyline with the ArrorMarker at both ends of the line ----------- ArcMap.Application.CurrentTool = null; }
private static LineSymbol cloneLineSymbol(LineSymbol lineSymbol) { if (lineSymbol == null) { return(null); } ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol mappingSimpleLineSymbol = lineSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol; if (mappingSimpleLineSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol ls = new ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol() { Color = CloneBrush(mappingSimpleLineSymbol.Color), ControlTemplate = mappingSimpleLineSymbol.ControlTemplate, SelectionColor = CloneBrush(mappingSimpleLineSymbol.SelectionColor), Width = mappingSimpleLineSymbol.Width, }; return(ls); } SimpleLineSymbol simpleLineSymbol = lineSymbol as SimpleLineSymbol; if (simpleLineSymbol != null) { SimpleLineSymbol ls = new SimpleLineSymbol() { Color = CloneBrush(simpleLineSymbol.Color), ControlTemplate = simpleLineSymbol.ControlTemplate, Style = simpleLineSymbol.Style, Width = simpleLineSymbol.Width, }; return(ls); } CartographicLineSymbol cLineSymbol = lineSymbol as CartographicLineSymbol; if (cLineSymbol != null) { CartographicLineSymbol cs = new CartographicLineSymbol() { Color = CloneBrush(cLineSymbol.Color), ControlTemplate = cLineSymbol.ControlTemplate, DashArray = cLineSymbol.DashArray, DashCap = cLineSymbol.DashCap, DashOffset = cLineSymbol.DashOffset, EndLineCap = cLineSymbol.EndLineCap, LineJoin = cLineSymbol.LineJoin, MiterLimit = cLineSymbol.MiterLimit, StartLineCap = cLineSymbol.StartLineCap, Width = cLineSymbol.Width, }; return(cs); } LineSymbol l = new LineSymbol() { Color = CloneBrush(lineSymbol.Color), ControlTemplate = lineSymbol.ControlTemplate, Width = lineSymbol.Width, }; return(l); }
private void btnApply_Click(object sender, EventArgs e) { try { string strLayerName = cboSourceLayer.Text; if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "") { MessageBox.Show("Assign proper layer and field"); return; } int intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName); ILayer pLayer = mForm.axMapControl1.get_Layer(intLIndex); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFClass = pFLayer.FeatureClass; //Create Rendering of Mean Value at Target Layer int intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value); string strGCRenderField = cboValueField.Text; IGeoFeatureLayer pGeofeatureLayer; if (chkNewLayer.Checked == true) { IFeatureLayer pflOutput = new FeatureLayerClass(); pflOutput.FeatureClass = pFClass; pflOutput.Name = txtNewLayer.Text; pflOutput.Visible = true; pGeofeatureLayer = (IGeoFeatureLayer)pflOutput; } else { pGeofeatureLayer = (IGeoFeatureLayer)pFLayer; } ITable pTable = (ITable)pFClass; IClassifyGEN pClassifyGEN; switch (cboGCClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } //Need to be changed 1/29/15 ITableHistogram pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strGCRenderField; pTableHistogram.Table = pTable; IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram; object xVals, frqs; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount); ClassBreaksRenderer pRender = new ClassBreaksRenderer(); double[] cb = (double[])pClassifyGEN.ClassBreaks; pRender.Field = strGCRenderField; pRender.BreakCount = intGCBreakeCount; pRender.MinimumBreak = cb[0]; //' create our color ramp IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass(); pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm; IRgbColor pColor1 = new RgbColor(); IRgbColor pColor2 = new RgbColor(); //Can Change the color in here! pColor1.Red = picSymolfrom.BackColor.R; pColor1.Green = picSymolfrom.BackColor.G; pColor1.Blue = picSymolfrom.BackColor.B; Boolean blnOK = true; pColor2.Red = picSymbolTo.BackColor.R; pColor2.Green = picSymbolTo.BackColor.G; pColor2.Blue = picSymbolTo.BackColor.B; pColorRamp.FromColor = pColor1; pColorRamp.ToColor = pColor2; pColorRamp.Size = intGCBreakeCount; pColorRamp.CreateRamp(out blnOK); IEnumColors pEnumColors = pColorRamp.Colors; pEnumColors.Reset(); IRgbColor pColorOutline = new RgbColor(); //Can Change the color in here! pColorOutline.Red = picGCLineColor.BackColor.R; pColorOutline.Green = picGCLineColor.BackColor.G; pColorOutline.Blue = picGCLineColor.BackColor.B; double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblGCOutlineSize; pOutLines.Color = (IColor)pColorOutline; //' use this interface to set dialog properties IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender; pUIProperties.ColorRamp = "Custom"; ISimpleFillSymbol pSimpleFillSym; //' be careful, indices are different for the diff lists for (int j = 0; j < intGCBreakeCount; j++) { pRender.Break[j] = cb[j + 1]; pRender.Label[j] = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString(); pUIProperties.LowBreak[j] = cb[j]; pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = pEnumColors.Next(); pSimpleFillSym.Outline = pOutLines; pRender.Symbol[j] = (ISymbol)pSimpleFillSym; } pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender; if (chkNewLayer.Checked == true) { mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer); } ////* Uncertainty Part *//// //Declare variables in if parts if (tcUncern.SelectedIndex == 0) //Graduated Color { int intUncernBreakCount = Convert.ToInt32(nudCoNClasses.Value); string strUncerFieldName = cboUField.Text; IFeatureLayer pflUncern = new FeatureLayerClass(); pflUncern.FeatureClass = pFClass; pflUncern.Name = cboSourceLayer.Text + " Uncertainty"; pflUncern.Visible = true; IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern; switch (cboTeClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } //Need to be changed 1/29/15 pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strUncerFieldName; pTableHistogram.Table = pTable; pHistogram = (IBasicHistogram)pTableHistogram; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount); pRender = new ClassBreaksRenderer(); cb = (double[])pClassifyGEN.ClassBreaks; pRender.Field = strUncerFieldName; pRender.BreakCount = intUncernBreakCount; pRender.MinimumBreak = cb[0]; IClassBreaksUIProperties pUIColProperties = (IClassBreaksUIProperties)pRender; pUIColProperties.ColorRamp = "Custom"; pColorRamp = new AlgorithmicColorRampClass(); pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm; pColor1 = new RgbColor(); pColor2 = new RgbColor(); //Can Change the color in here! pColor1 = pSnippet.getRGB(picCoColorFrom.BackColor.R, picCoColorFrom.BackColor.G, picCoColorFrom.BackColor.B); pColor2 = pSnippet.getRGB(picCoColorTo.BackColor.R, picCoColorTo.BackColor.G, picCoColorTo.BackColor.B); if (pColor1 == null || pColor2 == null) { return; } blnOK = true; pColorRamp.FromColor = pColor1; pColorRamp.ToColor = pColor2; pColorRamp.Size = intUncernBreakCount; pColorRamp.CreateRamp(out blnOK); pEnumColors = pColorRamp.Colors; pEnumColors.Reset(); pColorOutline = pSnippet.getRGB(picCoLineColor.BackColor.R, picCoLineColor.BackColor.G, picCoLineColor.BackColor.B); if (pColorOutline == null) { return; } double dblCoOutlineSize = Convert.ToDouble(nudCoLinewidth.Value); pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblCoOutlineSize; pOutLines.Color = (IColor)pColorOutline; //' use this interface to set dialog properties pUIColProperties = (IClassBreaksUIProperties)pRender; pUIColProperties.ColorRamp = "Custom"; ISimpleMarkerSymbol pSimpleMarkerSym; double dblCoSymSize = Convert.ToDouble(nudCoSymbolSize.Value); //' be careful, indices are different for the diff lists for (int j = 0; j < intUncernBreakCount; j++) { pRender.Break[j] = cb[j + 1]; pRender.Label[j] = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString(); pUIColProperties.LowBreak[j] = cb[j]; pSimpleMarkerSym = new SimpleMarkerSymbolClass(); pSimpleMarkerSym.Size = dblCoSymSize; pSimpleMarkerSym.Color = pEnumColors.Next(); pSimpleMarkerSym.Outline = true; pSimpleMarkerSym.OutlineColor = pColorOutline; pSimpleMarkerSym.OutlineSize = dblCoOutlineSize; pRender.Symbol[j] = (ISymbol)pSimpleMarkerSym; } pGFLUncern.Renderer = (IFeatureRenderer)pRender; mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern); } else if (tcUncern.SelectedIndex == 1) //Texture { //Create Rendering of Uncertainty at Target Layer int intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value); string strUncerFieldName = cboUField.Text; IFeatureLayer pflUncern = new FeatureLayerClass(); pflUncern.FeatureClass = pFClass; pflUncern.Name = cboSourceLayer.Text + " Uncertainty"; pflUncern.Visible = true; IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern; switch (cboTeClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } //Need to be changed 1/29/15 pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strUncerFieldName; pTableHistogram.Table = pTable; pHistogram = (IBasicHistogram)pTableHistogram; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intUncernBreakCount); pRender = new ClassBreaksRenderer(); cb = (double[])pClassifyGEN.ClassBreaks; pRender.Field = strUncerFieldName; pRender.BreakCount = intUncernBreakCount; pRender.MinimumBreak = cb[0]; IClassBreaksUIProperties pUITexProperties = (IClassBreaksUIProperties)pRender; pUITexProperties.ColorRamp = "Custom"; ILineFillSymbol pLineFillSym = new LineFillSymbolClass(); double dblFromSep = Convert.ToDouble(nudSeperationFrom.Value); double dblToSep = Convert.ToDouble(nudSeperationTo.Value); double dblInstantSep = (dblFromSep - dblToSep) / Convert.ToDouble(intUncernBreakCount - 1); double dblFromAngle = Convert.ToDouble(nudAngleFrom.Value); double dblToAngle = Convert.ToDouble(nudAngleFrom.Value); // Remove the angle part (04/16) double dblInstantAngle = (dblToAngle - dblFromAngle) / Convert.ToDouble(intUncernBreakCount - 1); double dblLinewidth = Convert.ToDouble(nudTeLinewidth.Value); IRgbColor pLineColor = new RgbColor(); pLineColor.Red = picTeLineColor.BackColor.R; pLineColor.Green = picTeLineColor.BackColor.G; pLineColor.Blue = picTeLineColor.BackColor.B; //' be careful, indices are different for the diff lists for (int j = 0; j < intUncernBreakCount; j++) { pRender.Break[j] = cb[j + 1]; pRender.Label[j] = Math.Round(cb[j], 5).ToString() + " - " + Math.Round(cb[j + 1], 5).ToString(); pUITexProperties.LowBreak[j] = cb[j]; pLineFillSym = new LineFillSymbolClass(); pLineFillSym.Angle = dblFromAngle + (dblInstantAngle * Convert.ToDouble(j)); pLineFillSym.Color = pLineColor; pLineFillSym.Separation = dblFromSep - (dblInstantSep * Convert.ToDouble(j)); pLineFillSym.LineSymbol.Width = dblLinewidth; pRender.Symbol[j] = (ISymbol)pLineFillSym; } pGFLUncern.Renderer = (IFeatureRenderer)pRender; mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern); } else if (tcUncern.SelectedIndex == 2) //For Proportional Symbols { string strUncerFieldName = cboUField.Text; double dblMinPtSize = Convert.ToDouble(nudProSymbolSize.Value); double dblLineWidth = Convert.ToDouble(nudProLinewidth.Value); IFeatureLayer pflUncern = new FeatureLayerClass(); pflUncern.FeatureClass = pFClass; pflUncern.Name = cboSourceLayer.Text + " Uncertainty"; pflUncern.Visible = true; //Find Fields int intUncernIdx = pTable.FindField(strUncerFieldName); //Find Min value //Set to initial value for min IField pUncernField = pTable.Fields.get_Field(intUncernIdx); ICursor pCursor = pTable.Search(null, false); IDataStatistics pDataStat = new DataStatisticsClass(); pDataStat.Field = pUncernField.Name; pDataStat.Cursor = pCursor; IStatisticsResults pStatResults = pDataStat.Statistics; double dblMinValue = pStatResults.Minimum; double dblMaxValue = pStatResults.Maximum; pCursor.Flush(); IRgbColor pSymbolRgb = pSnippet.getRGB(picProSymbolColor.BackColor.R, picProSymbolColor.BackColor.G, picProSymbolColor.BackColor.B); if (pSymbolRgb == null) { return; } IRgbColor pLineRgb = pSnippet.getRGB(picProiLineColor.BackColor.R, picProiLineColor.BackColor.G, picProiLineColor.BackColor.B); if (pLineRgb == null) { return; } ISimpleMarkerSymbol pSMarkerSym = new SimpleMarkerSymbolClass(); pSMarkerSym.Style = esriSimpleMarkerStyle.esriSMSCircle; pSMarkerSym.Size = dblMinPtSize; pSMarkerSym.OutlineSize = dblLineWidth; pSMarkerSym.Outline = true; pSMarkerSym.OutlineColor = (IColor)pLineRgb; pSMarkerSym.Color = (IColor)pSymbolRgb; IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern; IProportionalSymbolRenderer pUncernRender = new ProportionalSymbolRendererClass(); pUncernRender.LegendSymbolCount = 2; //Need to be changed 0219 pUncernRender.Field = strUncerFieldName; pUncernRender.MaxDataValue = dblMaxValue; pUncernRender.MinDataValue = dblMinValue; pUncernRender.MinSymbol = (ISymbol)pSMarkerSym; pUncernRender.ValueUnit = esriUnits.esriUnknownUnits; pUncernRender.BackgroundSymbol = null; pUncernRender.CreateLegendSymbols(); pGFLUncern.Renderer = (IFeatureRenderer)pUncernRender; mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern); } else if (tcUncern.SelectedIndex == 3) // Bar { string strUncerFieldName = cboUField.Text; double dblMaxLength = Convert.ToDouble(nudMaxBarHeight.Value); double dblBarWidth = Convert.ToDouble(nudBarWidth.Value); IFeatureLayer pflUncern = new FeatureLayerClass(); pflUncern.FeatureClass = pFClass; pflUncern.Name = cboSourceLayer.Text + " Uncertainty"; pflUncern.Visible = true; int intUncernIdx = pTable.FindField(strUncerFieldName); IField pUncernField = pTable.Fields.get_Field(intUncernIdx); ICursor pCursor = pTable.Search(null, false); IDataStatistics pDataStat = new DataStatisticsClass(); pDataStat.Field = pUncernField.Name; pDataStat.Cursor = pCursor; IStatisticsResults pStatResults = pDataStat.Statistics; double dblMaxValue = pStatResults.Maximum; pCursor.Flush(); IChartRenderer chartRenderer = new ChartRendererClass(); IRendererFields rendererFields = chartRenderer as IRendererFields; rendererFields.AddField(strUncerFieldName); IBarChartSymbol barChartSymbol = new BarChartSymbolClass(); barChartSymbol.Width = dblBarWidth; IMarkerSymbol markerSymbol = barChartSymbol as IMarkerSymbol; markerSymbol.Size = dblMaxLength; IChartSymbol chartSymbol = barChartSymbol as IChartSymbol; chartSymbol.MaxValue = dblMaxValue; ISymbolArray symbolArray = barChartSymbol as ISymbolArray; IFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B); if (fillSymbol.Color == null) { return; } symbolArray.AddSymbol(fillSymbol as ISymbol); if (chk3D.Checked) { I3DChartSymbol p3DChartSymbol = barChartSymbol as I3DChartSymbol; p3DChartSymbol.Display3D = true; p3DChartSymbol.Thickness = 3; } chartRenderer.ChartSymbol = barChartSymbol as IChartSymbol; SimpleFillSymbol pBaseFillSym = new SimpleFillSymbolClass(); //pBaseFillSym.Color = pSnippet.getRGB(picBarSymCol.BackColor.R, picBarSymCol.BackColor.G, picBarSymCol.BackColor.B); //chartRenderer.BaseSymbol = pBaseFillSym as ISymbol; chartRenderer.UseOverposter = false; chartRenderer.CreateLegend(); IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern; pGFLUncern.Renderer = (IFeatureRenderer)chartRenderer; mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGFLUncern); } #region illumination //This function is not applied in this version. 032317 HK //} // else if (tcUncern.SelectedIndex == 4) //illumination // { // frmProgress pfrmProgress = new frmProgress(); // pfrmProgress.lblStatus.Text = "Processing:"; // pfrmProgress.pgbProgress.Style = ProgressBarStyle.Marquee; // pfrmProgress.Show(); // string strUncerFieldName = cboUField.Text; // IGeoDataset geoDataset_output = createRasterfromPolygon(pFClass, strUncerFieldName, pFLayer, 100); // double altitude = Convert.ToDouble(nudAltitude.Value); // double azimuth = Convert.ToDouble(nudAzimuth.Value); // object zFactor = Convert.ToDouble(nudZFactor.Value); // ISurfaceOp2 pSurfOP = new RasterSurfaceOpClass(); // IRaster pOutputDS = (IRaster)pSurfOP.HillShade(geoDataset_output, azimuth, altitude, true, ref zFactor); // ((IDataset)geoDataset_output).Delete(); // // Create a raster for viewing // ESRI.ArcGIS.Carto.IRasterLayer rasterLayer = new ESRI.ArcGIS.Carto.RasterLayerClass(); // rasterLayer.CreateFromRaster(pOutputDS); // //Calculate hillshade value at slope 0 to set as background value // double dblRadian = (Math.PI / 180) * (90 - altitude); // double dblBackValue = Math.Truncate(255 * Math.Cos(dblRadian)); // IRasterStretch pRasterStretch = new RasterStretchColorRampRendererClass(); // IColor pColor = new RgbColorClass(); // pColor.NullColor = true; // pColor.Transparency = 0; // pRasterStretch.Background = true; // pRasterStretch.BackgroundColor = pColor; // pRasterStretch.set_BackgroundValues(ref dblBackValue); // rasterLayer.Name = "Uncertainty of " + strGCRenderField; // rasterLayer.Renderer = pRasterStretch as IRasterRenderer; // rasterLayer.Renderer.Update(); // //Apply Transparency // ILayerEffects pLayerEffect = (ILayerEffects)rasterLayer; // pLayerEffect.Transparency = Convert.ToInt16(nudTransparent.Value); // pfrmProgress.Close(); // // Add the raster to the map // pActiveView.FocusMap.AddLayer(rasterLayer); // } // mForm.axMapControl1.ActiveView.Refresh(); // mForm.axTOCControl1.Update(); #endregion } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
private void DrawingChoroplethmap(IFeatureLayer pFLayer, string strRenderField, decimal NClasses) { IFeatureClass pFClass = pFLayer.FeatureClass; //Create Rendering of Mean Value at Target Layer int intGCBreakeCount = Convert.ToInt32(NClasses); IGeoFeatureLayer pGeofeatureLayer; IFeatureLayer pflOutput = new FeatureLayerClass(); pflOutput.FeatureClass = pFClass; pflOutput.Name = strRenderField; pflOutput.Visible = true; pGeofeatureLayer = (IGeoFeatureLayer)pflOutput; ITable pTable = (ITable)pFClass; IClassifyGEN pClassifyGEN; switch (cboGCClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } ITableHistogram pTableHistogram = new TableHistogramClass(); pTableHistogram.Field = strRenderField; pTableHistogram.Table = pTable; IHistogram pHistogram = (IHistogram)pTableHistogram; object xVals, frqs; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount); ClassBreaksRenderer pRender = new ClassBreaksRenderer(); double[] cb = (double[])pClassifyGEN.ClassBreaks; pRender.Field = strRenderField; pRender.BreakCount = intGCBreakeCount; pRender.MinimumBreak = cb[0]; string strColorRamp = cboColorRamp.Text; IEnumColors pEnumColors = MultiPartColorRamp(strColorRamp, intGCBreakeCount); pEnumColors.Reset(); IRgbColor pColorOutline = new RgbColor(); //Can Change the color in here! pColorOutline.Red = picGCLineColor.BackColor.R; pColorOutline.Green = picGCLineColor.BackColor.G; pColorOutline.Blue = picGCLineColor.BackColor.B; double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblGCOutlineSize; pOutLines.Color = (IColor)pColorOutline; //' use this interface to set dialog properties IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender; pUIProperties.ColorRamp = "Custom"; ISimpleFillSymbol pSimpleFillSym; //' be careful, indices are different for the diff lists for (int j = 0; j < intGCBreakeCount; j++) { pRender.Break[j] = cb[j + 1]; pRender.Label[j] = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString(); pUIProperties.LowBreak[j] = cb[j]; pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = pEnumColors.Next(); pSimpleFillSym.Outline = pOutLines; pRender.Symbol[j] = (ISymbol)pSimpleFillSym; } pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender; mForm.axMapControl1.ActiveView.FocusMap.AddLayer(pGeofeatureLayer); }
private void DrawCCMaps() { m_intClassNumber = Convert.ToInt32(nudGCNClasses.Value); IFeatureClass pFClass = pFLayer.FeatureClass; //Determine Class Breaks for variable int intValueFldIdx = pFClass.FindField(strVarFldName); ITable pTable = (ITable)pFClass; IClassifyGEN pClassifyGEN = null; switch (cboGCClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } ITableHistogram pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strVarFldName; pTableHistogram.Table = pTable; //IHistogram pHistogram = (IHistogram)pTableHistogram2; IBasicHistogram pHistogram = (IBasicHistogram)pTableHistogram; ////Not working in ArcGIS 10.5 022417 HK //ITableHistogram pTableHistogram = new TableHistogramClass(); //pTableHistogram.Field = strVarFldName; //pTableHistogram.Table = pTable; //IHistogram pHistogram = (IHistogram)pTableHistogram; object xVals, frqs; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, m_intClassNumber); double[] cb = (double[])pClassifyGEN.ClassBreaks; //Class Determinations for vertical and horizontal axis if (m_VerticalBreaks == null) { pClassifyGEN = new QuantileClass(); //Using Quatile pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strVerConFldName; pTableHistogram.Table = pTable; pHistogram = (IBasicHistogram)pTableHistogram; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intVerCnt); m_VerticalBreaks = (double[])pClassifyGEN.ClassBreaks; } if (m_HorizontalBreaks == null) { pClassifyGEN = new QuantileClass(); //Using Quatile pTableHistogram = new BasicTableHistogramClass(); pTableHistogram.Field = strHorConFldName; pTableHistogram.Table = pTable; pHistogram = (IBasicHistogram)pTableHistogram; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intHorCnt); m_HorizontalBreaks = (double[])pClassifyGEN.ClassBreaks; } //Create Renderer IClassBreaksRenderer pRender = new ClassBreaksRenderer(); pRender.Field = strVarFldName; pRender.BreakCount = m_intClassNumber; pRender.MinimumBreak = cb[0]; string strColorRamp = cboColorRamp.Text; IEnumColors pEnumColors = MultiPartColorRamp(strColorRamp, "CIE Lab", m_intClassNumber); pEnumColors.Reset(); int[,] arrColors = new int[m_intClassNumber, 3]; for (int k = 0; k < m_intClassNumber; k++) { IColor pColor = pEnumColors.Next(); IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.RGB = pColor.RGB; arrColors[k, 0] = pRGBColor.Red; arrColors[k, 1] = pRGBColor.Green; arrColors[k, 2] = pRGBColor.Blue; } pEnumColors.Reset(); IRgbColor pColorOutline = new RgbColor(); //Can Change the color in here! pColorOutline = m_pSnippet.getRGB(picOutlineColor.BackColor.R, picOutlineColor.BackColor.G, picOutlineColor.BackColor.B); double dblGCOutlineSize = Convert.ToDouble(nudOutlinewidth.Value); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblGCOutlineSize; pOutLines.Color = (IColor)pColorOutline; //' use this interface to set dialog properties IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender; pUIProperties.ColorRamp = "Custom"; ISimpleFillSymbol pSimpleFillSym; pEnumColors.Reset(); double dblAdding = Math.Pow(0.1, m_intRounding); for (int j = 0; j < m_intClassNumber; j++) { pRender.Break[j] = cb[j + 1]; if (j == 0) { pRender.Label[j] = Math.Round(cb[j], m_intRounding).ToString("N" + m_intRounding.ToString()) + " - " + Math.Round(cb[j + 1], 2).ToString("N" + m_intRounding.ToString()); } else { pRender.Label[j] = Math.Round(cb[j] + dblAdding, m_intRounding).ToString("N" + m_intRounding.ToString()) + " - " + Math.Round(cb[j + 1], 2).ToString("N" + m_intRounding.ToString()); } pUIProperties.LowBreak[j] = cb[j]; pSimpleFillSym = new SimpleFillSymbolClass(); IRgbColor pRGBColor = m_pSnippet.getRGB(arrColors[j, 0], arrColors[j, 1], arrColors[j, 2]); pSimpleFillSym.Color = (IColor)pRGBColor; pSimpleFillSym.Outline = pOutLines; pRender.Symbol[j] = (ISymbol)pSimpleFillSym; } //Background Layer ISimpleRenderer pSimpleRender = new SimpleRendererClass(); ISimpleFillSymbol pBGSymbol = new SimpleFillSymbolClass(); pBGSymbol.Color = (IColor)m_pSnippet.getRGB(picBGColor.BackColor.R, picBGColor.BackColor.G, picBGColor.BackColor.B); ICartographicLineSymbol pBGOutLines = new CartographicLineSymbol(); pBGOutLines.Width = 0; pBGOutLines.Color = m_pSnippet.getRGB(255, 255, 255); pBGSymbol.Outline = pBGOutLines; pSimpleRender.Symbol = (ISymbol)pBGSymbol; IFeatureLayer pflBG = new FeatureLayerClass(); pflBG.FeatureClass = pFClass; IGeoFeatureLayer pGeoBG = (IGeoFeatureLayer)pflBG; pGeoBG.Renderer = (IFeatureRenderer)pSimpleRender; pGeoBG.Selectable = false; //Feature Count for each map m_intsFeatureCnts = new int[intVerCnt * intHorCnt]; int l = 0; for (int i = 0; i < intVerCnt; i++) { for (int j = 0; j < intHorCnt; j++) { IFeatureLayer pflOutput = new FeatureLayerClass(); pflOutput.FeatureClass = pFClass; IGeoFeatureLayer pGeofeatureLayer = (IGeoFeatureLayer)pflOutput; pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender; IFeatureLayerDefinition2 pFDefinition = (IFeatureLayerDefinition2)pGeofeatureLayer; string strWhereClause = null; if (i == 0 && j == 0) { strWhereClause = strVerConFldName + " >= " + m_VerticalBreaks[i].ToString() + " AND " + strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " + strHorConFldName + " >= " + m_HorizontalBreaks[j].ToString() + " AND " + strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString(); } else if (i != 0 && j == 0) { strWhereClause = strVerConFldName + " > " + m_VerticalBreaks[i].ToString() + " AND " + strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " + strHorConFldName + " >= " + m_HorizontalBreaks[j].ToString() + " AND " + strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString(); } else if (i == 0 && j != 0) { strWhereClause = strVerConFldName + " >= " + m_VerticalBreaks[i].ToString() + " AND " + strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " + strHorConFldName + " > " + m_HorizontalBreaks[j].ToString() + " AND " + strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString(); } else { strWhereClause = strVerConFldName + " > " + m_VerticalBreaks[i].ToString() + " AND " + strVerConFldName + " <= " + m_VerticalBreaks[i + 1].ToString() + " AND " + strHorConFldName + " > " + m_HorizontalBreaks[j].ToString() + " AND " + strHorConFldName + " <= " + m_HorizontalBreaks[j + 1].ToString(); } pFDefinition.DefinitionExpression = strWhereClause; IQueryFilter pQfilter = new QueryFilterClass(); pQfilter.WhereClause = strWhereClause; m_intsFeatureCnts[l] = pGeofeatureLayer.FeatureClass.FeatureCount(pQfilter); m_axMapControls[l].ActiveView.FocusMap.ClearLayers(); m_axMapControls[l].ActiveView.FocusMap.AddLayer(pGeoBG); m_axMapControls[l].ActiveView.FocusMap.AddLayer(pGeofeatureLayer); m_axMapControls[l].ActiveView.Extent = m_axMapControls[l].ActiveView.FullExtent; m_axMapControls[l].ActiveView.Refresh(); l++; } } lblVariable.Text = "Selected Variable: " + strVarFldName; UpdateRange(lvSymbol, m_intClassNumber, cb, arrColors, m_intRounding); if (m_blnAddBoxes) { UpdateTextBoxes(); } else { AddTextBoxes(); } UpdateLabels(); UpdateHorVerLabels(); }
/// <summary> /// 带箭头的线段 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="fillColor"></param> public static void TrackLine(IPoint start, IPoint end, Color fillColor) { //将线段打断生成两条线段 以实现线段中间箭头显示 IPoint middle = new PointClass(); middle.PutCoords((end.X + start.X) / 2, (end.Y + start.Y) / 2); IActiveView pActiveView = Program.myMap.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; IPolyline pLine = new PolylineClass(); IPolyline pLine1 = new PolylineClass(); pLine.FromPoint = start; pLine.ToPoint = middle; pLine1.FromPoint = middle; pLine1.ToPoint = end; pLine.Project(pActiveView.FocusMap.SpatialReference); pLine1.Project(pActiveView.FocusMap.SpatialReference); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbol(); pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecoration(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElement(); pSimpleLineDecoElem.AddPosition(1); IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbol(); pArrowMarkerSym.Size = 12; pArrowMarkerSym.Color = GetColor(fillColor.R, fillColor.G, fillColor.B); pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol; pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; pLineSymbol.Color = GetColor(fillColor.R, fillColor.G, fillColor.B);; pLineSymbol.Width = 2; ILineElement pLineElem = new LineElementClass(); ILineElement pLineElem1 = new LineElementClass(); pLineElem.Symbol = pLineSymbol; pLineElem1.Symbol = pLineSymbol; IElement pElem = pLineElem as IElement; IElement pElem1 = pLineElem1 as IElement; pElem.Geometry = pLine; pElem1.Geometry = pLine1; pGraphicsContainer.AddElement(pElem, 0); pGraphicsContainer.AddElement(pElem1, 0); pActiveView.Refresh(); }
private void btnRender_Click(object sender, EventArgs e) { IGeoFeatureLayer geoLayer = GetLayerByName(cboLayer.Text); MessageBox.Show(geoLayer.FeatureClass.ShapeType.ToString()); switch (m_strOption) { // case "Simple": IRgbColor rgbColor = new RgbColor(); rgbColor.Red = Convert.ToInt32(cboRed.Text); rgbColor.Green = Convert.ToInt32(cboGreen.Text); rgbColor.Blue = Convert.ToInt32(cboGreen.Text); //only used to Polygon Layer ISymbol sym = null; //Acording the shape type, use different sympol if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { //Polygon Feature //Orginate Code // ISimpleFillSymbol fillSym = new SimpleFillSymbol() ; //sym.style // fillSym.Style = esriSimpleFillStyle.esriSFSSolid; //sym.color // fillSym.Color = rgbColor; //new Code for IGradientFillSymbol by jin IGradientFillSymbol fillSym = new GradientFillSymbol(); fillSym.Style = esriGradientFillStyle.esriGFSBuffered; IRgbColor fromColor = new RgbColor(); fromColor.Red = 255; fromColor.Green = 0; fromColor.Blue = 0; IRgbColor toColor = new RgbColor(); toColor.Red = 0; toColor.Green = 0; toColor.Blue = 255; IAlgorithmicColorRamp ramp = new AlgorithmicColorRamp(); ramp.Size = 16; ramp.FromColor = fromColor; ramp.ToColor = toColor; fillSym.ColorRamp = ramp; sym = fillSym as ISymbol; } else if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { //Line Feature // ISimpleLineSymbol lineSym = new SimpleLineSymbol(); // lineSym.Style = esriSimpleLineStyle.esriSLSSolid; // lineSym.Color = rgbColor; // sym = lineSym as ISymbol; // ICartographicLineSymbol cartLineSym = new CartographicLineSymbol(); cartLineSym.Color = rgbColor; cartLineSym.Cap = esriLineCapStyle.esriLCSSquare; cartLineSym.Join = esriLineJoinStyle.esriLJSMitre; ISimpleLineDecorationElement pSimpleLineDecoEle = new SimpleLineDecorationElement(); pSimpleLineDecoEle.FlipAll = true; pSimpleLineDecoEle.FlipFirst = true; ILineDecoration pLineDeco = new LineDecoration(); pLineDeco.AddElement(pSimpleLineDecoEle); // //QI ILineProperties pLinePro = cartLineSym as ILineProperties; pLinePro.LineDecoration = pLineDeco; sym = cartLineSym as ISymbol; } else if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { //Point Feature ISimpleMarkerSymbol marketSym = new SimpleMarkerSymbol(); marketSym.Style = esriSimpleMarkerStyle.esriSMSCircle; //;esriSMSX;cross marketSym.Color = rgbColor; sym = marketSym as ISymbol; } ApplySimple(geoLayer, sym); break; case "Unique": ApplyUniqueValue(geoLayer, cboUniqueVals.Text); break; case "Chart": ApplyBarChartValue(geoLayer, cbxProp1.Text); break; case "Breaks": ApplyClsssBreaks(geoLayer, cboNumericVals.Text, long.Parse(cboBreaks.Text)); break; default: break; } }
private static LineSymbol cloneLineSymbol(LineSymbol lineSymbol) { if (lineSymbol == null) return null; ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol mappingSimpleLineSymbol = lineSymbol as ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol; if (mappingSimpleLineSymbol != null) { ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol ls = new ESRI.ArcGIS.Mapping.Core.Symbols.SimpleLineSymbol() { Color = CloneBrush(mappingSimpleLineSymbol.Color), ControlTemplate = mappingSimpleLineSymbol.ControlTemplate, SelectionColor = CloneBrush(mappingSimpleLineSymbol.SelectionColor), Width = mappingSimpleLineSymbol.Width, }; return ls; } SimpleLineSymbol simpleLineSymbol = lineSymbol as SimpleLineSymbol; if (simpleLineSymbol != null) { SimpleLineSymbol ls = new SimpleLineSymbol() { Color = CloneBrush(simpleLineSymbol.Color), ControlTemplate = simpleLineSymbol.ControlTemplate, Style = simpleLineSymbol.Style, Width = simpleLineSymbol.Width, }; return ls; } CartographicLineSymbol cLineSymbol = lineSymbol as CartographicLineSymbol; if (cLineSymbol != null) { CartographicLineSymbol cs = new CartographicLineSymbol() { Color = CloneBrush(cLineSymbol.Color), ControlTemplate = cLineSymbol.ControlTemplate, DashArray = cLineSymbol.DashArray, DashCap = cLineSymbol.DashCap, DashOffset = cLineSymbol.DashOffset, EndLineCap = cLineSymbol.EndLineCap, LineJoin = cLineSymbol.LineJoin, MiterLimit = cLineSymbol.MiterLimit, StartLineCap = cLineSymbol.StartLineCap, Width = cLineSymbol.Width, }; return cs; } LineSymbol l = new LineSymbol() { Color = CloneBrush(lineSymbol.Color), ControlTemplate = lineSymbol.ControlTemplate, Width = lineSymbol.Width, }; return l; }
/// <summary> /// Initializes tool with map control. /// </summary> /// <param name="mapControl">Parent map control.</param> public void Initialize(MapControl mapControl) { _mapControl = mapControl; _cursor = Cursors.Cross; CartographicLineSymbol simpleLineSymbol = new CartographicLineSymbol() { Color=new SolidColorBrush(Colors.Blue), Width=2 }; SimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol() { BorderThickness = 1, BorderBrush = new System.Windows.Media.SolidColorBrush(Colors.Black), Fill = new SolidColorBrush(Color.FromArgb(128,128,128,128)) }; _polygonDrawObject = new Draw(mapControl.map); _polygonDrawObject.LineSymbol = simpleLineSymbol; _polygonDrawObject.FillSymbol = simpleFillSymbol; _polygonDrawObject.DrawComplete += _PolygonDrawComplete; _polygonDrawObject.DrawMode = DrawMode.Polygon; }
private void btnApply_Click(object sender, EventArgs e) { //Choropleth mapping : Exactly same with the function in frmChoroplethwithOverlay HK102915 string strLayerName = cboSourceLayer.Text; if (cboSourceLayer.Text == "" || cboValueField.Text == "" || cboUField.Text == "") { MessageBox.Show("Assign proper layer and field"); return; } int intLIndex = pSnippet.GetIndexNumberFromLayerName(pActiveView, strLayerName); ILayer pLayer = mForm.axMapControl1.get_Layer(intLIndex); IFeatureLayer pFLayer = pLayer as IFeatureLayer; IFeatureClass pFClass = pFLayer.FeatureClass; //Create Rendering of Mean Value at Target Layer int intGCBreakeCount = Convert.ToInt32(nudGCNClasses.Value); string strGCRenderField = cboValueField.Text; IGeoFeatureLayer pGeofeatureLayer; pGeofeatureLayer = (IGeoFeatureLayer)pFLayer; ITable pTable = (ITable)pFClass; IClassifyGEN pClassifyGEN; switch (cboGCClassify.Text) { case "Equal Interval": pClassifyGEN = new EqualIntervalClass(); break; case "Geometrical Interval": pClassifyGEN = new GeometricalInterval(); break; case "Natural Breaks": pClassifyGEN = new NaturalBreaksClass(); break; case "Quantile": pClassifyGEN = new QuantileClass(); break; case "StandardDeviation": pClassifyGEN = new StandardDeviationClass(); break; default: pClassifyGEN = new NaturalBreaksClass(); break; } //Need to be changed 1/29/15 ITableHistogram pTableHistogram = new TableHistogramClass(); pTableHistogram.Field = strGCRenderField; pTableHistogram.Table = pTable; IHistogram pHistogram = (IHistogram)pTableHistogram; object xVals, frqs; pHistogram.GetHistogram(out xVals, out frqs); pClassifyGEN.Classify(xVals, frqs, intGCBreakeCount); ClassBreaksRenderer pRender = new ClassBreaksRenderer(); double[] cb = (double[])pClassifyGEN.ClassBreaks; pRender.Field = strGCRenderField; pRender.BreakCount = intGCBreakeCount; pRender.MinimumBreak = cb[0]; //' create our color ramp IAlgorithmicColorRamp pColorRamp = new AlgorithmicColorRampClass(); pColorRamp.Algorithm = esriColorRampAlgorithm.esriCIELabAlgorithm; IRgbColor pColor1 = new RgbColor(); IRgbColor pColor2 = new RgbColor(); //Can Change the color in here! pColor1.Red = picSymolfrom.BackColor.R; pColor1.Green = picSymolfrom.BackColor.G; pColor1.Blue = picSymolfrom.BackColor.B; Boolean blnOK = true; pColor2.Red = picSymbolTo.BackColor.R; pColor2.Green = picSymbolTo.BackColor.G; pColor2.Blue = picSymbolTo.BackColor.B; pColorRamp.FromColor = pColor1; pColorRamp.ToColor = pColor2; pColorRamp.Size = intGCBreakeCount; pColorRamp.CreateRamp(out blnOK); IEnumColors pEnumColors = pColorRamp.Colors; pEnumColors.Reset(); IRgbColor pColorOutline = new RgbColor(); //Can Change the color in here! pColorOutline.Red = picGCLineColor.BackColor.R; pColorOutline.Green = picGCLineColor.BackColor.G; pColorOutline.Blue = picGCLineColor.BackColor.B; double dblGCOutlineSize = Convert.ToDouble(nudGCLinewidth.Value); ICartographicLineSymbol pOutLines = new CartographicLineSymbol(); pOutLines.Width = dblGCOutlineSize; pOutLines.Color = (IColor)pColorOutline; //' use this interface to set dialog properties IClassBreaksUIProperties pUIProperties = (IClassBreaksUIProperties)pRender; pUIProperties.ColorRamp = "Custom"; ISimpleFillSymbol pSimpleFillSym; //' be careful, indices are different for the diff lists for (int j = 0; j < intGCBreakeCount; j++) { pRender.Break[j] = cb[j + 1]; pRender.Label[j] = Math.Round(cb[j], 2).ToString() + " - " + Math.Round(cb[j + 1], 2).ToString(); pUIProperties.LowBreak[j] = cb[j]; pSimpleFillSym = new SimpleFillSymbolClass(); pSimpleFillSym.Color = pEnumColors.Next(); pSimpleFillSym.Outline = pOutLines; pRender.Symbol[j] = (ISymbol)pSimpleFillSym; } pGeofeatureLayer.Renderer = (IFeatureRenderer)pRender; //////////////////The Robustness int intRoundingDigits = 2; int intUncernBreakCount = Convert.ToInt32(nudTeNClasses.Value); string strUncerFieldName = cboUField.Text; int intUncernIdx = pFClass.FindField(strUncerFieldName); int intValueIdx = pFClass.FindField(strGCRenderField); //Calculate Robustness //Add fld int intTempfldIdx = 0; string strTempfldName = txtFldName.Text; if (chkRobustness.Checked) { if (pFClass.FindField(strTempfldName) == -1) { AddField(pFClass, strTempfldName); } intTempfldIdx = pFClass.FindField(strTempfldName); } Chart pChart = new Chart(); IFeature pFeat = null; //IFeatureCursor pFCursor = pFClass.Search(null, false); IFeatureCursor pFCursor = null; if (chkRobustness.Checked) { pFCursor = pFClass.Update(null, false); } else { pFCursor = pFClass.Search(null, false); } pFeat = pFCursor.NextFeature(); double[] arrRobustness = new double[pFClass.FeatureCount(null)]; int i = 0; while (pFeat != null) { for (int j = 0; j < (cb.Length - 1); j++) { double dblValue = Convert.ToDouble(pFeat.get_Value(intValueIdx)); double dblStd = Convert.ToDouble(pFeat.get_Value(intUncernIdx)); if (j == 0) { if (dblValue >= cb[j] && dblValue <= cb[j + 1]) { double dblUpperZvalue = (cb[j + 1] - dblValue) / dblStd; double dblUpperConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblUpperZvalue); double dblLowerZvalue = (cb[j] - dblValue) / dblStd; double dblLowerConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblLowerZvalue); arrRobustness[i] = dblUpperConfLev - dblLowerConfLev; if (chkRobustness.Checked) { pFeat.set_Value(intTempfldIdx, arrRobustness[i]); } } } else { if (dblValue > cb[j] && dblValue <= cb[j + 1]) { double dblUpperZvalue = (cb[j + 1] - dblValue) / dblStd; double dblUpperConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblUpperZvalue); double dblLowerZvalue = (cb[j] - dblValue) / dblStd; double dblLowerConfLev = pChart.DataManipulator.Statistics.NormalDistribution(dblLowerZvalue); arrRobustness[i] = dblUpperConfLev - dblLowerConfLev; if (chkRobustness.Checked) { pFeat.set_Value(intTempfldIdx, arrRobustness[i]); } } } } if (chkRobustness.Checked) { pFCursor.UpdateFeature(pFeat); } i++; pFeat = pFCursor.NextFeature(); } //Define the intervals (the last class is fixed to 1) if (intUncernBreakCount == 1) { return; } double[] arrRobustBrks = new double[intUncernBreakCount + 1]; double dblRBrksIntervals = Math.Round(1 / Convert.ToDouble(intUncernBreakCount - 1), intRoundingDigits); arrRobustBrks[0] = 0; for (int j = 1; j < intUncernBreakCount; j++) { arrRobustBrks[j] = dblRBrksIntervals * j; } arrRobustBrks[intUncernBreakCount] = 1; IFeatureLayer pflUncern = new FeatureLayerClass(); pflUncern.FeatureClass = pFClass; pflUncern.Name = "Robustness"; pflUncern.Visible = true; IGeoFeatureLayer pGFLUncern = (IGeoFeatureLayer)pflUncern; pFCursor = pGFLUncern.Search(null, true); RobustnessRenderer pRobustnessRenderer = new RobustnessRenderer(); pRobustnessRenderer.arrRobustBrks = arrRobustBrks; pRobustnessRenderer.arrRobustness = arrRobustness; pRobustnessRenderer.dblAngle = Convert.ToDouble(nudAngleFrom.Value); pRobustnessRenderer.dblFromSep = Convert.ToDouble(nudSeperationFrom.Value); pRobustnessRenderer.dblLinewidth = Convert.ToDouble(nudTeLinewidth.Value); pRobustnessRenderer.dblToSep = Convert.ToDouble(nudSeperationTo.Value); pRobustnessRenderer.intUncernBreakCount = intUncernBreakCount; pRobustnessRenderer.pLineColor = pSnippet.getRGB(picTeLineColor.BackColor.R, picTeLineColor.BackColor.G, picTeLineColor.BackColor.B); IQueryFilter pQFilter = new QueryFilterClass(); pRobustnessRenderer.PrepareFilter(pFClass, pQFilter); pRobustnessRenderer.Draw(pFCursor, esriDrawPhase.esriDPSelection, pActiveView.ScreenDisplay, null); pRobustnessRenderer.CreateLegend(); pGFLUncern.Renderer = pRobustnessRenderer; pActiveView.FocusMap.AddLayer(pGFLUncern as ILayer); mForm.axMapControl1.ActiveView.Refresh(); mForm.axTOCControl1.Update(); }