private void buttonItem16_Click(object sender, EventArgs e) { Thematicmap tm = new Thematicmap(); ESRI.ArcGIS.Display.IColor rgbColor = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColor.RGB = 255; ESRI.ArcGIS.Display.IColor rgbColor1 = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColor1.RGB = 100; tm.createSimpleFillSymbol("boundary", ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSDiagonalCross, rgbColor, rgbColor1,"AREA","test"); ESRI.ArcGIS.Carto.IActiveView pActiveView = Global.mainmap.Map as ESRI.ArcGIS.Carto.IActiveView; pActiveView.Refresh(); Global.toc.Update(); }
private ESRI.ArcGIS.Display.IFillSymbol CreateFillSymbol() { ESRI.ArcGIS.Display.IRgbColor color = new ESRI.ArcGIS.Display.RgbColorClass(); color.Red = 255; color.Transparency = 255; ESRI.ArcGIS.Display.ILineSymbol outLine = new ESRI.ArcGIS.Display.SimpleLineSymbolClass(); outLine.Width = 1; outLine.Color = color; color.Transparency = 0; ESRI.ArcGIS.Display.IFillSymbol fillSymbol = new ESRI.ArcGIS.Display.SimpleFillSymbolClass(); fillSymbol.Color = color; fillSymbol.Outline = outLine; ESRI.ArcGIS.Display.ISimpleFillSymbol simpleFillSymbol = (ESRI.ArcGIS.Display.ISimpleFillSymbol)fillSymbol; simpleFillSymbol.Style = ESRI.ArcGIS.Display.esriSimpleFillStyle.esriSFSCross; return(fillSymbol); }
//this method is called when the user clicks the "Compare Vertices" button at the bottom of the form private void cmdCompare_Click(object sender, EventArgs e) { try { if (cboLayer1.SelectedItem.ToString() == "" || cboLayer2.SelectedItem.ToString() == "" || txtOID1.Text == "" || txtOID2.Text == "") //the double pipe is an or operator that "short circuts", meaning that it will bail out early if the condition is true, whereas the single pipe evaluates all conditions { MessageBox.Show("Choose polygon layer, or specify OBJECTID.", "Verify Selections...", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //show busy mouse System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; IFeatureLayer pFeatureLayer1 = null; IFeatureLayer pFeatureLayer2 = null; IPointCollection pPtnCollMissingVertices = new MultipointClass(); //point collection for missing vertices and used for graphics layer IPoint pPointMissing = new PointClass(); //used for graphics layer //get access to polygon layer 1 for (int i = 0; i < pMap.LayerCount; i++) { if (pMap.get_Layer(i) is IFeatureLayer) { if (pMap.get_Layer(i).Name.ToString() == cboLayer1.SelectedItem.ToString()) { pFeatureLayer1 = pMap.get_Layer(i) as IFeatureLayer; break; } } } //get access to polygon layer 2 for (int i = 0; i < pMap.LayerCount; i++) { if (pMap.get_Layer(i) is IFeatureLayer) { if (pMap.get_Layer(i).Name.ToString() == cboLayer2.SelectedItem.ToString()) { pFeatureLayer2 = pMap.get_Layer(i) as IFeatureLayer; break; } } } //clear the x,y report list box lstMissingVertices.Items.Clear(); //get vertices for feature 1 //set up query filter for feature 1 IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = "OBJECTID = " + txtOID1.Text; //set up feature cursor for feature 1 IFeatureCursor pFeatureCursor = pFeatureLayer1.Search(pQueryFilter, false); //get feature 1 IFeature pFeature1 = pFeatureCursor.NextFeature(); //if no objectid is found if (pFeature1 == null) { MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //get feature 1 as a polygon IPolygon pPolygon1 = pFeature1.Shape as IPolygon; //get the point collection for feature 1 IPointCollection pPointColl1 = pPolygon1 as IPointCollection; //get vertices for feature 2 //set up query filter for feature 2 pQueryFilter = new QueryFilter(); pQueryFilter.WhereClause = "OBJECTID = " + txtOID2.Text; //set up feature cursor for feature 2 pFeatureCursor = null; //reuse the feature cursor from above pFeatureCursor = pFeatureLayer2.Search(pQueryFilter, false); //get feature 2 IFeature pFeature2 = pFeatureCursor.NextFeature(); //if no objectid is found if (pFeature2 == null) { MessageBox.Show("The provided OBJECTID was not found for layer: " + cboLayer1.SelectedItem, "ObjectID Not Found", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //get feature 1 as a polygon IPolygon pPolygon2 = pFeature2.Shape as IPolygon; //get the point collection for feature 1 IPointCollection pPointColl2 = pPolygon2 as IPointCollection; //loop through point collection and check for missing vertices IPoint pPoint1; IPoint pPoint2; Boolean blnFound; //loop through each point in the first collection and check for missing for (int i = 0; i < pPointColl1.PointCount; i++) { pPoint1 = pPointColl1.get_Point(i); //loop through all the points in the second collection and check for the point from the above collection blnFound = false; for (int j = 0; j < pPointColl2.PointCount; j++) { pPoint2 = pPointColl2.get_Point(j); //check for overlapping points if (pPoint1.X == pPoint2.X && pPoint1.Y == pPoint2.Y) { blnFound = true; } } //if no overlapping points were found, report the missing x,y location to the listbox if (blnFound == false) { lstMissingVertices.Items.Add(pPoint1.X + " " + pPoint1.Y + " " + " Feet" + " (missing from polygon 2)"); //add the missing point to a new collection for display on map pPtnCollMissingVertices.AddPoint(pPoint1); } } //loop through each point in the first collection and check for missing for (int i = 0; i < pPointColl2.PointCount; i++) { pPoint2 = pPointColl2.get_Point(i); //loop through all the points in the second collection and check for the point from the above collection blnFound = false; for (int j = 0; j < pPointColl1.PointCount; j++) { pPoint1 = pPointColl1.get_Point(j); //check for overlapping points if (pPoint2.X == pPoint1.X && pPoint2.Y == pPoint1.Y) { blnFound = true; } } //if no overlapping points were found, report the missing x,y location to the listbox if (blnFound == false) { lstMissingVertices.Items.Add(pPoint2.X + " " + pPoint2.Y + " " + " Feet" + " (missing from polygon 1)"); //add the missing point to a new collection for display on map pPtnCollMissingVertices.AddPoint(pPoint2); } } //if no missing vertices were found, inform the user if (lstMissingVertices.Items.Count < 1) { lstMissingVertices.Items.Add("No Missing Vertices Found"); } //display vertices if checkbox is checked if (chkDisplayVertices.Checked == true) { //show busy mouse System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor; //set up the graphics layer for the display of vertices ICompositeGraphicsLayer2 pCompositeGraphicLayer = pMap.BasicGraphicsLayer as ICompositeGraphicsLayer2; ICompositeLayer pCompositeLayer = pCompositeGraphicLayer as ICompositeLayer; ILayer pLayer; IGraphicsLayer pGraphicsLayer; IGraphicsContainer pGraphicsContainer; //loop through the graphics layer and check for the missing vertices layer. if found, delete it for (int i = 0; i < pCompositeLayer.Count; i++) { pLayer = pCompositeLayer.Layer[i]; if (pLayer.Name == "MissingVertices") { pCompositeGraphicLayer.DeleteLayer("MissingVertices"); break; } } //set up a new 'missing vertices' graphics layer pGraphicsLayer = pCompositeGraphicLayer.AddLayer("MissingVertices", null); pMap.ActiveGraphicsLayer = pGraphicsLayer as ILayer; pGraphicsContainer = pCompositeGraphicLayer.FindLayer("MissingVertices") as IGraphicsContainer; //define the color ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new ESRI.ArcGIS.Display.RgbColorClass(); rgbColorCls.Red = 250; rgbColorCls.Green = 0; rgbColorCls.Blue = 0; //define the font stdole.IFontDisp stdFontCls = new stdole.StdFontClass() as stdole.IFontDisp; stdFontCls.Name = "ESRI Surveyor Marker"; //this one has a thin-line hollow circle stdFontCls.Name = "ESRI Surveyor"; //this one has a bold-line hollow circle stdFontCls.Size = 16; //set the character marker symbol's properties ESRI.ArcGIS.Display.ICharacterMarkerSymbol charMarkerSymb = new ESRI.ArcGIS.Display.CharacterMarkerSymbolClass(); charMarkerSymb.Angle = 0; charMarkerSymb.CharacterIndex = 47; charMarkerSymb.Color = rgbColorCls; charMarkerSymb.Font = stdFontCls; charMarkerSymb.Size = 16; charMarkerSymb.XOffset = 0; charMarkerSymb.YOffset = 0; //place the graphics on the map for (int i = 0; i < pPtnCollMissingVertices.PointCount; i++) { pPointMissing = pPtnCollMissingVertices.Point[i]; IElement pElement = new MarkerElement(); pElement.Geometry = pPointMissing; IMarkerElement pMarkerElement = pElement as IMarkerElement; pMarkerElement.Symbol = charMarkerSymb; pGraphicsContainer.AddElement(pElement, 0); } //refresh the map, in order to see the newly added graphics pActiveView.Refresh(); } } catch (Exception ex) { MessageBox.Show("Error Message: " + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + "Error Source: " + Environment.NewLine + ex.Source + Environment.NewLine + Environment.NewLine + "Error Location:" + Environment.NewLine + ex.StackTrace, "AGRC Custom Tools ArcMap Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }