private void axSceneControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.ISceneControlEvents_OnMouseDownEvent e) { IPoint pPoint = null; object objOwner = null; object objObject = null; axSceneControl1.SceneGraph.Locate(axSceneControl1.SceneViewer, e.x, e.y, esriScenePickMode.esriScenePickGeography, true, out pPoint, out objOwner, out objObject); ITextElement pTextElement = new TextElementClass(); pTextElement.Text = "dddddd"; IGraphicsContainer3D pGCon3D = axSceneControl1.Scene.BasicGraphicsLayer as IGraphicsContainer3D; IElement pElement = new MarkerElementClass(); IMarkerElement pPointElement = pElement as MarkerElementClass; ILineElement pLineElement = pElement as ILineElement; ISimpleLineSymbol pLSymbol = new SimpleLineSymbolClass(); ISimpleMarkerSymbol pMSym = new SimpleMarkerSymbolClass(); IColor pFromColor = new RgbColorClass(); IRgbColor pRgbColor = pFromColor as IRgbColor; pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; pMSym.Size = 10; pMSym.Color = pFromColor; pMSym.Style = esriSimpleMarkerStyle.esriSMSDiamond; pPointElement.Symbol = pMSym; pLSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pElement.Geometry = pPoint; pGCon3D.AddElement(pElement as IElement ); axSceneControl1.Scene.SceneGraph.RefreshViewers(); IDisplay3D pIDisplay3D = axSceneControl1.Scene.SceneGraph as IDisplay3D ; pIDisplay3D.FlashLocation(pPoint); }
protected override void OnClick() { // Access a feature layer from ArcMap IMap map = ArcMap.Document.FocusMap; IFeatureLayer featureLayer = map.Layer[0] as IFeatureLayer; IFeatureClass featureclass = featureLayer.FeatureClass; IRgbColor lineColor = new RgbColorClass(); lineColor.Red = 255; lineColor.Green = 255; lineColor.Blue = 0; ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = lineColor; lineSymbol.Width = 3.0; ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Label = "Taper"; simpleRenderer.Symbol = lineSymbol as ISymbol; IGeoFeatureLayer geoFL = featureLayer as IGeoFeatureLayer; geoFL.Renderer = simpleRenderer as IFeatureRenderer; ArcMap.Document.ActivatedView.Refresh(); ArcMap.Document.ActivatedView.PartialRefresh(esriViewDrawPhase.esriViewGeography, geoFL, ArcMap.Document.ActivatedView.Extent); ArcMap.Document.UpdateContents(); }
//添加标注 void itemaddlable_Click(object sender, EventArgs e) { // //使用TextElment绘制标注, fieldName为要绘制的属性 //public static void AddLable(AxMapControl axMapControl, ILayer layer, string fieldName) //{ ILayer layer = Global.mainmap.Map.get_Layer(0); IRgbColor pColor = new RgbColorClass() { Red = 255, Blue = 0, Green = 0 }; IFontDisp pFont = new StdFont() { Name = "宋体", Size = 5 } as IFontDisp; ITextSymbol pTextSymbol = new TextSymbolClass() { Color = pColor, Font = pFont, Size = 11 }; IGraphicsContainer pGraContainer = Global.mainmap.Map as IGraphicsContainer; //遍历要标注的要素 IFeatureLayer pFeaLayer = layer as IFeatureLayer; IFeatureClass pFeaClass = pFeaLayer.FeatureClass; IFeatureCursor pFeatCur = pFeaClass.Search(null, false); IFeature pFeature = pFeatCur.NextFeature(); int index = pFeature.Fields.FindField("NAME");//要标注的字段的索引 IEnvelope pEnv = null; ITextElement pTextElment = null; IElement pEle = null; while (pFeature != null) { //使用地理对象的中心作为标注的位置 pEnv = pFeature.Extent; IPoint pPoint = new PointClass(); pPoint.PutCoords(pEnv.XMin + pEnv.Width * 0.5, pEnv.YMin + pEnv.Height * 0.5); pTextElment = new TextElementClass() { Symbol = pTextSymbol, ScaleText = true, Text = pFeature.get_Value(index).ToString() }; pEle = pTextElment as IElement; pEle.Geometry = pPoint; //添加标注 pGraContainer.AddElement(pEle, 0); pFeature = pFeatCur.NextFeature(); } (Global.mainmap.Map as IActiveView).PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, Global.mainmap.Extent); }
public static IColor CreateColor(int red, int green, int blue) { RgbColorClass class2 = new RgbColorClass(); class2.Red = red; class2.Green = green; class2.Blue = blue; return class2; }
public static IRgbColor get_RgbColor(int red, int green, int blue) { IRgbColor theReturn = new RgbColorClass(); theReturn.Red = red; theReturn.Green = green; theReturn.Blue = blue; return theReturn; }
public static IRgbColor GET(int red, int green, int blue) { IRgbColor RGB = new RgbColorClass(); RGB.Red = red; RGB.Green = green; RGB.Blue = blue; return RGB; }
public IColor ConvertColorToIColor(Color color) { IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; return pColor; }
private IRgbColor GetRGBColor(int yourRed, int yourGreen, int yourBlue) { IRgbColor pRGB; pRGB = new RgbColorClass(); pRGB.Red = yourRed; pRGB.Green = yourGreen; pRGB.Blue = yourBlue; return pRGB; }
public static IColor CreateColor(byte alpha, int red, int green, int blue) { RgbColorClass class2 = new RgbColorClass(); class2.Red = red; class2.Green = green; class2.Blue = blue; class2.Transparency = alpha; return class2; }
public static void SetColor(int red, int green, int blue) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = red; rgbColor.Green = green; rgbColor.Blue = blue; _color = rgbColor as IColor; }
public static IRgbColor CreateRGBColor(System.Byte myRed, System.Byte myGreen, System.Byte myBlue) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = myRed; rgbColor.Green = myGreen; rgbColor.Blue = myBlue; rgbColor.UseWindowsDithering = true; return rgbColor; }
public static IRgbColor GetRGBColor(int Red, int Green, int Blue, byte Alpha = 255) { IRgbColor color = new RgbColorClass(); color.Red = Red; color.Green = Green; color.Blue = Blue; color.Transparency = Alpha; return color; }
private static ISimpleFillSymbol CreateSimpleFillSymbol(int red, int green, int blue) { ISimpleFillSymbol sfs = new SimpleFillSymbolClass(); IRgbColor color = new RgbColorClass(); color.Red = red; color.Green = green; color.Blue = blue; sfs.Color = color; return sfs; }
/// <summary> /// Covert a .Net Color class to an ArcObject IColor class. /// </summary> /// <param name="color"></param> /// <returns></returns> public static IColor Color2IColor(Color color) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.NullColor = color.IsEmpty; rgbColor.Red = color.R; rgbColor.Green = color.G; rgbColor.Blue = color.B; return (IColor)rgbColor; }
public static IColor GetColor(int red, int green, int blue) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = red; rgbColor.Green = green; rgbColor.Blue = blue; IColor color = rgbColor as IColor; color.Transparency = (byte)_transparency; return color; }
/// <summary> /// 拉伸渲染raster图层 /// </summary> /// <params name="pRLayer">raster图层</params> /// <remarks></remarks> public void UsingRasterStretchColorRampRender(IRasterLayer pRLayer) { //获得图层 IRaster pRaster = default(IRaster); pRaster = pRLayer.Raster; //创建渲染并转换到栅格渲染 IRasterStretchColorRampRenderer pStretchRen = default(IRasterStretchColorRampRenderer); pStretchRen = new RasterStretchColorRampRenderer(); IRasterRenderer pRasRen = default(IRasterRenderer); pRasRen = (IRasterRenderer)pStretchRen; //栅格渲染赋值和更新 pRasRen.Raster = pRaster; pRasRen.Update(); //定义起止颜色 IRgbColor pFromColor = new RgbColorClass(); pFromColor.Red = 0; pFromColor.Green = 255; pFromColor.Blue = 0; IRgbColor pToColor = new RgbColorClass(); pToColor.Red = 255; pToColor.Green = 0; pToColor.Blue = 0; //创建颜色条 IAlgorithmicColorRamp pRamp = new AlgorithmicColorRamp(); pRamp.Size = 255; pRamp.FromColor = pFromColor; pRamp.ToColor = pToColor; bool bOK; pRamp.CreateRamp(out bOK); //插入颜色条和选择渲染波段 pStretchRen.BandIndex = 0; pStretchRen.ColorRamp = pRamp; //用新的设置更新渲染并赋值给图层 pRasRen.Update(); pRLayer.Renderer = (IRasterRenderer)pStretchRen; //释放内存 pRLayer = null; pRaster = null; pStretchRen = null; pRasRen = null; pRamp = null; pToColor = null; pFromColor = null; }
public static IColor GetColor() { if (_color == null) { IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Green = 0; rgbColor.Blue = 0; _color = rgbColor as IColor; } return _color; }
public void SetResults(IEnumNetEID edgeEnumNetEID, IEnumNetEID juncEnumNetEID, bool asSelection, INetworkAnalysisExt netAnalExt, Color namedColor) { INetworkAnalysisExtResults netAnalResults = (INetworkAnalysisExtResults)_netAnalExt; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = namedColor.R; rgbColor.Blue = namedColor.B; rgbColor.Green = namedColor.G; netAnalResults.ResultsAsSelection = asSelection; netAnalResults.DrawComplex = true; INetworkAnalysisExtResultColor netAnalColor = (INetworkAnalysisExtResultColor)netAnalExt; netAnalColor.Color = rgbColor; netAnalResults.SetResults(juncEnumNetEID, edgeEnumNetEID); }
private void MainForm_Load(object sender, EventArgs e) { m_mapControl = (IMapControl3) axMapControl1.Object; //relative file path to the sample data from EXE location string filePath = @"..\..\..\data\USAMajorHighways"; //Add Lakes layer IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace workspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile(filePath, axMapControl1.hWnd); IFeatureLayer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Lakes"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("us_lakes"); #region create a SimplerRenderer IRgbColor color = new RgbColorClass(); color.Red = 190; color.Green = 232; color.Blue = 255; ISimpleFillSymbol sym = new SimpleFillSymbolClass(); sym.Color = color; ISimpleRenderer renderer = new SimpleRendererClass(); renderer.Symbol = sym as ISymbol; #endregion ((IGeoFeatureLayer)featureLayer).Renderer = renderer as IFeatureRenderer; axMapControl1.Map.AddLayer((ILayer)featureLayer); //Add Highways layer featureLayer = new FeatureLayerClass(); featureLayer.Name = "Highways"; featureLayer.Visible = true; featureLayer.FeatureClass = workspace.OpenFeatureClass("usa_major_highways"); axMapControl1.Map.AddLayer((ILayer)featureLayer); //******** Important ************* //store a reference to this form (Mainform) using the EditHelper class EditHelper.TheMainForm = this; EditHelper.IsEditorFormOpen = false; //add the EditCmd command to the toolbar axEditorToolbar.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axEditorToolbar.AddItem(new EditCmd(), 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); }
/// <summary> /// Adds a sphere element to the given graphics layer at the specified position /// </summary> /// <param name="globeGraphicsLayer"></param> /// <param name="position"></param> /// <returns></returns> private int AddTrackElement(IGlobeGraphicsLayer globeGraphicsLayer, esriGpsPositionInfo position) { if (null == globeGraphicsLayer) { return(-1); } //create a new point at the given position IPoint point = new PointClass(); ((IZAware)point).ZAware = true; point.X = position.longitude; point.Y = position.latitude; point.Z = 0.0; //set the color for the element (red) IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 0; color.Blue = 0; //create a new 3D marker symbol IMarkerSymbol markerSymbol = new SimpleMarker3DSymbolClass(); //set the marker symbol's style and resolution ((ISimpleMarker3DSymbol)markerSymbol).Style = esriSimple3DMarkerStyle.esriS3DMSSphere; ((ISimpleMarker3DSymbol)markerSymbol).ResolutionQuality = 1.0; //set the symbol's size and color markerSymbol.Size = 700; markerSymbol.Color = color as IColor; //crate the graphic element IElement trackElement = new MarkerElementClass(); //set the element's symbol and geometry (location and shape) ((IMarkerElement)trackElement).Symbol = markerSymbol; trackElement.Geometry = point as IPoint; //add the element to the graphics layer int elemIndex = 0; ((IGraphicsContainer)globeGraphicsLayer).AddElement(trackElement, 0); //get the element's index globeGraphicsLayer.FindElementIndex(trackElement, out elemIndex); return(elemIndex); }
public IRgbColor GetRgb(int r, int g, int b) { IRgbColor pRGB; pRGB = new RgbColorClass(); pRGB.Red = r; pRGB.Green = g; pRGB.Blue = b; return pRGB; }
public IDotDensityFillSymbol CreateDotDensityFillSymbol() { IDotDensityFillSymbol symbol = new DotDensityFillSymbolClass { DotSize = 2.0 }; IColor color = new RgbColorClass { NullColor = true }; symbol.BackgroundColor = color; return(symbol); }
//���ำ������ private IRgbColor GetRGBColor(int R, int G, int B) { IRgbColor pRGB; pRGB = new RgbColorClass(); pRGB.Red = R; pRGB.Green = G; pRGB.Green = B; return pRGB; }
private void AddElement(IMap map, IGeometry geom) { IGraphicsContainer graphicsContainer = map as IGraphicsContainer; IRgbColor color = new RgbColorClass(); color.Green = 80; color.Red = 22; color.Blue = 68; IElement element = null; if (geom is IPoint) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = markerElement as IElement; if (element != null) { element.Geometry = geom; } } else if (geom is IPolygon) { var temp = new SimpleLineSymbol(); temp.Color = color; temp.Style = esriSimpleLineStyle.esriSLSSolid; temp.Width = 2; var s = new SimpleFillSymbol(); s.Color = color; s.Outline = temp; s.Style = esriSimpleFillStyle.esriSFSBackwardDiagonal; var pe = new PolygonElementClass(); element = pe as IElement; var fill = pe as IFillShapeElement; fill.Symbol = s; element.Geometry = geom; } graphicsContainer.AddElement(element, 0); IActiveView activeView = map as IActiveView; activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void colorEditTransColor_EditValueChanged(object sender, EventArgs e) { if (this.m_CanDo) { IColor bitmapTransparencyColor = this.m_pTextureLineSymbol.BitmapTransparencyColor; if (bitmapTransparencyColor == null) { bitmapTransparencyColor = new RgbColorClass(); } this.UpdateColorFromColorEdit(this.colorEditTransColor, bitmapTransparencyColor); this.m_pTextureLineSymbol.BitmapTransparencyColor = bitmapTransparencyColor; this.refresh(e); } }
private void drawMapshape(IGeometry pgeo) { IRgbColor pcolor = new RgbColorClass(); pcolor.Red = 135; pcolor.Green = 206; pcolor.Blue = 250; object symbol = null; ISimpleFillSymbol simplefillsymbol = new SimpleFillSymbolClass(); simplefillsymbol.Color = pcolor; symbol = simplefillsymbol; axMapControl1.DrawShape(pgeo, ref symbol); }
private IRgbColor GetRGBColor(int R, int G, int B)//子类赋给父类 { IRgbColor pRGB; pRGB = new RgbColorClass(); pRGB.Red = R; pRGB.Green = G; pRGB.Green = B; return(pRGB); }
public override void OnMouseDown(int button, int shift, int x, int y, double mapX, double mapY) { //弹出对话框 IGraphicElements iGraphicElements = new GraphicElementsClass(); FrmCreateText frmCreateText = new FrmCreateText(); ITextElement iTextElement = new TextElementClass(); //XtraMessageBox.Show("请输入文本"); //string str = Interaction.InputBox("请输入文本", "字符串", "", 100, 100);//即获取用户输入的数据 if (frmCreateText.ShowDialog() == DialogResult.OK) { //string str = textEdit1.Text; iTextElement.Text = FrmCreateText.value; iTextElement.ScaleText = true; //string str = frmCreateText.textEdit1.Text; //iTextElement.Text = "HAO";//this.iMapDocument.DocumentFilename;//判断 ITextSymbol sce = new TextSymbolClass(); //ISymbolCollectionElement sce = (ISymbolCollectionElement)iTextElement; sce.Size = 200; Color color = ColorTranslator.FromHtml(SystemInfo.Instance.TextColor); IColor pColor = new RgbColorClass(); pColor.RGB = color.B * 65536 + color.G * 256 + color.R; sce.Color = pColor; iTextElement.Symbol = sce; IElement iElement = (IElement)iTextElement; IActiveView iActiveView = this.m_pMapControl.ActiveView; IEnvelope env = m_pMapControl.ActiveView.Extent; tagRECT rect = new tagRECT(); m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.TransformRect(env, ref rect, (int)esriDisplayTransformationEnum.esriTransformToDevice); Rectangle rectangle = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top); int x1 = (rectangle.Left + rectangle.Right) / 2; int y1 = (rectangle.Top + rectangle.Bottom) / 2; IPoint pt = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); int x2 = (int)pt.X; int y2 = (int)pt.Y; iElement.Geometry = iActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x2, y2); iElement.Geometry = this.m_pMapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y); this.m_pMapControl.ActiveView.GraphicsContainer.AddElement(iElement, 0); this.m_pMapControl.ActiveView.Refresh(); } }
/// <summary> /// Adds a point /// </summary> /// <param name="x">The X Coordinate</param> /// <param name="y">The y Coordinate</param> /// <param name="coordinateSystem">The coordinate system.</param> /// <param name="description">The description.</param> /// <param name="minX">The extent min X.</param> /// <param name="minY">The extent min Y.</param> /// <param name="maxX">The extent max X.</param> /// <param name="maxY">The extent max Y.</param> private void AddPoint(Double x, Double y, int coordinateSystem, String description, Double minX, Double minY, Double maxX, Double maxY) { try { //get mapdocument IMxDocument mxDocument = ArcMap.Application.Document as IMxDocument; //get map IMap map = mxDocument.FocusMap; //get the active view IActiveView activeView = mxDocument.ActiveView; //get the point from the matched record ESRI.ArcGIS.Geometry.Point point = CreatePoint(x, y, coordinateSystem, map.SpatialReference); //create a simple marker and set attributes ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Size = 10; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IRgbColor color = new RgbColorClass(); color.Red = Color.Blue.R; color.Green = Color.Blue.G; color.Blue = Color.Blue.B; simpleMarkerSymbol.Color = color; //Create the Grapthics Element IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol as IMarkerSymbol; IElement markerElementAsElement = markerElement as IElement; markerElementAsElement.Geometry = point; IElementProperties markerElementAsElementProperties = markerElement as IElementProperties; markerElementAsElementProperties.Name = LOCATOR_ELEMENT_NAME; //Add the Element to the view IGraphicsContainer graphicsContainer = map as IGraphicsContainer; graphicsContainer.AddElement(markerElementAsElement as IElement, 0); markerElementAsElement.Activate(activeView.ScreenDisplay); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); //Add the callout box AddCallout(point, description); //move to location MoveToLocation(point, map, coordinateSystem, minX, minY, maxX, maxY); } catch (Exception ex) { ShowError(ex); } }
/// <summary> /// 根据容积率大小进行梯度颜色显示 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button4_Click(object sender, EventArgs e) { //梯度颜色算法 IAlgorithmicColorRamp pAlgoColorRamp = new AlgorithmicColorRampClass(); pAlgoColorRamp.Size = MyArray.Length; IRgbColor pFromColor = new RgbColorClass(), pToColor = new RgbColorClass(); pFromColor.Red = 255; pFromColor.Green = 255; pFromColor.Blue = 255; pToColor.Red = 0; pToColor.Green = 255; pToColor.Blue = 255; pAlgoColorRamp.FromColor = pFromColor; pAlgoColorRamp.ToColor = pToColor; bool ok = true; pAlgoColorRamp.CreateRamp(out ok); IClassBreaksRenderer pRender = new ClassBreaksRendererClass(); pRender.BreakCount = MyArray.Length; pRender.Field = "Plot_Ratio"; ISimpleFillSymbol pSym; System.Array.Sort(MyArray); for (int i = 0; i < MyArray.Length; i++) { pRender.set_Break(i, (double)MyArray.GetValue(i)); pSym = new SimpleFillSymbolClass(); pSym.Color = pAlgoColorRamp.get_Color(i); pRender.set_Symbol(i, (ISymbol)pSym); } IGeoFeatureLayer pGeoLyr = (IGeoFeatureLayer)Form1.mainForm.axMapControl1.get_Layer(1);//确保先加入地块图层 pGeoLyr.Renderer = (IFeatureRenderer)pRender; Form1.mainForm.axMapControl1.Refresh(); Form1.mainForm.axTOCControl1.Update(); }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { // TODO: Add AddNetBarriesTool.OnMouseDown implementation try { IPoint pStopsPoint = new PointClass(); pStopsPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IFeature newPointFeature = barriesFClass.CreateFeature(); try { newPointFeature.Shape = pStopsPoint; } catch { IGeometry pGeo = pStopsPoint; IZAware pZAware = pGeo as IZAware; pZAware.ZAware = false; newPointFeature.Shape = pGeo; } newPointFeature.Store(); IGraphicsContainer pGrap = m_hookHelper.ActiveView as IGraphicsContainer; IColor pColor; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Green = 255; pRgbColor.Blue = 255; pColor = pRgbColor as IColor; IPictureMarkerSymbol pms = new PictureMarkerSymbolClass(); pms.BitmapTransparencyColor = pColor; //添加自定义障碍点图片 pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, NetWorkAnalysClass.getPath(path) + "\\data\\Img\\barries.bmp"); pms.Size = 18; IMarkerElement pMarkerEle = new MarkerElementClass(); pMarkerEle.Symbol = pms as IMarkerSymbol; pStopsPoint.SpatialReference = m_hookHelper.ActiveView.FocusMap.SpatialReference; IElement pEle = pMarkerEle as IElement; pEle.Geometry = pStopsPoint; pGrap.AddElement(pEle, 1); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } catch { MessageBox.Show("障碍点添加失败!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
/// <summary> /// Handler for the new map point click event /// </summary> /// <param name="obj">IPoint</param> internal virtual void OnNewMapPointEvent(object obj) { if (!IsActiveTab) { return; } var mxdoc = ArcMap.Application.Document as IMxDocument; var av = mxdoc.FocusMap as IActiveView; var point = obj as IPoint; if (point == null) { return; } if (!HasPoint1) { // clear temp graphics ClearTempGraphics(); Point1 = point; HasPoint1 = true; Point1Formatted = string.Empty; var color = new RgbColorClass() { Green = 255 } as IColor; AddGraphicToMap(Point1, color, true); // lets try feedback CreateFeedback(point, av); feedback.Start(point); } else if (!HasPoint2) { ResetFeedback(); Point2 = point; HasPoint2 = true; point2Formatted = string.Empty; RaisePropertyChanged(() => Point2Formatted); } if (HasPoint1 && HasPoint2) { CreateMapElement(); ResetPoints(); } }
private static ITextElement MakeTextElement(IPoint pPoint, string strText, string sFontName, bool Centered = false, long FontSize = 8) { // Setup a color IRgbColor pRGBColor = new RgbColorClass(); pRGBColor.Blue = 0; pRGBColor.Red = 0; pRGBColor.Green = 0; // Set text element at the right place ITextElement pTextElement = new TextElementClass(); IElement pElement = pTextElement as IElement; pElement.Geometry = pPoint; try { // Setup a Font IFontDisp pFontDisp = new stdole.StdFontClass() as IFontDisp; pFontDisp.Name = sFontName; // Setup a TextSymbol that the TextElement will draw with ITextSymbol pTextSymbol = new TextSymbolClass(); pTextSymbol.Font = pFontDisp; pTextSymbol.Color = pRGBColor; pTextSymbol.Size = FontSize; // Center if appropriate if (Centered == true) { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHACenter; pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVACenter; } else { pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; pTextSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVATop; } // Give the TextSymbol and string to the TextElement pTextElement.Symbol = pTextSymbol; pTextElement.Text = strText; } catch (Exception e) { MessageBox.Show("Make Text Element : " + strText + " " + sFontName + " Error: " + e.StackTrace); } return(pTextElement); }
private void CreateFeed() { this._lineFeedback = new NewLineFeedbackClass(); this._lineFeedback.Display = this._hookHelper.ActiveView.ScreenDisplay; IRgbColor color = new RgbColorClass { Blue = 0xff, Green = 0, Red = 0xc5 }; IColor color2 = color; ILineSymbol symbol = this._lineFeedback.Symbol as ILineSymbol; symbol.Color = color2; symbol.Width = 2.0; }
private void CreateOverviewSymbol() { IRgbColor iRgb = new RgbColorClass(); iRgb.RGB = 255; ILineSymbol pOutline = new SimpleLineSymbolClass(); pOutline.Color = iRgb; pOutline.Width = 2.3; ISimpleFillSymbol pSimpleFillSymbol = new SimpleFillSymbolClass(); pSimpleFillSymbol.Outline = pOutline; pSimpleFillSymbol.Style = esriSimpleFillStyle.esriSFSHollow; oFillobject = pSimpleFillSymbol; }
/// <summary> /// Occurs when this tool is created /// </summary> /// <param name="hook">Instance of the application</param> public override void OnCreate(object hook) { m_application = hook as IApplication; //Set up m_geomEnv = new GeometryEnvironmentClass(); m_feedbackSymbol = new SimpleLineSymbolClass(); ((ISymbol)m_feedbackSymbol).ROP2 = esriRasterOpCode.esriROPNotXOrPen; IRgbColor solidColor = new RgbColorClass(); solidColor.Red = 255; m_feedbackSymbol.Color = solidColor; m_feedbackSymbol.Width = 2; }
/// <summary> /// 设置点的颜色 /// </summary> /// <param name="argb">argb</param> public void SetColor(int argb) { bColor = Color.FromArgb(argb); IColor c = new RgbColorClass() { Transparency = bColor.A, Red = bColor.R, Green = bColor.G, Blue = bColor.B }; pMarkerSymbol.Color = c; Update(); }
private static ISymbol CreateFillSym() { IRgbColor pOutlineColor = new RgbColorClass(); pOutlineColor.Red = 0; pOutlineColor.Green = 0; pOutlineColor.Blue = 0; IRgbColor pFillColor = new RgbColorClass(); pFillColor.Red = 128; pFillColor.Green = 255; pFillColor.Blue = 128; return(ModuleCommon.CreateFillSym(pFillColor, 0.1, pOutlineColor)); }
/// <summary> /// Get the default selection line symbol (black color and width equals to one) /// </summary> /// <returns></returns> public static ISimpleLineSymbol GetDefaultSelectLineSymbol() { IRgbColor color = new RgbColorClass(); color.Red = 255; color.Green = 255; color.Blue = 255; ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Width = 1; lineSymbol.Color = (IColor)color; return(lineSymbol); }
/// <summary> /// 构造RGBa颜色 /// </summary> /// <param name="intR"></param> /// <param name="intG"></param> /// <param name="intB"></param> /// <param name="alpha"></param> /// <returns></returns> static public IRgbColor getRgbColor(int intR, int intG, int intB, byte alpha) { IRgbColor pRgbColor = null; if (intR < 0 || intR > 255 || intG < 0 || intG > 255 || intB < 0 || intB > 255) { return(pRgbColor); } pRgbColor = new RgbColorClass(); pRgbColor.Red = intR; pRgbColor.Green = intG; pRgbColor.Blue = intB; pRgbColor.Transparency = alpha; return(pRgbColor); }
/// <summary> /// 设置透明度 /// </summary> /// <param name="_opacity"></param> public void SetOpacity(int _opacity) { IRgbColor color = new RgbColorClass(); color.Transparency = (byte)_opacity; color.Red = fillColor.R; color.Green = fillColor.G; color.Blue = fillColor.B; Dosomething((Action) delegate() { fillSymbol.Color = color; base.Symbol = fillSymbol; }, true); }
/// <summary> /// 配置指定的注记要素 /// </summary> /// <param name="feature">要修改的注记要素</param> /// <param name="pointGeometry">注记要素坐标</param> /// <param name="text">注记内容</param> /// <param name="fontSize"></param> /// <param name="verticalAlignment"></param> /// <param name="horizontalAlignment"></param> public void ConfigAnnotation(IFeature feature, IGeometry pointGeometry, string text, int fontSize, esriTextVerticalAlignment verticalAlignment, esriTextHorizontalAlignment horizontalAlignment) { IFontDisp font = new StdFontClass() as IFontDisp; font.Name = "宋体"; font.Bold = true; IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass(); formattedTextSymbol.Font = font; formattedTextSymbol.Size = fontSize; formattedTextSymbol.VerticalAlignment = verticalAlignment; formattedTextSymbol.HorizontalAlignment = horizontalAlignment; formattedTextSymbol.Angle = 0; formattedTextSymbol.CharacterSpacing = 10; formattedTextSymbol.CharacterWidth = 80; formattedTextSymbol.FlipAngle = 90; formattedTextSymbol.Leading = 0; formattedTextSymbol.WordSpacing = 10; formattedTextSymbol.Text = text; IColor rgb = new RgbColorClass(); rgb.RGB = 15354; formattedTextSymbol.Color = rgb; ITextElement textElement = new TextElementClass(); textElement.Symbol = formattedTextSymbol; textElement.Text = text; IElement element = textElement as IElement; element.Geometry = pointGeometry; element.Geometry.Envelope.Width = 0.06; IAnnotationFeature2 annotationFeature2 = feature as IAnnotationFeature2; try { // annotationFeature2.Annotation.Geometry = pointGeometry; annotationFeature2.Annotation = element; annotationFeature2.Status = esriAnnotationStatus.esriAnnoStatusPlaced; feature.Store(); } catch { } }
private void createGrapicAndZoomTo(string capakeyResponse, datacontract.geojson Geom) { IRgbColor inClr = new RgbColorClass() { Red = 0, Blue = 100, Green = 0 };; IRgbColor outLine = new RgbColorClass() { Red = 0, Blue = 200, Green = 0, Transparency = 240 }; if (Geom.type == "MultiPolygon") { datacontract.geojsonMultiPolygon muniPolygons = JsonConvert.DeserializeObject <datacontract.geojsonMultiPolygon>(capakeyResponse); IGeometryCollection multiPoly = new GeometryBagClass(); clearGraphics(); foreach (datacontract.geojsonPolygon poly in muniPolygons.toPolygonList()) { IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(poly, (int)dataHandler.CRS.Lambert72); lbPoly.SimplifyPreserveFromTo(); IGeometry prjGeom = geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference); IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, prjGeom, inClr, outLine, 2, true); graphics.Add(muniGrapic); multiPoly.AddGeometry(prjGeom); } view.Extent = ((IGeometryBag)multiPoly).Envelope; view.Refresh(); } else if (Geom.type == "Polygon") { datacontract.geojsonPolygon municipalityPolygon = JsonConvert.DeserializeObject <datacontract.geojsonPolygon>(capakeyResponse); IPolygon lbPoly = geopuntHelper.geojson2esriPolygon(municipalityPolygon, (int)dataHandler.CRS.Lambert72); lbPoly.SimplifyPreserveFromTo(); IPolygon prjPoly = (IPolygon)geopuntHelper.Transform((IGeometry)lbPoly, map.SpatialReference); view.Extent = prjPoly.Envelope; clearGraphics(); IElement muniGrapic = geopuntHelper.AddGraphicToMap(map, (IGeometry)prjPoly, inClr, outLine, 3, true); graphics.Add(muniGrapic); view.Refresh(); } }
internal override void OnNewMapPointEvent(object obj) { base.OnNewMapPointEvent(obj); if (!IsActiveTab) { return; } var point = obj as IPoint; if (point != null && ToolMode == MapPointToolMode.Target) { if (IsMapClick) { if (!(IsValidPoint(point, true))) { IsMapClick = false; return; } } var color = new RgbColorClass() { Red = 255 } as IColor; var guid = AddGraphicToMap(point, color, true, esriSimpleMarkerStyle.esriSMSSquare); var addInPoint = new AddInPoint() { Point = point, GUID = guid }; bool isValid = IsValidPoint(point, false); if (!isValid) { TargetOutExtentPoints.Insert(0, addInPoint); } else { TargetInExtentPoints.Insert(0, addInPoint); } TargetAddInPoints.Insert(0, addInPoint); IsMapClick = false; } ValidateLLOS_LayerSelection(); }
public void DrawDifferenceGeometry(IGeometry igeometry_0, IScreenDisplay iscreenDisplay_0) { IRgbColor color = new RgbColorClass { Red = 255 }; iscreenDisplay_0.StartDrawing(iscreenDisplay_0.hDC, -1); switch (igeometry_0.GeometryType) { case esriGeometryType.esriGeometryPoint: { ISimpleMarkerSymbol symbol = new SimpleMarkerSymbolClass { Color = color, Size = 10.0 }; iscreenDisplay_0.SetSymbol(symbol as ISymbol); iscreenDisplay_0.DrawPoint(igeometry_0); break; } case esriGeometryType.esriGeometryPolyline: { ISimpleLineSymbol symbol2 = new SimpleLineSymbolClass { Color = color, Width = 2.0 }; iscreenDisplay_0.SetSymbol(symbol2 as ISymbol); iscreenDisplay_0.DrawPolyline(igeometry_0); break; } case esriGeometryType.esriGeometryPolygon: { ISimpleFillSymbol symbol3 = new SimpleFillSymbolClass { Outline = { Color = color, Width = 2.0 }, Style = esriSimpleFillStyle.esriSFSForwardDiagonal }; iscreenDisplay_0.SetSymbol(symbol3 as ISymbol); iscreenDisplay_0.DrawPolygon(igeometry_0); break; } } iscreenDisplay_0.FinishDrawing(); }
/// <summary> /// 构造函数 /// </summary> /// <param name="graphicsLayer"></param> /// <param name="textKml">文字kml</param> public Text_ArcGlobe(IGlobeGraphicsLayer graphicsLayer, KmlText textKml) { this.graphicsLayer = graphicsLayer; this.ElementType = ElementTypeEnum.Text; //图元类型 this.Description = textKml.Description; //图元描述 #region 位置 IPoint point = new PointClass() { X = textKml.Position.Lng, Y = textKml.Position.Lat, Z = textKml.Position.Alt }; (point as IZAware).ZAware = true; //base.Geometry = point; #endregion #region 符号 base.FixedAspectRatio = true; //表明是否固定界限比例 //this.ReferenceScale = 100;//设置固定比例,不知道具体作用 base.AnchorPoint = point; //锚 base.Text = textKml.Content; base.Height = textKml.Size; base.FontName = textKml.Font; base.AxisRotation = esriT3DRotationAxis.esriT3DRotateAxisX; //旋转轴 base.RotationAngle = -90; //旋转角度 Color _color = textKml.Color; IRgbColor color = new RgbColorClass() { Red = _color.R, Green = _color.G, Blue = _color.B }; fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = color; base.Symbol = fillSymbol; this.fontColor = textKml.Color; this.fontSize = textKml.Size; #endregion isFlash = false; flashTimer = new System.Timers.Timer(); flashTimer.Elapsed += new System.Timers.ElapsedEventHandler(flashTimer_Elapsed); flashTimer.Interval = 500; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { try { IPoint pBarriesPoint = new PointClass(); //将鼠标在屏幕上点击的一点的坐标转换为地图上的坐标,并赋给pBarriesPoint pBarriesPoint = m_hookHelper.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y); IFeature newPointFeature = barriesFClass.CreateFeature();//创建新的障碍点要素 try { newPointFeature.Shape = pBarriesPoint;//将pStopsPoint赋给新要素的Shape属性 } catch { IGeometry pGeo = pBarriesPoint; IZAware pZAware = pGeo as IZAware; pZAware.ZAware = false; newPointFeature.Shape = pGeo; } newPointFeature.Store();//存储障碍点要素 //将障碍点图标添加到图层 IGraphicsContainer pGrap = m_hookHelper.ActiveView as IGraphicsContainer; IColor pColor; IRgbColor pRgbColor = new RgbColorClass(); pRgbColor.Red = 255; pRgbColor.Green = 255; pRgbColor.Blue = 255; pColor = pRgbColor as IColor; IPictureMarkerSymbol pms = new PictureMarkerSymbolClass(); pms.BitmapTransparencyColor = pColor; string picturePath = NetWorkAnalysClass.getPath(path) + "\\data\\Img\\barries.bmp"; //添加自定义障碍点图片 pms.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, picturePath); pms.Size = 18; IMarkerElement pMarkerEle = new MarkerElementClass(); pMarkerEle.Symbol = pms as IMarkerSymbol; //将障碍点位置数据的空间参考设为与地图空间参考一致 pBarriesPoint.SpatialReference = m_hookHelper.ActiveView.FocusMap.SpatialReference; IElement pEle = pMarkerEle as IElement; pEle.Geometry = pBarriesPoint; pGrap.AddElement(pEle, 1); m_hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } catch { MessageBox.Show("添加障碍点失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
/// <summary> /// 绘制鹰眼矩形框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void axMapControl1_OnExtentUpdated(object sender, IMapControlEvents2_OnExtentUpdatedEvent e) { //得到新范围 IEnvelope pEnv = (IEnvelope)e.newEnvelope; IGraphicsContainer pGra = axMapControl2.Map as IGraphicsContainer; IActiveView pAv = pGra as IActiveView; //在绘制前,清除axMapControl2中的任何图形元素 pGra.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pEle = pRectangleEle as IElement; pEle.Geometry = pEnv; //设置鹰眼图中的红线框 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 255; //产生一个线符号对象 ILineSymbol pOutline = new SimpleLineSymbolClass(); pOutline.Width = 2; pOutline.Color = pColor; //设置颜色属性 pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0; //设置填充符号的属性 IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline; IFillShapeElement pFillShapeEle = pEle as IFillShapeElement; pFillShapeEle.Symbol = pFillSymbol; pGra.AddElement((IElement)pFillShapeEle, 0); //刷新 pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
/// <summary> /// Creates a Temporal Layer using the specified feature class and add it to the map. /// </summary> /// <param name="featureClass">The feature class to use for the temporal layer.</param> /// <param name="eventFieldName">Indicates the feature class column that identifies or groups temporal observations with time series.</param> /// <param name="temporalFieldName">Identifies the temporal field, which must be a field type whose data can be converted to a date value.</param> private void AddTemporalLayer(IFeatureClass featureClass, string eventFieldName, string temporalFieldName) { ITemporalLayer temporalFeatureLayer = new TemporalFeatureLayerClass(); IFeatureLayer2 featureLayer = temporalFeatureLayer as IFeatureLayer2; ILayer layer = temporalFeatureLayer as ILayer; ITemporalRenderer temporalRenderer = new CoTrackSymbologyRendererClass(); ITemporalRenderer2 temporalRenderer2 = (ITemporalRenderer2)temporalRenderer; IFeatureRenderer featureRenderer = temporalRenderer as IFeatureRenderer; ITrackSymbologyRenderer trackRenderer = temporalRenderer as ITrackSymbologyRenderer; if (featureLayer != null) { featureLayer.FeatureClass = featureClass; } if (featureRenderer != null) { temporalRenderer.TemporalObjectColumnName = eventFieldName; temporalRenderer.TemporalFieldName = temporalFieldName; temporalFeatureLayer.Renderer = featureRenderer; } if (trackRenderer != null) { //Create green color value IRgbColor rgbColor = new RgbColorClass(); rgbColor.RGB = 0x00FF00; //Create simple thin green line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = (IColor)rgbColor; simpleLineSymbol.Width = 1.0; //Create simple renderer using line symbol ISimpleRenderer simpleRenderer = new SimpleRendererClass(); simpleRenderer.Symbol = (ISymbol)simpleLineSymbol; //Apply line renderer as track symbol and enable track rendering trackRenderer.TrackSymbologyRenderer = (IFeatureRenderer)simpleRenderer; trackRenderer.ShowTrackSymbologyLegendGroup = true; temporalRenderer2.TrackRendererEnabled = true; } if (layer != null) { ArcMap.Document.FocusMap.AddLayer(layer); } }
/// <summary> /// 获得三维视图的显示范围,并在二维地图上显示 /// </summary> /// <param name="pViewer"></param> void m_GlobeDisplayEvents_AfterDraw(ISceneViewer pViewer) { m_MapExtent = new EnvelopeClass(); m_GlobeViewUtil.QueryVisibleGeographicExtent(m_MapExtent); IGraphicsContainer pGra = axMapControl1.Map as IGraphicsContainer; IActiveView pAv = pGra as IActiveView; pGra.DeleteAllElements(); IRectangleElement rec = new RectangleElementClass(); IElement ele = rec as IElement; ele.Geometry = m_MapExtent; //创建颜色对象 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; //创建线型对象并设置颜色和宽度 ILineSymbol line = new SimpleLineSymbolClass(); line.Color = pColor; line.Width = 2; pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0;//设置透明度 IFillSymbol fill = new SimpleFillSymbolClass(); fill.Outline = line; fill.Color = pColor; IFillShapeElement pFillElement = ele as IFillShapeElement; pFillElement.Symbol = fill; pGra.AddElement((IElement)pFillElement, 0); pAv.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e) { IActiveView pActiveView = axMapControl1.ActiveView; IScreenDisplay screenDisplay = pActiveView.ScreenDisplay; ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; lineSymbol.Color = rgbColor; // IRubberBand rubberLine = new RubberLineClass(); // IPolyline pLine = (IPolyline)rubberLine.TrackNew(screenDisplay, (ISymbol)lineSymbol); IPolyline pLine = axMapControl1.TrackLine() as IPolyline; screenDisplay.StartDrawing(screenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); screenDisplay.SetSymbol((ISymbol)lineSymbol); screenDisplay.DrawPolyline(pLine); screenDisplay.FinishDrawing(); }
/// <summary> /// 拉伸渲染模式(貌似) /// </summary> /// <param name="rasterDataset"></param> /// <returns></returns> private static IRasterRenderer StretchRenderer(ESRI.ArcGIS.Geodatabase.IRasterDataset rasterDataset, int graypos,int i) { try { //Define the from and to colors for the color ramp. IRgbColor fromColor = new RgbColorClass(); fromColor.Red = 255; fromColor.Green = 0; fromColor.Blue = 0; IColor toColor = new RgbColorClass(); //此处应该是写错了 fromColor.Red = 0; fromColor.Green = 255; fromColor.Blue = 0; //Create the color ramp. IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass(); colorRamp.Size = 255; colorRamp.FromColor = fromColor; colorRamp.ToColor = toColor; bool createColorRamp; colorRamp.CreateRamp(out createColorRamp); //Create a stretch renderer. IRasterStretchColorRampRenderer stretchRenderer = new RasterStretchColorRampRendererClass(); //设置显示对比度和亮度 //((IRasterDisplayProps)stretchRenderer).BrightnessValue = -90; IRasterRenderer rasterRenderer = (IRasterRenderer)stretchRenderer; //Set the renderer properties. IRaster raster = rasterDataset.CreateDefaultRaster(); rasterRenderer.Raster = raster; rasterRenderer.Update(); stretchRenderer.BandIndex = graypos; //stretchRenderer.ColorRamp = colorRamp; //Set the stretch type. IRasterStretch stretchType = (IRasterStretch)rasterRenderer; stretchType.StretchType = esriRasterStretchTypesEnum.esriRasterStretch_StandardDeviations; stretchType.StandardDeviationsParam = 2; return rasterRenderer; } catch { return null; } }
protected override void OnMouseDown(MouseEventArgs arg) { //Get the active view from the AecMap static class IActiveView activeView = ArcMap.Document.ActiveView; //if polyline object then get from the user's mouse clicks. IPolyline polyline = GetPolylineFromMouseClicks(activeView); //Make a color to draw the polyline. IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; //Add the user's drawn graphics as persistent on the map. AddGraphicToMap(activeView.FocusMap, polyline, rgbColor, rgbColor); //Best practice: Only redraw the portion of the active view that contains graphics. activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
public IBalloonCallout CreateBalloonCallout(double x, double y) { IRgbColor pRgbClr = new RgbColorClass(); pRgbClr.Red = 255; pRgbClr.Blue = 255; pRgbClr.Green = 255; ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass(); pSmplFill.Color = pRgbClr; pSmplFill.Style = esriSimpleFillStyle.esriSFSSolid; IBalloonCallout pBllnCallout = new BalloonCalloutClass(); pBllnCallout.Style = esriBalloonCalloutStyle.esriBCSRectangle; pBllnCallout.Symbol = pSmplFill; pBllnCallout.LeaderTolerance = 1; IPoint pPoint = new ESRI.ArcGIS.Geometry.PointClass(); pPoint.X = x; pPoint.Y = y; pBllnCallout.AnchorPoint = pPoint; return pBllnCallout; }
protected override void OnClick(EventArgs e) { base.OnClick(e); tagRECT rect = new tagRECT(); GetWindowRect(this.Handle, ref rect); IColorPalette pColorPalette = new ColorPaletteClass(); IColor pInColor = new RgbColorClass(); pInColor.Transparency = 255; if (m_IsNoColor == true) pInColor.NullColor = true; else { if (m_ESRIColor == null) pInColor.RGB = ConvertSystemColorToESRIColor(m_SystemColor.ToArgb()); else { pInColor.RGB = m_ESRIColor.RGB; } } bool bSelectColor = false; bSelectColor = pColorPalette.TrackPopupMenu(ref rect, pInColor, false, this.Handle.ToInt32()); if (bSelectColor == true) { m_ESRIColor = pColorPalette.Color; if (m_ESRIColor.NullColor != true) { m_IsNoColor = false; m_SystemColor = Color.FromArgb(ConvertSystemColorToESRIColor(m_ESRIColor.RGB)); } else { m_IsNoColor = true; m_SystemColor = this.BackColor; } Invalidate(); } }
/// <summary> /// 点图层的简单渲染 /// </summary> /// <param name="pGeoFeatureLayer"></param> public void DefinePointSimpleValueRenderer(IGeoFeatureLayer pGeoFeatureLayer) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbolClass(); pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; pSimpleMarkerSymbol.Size = 5; pSimpleMarkerSymbol.Outline = true; IRgbColor pLineRgbColor = new RgbColorClass(); pLineRgbColor.RGB = 0; // pLineRgbColor.Red = 0; // pLineRgbColor.Green = 0; // pLineRgbColor.Blue = 0; pSimpleMarkerSymbol.OutlineColor = pLineRgbColor as IColor; pLineRgbColor.Red = 34; pLineRgbColor.Green = 139; pLineRgbColor.Blue = 34; pSimpleMarkerSymbol.Color = pLineRgbColor as IColor; ISimpleRenderer simpleRender = new SimpleRendererClass(); simpleRender.Symbol = pSimpleMarkerSymbol as ISymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)simpleRender; }
public Button1() { mxdoc = ArcMap.Application.Document as IMxDocument; map = mxdoc.FocusMap as IMap; IActiveViewEvents_Event evt = map as IActiveViewEvents_Event; evt.AfterDraw += (IDisplay disp, esriViewDrawPhase phase) => { if (hasClicked && esriViewDrawPhase.esriViewForeground == phase) { disp.StartDrawing(disp.hDC, Convert.ToInt16(esriScreenCache.esriNoScreenCache)); disp.SetSymbol(marker as ISymbol); foreach (IPoint pc in pntclassList) disp.DrawPoint(pc); disp.FinishDrawing(); } }; IRgbColor color = new RgbColorClass(); color.Red = 255; color.Blue = 0; color.Green = 0; marker.Color = color; }
private void axMapControl1_OnExtentUpdated(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnExtentUpdatedEvent e) { //得到新范围 IEnvelope pEnvelop = (IEnvelope)e.newEnvelope; IGraphicsContainer pGraphicsContainer = Global.eagleeye.Map as IGraphicsContainer; IActiveView pActiveView = pGraphicsContainer as IActiveView; //在绘制前。清除axMapControl2 中的任何图形元素 pGraphicsContainer.DeleteAllElements(); IRectangleElement pRectangleEle = new RectangleElementClass(); IElement pElement = pRectangleEle as IElement; pElement.Geometry = pEnvelop; //设置鹰眼中的红线框 IRgbColor pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 255; //产生一个线符号对象 ILineSymbol pOutline = new SimpleLineSymbolClass(); pOutline.Width = 1; pOutline.Color = pColor; //设置颜色属性 pColor = new RgbColorClass(); pColor.Red = 255; pColor.Green = 0; pColor.Blue = 0; pColor.Transparency = 0; //设置填充符号的属性 IFillSymbol pFillSymbol = new SimpleFillSymbolClass(); pFillSymbol.Color = pColor; pFillSymbol.Outline = pOutline; IFillShapeElement pFillShapeEle = pElement as IFillShapeElement; pFillShapeEle.Symbol = pFillSymbol; pGraphicsContainer.AddElement((IElement)pFillShapeEle, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void SetDefaultSymbol(ILineElement elem) { ILineSymbol defaultLineSym = null; String esriStylePath; IStyleGallery styleGallery = new StyleGalleryClass(); IStyleGalleryStorage styleStor = (IStyleGalleryStorage)styleGallery; esriStylePath = styleStor.DefaultStylePath + "ESRI.style"; IEnumStyleGalleryItem styleItems = styleGallery.get_Items("Line Symbols",esriStylePath,"Dashed"); styleItems.Reset(); IStyleGalleryItem styleGalleryItem = styleItems.Next(); while (!(styleGalleryItem == null)) { if (styleGalleryItem.Name == "Dashed 4:4") { defaultLineSym = (ILineSymbol)styleGalleryItem.Item; defaultLineSym.Width = 1.50; IRgbColor rgbColor = new RgbColorClass(); rgbColor.Red = 255; rgbColor.Blue = 0; rgbColor.Green = 0; rgbColor.Transparency = 50; defaultLineSym.Color = rgbColor; break; } else { styleGalleryItem = styleItems.Next(); } } elem.Symbol = defaultLineSym; }
private static void FixSymbology(IFeatureLayer featureLayer) { //Color var geoLayer = featureLayer as IGeoFeatureLayer; if (geoLayer == null) return; var renderer = geoLayer.Renderer as ISimpleRenderer; if (renderer == null) return; var symbol = renderer.Symbol as IFillSymbol; if (symbol == null) return; //The objects at symbol.Color and symbol.Outline are immutable while the properties are not. //The objects don't complain if you try and change them, it just has no effect. //symbol.Color.NullColor = true; // appears to work but has no effect. IRgbColor nullColor = new RgbColorClass(); nullColor.NullColor = true; symbol.Color = nullColor; ILineSymbol outline = new SimpleLineSymbol(); outline.Width = 1.0; IRgbColor color = new RgbColorClass(); color.Red = 255; color.UseWindowsDithering = true; outline.Color = color; symbol.Outline = outline; //Labeling IAnnotateLayerProperties annotationProperties; IElementCollection unused; geoLayer.AnnotationProperties.QueryItem(0, out annotationProperties, out unused, out unused); ((ILabelEngineLayerProperties)annotationProperties).Expression = "[Cell_Label]"; geoLayer.DisplayAnnotation = true; }