private static ISymbol getISymbolByGeomType(IFeatureLayer featLayer, IColor pColor) { ProgressWindow window = new ProgressWindow(); ISymbol pSymbol = null; switch (featLayer.FeatureClass.ShapeType) { case esriGeometryType.esriGeometryPolygon: ISimpleFillSymbol pNextSymbol = new SimpleFillSymbolClass(); pNextSymbol.Color = pColor; pSymbol = (ISymbol)pNextSymbol; break; case esriGeometryType.esriGeometryPolyline: ILineSymbol pNextSymbol1 = new CartographicLineSymbolClass(); pNextSymbol1.Color = pColor; pSymbol = (ISymbol)pNextSymbol1; break; case esriGeometryType.esriGeometryPoint: ISimpleMarkerSymbol pNextSymbol2 = new SimpleMarkerSymbolClass(); pNextSymbol2.Size = 4; pNextSymbol2.Outline = true; pNextSymbol2.OutlineColor = getcolor(0, 0, 0); pNextSymbol2.OutlineSize = 1; pNextSymbol2.Style = esriSimpleMarkerStyle.esriSMSCircle; pNextSymbol2.Color = pColor; pSymbol = (ISymbol)pNextSymbol2; break; default: break; } return(pSymbol); }
/// <summary> /// 改变面轮廓颜色 /// </summary> /// <param name="vSymbol"></param> /// <param name="pColor"></param> private void ChangeAreaSymboOutlineColor(ISymbol vSymbol, IColor pColor) { IMultiLayerFillSymbol pMultiLayerFillSymbol; ISimpleFillSymbol pSimpleFillSymbol; ICartographicLineSymbol pLineSymbol; int i; if (vSymbol is ISimpleFillSymbol) { pSimpleFillSymbol = (ISimpleFillSymbol)vSymbol; pLineSymbol = new CartographicLineSymbolClass(); pLineSymbol.Color = pColor; pLineSymbol.Width = pSimpleFillSymbol.Outline.Width; pSimpleFillSymbol.Outline = pLineSymbol; } else if (vSymbol is IMultiLayerFillSymbol) { pMultiLayerFillSymbol = (IMultiLayerFillSymbol)vSymbol; for (i = 0; i <= pMultiLayerFillSymbol.LayerCount - 1; i++) { pLineSymbol = new CartographicLineSymbolClass(); pLineSymbol.Color = pColor; pLineSymbol.Width = pMultiLayerFillSymbol.get_Layer(i).Outline.Width; pMultiLayerFillSymbol.get_Layer(i).Outline = pLineSymbol; } } }
//MultiLayerLineSymbol private void button8_Click(object sender, EventArgs e) { IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; simpleLineSymbol.Width = 10; IRgbColor rgbColor = getRGB(255, 0, 0); simpleLineSymbol.Color = rgbColor; ISymbol symbol = simpleLineSymbol as ISymbol; symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen; ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel; cartographicLineSymbol.Width = 10; cartographicLineSymbol.MiterLimit = 4; ILineProperties lineProperties; lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; double[] dob = new double[6]; dob[0] = 0; dob[1] = 1; dob[2] = 2; dob[3] = 3; dob[4] = 4; dob[5] = 5; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < dob.Length; i += 2) { template.AddPatternElement(dob[i], dob[i + 1]); } lineProperties.Template = template; IPolyline polyline = new PolylineClass(); IPoint point = new PointClass(); point.PutCoords(1, 1); polyline.FromPoint = point; point.PutCoords(10, 10); polyline.ToPoint = point; rgbColor = getRGB(0, 255, 0); cartographicLineSymbol.Color = rgbColor; multiLayerLineSymbol.AddLayer(simpleLineSymbol); multiLayerLineSymbol.AddLayer(cartographicLineSymbol); IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol); activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry); activeView.ScreenDisplay.FinishDrawing(); activeView.ScreenDisplay.FinishDrawing(); }
public OtherGridPropertyPage() { this.InitializeComponent(); SimpleMarkerSymbolClass class2 = new SimpleMarkerSymbolClass { Style = esriSimpleMarkerStyle.esriSMSCross, Size = 28.0 }; this.imarkerSymbol_0 = class2; CartographicLineSymbolClass class3 = new CartographicLineSymbolClass { Cap = esriLineCapStyle.esriLCSSquare }; RgbColorClass class4 = new RgbColorClass { Red = 0, Blue = 0, Green = 0 }; class3.Color = class4; class3.Join = esriLineJoinStyle.esriLJSMitre; class3.Width = 1.0; this.ilineSymbol_0 = class3; this.cboFontName.Items.Clear(); InstalledFontCollection fonts = new InstalledFontCollection(); for (int i = 0; i < fonts.Families.Length; i++) { this.cboFontName.Items.Add(fonts.Families[i].Name); } }
private void btnApply_Click(object sender, EventArgs e) { clsSnippet pSnippet = new clsSnippet(); FormCollection pFormCollection = System.Windows.Forms.Application.OpenForms; frmSymbology pfrmSymbology = null; for (int j = 0; j < pFormCollection.Count; j++) { if (pFormCollection[j].Name == "frmSymbology")//Brushing to Histogram { pfrmSymbology = pFormCollection[j] as frmSymbology; } } ISimpleFillSymbol pBackFillSymbol = null; if (pfrmSymbology != null) { pBackFillSymbol = new SimpleFillSymbolClass(); IRgbColor pBackRGB = new RgbColorClass(); pBackRGB = pSnippet.getRGB(picSymColor.BackColor.R, picSymColor.BackColor.G, picSymColor.BackColor.B); pBackFillSymbol.Color = (IColor)pBackRGB; ICartographicLineSymbol pBackOut = new CartographicLineSymbolClass(); IRgbColor pBackOutRGB = new RgbColorClass(); pBackOutRGB = pSnippet.getRGB(picOutColor.BackColor.R, picOutColor.BackColor.G, picOutColor.BackColor.B); pBackOut.Color = (IColor)pBackOutRGB; pBackOut.Width = Convert.ToDouble(nudOutWidth.Value); pBackFillSymbol.Outline = pBackOut; pfrmSymbology.m_BackSymbol = pBackFillSymbol; } this.Close(); }
/// <summary> /// Flash a line feature on the map /// <param name="pDisplay">The map screen</param> /// <param name="pGeometry">The geometry of the feature to be flashed</param> /// <param name="direction">The digitized direction of the barrier with respect to the underlying source feature</param> /// </summary> private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry, esriNetworkEdgeDirection direction) { // The flash will be on a line symbol with an arrow on it ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbolClass(); // 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; // Set up the Raster Op-Code to help the flash mechanism ((ISymbol)ipArrowMarker).ROP2 = esriRasterOpCode.esriROPNotXOrPen; ((ISymbol)ipArrowLineSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen; // decorate the line with the arrow symbol ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass(); ipSimpleLineDecorationElement.Rotate = true; ipSimpleLineDecorationElement.PositionAsRatio = true; ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker; ipSimpleLineDecorationElement.AddPosition(0.5); ILineDecoration ipLineDecoration = new LineDecorationClass(); ipLineDecoration.AddElement(ipSimpleLineDecorationElement); ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration; // the arrow is initially set to correspond to the digitized direction of the line // if the barrier direction is against digitized, then we need to flip the arrow direction if (direction == esriNetworkEdgeDirection.esriNEDAgainstDigitized) { ipSimpleLineDecorationElement.FlipAll = true; } // Flash the line // Two calls are made to Draw. Since the ROP2 setting is NotXOrPen, the first call // draws the symbol with our new symbology and the second call redraws what was originally // in the place of the symbol pDisplay.SetSymbol(ipArrowLineSymbol as ISymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
/// <summary> /// 获取网格线的符号样式 /// </summary> /// <returns></returns> public static ICartographicLineSymbol GetLineSymbol() { //设置网格线的符号样式 ICartographicLineSymbol pLineSymbol = new CartographicLineSymbolClass(); pLineSymbol.Cap = esriLineCapStyle.esriLCSButt; pLineSymbol.Width = 1; pLineSymbol.Color = AeColor.GetRgbColor(0, 0, 0); //黑色 return(pLineSymbol); }
private static ILineSymbol DefineProfileLineSymbol(MilSpaceGraphicsTypeEnum graphicsType, IRgbColor color, int width = 2) { //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = width; return(cartographicLineSymbol); }
public void CreateGrid(IActiveView activeView, IPageLayout pageLayout) { IMapGrid mapGrid = new GraticuleClass(); mapGrid.Name = "Map Grid"; IColor color = new RgbColorClass(); color.RGB = 0XBBBBBB; ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 2; mapGrid.LineSymbol = (ILineSymbol)cartographicLineSymbol; mapGrid.Border = null; mapGrid.TickLength = 15; cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 1; mapGrid.TickLineSymbol = (ILineSymbol)cartographicLineSymbol; mapGrid.TickMarkSymbol = null; mapGrid.SubTickCount = 5; mapGrid.SubTickLength = 10; cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = 0.2; mapGrid.SubTickLineSymbol = (ILineSymbol)cartographicLineSymbol; IGridLabel gridLabel = mapGrid.LabelFormat; gridLabel.LabelOffset = 15; mapGrid.SetTickVisibility(true, true, true, true); mapGrid.SetSubTickVisibility(true, true, true, true); mapGrid.SetLabelVisibility(true, true, true, true); mapGrid.Visible = true; IMeasuredGrid measuredGrid = mapGrid as IMeasuredGrid; measuredGrid.FixedOrigin = true; measuredGrid.XIntervalSize = 10; measuredGrid.XOrigin = 5; //Shift grid 5 measuredGrid.YIntervalSize = 10; //Parallel interval. measuredGrid.YOrigin = 5; //Shift grid 5 IMap map = activeView.FocusMap; IGraphicsContainer graphicsContainer = pageLayout as IGraphicsContainer; IFrameElement frameElement = graphicsContainer.FindFrame(map); IMapFrame mapFrame = frameElement as IMapFrame; IMapGrids mapGrids = null; mapGrids = mapFrame as IMapGrids; mapGrids.AddMapGrid(mapGrid); activeView.PartialRefresh(esriViewDrawPhase.esriViewBackground, null, null); }
private ILineSymbol CreateNewSymbol(int type) { ILineSymbol simpleLineSymbolClass = null; switch (type) { case 0: { simpleLineSymbolClass = new SimpleLineSymbolClass(); break; } case 1: { simpleLineSymbolClass = new CartographicLineSymbolClass(); break; } case 2: { simpleLineSymbolClass = new MarkerLineSymbolClass(); break; } case 3: { simpleLineSymbolClass = new HashLineSymbolClass(); break; } case 4: { simpleLineSymbolClass = new PictureLineSymbolClass(); break; } case 5: { simpleLineSymbolClass = new SimpleLine3DSymbolClass(); break; } case 6: { simpleLineSymbolClass = new TextureLineSymbolClass(); break; } } return(simpleLineSymbolClass); }
public static ILineSymbol CreateLineDirectionSymbol() { ILineSymbol symbol = new CartographicLineSymbolClass(); symbol.Color = ColorHelper.CreateColor(0, 0, 200); LineDecorationClass class2 = new LineDecorationClass(); SimpleLineDecorationElementClass lineDecorationElement = new SimpleLineDecorationElementClass(); 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; }
public static void DrawLine(IPoint fromPoint, IPoint toPoint) { IPolyline pPolyline = new PolylineClass() { FromPoint = fromPoint, ToPoint = toPoint }; IRgbColor pColor = Func.CreateRgbColor(0, 0, 0); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass() { Cap = esriLineCapStyle.esriLCSRound, Color = pColor, Width = 1 }; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecorationClass(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass() { MarkerSymbol = new ArrowMarkerSymbolClass() { Size = 16, Color = pColor } }; pSimpleLineDecoElem.AddPosition(1); pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; IElement pElement = new LineElementClass() { Symbol = pLineSymbol, Geometry = pPolyline }; IGraphicsContainer pGC = m_pMapC2.Map as IGraphicsContainer; pGC.AddElement(pElement, 0); IEnvelope pEnvelope = pPolyline.Envelope; pEnvelope.Expand(5, 5, true); m_pMapC2.Extent = pEnvelope; m_pMapC2.Refresh(); }
public static ILineSymbol CreateLineDirectionSymbol() { ILineSymbol symbol = new CartographicLineSymbolClass(); symbol.Color = ColorHelper.CreateColor(0, 0, 200); LineDecorationClass class2 = new LineDecorationClass(); SimpleLineDecorationElementClass lineDecorationElement = new SimpleLineDecorationElementClass(); 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); }
private static ILineSymbol DefineProfileLineSymbol(MilSpaceGraphicsTypeEnum graphicsType) { //TODO: Get symbol from ESRITools IRgbColor rgbColor = grapchucsTypeColors[graphicsType](); //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = rgbColor; arrowMarkerSymbol.Size = 6; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 6; //Add an offset to make sure the square end of the line is hidden arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = rgbColor; cartographicLineSymbol.Width = 1; //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line (the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(simpleLineDecorationElement); //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; return(cartographicLineSymbol); }
private ILineSymbol _GetZingerSymbol() { // Create a color Color color = Color.Green; IRgbColor symbolColor = new RgbColorClass(); symbolColor.Red = color.R; symbolColor.Green = color.G; symbolColor.Blue = color.B; // Create an arrow marker IArrowMarkerSymbol arrowMarker = new ArrowMarkerSymbolClass(); arrowMarker.Color = symbolColor; arrowMarker.Length = 6.125; arrowMarker.Width = 7.0; // Create an decoration element from arrow marker to be positioned on the line ISimpleLineDecorationElement decorationElement = new SimpleLineDecorationElementClass(); decorationElement.MarkerSymbol = arrowMarker; decorationElement.AddPosition(0.5); decorationElement.PositionAsRatio = true; // Create a line decoration to be added to the line ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(decorationElement); // Create the line symbol with decoration ICartographicLineSymbol lineSymbol = new CartographicLineSymbolClass(); lineSymbol.Color = symbolColor; ILineProperties lineProperties = (ILineProperties)lineSymbol; lineProperties.LineDecoration = lineDecoration; return(lineSymbol); }
public override void OnDblClick() { //双击屏幕 try { IScreenDisplay pScreenDisplay; pScreenDisplay = m_HookHelper.ActiveView.ScreenDisplay; ILineSymbol ipLineSymbol = new CartographicLineSymbolClass(); ipLineSymbol.Width = 5; if (slovePath() == false) { return; } pathToPolyline(); //if(ipPolyResult!=null) //{ // Utility.drawPolyline(m_HookHelper.ActiveView,ipPolyResult); // pScreenDisplay.StartDrawing(0,(short)esriScreenCache.esriNoScreenCache); // pScreenDisplay.DrawPolyline(ipPolyResult); // pScreenDisplay.FinishDrawing(); //} } catch (Exception e) { MessageBox.Show(e.Message); } }
public DotRender(AxMapControl pMapControl, IFeatureLayer pFtLayer, double pValue,string pFieldName) { //IActiveView pActiveView; //this.pGeoLayer = pFtLayer as IGeoFeatureLayer; //pActiveView = pMapControl.ActiveView; //pDotDensityRenderer = new DotDensityRendererClass(); //pRendFields = pDotDensityRenderer as IRendererFields; //pRendFields.AddField(pFieldName, pFieldName); //ͬһ������Ľӿڵ��л����ܷ���ġ� //this.pDotDensityFill = new DotDensityFillSymbolClass(); //pDotDensityFill.DotSize = 8; //pDotDensityFill.Color = GetRGBColor(10, 20, 0); //pDotDensityFill.BackgroundColor = GetRGBColor(100, 108, 190); //pSymbolArry = pDotDensityFill as ISymbolArray;//�ѵ����ܶȡ� //ISimpleMarkerSymbol pSimpleMark; //pSimpleMark = new SimpleMarkerSymbolClass(); //pSimpleMark.Style = esriSimpleMarkerStyle.esriSMSDiamond; //pSimpleMark.Size = 8; //pSimpleMark.Color = GetRGBColor(128, 128, 255); //pSymbolArry.AddSymbol(pSimpleMark as ISymbol); //pDotDensityRenderer.DotDensitySymbol = pDotDensityFill; //pDotDensityRenderer.DotValue = pValue; //pDotDensityRenderer.CreateLegend(); //pGeoLayer.Renderer = (IFeatureRenderer)pDotDensityRenderer; //pActiveView.Refresh(); //��ȡ��ǰͼ�� �����������ó�IGeoFeatureLayer��ʵ�� IMap pMap = pMapControl.Map; // ILayer pFtLayer = pMap.get_Layer(0) as IFeatureLayer; IFeatureLayer pFeatureLayer = pFtLayer as IFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer = pFtLayer as IGeoFeatureLayer; //��ȡͼ���ϵ�feature IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); /////////////////////// /////////////////////////////////////////////////////////////////// //������ܶ�ͼ��Ⱦ��� IDotDensityRenderer DotDensityRenderer = new DotDensityRendererClass(); //������ܶ�ͼ��Ⱦ����������Ⱦ�ֶζ��� IRendererFields flds = (IRendererFields)DotDensityRenderer; flds.AddField(pFieldName, pFieldName); //flds.AddField("Shape", "Shape"); //������ܶ�ͼ��Ⱦ�÷��Ŷ��� IDotDensityFillSymbol ddSym = new DotDensityFillSymbolClass(); IRgbColor BackColor = new RgbColorClass(); BackColor.Red = 234; BackColor.Blue = 128; BackColor.Green = 220; IRgbColor SymbolColor = new RgbColorClass(); SymbolColor.Red = 234; SymbolColor.Blue = 128; SymbolColor.Green = 220; ////���ܶ�ͼ��Ⱦ������ɫ //ddSym.BackgroundColor = BackColor; ddSym.DotSize = 8; ddSym.FixedPlacement = true; //ddSym.Color = SymbolColor; ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); ddSym.Outline = pLineSymbol; //����������� ISymbolArray symArray = (ISymbolArray)ddSym; //��ӵ��ܶ�ͼ��Ⱦ�ĵ���ŵ�����������ȥ ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Size = 0.2; pMarkerSymbol.Color = SymbolColor; ; symArray.AddSymbol(pMarkerSymbol as ISymbol); //���õ��ܶ�ͼ��Ⱦ�ĵ���� //DotDensityRenderer.DotDensitySymbol =symArray; DotDensityRenderer.DotDensitySymbol = ddSym; //ȷ��һ����������ֵ DotDensityRenderer.DotValue = pValue; //���ܶ���Ⱦ���õ���ɫģʽ DotDensityRenderer.ColorScheme = "Custom"; //�������ܶ�ͼ��Ⱦͼ�� DotDensityRenderer.CreateLegend(); //���÷��Ŵ�С�Ƿ�̶� DotDensityRenderer.MaintainSize = true; //�����ܶ�ͼ��Ⱦ��������Ⱦͼ��ҹ� pGeoFeatureLayer.Renderer = (IFeatureRenderer)DotDensityRenderer; //ˢ�µ�ͼ��TOOCotrol IActiveView pActiveView = pMap as IActiveView; pActiveView.Refresh(); }
public static void drawPolyline(IActiveView pActiveView, IPolyline pGeom) { try { IGraphicsContainer iGC = pActiveView as IGraphicsContainer; ILineSymbol ipLineSymbol = new CartographicLineSymbolClass(); ipLineSymbol.Width = 5; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; ipLineSymbol.Color = pRgbColor as IColor; IElement pEle; ILineElement pLE; if (pGeom != null) { pEle = new LineElementClass() as IElement; pLE = pEle as ILineElement; pLE.Symbol = ipLineSymbol; pEle.Geometry = pGeom; iGC.AddElement(pEle, 0); } pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, pActiveView.Extent); } catch (Exception e) { MessageBox.Show(e.Message); } }
//��˷�ٲ��ҹ����漰�ĵؿ� public static void UpStreamFindParcels(AxMapControl ppAxMapControl, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork) { try { IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", ppAxMapControl); IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", ppAxMapControl); //����ѡ���Sewer�������д������ΰ� IGeometryCollection pGeomBag = new GeometryBagClass(); object missing = Type.Missing; int lEID; int iUserClassID; int iUserID; int iUserSubID; INetElements pNetElements = pGeoNetwork.Network as INetElements; pEnumResultEdges.Reset(); IFeature pFeature; for (int j = 0; j <= pEnumResultEdges.Count - 1; j++) { lEID = pEnumResultEdges.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID); pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing); // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString()); } //���пռ����˵��Ӳ��������ڲ��ҵؿ���Ϣ ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeomBag as IGeometry; pSpatialFilter.GeometryField = "Shape"; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial; //��ý��浽�ĵؿ���Ϣ IFeatureCursor pFeatCursor = pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false); //���ӱ�ѡ��ĵؿ����ݵ���ͼ��ͼ��ͼ�������� ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass(); ILayer pLayer = pComGraphicLayer as ILayer; pLayer.Name = "��Ӱ��ĵؿ�"; IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer; //������ѡ��ĵؿ鵽ͼ�������� ISimpleFillSymbol pSymFill = new SimpleFillSymbolClass(); IFillSymbol pFillSymbol = pSymFill as IFillSymbol; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 0; pRgbColor.Green = 200; pRgbColor.Blue = 100; pFillSymbol.Color = pRgbColor as IColor; ICartographicLineSymbol pCartoLine = new CartographicLineSymbolClass(); IRgbColor pRgbColor2 = new RgbColorClass(); pRgbColor2.Red = 100; pRgbColor2.Green = 200; pRgbColor2.Blue = 100; pCartoLine.Width = 2; pCartoLine.Color = pRgbColor2 as IColor; pFillSymbol.Outline = pCartoLine; //����������еؿ����������� IArray pFeatArray = new ArrayClass(); pFeature = pFeatCursor.NextFeature(); while (pFeature != null) { IElement pPolyElement = new PolygonElementClass(); IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement; pPolyElement.Geometry = pFeature.Shape; pFillShapeElement.Symbol = pFillSymbol; pGraphicContainer.AddElement(pPolyElement, 0); pFeatArray.Add(pFeature); pFeature = pFeatCursor.NextFeature(); } ppAxMapControl.AddLayer(pGraphicContainer as ILayer); ppAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //ma //frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(ppAxMapControl,pFeatLayerParcels, pFeatArray); //frmUpstreamCreateOwnerList1.Show(); } catch (Exception eX) { MessageBox.Show(eX.Message); } }
public override void OnDblClick() { //˫����Ļ try { IScreenDisplay pScreenDisplay; pScreenDisplay=m_HookHelper.ActiveView.ScreenDisplay; ILineSymbol ipLineSymbol=new CartographicLineSymbolClass(); ipLineSymbol.Width = 5; if(slovePath()==false) return; pathToPolyline(); //if(ipPolyResult!=null) //{ // Utility.drawPolyline(m_HookHelper.ActiveView,ipPolyResult); // pScreenDisplay.StartDrawing(0,(short)esriScreenCache.esriNoScreenCache); // pScreenDisplay.DrawPolyline(ipPolyResult); // pScreenDisplay.FinishDrawing(); //} } catch(Exception e){ MessageBox.Show(e.Message); } }
private static ILineSymbol DefineProfileDecorationLineSymbol(MilSpaceGraphicsTypeEnum graphicsType, IRgbColor color, int width = 2, LineType lineType = LineType.Arrow) { //TODO: Get symbol from ESRITools //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = width; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); if (lineType == LineType.Arrow || lineType == LineType.DefaultLine) { //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line(the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = color; arrowMarkerSymbol.Size = 5; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 5 + width; //Add an offset to make sure the square end of the line is hidden arrowMarkerSymbol.XOffset = 0.8; simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; lineDecoration.AddElement(simpleLineDecorationElement); } if (lineType == LineType.Point || lineType == LineType.DefaultLine) { //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); simpleLineDecorationElement.AddPosition(0); SimpleMarkerSymbol circleMarkerSymbol = new SimpleMarkerSymbol() { Color = color, Size = 5, Style = esriSimpleMarkerStyle.esriSMSCircle, }; //Add an offset to make sure the square end of the line is hidden circleMarkerSymbol.XOffset = 0.8; simpleLineDecorationElement.MarkerSymbol = circleMarkerSymbol; lineDecoration.AddElement(simpleLineDecorationElement); } //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; return(cartographicLineSymbol); }
private ISymbol GetFeatureSymbol(IFeature Feature) { ICartographicLineSymbol hashsym = null; IRgbColor pcolor = null; ILineSymbol lsym = null; // ISimpleEdgeFeature seFeat = null; ILineProperties lineProperties = null; IArrowMarkerSymbol aMSymbol = null; ILineDecoration lineDecoration = null; ISimpleLineDecorationElement simpleLineDecorationElement = null; IMarkerSymbol smSym = null; bool isMultiLyrSym = false; int multiLyrSymIndex = -1; try { if (Feature.HasOID) { int status = 0; if (string.Compare(Feature.Class.AliasName.Substring(Feature.Class.AliasName.LastIndexOf('.') + 1), "PrimaryConductor", true) == 0) { if (ExtensionInfo.netUtil.primaryStatuses.ContainsKey(Feature.OID)) status = ExtensionInfo.netUtil.primaryStatuses[Feature.OID]; } else if (ExtensionInfo.netUtil.secondaryStatuses.ContainsKey(Feature.OID)) status = ExtensionInfo.netUtil.secondaryStatuses[Feature.OID]; //int fldIndexGUID = Feature.Fields.FindField("FuturaGUID"); //if (fldIndexGUID != -1) //{ // IFeatureClass featCls = Feature.Class as IFeatureClass; // IFeature feat = featCls.GetFeature(Feature.OID); // string guid = feat.get_Value(fldIndexGUID).ToString(); // if (guid != null) // status = (int)NetworkExtension.FuturaNetworkExt.netUtil._sectionList[guid].status; //} // int status = NetworkExtension.FuturaNetworkExt.netUtil._sectionList.Values.FirstOrDefault(obj => (obj.objectId == Feature.OID && string.Compare(Feature.Class.AliasName.Substring(Feature.Class.AliasName.LastIndexOf('.')+1), obj.className, true) == 0)).status; // string guid = Feature.get_Value(Feature.Fields.FindField("FuturaGUID")).ToString(); // int status = NetworkExtension.FuturaNetworkExt.netUtil._sectionList[guid].status; pcolor = new RgbColor(); //FeatureRenderer.PrepareFilter(Feature.Class as IFeatureClass, new QueryFilterClass()); //below line used to get default linesymbol of a featureclass lsym = FeatureRenderer.get_SymbolByFeature(Feature) as ILineSymbol; if (lsym is ICartographicLineSymbol) hashsym = lsym as ICartographicLineSymbol; else if (lsym is IMultiLayerLineSymbol) { IMultiLayerLineSymbol multiLyrLineSymbol = lsym as IMultiLayerLineSymbol; for (int i = 0; i < multiLyrLineSymbol.LayerCount; i++) { if (multiLyrLineSymbol.get_Layer(i) != null && multiLyrLineSymbol.get_Layer(i) is ICartographicLineSymbol) { hashsym = multiLyrLineSymbol.get_Layer(i) as ICartographicLineSymbol; isMultiLyrSym = true; multiLyrSymIndex = i; break; } } } if (hashsym == null) { hashsym = new CartographicLineSymbolClass(); hashsym.Color = lsym.Color; hashsym.Width = lsym.Width; } if (FeatureSelection.SelectionSet.Count > 0 && IsSelected(Feature.OID)) { //if (MobileSettings.settings.UserSettings.TraceSettings.LineColor.R == 0 && MobileSettings.settings.UserSettings.TraceSettings.LineColor.G == 255 && MobileSettings.settings.UserSettings.TraceSettings.LineColor.B == 255) //{ // pcolor.Red = 0; // pcolor.Green = 255; // pcolor.Blue = 0; //} //else //{ pcolor.Red = 0; pcolor.Green = 255; pcolor.Blue = 255; // } //lsym.Color = pcolor; //lsym.Width = lsym.Width + 1; hashsym.Color = pcolor; hashsym.Width = hashsym.Width + 1; } else { //pcolor.Red = MobileSettings.settings.UserSettings.TraceSettings.LineColor.R; //pcolor.Green = MobileSettings.settings.UserSettings.TraceSettings.LineColor.G; //pcolor.Blue = MobileSettings.settings.UserSettings.TraceSettings.LineColor.B; //lsym.Color = pcolor; } if (Feature.Shape.GeometryType == esriGeometryType.esriGeometryLine || Feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline) { // SectionObject sObj = null; // Orientation dir = Orientation.Uninitialized; // seFeat = Feature as ISimpleEdgeFeature; // int fldIndexGUID = Feature.Fields.FindField(((IClassEx)Feature.Class).GlobalIDFieldName); // if(fldIndexGUID != -1) // { //IFeatureClass featCls = Feature.Class as IFeatureClass; //IFeature feat = featCls.GetFeature(Feature.OID); //object guid = feat.get_Value(fldIndexGUID); // if (guid != null) // sObj = secElements.ContainsKey(guid.ToString()) ? secElements[guid.ToString()] : null; //if(sObj != null) //{ // IPolyline pl = Feature.ShapeCopy as IPolyline; // NodeObject fNode = nodeElements.ContainsKey(sObj.Parent) ? nodeElements[sObj.Parent] : null; // NodeObject tNode = nodeElements.ContainsKey(sObj.Child) ? nodeElements[sObj.Child] : null; // if(fNode != null && tNode != null) // { // if (Math.Abs(fNode.X - pl.FromPoint.X) < 0.001 && Math.Abs(fNode.Y - pl.FromPoint.Y) < 0.001) // dir = Orientation.WithFlow; // else // dir = Orientation.AgainstFlow; // } //} // } //bool isPrimary = string.Compare(Feature.Class.AliasName, "PrimaryConductor", true) == 0; //try //{ // if (isPrimary && PrimaryFlowDirections != null) // dir = PrimaryFlowDirections[Feature.OID]; // // dir = secElements.Values.FirstOrDefault(obj => (obj.OID == Feature.OID && string.Compare(Feature.Class.AliasName, obj.LayerName, true) == 0)); // else if (SecFlowDirections != null) // dir = SecFlowDirections[Feature.OID]; //} //catch //{ // dir = Orientation.Uninitialized; //} //if (sObj != null) // { // dir = sObj.FlowDirection; //IPolyline pl = Feature.ShapeCopy as IPolyline; //NodeObject fNode = nodeElements.ContainsKey(sObj.Parent) ? nodeElements[sObj.Parent] : null; //NodeObject tNode = nodeElements.ContainsKey(sObj.Child) ? nodeElements[sObj.Child] : null; //if (fNode != null && tNode != null) //{ // bool isUninitialized = false; // if (string.Compare(fNode.LayerName, FuturaNetJunctions.Futura_NetJunctions_TableName, true) == 0 && secElements.Values.FirstOrDefault(obj => (obj.Child == fNode.GUID)) == null) // dir = Orientation.Indeterminate; // else // { // if (Math.Abs(fNode.X - pl.FromPoint.X) < 0.001 && Math.Abs(fNode.Y - pl.FromPoint.Y) < 0.001) // dir = Orientation.WithFlow; // else // dir = Orientation.AgainstFlow; // } //} // } lineProperties = hashsym as ILineProperties; simpleLineDecorationElement = new SimpleLineDecorationElement(); if (FuturaNetwork.StatusExtensions.IsLoop(status)) simpleLineDecorationElement.MarkerSymbol = DefaultUninitializedSymbol(); else if (FuturaNetwork.StatusExtensions.IsEnergized(status)) { //if (smSym == null) // smSym = Global.DefaultFlowSymbol(); if (FuturaNetwork.StatusExtensions.BreakDown(status).Contains(FuturaNetwork.Constants.WithFlow)) simpleLineDecorationElement.MarkerSymbol = DefaultFlowSymbol(false); else simpleLineDecorationElement.MarkerSymbol = DefaultFlowSymbol(true); } else simpleLineDecorationElement.MarkerSymbol = DefaultUninitializedSymbol(); simpleLineDecorationElement.AddPosition(0.5); simpleLineDecorationElement.PositionAsRatio = true; lineDecoration = new LineDecoration(); lineDecoration.AddElement(simpleLineDecorationElement); lineProperties.LineDecoration = lineDecoration; } ISymbol featSymbol = null; if (isMultiLyrSym && multiLyrSymIndex != -1) { IMultiLayerLineSymbol multiLyrLineSymbol = lsym as IMultiLayerLineSymbol; if (multiLyrLineSymbol.get_Layer(multiLyrSymIndex) != null && multiLyrLineSymbol.get_Layer(multiLyrSymIndex) is ICartographicLineSymbol) { ILineSymbol lineSymbol = multiLyrLineSymbol.get_Layer(multiLyrSymIndex); multiLyrLineSymbol.DeleteLayer(lineSymbol); multiLyrLineSymbol.AddLayer(hashsym as ILineSymbol); } featSymbol = multiLyrLineSymbol as ISymbol; } else featSymbol = hashsym as ISymbol; return featSymbol; } else { return null; } } catch (Exception ex) { //EngineLogger.Logger.LogException(ex); return null; } finally { hashsym = null; pcolor = null; lsym = null; //seFeat = null; lineProperties = null; aMSymbol = null; lineDecoration = null; simpleLineDecorationElement = null; smSym = null; } }
private void btnChangeY_Click(object sender, EventArgs e) { maploaded = true; System.Windows.Forms.Cursor.Current = Cursors.WaitCursor; if ((cboBotYear.Text != "") && (cboTopYear.Text != "")) { label3.Text = cboTopYear.Text; label4.Text = cboBotYear.Text; if (!(topPublicMosaicLayer == null)) { //Delete old top layer, ??check still the same top to save time? m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer); m_MapControltop.ActiveView.FocusMap.DeleteLayer((ILayer)topPublicMosaicLayer); } if (!(botPublicMosaicLayer == null)) { //Delete old bot layer, ??check still the same bot to save time? m_MapControl.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer); m_MapControlbase.ActiveView.FocusMap.DeleteLayer((ILayer)botPublicMosaicLayer); } //This version, we will use mosaicdataset======================== IMosaicWorkspaceExtensionHelper MosaicWsHelper = new MosaicWorkspaceExtensionHelperClass(); IWorkspaceFactory2 workspaceFactory = new FileGDBWorkspaceFactoryClass(); string mosaicdatabase = ConfigurationManager.AppSettings["MosaicDatabase"]; IWorkspace ws = workspaceFactory.OpenFromFile(mosaicdatabase, 0); IMosaicWorkspaceExtension mosaicWsExtension = MosaicWsHelper.FindExtension(ws); //BOT strBaseYr = "AmherstOrthoMosaic" + cboBotYear.Text; IMosaicDataset pMosaicDatasetBot = mosaicWsExtension.OpenMosaicDataset(strBaseYr); botPublicMosaicLayer = new MosaicLayerClass(); botPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetBot); if (!(botPublicMosaicLayer == null)) { IFeatureLayer footprint = (IFeatureLayer)botPublicMosaicLayer.FootprintLayer; ((ILayer)footprint).Visible = false; ILayer botLayer = (ILayer)botPublicMosaicLayer; botLayer.MinimumScale = 6000; m_MapControl.ActiveView.FocusMap.AddLayer(botLayer); m_MapControlbase.ActiveView.FocusMap.AddLayer(botLayer); } //TOP strTopYr = "AmherstOrthoMosaic" + cboTopYear.Text; IMosaicDataset pMosaicDatasetTop = mosaicWsExtension.OpenMosaicDataset(strTopYr); topPublicMosaicLayer = new MosaicLayerClass(); topPublicMosaicLayer.CreateFromMosaicDataset(pMosaicDatasetTop); if (!(topPublicMosaicLayer == null)) { IFeatureLayer footprint = (IFeatureLayer)topPublicMosaicLayer.FootprintLayer; ((ILayer)footprint).Visible = false; ILayer topLayer = (ILayer)topPublicMosaicLayer; topLayer.MinimumScale = 6000; m_MapControl.ActiveView.FocusMap.AddLayer(topLayer); m_MapControltop.ActiveView.FocusMap.AddLayer(topLayer); ILayerEffectProperties lepSwip = m_CommandsEnvironment as ILayerEffectProperties; lepSwip.SwipeLayer = topLayer; //===possible problem toplayer is not public variable any more } IFeatureLayer featurelayerParcel = new FeatureLayerClass(); featurelayerParcel.FeatureClass = featureClassParcels; featurelayerParcel.Name = "parcels"; featurelayerParcel.MinimumScale = 6000; featurelayerParcel.Visible = false; IRgbColor pLColor = new RgbColorClass(); pLColor.Red = 255; pLColor.Green = 255; pLColor.Blue = 255; ISimpleFillSymbol pSFS = new SimpleFillSymbolClass(); ICartographicLineSymbol pCLineS = new CartographicLineSymbolClass(); pCLineS.Color = pLColor; ILineProperties lineProperties = pCLineS as ILineProperties; lineProperties.Offset = 0; System.Double[] hpe = new System.Double[4]; hpe[0] = 7; hpe[1] = 2; hpe[2] = 1; hpe[3] = 2; ITemplate template = new TemplateClass(); template.Interval = 3; for (int i = 0; i < hpe.Length; i = i + 2) { template.AddPatternElement(hpe[i], hpe[i + 1]); } lineProperties.Template = template; pCLineS.Width = 1; pCLineS.Cap = esriLineCapStyle.esriLCSButt; pCLineS.Join = esriLineJoinStyle.esriLJSBevel; pCLineS.Color = pLColor; pSFS.Outline = pCLineS; pSFS.Style = esriSimpleFillStyle.esriSFSHollow; IGeoFeatureLayer pGFL = (IGeoFeatureLayer)featurelayerParcel; ISimpleRenderer pRend = pGFL.Renderer as ISimpleRenderer; pRend.Symbol = pSFS as ISymbol; if ((Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels") == null)) { if (!(featurelayerParcel == null)) { m_MapControl.ActiveView.FocusMap.AddLayer(featurelayerParcel); m_MapControltop.ActiveView.FocusMap.AddLayer(featurelayerParcel); m_MapControlbase.ActiveView.FocusMap.AddLayer(featurelayerParcel); } } else { //is this temp necessary??????? IFeatureLayer parcellayertemp = Helper.FindMyFeatureLayer(m_MapControl.ActiveView.FocusMap, "parcels"); m_MapControl.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); m_MapControltop.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); m_MapControlbase.ActiveView.FocusMap.MoveLayer(parcellayertemp, 0); } //MessageBox.Show("Top aerophoto is taken on: " + cboTopYear.Text + ".\r\nBottom areophoto is taken on: " + cboBotYear.Text + "."); } else { MessageBox.Show("Please select two years to compare"); } GeneratePageLayout(); System.Windows.Forms.Cursor.Current = Cursors.Default; }
private void button2_Click(object sender, EventArgs e) { Form1 path1 = (Form1)this.Owner; //把查询到的点加入到点集中 if (mPointCollectionNet == null) { mPointCollectionNet = new MultipointClass(); } object before = Type.Missing; object after = Type.Missing; mPointCollectionNet.AddPoint(path1.pNewPointBegin, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia1, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia2, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointVia3, ref before, ref after); mPointCollectionNet.AddPoint(path1.pNewPointEnd, ref before, ref after); SolvePath("lenth"); pPolyLineResult = PathToPolyLine(); //mPointCollectionNet.AddPoint(path1.pNewPointVia1, ref before, ref after); //mPointCollectionNet.AddPoint(path1.pNewPointVia2, ref before, ref after); //mPointCollectionNet.AddPoint(path1.pNewPointVia3, ref before, ref after); //路径计算 //注意权重名称与设置保持一致 //SolvePath("lenth"); //路径转换为几何要素 //pPolyLineResult1 = PathToPolyLine(); //pPolyLineResult2 = PathToPolyLine(); //pPolyLineResult3 = PathToPolyLine(); //pPolyLineResult4 = PathToPolyLine(); path1._pPolyLine = this.pPolyLineResult; try { //获取屏幕显示 IActiveView pActiveView = this.axMapControl1.ActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; //设置显示符号 ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; //设置线宽 pLineSymbol.Width = 4; //设置颜色 pLineSymbol.Color = pColor as IColor; //绘制线型符号 pScreenDisplay.StartDrawing(0, 0); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyLineResult); //注记 ITextElement te1 = createTextElement(path1.pNewPointBegin.X, path1.pNewPointBegin.Y, path1.pQueryFilterBegin.WhereClause); ITextElement te2 = createTextElement(path1.pNewPointVia1.X, path1.pNewPointVia1.Y, path1.pQueryFilterVia1.WhereClause); ITextElement te3 = createTextElement(path1.pNewPointVia2.X, path1.pNewPointVia2.Y, path1.pQueryFilterVia2.WhereClause); ITextElement te4 = createTextElement(path1.pNewPointVia3.X, path1.pNewPointVia3.Y, path1.pQueryFilterVia3.WhereClause); ITextElement te5 = createTextElement(path1.pNewPointEnd.X, path1.pNewPointEnd.Y, path1.pQueryFilterEnd.WhereClause); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te1 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te2 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te3 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te4 as IElement, 1); this.axMapControl1.ActiveView.GraphicsContainer.AddElement(te5 as IElement, 1); this.axMapControl1.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); pScreenDisplay.FinishDrawing(); } catch (System.Exception ex) { MessageBox.Show("路径分析出现错误:" + "\r\n" + ex.Message); } //点集设为空 mPointCollectionNet = null; }
public static void DrawArrow(IActiveView pActiveView, CPoint frcpt, CPoint tocpt, double dblArrowLength = 6, double dblArrowWidth = 6, int intRed = 0, int intGreen = 0, int intBlue = 0) { var iColor = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor; //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = iColor; //arrowMarkerSymbol.Size = 6; //it seems size has no effect arrowMarkerSymbol.Length = dblArrowLength; arrowMarkerSymbol.Width = dblArrowWidth; //Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = iColor; cartographicLineSymbol.Width = 1; //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line (the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(simpleLineDecorationElement); //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; //Define line element ILineElement lineElement = new LineElementClass(); lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; var cpl = new CPolyline(-1, frcpt, tocpt); //Cast to Element and set geometry var element = (IElement)lineElement; element.Geometry = cpl.JudgeAndSetPolyline(); //Set the name //IElementProperties3 elementProperties3.Name = elementName; //Add element to graphics container pActiveView.GraphicsContainer.AddElement(element, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); #region a useful example https://community.esri.com/thread/69395 ////Set the element name //string elementName = "ArrowTest"; ////Get the graphics container from the page layout (set elsewhere) //IActiveView activeView = (IActiveView)pageLayout; //IGraphicsContainer graphicsContainer = (IGraphicsContainer)pageLayout; ////Find all existing elements with specified name ////Build a list of elements and then loop over the list to delete them //List<IElement> elementsToDelete = new List<IElement>(); //graphicsContainer.Reset(); //IElementProperties3 elementProperties3 = null; //IElement element = null; //while ((element = graphicsContainer.Next()) != null) //{ // elementProperties3 = (IElementProperties3)element; // if (elementProperties3.Name == elementName) // { // elementsToDelete.Add(element); // } //} //foreach (IElement elementToDelete in elementsToDelete) //{ // graphicsContainer.DeleteElement(elementToDelete); //} ////Define color //IRgbColor rgbColor = new RgbColorClass(); //rgbColor.RGB = Color.Black.ToArgb(); ////Define an arrow marker //IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); //arrowMarkerSymbol.Color = rgbColor; //arrowMarkerSymbol.Size = 6; //arrowMarkerSymbol.Length = 8; //arrowMarkerSymbol.Width = 6; ////Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; ////Create cartographic line symbol //ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); //cartographicLineSymbol.Color = rgbColor; //cartographicLineSymbol.Width = 1; ////Define simple line decoration //ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); ////Place the arrow at the end of the line (the "To" point in the geometry below) //simpleLineDecorationElement.AddPosition(1); //simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; ////Define line decoration //ILineDecoration lineDecoration = new LineDecorationClass(); //lineDecoration.AddElement(simpleLineDecorationElement); ////Set line properties //ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; //lineProperties.LineDecoration = lineDecoration; ////Define line element //ILineElement lineElement = new LineElementClass(); //lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; ////Create the line geometry //IPoint fromPoint = new PointClass(); //fromPoint.X = 4.0; //fromPoint.Y = 0.8; //IPoint toPoint = new PointClass(); //toPoint.X = 5.0; //toPoint.Y = 0.8; //IPolyline polyline = new PolylineClass(); //polyline.FromPoint = fromPoint; //polyline.ToPoint = toPoint; ////Cast to Element and set geometry //element = (IElement)lineElement; //element.Geometry = polyline; ////Set the name //elementProperties3.Name = elementName; ////Add element to graphics container //graphicsContainer.AddElement(element, 0); ////Clear the graphics selection (graphics are selected when added) //IGraphicsContainerSelect graphicsContainerSelect = (IGraphicsContainerSelect)graphicsContainer; //graphicsContainerSelect.UnselectAllElements(); //activeView.Refresh(); #endregion }
public DotRender(AxMapControl pMapControl, IFeatureLayer pFtLayer, double pValue, string pFieldName) { //IActiveView pActiveView; //this.pGeoLayer = pFtLayer as IGeoFeatureLayer; //pActiveView = pMapControl.ActiveView; //pDotDensityRenderer = new DotDensityRendererClass(); //pRendFields = pDotDensityRenderer as IRendererFields; //pRendFields.AddField(pFieldName, pFieldName); //同一个对象的接口的切换,很方便的。 //this.pDotDensityFill = new DotDensityFillSymbolClass(); //pDotDensityFill.DotSize = 8; //pDotDensityFill.Color = GetRGBColor(10, 20, 0); //pDotDensityFill.BackgroundColor = GetRGBColor(100, 108, 190); //pSymbolArry = pDotDensityFill as ISymbolArray;//难道是密度。 //ISimpleMarkerSymbol pSimpleMark; //pSimpleMark = new SimpleMarkerSymbolClass(); //pSimpleMark.Style = esriSimpleMarkerStyle.esriSMSDiamond; //pSimpleMark.Size = 8; //pSimpleMark.Color = GetRGBColor(128, 128, 255); //pSymbolArry.AddSymbol(pSimpleMark as ISymbol); //pDotDensityRenderer.DotDensitySymbol = pDotDensityFill; //pDotDensityRenderer.DotValue = pValue; //pDotDensityRenderer.CreateLegend(); //pGeoLayer.Renderer = (IFeatureRenderer)pDotDensityRenderer; //pActiveView.Refresh(); //获取当前图层 ,并把它设置成IGeoFeatureLayer的实例 IMap pMap = pMapControl.Map; // ILayer pFtLayer = pMap.get_Layer(0) as IFeatureLayer; IFeatureLayer pFeatureLayer = pFtLayer as IFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer = pFtLayer as IGeoFeatureLayer; //获取图层上的feature IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass; IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, false); IFeature pFeature = pFeatureCursor.NextFeature(); /////////////////////// /////////////////////////////////////////////////////////////////// //定义点密度图渲染组件 IDotDensityRenderer DotDensityRenderer = new DotDensityRendererClass(); //定义点密度图渲染组件对象的渲染字段对象 IRendererFields flds = (IRendererFields)DotDensityRenderer; flds.AddField(pFieldName, pFieldName); //flds.AddField("Shape", "Shape"); //定义点密度图渲染得符号对象 IDotDensityFillSymbol ddSym = new DotDensityFillSymbolClass(); IRgbColor BackColor = new RgbColorClass(); BackColor.Red = 234; BackColor.Blue = 128; BackColor.Green = 220; IRgbColor SymbolColor = new RgbColorClass(); SymbolColor.Red = 234; SymbolColor.Blue = 128; SymbolColor.Green = 220; ////点密度图渲染背景颜色 //ddSym.BackgroundColor = BackColor; ddSym.DotSize = 8; ddSym.FixedPlacement = true; //ddSym.Color = SymbolColor; ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); ddSym.Outline = pLineSymbol; //定义符号数组 ISymbolArray symArray = (ISymbolArray)ddSym; //添加点密度图渲染的点符号到符号数组中去 ISimpleMarkerSymbol pMarkerSymbol = new SimpleMarkerSymbolClass(); pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pMarkerSymbol.Size = 0.2; pMarkerSymbol.Color = SymbolColor;; symArray.AddSymbol(pMarkerSymbol as ISymbol); //设置点密度图渲染的点符号 //DotDensityRenderer.DotDensitySymbol =symArray; DotDensityRenderer.DotDensitySymbol = ddSym; //确定一个点代表多少值 DotDensityRenderer.DotValue = pValue; //点密度渲染采用的颜色模式 DotDensityRenderer.ColorScheme = "Custom"; //创建点密度图渲染图例 DotDensityRenderer.CreateLegend(); //设置符号大小是否固定 DotDensityRenderer.MaintainSize = true; //将点密度图渲染对象与渲染图层挂钩 pGeoFeatureLayer.Renderer = (IFeatureRenderer)DotDensityRenderer; //刷新地图和TOOCotrol IActiveView pActiveView = pMap as IActiveView; pActiveView.Refresh(); }
// ********************* // Author: Erika Kamptner // Created Date: 3/10/2017 // Description: This method takes several parameters from the BuildMap method to connect to geodatabase, load layer, // place in appropriate group layer, style, and label. Only Address points, Cadastral, Building, and Centerline layers // have specified labels and symbology. // // ************************** public static void LoadCSCLFeatureClass(bool isCSCL, string strFCName, IGroupLayer pGroupLayer, string strGeodatabase) { //Point to map document IMxDocument pMxDoc; pMxDoc = (IMxDocument)ArcMap.Application.Document; IMap pMap; pMap = pMxDoc.FocusMap; //Set up shapefile Workspace connection IWorkspaceFactory pWorkspaceFactory; pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); //If connecting to SDE, set up SDE workspace connection //IWorkspaceFactory pWorkspaceFactory; //pWorkspaceFactory = new SdeWorkspaceFactoryClass(); IWorkspace pWorkspace; pWorkspace = pWorkspaceFactory.OpenFromFile(strGeodatabase, 0); IFeatureWorkspace pFeatureWorkspace; pFeatureWorkspace = (IFeatureWorkspace)pWorkspace; IFeatureClass pFeatureClass; pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strFCName); IFeatureLayer pFeatureLayer; pFeatureLayer = new FeatureLayer(); pFeatureLayer.FeatureClass = pFeatureClass; pFeatureLayer.Name = pFeatureClass.AliasName; //Add layer to group if CSCL map type. Otherwise, just add layer. if (isCSCL) { pGroupLayer.Add((ILayer)pFeatureLayer); } else { pMap.AddLayer((ILayer)pFeatureLayer); } //Symbolize Address points based if the address has subaddresses if (pFeatureLayer.Name == "AddressPoint") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayAnnotation = true; //Create unique symbology based on subaddress flag using unique value renderer ISimpleMarkerSymbol pAddressSymbolDefault; pAddressSymbolDefault = new SimpleMarkerSymbolClass(); pAddressSymbolDefault.Color = SetColor(230, 0, 0); pAddressSymbolDefault.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolDefault.Size = 4; IUniqueValueRenderer pUniqueValueRenderer; pUniqueValueRenderer = new UniqueValueRendererClass(); pUniqueValueRenderer.FieldCount = 1; pUniqueValueRenderer.set_Field(0, "SUBADDRESS"); pUniqueValueRenderer.UseDefaultSymbol = false; //Create unique symbology for different values ISimpleMarkerSymbol pAddressSymbolYES; pAddressSymbolYES = new SimpleMarkerSymbolClass(); pAddressSymbolYES.Color = SetColor(230, 0, 0); pAddressSymbolYES.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolYES.Size = 8; pAddressSymbolYES.OutlineSize = 2; pAddressSymbolYES.OutlineColor = SetColor(255, 255, 0); pAddressSymbolYES.Outline = true; ISimpleMarkerSymbol pAddressSymbolNO; pAddressSymbolNO = new SimpleMarkerSymbolClass(); pAddressSymbolNO.Color = SetColor(230, 0, 0); pAddressSymbolNO.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolNO.Size = 4; pUniqueValueRenderer.AddValue("YES", "SUBADDRESS", pAddressSymbolYES as ISymbol); pUniqueValueRenderer.set_Label("YES", "YES"); pUniqueValueRenderer.set_Symbol("YES", pAddressSymbolYES as ISymbol); pUniqueValueRenderer.AddValue("NO", "SUBADDRESS", pAddressSymbolNO as ISymbol); pUniqueValueRenderer.set_Label("NO", "NO"); pUniqueValueRenderer.set_Symbol("NO", pAddressSymbolNO as ISymbol); //Create Label LabelFeatures(pGeoFeatureLayer, "\"ADDRESSID: \" + [ADDRESS_ID]"); pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer; } else if (pFeatureLayer.Name == "Building") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "BIN"; pGeoFeatureLayer.DisplayAnnotation = true; //Create ouline element ISimpleLineSymbol pOutline; pOutline = new SimpleLineSymbolClass(); pOutline.Color = SetColor(0, 0, 255); pOutline.Width = 2; //Create polygon with outline element ISimpleFillSymbol pBuildingSymbol; pBuildingSymbol = new SimpleFillSymbolClass(); pBuildingSymbol.Style = esriSimpleFillStyle.esriSFSHollow; pBuildingSymbol.Outline = pOutline; //Create Label LabelFeatures(pGeoFeatureLayer, "\"BIN : \" + [BIN]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pBuildingSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else if (pFeatureLayer.Name == "StreetCenterline") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "ST_NAME"; pGeoFeatureLayer.DisplayAnnotation = true; //Create arrow element to place at end of line segment IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = SetColor(0, 0, 0); arrowMarkerSymbol.Size = 6; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 6; arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol pCartographicLineSymbol; pCartographicLineSymbol = new CartographicLineSymbolClass(); pCartographicLineSymbol.Color = SetColor(0, 0, 0); pCartographicLineSymbol.Width = 2; //Place arrow at end of line ISimpleLineDecorationElement pCenterlineDecoration; pCenterlineDecoration = new SimpleLineDecorationElementClass(); pCenterlineDecoration.AddPosition(1); pCenterlineDecoration.MarkerSymbol = arrowMarkerSymbol; pCenterlineDecoration.Rotate = true; //set line decoration ILineDecoration pLineDecoration; pLineDecoration = new LineDecorationClass(); pLineDecoration.AddElement(pCenterlineDecoration); //Set line properties ILineProperties lineProperties = (ILineProperties)pCartographicLineSymbol; lineProperties.LineDecoration = pLineDecoration; lineProperties.Flip = false; //Create Label LabelFeatures(pGeoFeatureLayer, "[L_LOW_HN] + \" - \" + [L_HIGH_HN]+ \" \" +[ST_NAME] + vbCrLf + [PHYSICALID]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pCartographicLineSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else if (pFeatureLayer.Name == "Cadastral") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "BBL"; pGeoFeatureLayer.DisplayAnnotation = true; //Create ouline element ISimpleLineSymbol pOutline; pOutline = new SimpleLineSymbolClass(); pOutline.Color = SetColor(76, 230, 0); pOutline.Width = 2; //Create polygon with outline element ISimpleFillSymbol pTaxLotSymbol; pTaxLotSymbol = new SimpleFillSymbolClass(); pTaxLotSymbol.Style = esriSimpleFillStyle.esriSFSHollow; pTaxLotSymbol.Outline = pOutline; //Create label LabelFeatures(pGeoFeatureLayer, "\"BBL: \" + [BBL]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pTaxLotSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else { pFeatureLayer.Visible = false; } }
/// <summary> /// Flash a line feature on the map /// <param name="pDisplay">The map screen</param> /// <param name="pGeometry">The geometry of the feature to be flashed</param> /// <param name="direction">The digitized direction of the barrier with respect to the underlying source feature</param> /// </summary> private void FlashLine(IScreenDisplay pDisplay, IGeometry pGeometry, esriNetworkEdgeDirection direction) { // The flash will be on a line symbol with an arrow on it ICartographicLineSymbol ipArrowLineSymbol = new CartographicLineSymbolClass(); // 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; // Set up the Raster Op-Code to help the flash mechanism ((ISymbol)ipArrowMarker).ROP2 = esriRasterOpCode.esriROPNotXOrPen; ((ISymbol)ipArrowLineSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen; // decorate the line with the arrow symbol ISimpleLineDecorationElement ipSimpleLineDecorationElement = new SimpleLineDecorationElementClass(); ipSimpleLineDecorationElement.Rotate = true; ipSimpleLineDecorationElement.PositionAsRatio = true; ipSimpleLineDecorationElement.MarkerSymbol = ipArrowMarker; ipSimpleLineDecorationElement.AddPosition(0.5); ILineDecoration ipLineDecoration = new LineDecorationClass(); ipLineDecoration.AddElement(ipSimpleLineDecorationElement); ((ILineProperties)ipArrowLineSymbol).LineDecoration = ipLineDecoration; // the arrow is initially set to correspond to the digitized direction of the line // if the barrier direction is against digitized, then we need to flip the arrow direction if (direction == esriNetworkEdgeDirection.esriNEDAgainstDigitized) ipSimpleLineDecorationElement.FlipAll = true; // Flash the line // Two calls are made to Draw. Since the ROP2 setting is NotXOrPen, the first call // draws the symbol with our new symbology and the second call redraws what was originally // in the place of the symbol pDisplay.SetSymbol(ipArrowLineSymbol as ISymbol); pDisplay.DrawPolyline(pGeometry); System.Threading.Thread.Sleep(300); pDisplay.DrawPolyline(pGeometry); }
private void axMapControl1_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e) { switch (mTool) { case "Network": try { //路径计算 //注意权重名称与设置保持一致 SolvePath("LENGTH"); //路径转换为几何要素 IPolyline pPolyLineResult = PathToPolyLine(); //获取屏幕显示 IActiveView pActiveView = this.axMapControl1.ActiveView; IScreenDisplay pScreenDisplay = pActiveView.ScreenDisplay; //设置显示符号 ILineSymbol pLineSymbol = new CartographicLineSymbolClass(); IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; //设置线宽 pLineSymbol.Width = 4; //设置颜色 pLineSymbol.Color = pColor as IColor; //绘制线型符号 pScreenDisplay.StartDrawing(0, 0); pScreenDisplay.SetSymbol((ISymbol)pLineSymbol); pScreenDisplay.DrawPolyline(pPolyLineResult); pScreenDisplay.FinishDrawing(); } catch (System.Exception ex) { MessageBox.Show("路径分析出现错误:" + "\r\n" + ex.Message); } //点集设为空 mPointCollection = null; break; case "Edit": //判断是否鼠标左键 if (e.button != 1) { return; } ////判断是否处于编辑状态 if (mEdit != null && mEdit.IsEditing()) { switch (cboTasks.SelectedIndex) { case 0: mEdit.CreateDoubleClick(e.mapX, e.mapY); break; case 1: break; } } break; default: break; } }
private void MapTemplateGeneralPage_Load(object sender, EventArgs e) { this.cboStyle.SelectedIndex = 0; CartographicLineSymbolClass class2 = new CartographicLineSymbolClass { Cap = esriLineCapStyle.esriLCSSquare }; RgbColorClass class3 = new RgbColorClass { Red = 0, Blue = 0, Green = 0 }; class2.Color = class3; class2.Join = esriLineJoinStyle.esriLJSMitre; class2.Width = 1.0; this.ilineSymbol_0 = class2; SimpleFillSymbolClass class4 = new SimpleFillSymbolClass(); RgbColorClass class5 = new RgbColorClass { Red = 0, Blue = 0, Green = 0 }; class4.Color = class5; class4.Style = esriSimpleFillStyle.esriSFSSolid; SimpleLineSymbolClass class6 = new SimpleLineSymbolClass { Width = 0.0 }; RgbColorClass class7 = new RgbColorClass { Red = 0, Blue = 0, Green = 0 }; class6.Color = class7; class4.Outline = class6; this.ifillSymbol_0 = class4; this.styleButton1.Style = this.ilineSymbol_0; if (this.MapTemplate != null) { this.txtName.Text = this.MapTemplate.Name; if (this.MapTemplate.MapFramingType == MapFramingType.StandardFraming) { this.groupBoxPage.Enabled = true; this.panelScale.Enabled = true; } else { this.groupBoxPage.Enabled = true; this.panelScale.Enabled = true; //this.groupBoxPage.Enabled = false; //this.panelScale.Enabled = false; } if (this.MapTemplate.MapFrameType == MapFrameType.MFTRect) { this.rdoRect.Checked = true; } else { this.rdoTrapezoid.Checked = true; } this.txtLeftSpace.Text = this.MapTemplate.LeftInOutSpace.ToString(); this.txtRightSpace.Text = this.MapTemplate.RightInOutSpace.ToString(); this.txtTopSpace.Text = this.MapTemplate.TopInOutSpace.ToString(); this.txtBottomSpace.Text = this.MapTemplate.BottomInOutSpace.ToString(); this.txtOutBorderWidth.Text = this.MapTemplate.OutBorderWidth.ToString(); this.styleButton1.Style = this.MapTemplate.BorderSymbol; this.cboStyle.SelectedIndex = (int)this.MapTemplate.TemplateSizeStyle; this.txtWidth.Text = this.MapTemplate.Width.ToString(); this.txtHeight.Text = this.MapTemplate.Height.ToString(); this.txtScale.Text = this.MapTemplate.Scale.ToString(); this.txtXInterval.Text = this.MapTemplate.XInterval.ToString(); this.txtYInterval.Text = this.MapTemplate.YInterval.ToString(); if (this.MapTemplate.BorderSymbol is ILineSymbol) { this.rdoLine.Checked = true; this.ilineSymbol_0 = this.MapTemplate.BorderSymbol as ILineSymbol; } else if (this.MapTemplate.BorderSymbol is IFillSymbol) { this.ifillSymbol_0 = this.MapTemplate.BorderSymbol as IFillSymbol; this.rdoFill.Checked = true; } else { this.rdoNoOutLine.Checked = true; this.styleButton1.Enabled = false; } this.styleButton1.Style = this.MapTemplate.BorderSymbol; this.cboStyle.SelectedIndex = (int)this.MapTemplate.TemplateSizeStyle; this.chkMapGrid.Checked = this.MapTemplate.MapGrid != null; this.checkBox1.Checked = this.MapTemplate.FixedWidthAndBottomSpace; } this.bool_0 = true; }
public void RefreshLayer() { if (pGraphicsLayer != null) { IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer; int nCount = m_IMUFeatureList.Count; pGC.DeleteAllElements(); for (int i = 0; i < nCount; i++) { IPolyline ppl = new PolylineClass(); ppl.FromPoint = m_IMUFeatureList[i].Shape as IPoint; ppl.ToPoint = m_CenterlinePointFeatureList[i].Shape as IPoint; IRgbColor pColor = new RgbColorClass(); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass(); pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecorationClass(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass(); pSimpleLineDecoElem.AddPosition(1); IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass(); pArrowMarkerSym.Size = 8; pArrowMarkerSym.Color = pColor; pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol; pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; pLineSymbol.Color = pColor; pLineSymbol.Width = 1; ILineElement pLineElem = new LineElementClass(); pLineElem.Symbol = pLineSymbol; IElement pElem = pLineElem as IElement; pElem.Geometry = ppl; pGC.AddElement(pElem, 0); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); //pElement = new MarkerElementClass(); //pElement.Geometry = m_OriginPoints.get_Point(i); //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass(); //sms.Style = esriSimpleMarkerStyle.esriSMSSquare; //sms.Size = 9; //IMarkerElement im = pElement as IMarkerElement; //im.Symbol = sms ; // IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; // pGraphicsContainer.AddElement(pElement, 0); //pGC.AddElement(pElement,0); //pGC.UpdateElement(pElement); //IMarkerElement pMarkerEle = new MarkerElementClass(); //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol(); ////pPictureMarkerSymbol.Color = sitecolor as IColor; //pPictureMarkerSymbol.Size = 10; //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, // GetParentPathofExe() + @"Resource\Globe.bmp"); //IElement pEle = pMarkerEle as IElement; //pEle.Geometry = ppl.FromPoint; //pMarkerEle.Symbol = pPictureMarkerSymbol; //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; ////site.pEle = pEle; //pGraphicsContainer.AddElement(pEle, 0); } IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { if (m_IMUFeatureList.Count == 0) { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); } else { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } } } }
//上朔追踪查找管线涉及的地块 public static void UpStreamFindParcels(MainFrm pMainFrm, IEnumNetEID pEnumResultEdges, IGeometricNetwork pGeoNetwork) { try { AxMapControl axMap = pMainFrm.getMapControl(); IFeatureLayer pFeatLayerSewerLines = FindFeatLayer("Sewer Lines", pMainFrm); IFeatureLayer pFeatLayerParcels = FindFeatLayer("Parcels", pMainFrm); //从所选择的Sewer线特征中创建几何包 IGeometryCollection pGeomBag = new GeometryBagClass(); object missing = Type.Missing; int lEID; int iUserClassID; int iUserID; int iUserSubID; INetElements pNetElements = pGeoNetwork.Network as INetElements; pEnumResultEdges.Reset(); IFeature pFeature; for (int j = 0; j <= pEnumResultEdges.Count - 1; j++) { lEID = pEnumResultEdges.Next(); pNetElements.QueryIDs(lEID, esriElementType.esriETEdge, out iUserClassID, out iUserID, out iUserSubID); pFeature = pFeatLayerSewerLines.FeatureClass.GetFeature(iUserID); pGeomBag.AddGeometry(pFeature.Shape, ref missing, ref missing); // MessageBox.Show(iUserClassID.ToString()+","+iUserID.ToString()+","+iUserSubID.ToString()); } //进行空间拓扑叠加操作以用于查找地块信息 ISpatialFilter pSpatialFilter = new SpatialFilterClass(); pSpatialFilter.Geometry = pGeomBag as IGeometry ; pSpatialFilter.GeometryField = "Shape"; pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; pSpatialFilter.SearchOrder = esriSearchOrder.esriSearchOrderSpatial; //获得交叉到的地块信息 IFeatureCursor pFeatCursor=pFeatLayerParcels.FeatureClass.Search(pSpatialFilter, false); //增加被选择的地块数据到地图的图形图层数据中 ICompositeGraphicsLayer pComGraphicLayer = new CompositeGraphicsLayerClass(); ILayer pLayer = pComGraphicLayer as ILayer ; pLayer.Name = "受影响的地块"; IGraphicsContainer pGraphicContainer = pComGraphicLayer as IGraphicsContainer; //增加所选择的地块到图形容器中 ISimpleFillSymbol pSymFill=new SimpleFillSymbolClass(); IFillSymbol pFillSymbol=pSymFill as IFillSymbol; IRgbColor pRgbColor=new RgbColorClass(); pRgbColor.Red=0; pRgbColor.Green=200; pRgbColor.Blue=100; pFillSymbol.Color=pRgbColor as IColor; ICartographicLineSymbol pCartoLine=new CartographicLineSymbolClass(); IRgbColor pRgbColor2=new RgbColorClass(); pRgbColor2.Red=100; pRgbColor2.Green=200; pRgbColor2.Blue=100; pCartoLine.Width=2; pCartoLine.Color =pRgbColor2 as IColor; pFillSymbol.Outline=pCartoLine; //创建存放所有地块特征的数组 IArray pFeatArray = new ArrayClass(); pFeature=pFeatCursor.NextFeature(); while (pFeature != null) { IElement pPolyElement = new PolygonElementClass(); IFillShapeElement pFillShapeElement = pPolyElement as IFillShapeElement; pPolyElement.Geometry = pFeature.Shape; pFillShapeElement.Symbol = pFillSymbol; pGraphicContainer.AddElement(pPolyElement, 0); pFeatArray.Add(pFeature); pFeature = pFeatCursor.NextFeature(); } axMap.AddLayer(pGraphicContainer as ILayer); axMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics,null,null); frmUpstreamCreateOwnerList frmUpstreamCreateOwnerList1 = new frmUpstreamCreateOwnerList(pMainFrm,pFeatLayerParcels, pFeatArray); frmUpstreamCreateOwnerList1.Show(); } catch (Exception eX) { MessageBox.Show(eX.Message); } }