public static IRasterRenderer ClassifyRenderer(IRasterLayer raslyr,IRgbColor start_clr,IRgbColor end_clr,int count) { IRasterClassifyColorRampRenderer pRClassRend = new RasterClassifyColorRampRendererClass(); IRasterRenderer rasterRenderer = pRClassRend as IRasterRenderer; IRaster pRaster = raslyr.Raster; IRasterBandCollection pRBandCol = pRaster as IRasterBandCollection; IRasterBand pRBand = pRBandCol.Item(0); if (pRBand.Histogram == null) { pRBand.ComputeStatsAndHist(); } rasterRenderer.Raster = pRaster; pRClassRend.ClassCount = count; rasterRenderer.Update(); IAlgorithmicColorRamp colorRamp = new AlgorithmicColorRampClass(); colorRamp.Size = count; colorRamp.FromColor = start_clr; colorRamp.ToColor = end_clr; bool createColorRamp; colorRamp.CreateRamp(out createColorRamp); IFillSymbol fillSymbol = new SimpleFillSymbolClass(); for (int i = 0; i < pRClassRend.ClassCount; i++) { fillSymbol.Color = colorRamp.get_Color(i); pRClassRend.set_Symbol(i, fillSymbol as ISymbol); pRClassRend.set_Label(i, pRClassRend.get_Break(i).ToString("0.00")); } return rasterRenderer; }
/// <summary> /// 将ArcGIS Engine中的IRgbColor接口转换至.NET中的Color结构 /// </summary> /// <param name="pRgbColor">IRgbColor</param> /// <returns>.NET中的System.Drawing.Color结构表示ARGB颜色</returns> public Color ConvertIRgbColorToColor(IRgbColor pRgbColor) { IRgbColor pRGB = pRgbColor; Color color = ColorTranslator.FromOle(pRGB.RGB); //return ColorTranslator.FromOle(pRgbColor.RGB); return color; }
public static ISimpleLineSymbol GetSimpleLineSymbol(IRgbColor rgbColor,double width) { var simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Width = width; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; return simpleLineSymbol; }
public static ISimpleMarkerSymbol CreateSimpleMarkerSymbol(IRgbColor rgbColor, esriSimpleMarkerStyle inputStyle) { if (rgbColor == null || inputStyle == null) { return null; } ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Style = inputStyle; return simpleMarkerSymbol; }
public static ISimpleLineSymbol CreateSimpleLineSymbol(IRgbColor rgbColor, System.Double inWidth, esriSimpleLineStyle inStyle) { if (rgbColor == null) { return null; } ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Style = inStyle; simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Width = inWidth; return simpleLineSymbol; }
/// <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); }
private IElement LineElementRenderer(IGeometry geo, IRgbColor color) { ISimpleLineSymbol pLineSymbol = new SimpleLineSymbol(); pLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pLineSymbol.Width = 5; pLineSymbol.Color = color; IElement element = new LineElement(); element.Geometry = geo; ILineElement pLineElement = element as ILineElement; pLineElement.Symbol = pLineSymbol; return(element); }
//打开颜色选择对话框 并未IRGB类的三原色赋值 private void selectColor(IRgbColor selColor) { ColorDialog colorDialog = new ColorDialog(); colorDialog.AllowFullOpen = true; colorDialog.FullOpen = true; colorDialog.ShowHelp = true; colorDialog.Color = Color.Black; //获取或设置用户所选定的颜色 colorDialog.ShowDialog(); selColor.Red = colorDialog.Color.R; selColor.Green = colorDialog.Color.G; selColor.Blue = colorDialog.Color.B; MessageBox.Show("您选择的各颜色分量值分别为" + "\nR:" + colorDialog.Color.R.ToString() + "\nG:" + colorDialog.Color.G.ToString() + "\nB:" + colorDialog.Color.B.ToString()); }
//重置IRgb颜色。 private void ResetIRgbColor() { F = Properties.IRgbColorSettings.Default.FromColor; if (F == null) { F = Color.Black; } FromC = RGB2IRgb(F); T = Properties.IRgbColorSettings.Default.ToColor; if (T == null) { T = Color.White; } ToC = RGB2IRgb(T); }
public FrmCheQiConfig(IAppContext context) { InitializeComponent(); this.cmbFlagLayer.Map = context.FocusMap; this.cmbFlagLayer.GeometryTypes = new List <esriGeometryType>() { esriGeometryType.esriGeometryPoint, esriGeometryType.esriGeometryPolyline }; this.cmbFlagAnnoLayer.Map = context.FocusMap; this.cmbFlagLineLayer.Map = context.FocusMap; this.cmbFlagLineLayer.GeometryType = esriGeometryType.esriGeometryPolyline; _fontColor = new RgbColorClass(); }
public static void DrawExtent(IEnvelope envelope, AxMapControl axMapControl_HawkEye) { IRgbColor fillColor = CreateRgbColor(0, 0, 0, 0); IRgbColor outColor = CreateRgbColor(255, 0, 0); IElement pElement = new RectangleElementClass() { Geometry = envelope, Symbol = CreateSimpleFillSymbol(fillColor, outColor, 2) }; IGraphicsContainer pGC = axMapControl_HawkEye.Map as IGraphicsContainer; pGC.DeleteAllElements(); pGC.AddElement(pElement, 0); axMapControl_HawkEye.Refresh(esriViewDrawPhase.esriViewGraphics, null, null); }
//简单渲染,线符号 public static void easy_line(string filename, IRgbColor point_rgb, int width) { Console.WriteLine("++++++++++++++" + filename); //实例化ISimpleFillSysmbol变量, 提供简单的填充符号类型 ISimpleLineSymbol pSimplelineSymbol = new SimpleLineSymbol(); pSimplelineSymbol.Color = point_rgb; pSimplelineSymbol.Width = width; ISimpleRenderer pSimpleRender = new SimpleRenderer(); //设置pSimpleRender的符号样式 pSimpleRender.Symbol = pSimplelineSymbol as ISymbol; Render_tool(pSimpleRender, filename); }
/// <summary> /// 设置点元素的样式 /// </summary> /// <param name="rgbColor">颜色</param> /// <param name="OutLineColor">轮廓颜色</param> private IElement createElement(IRgbColor rgbColor, IRgbColor OutLineColor) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); pSimpleMarkerSymbol.Color = rgbColor; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = OutLineColor; pSimpleMarkerSymbol.Size = 15; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement pMElement = new MarkerElement() as IMarkerElement; pMElement.Symbol = pSimpleMarkerSymbol; IElement ele = (IElement)pMElement; return(ele); }
/// <summary> /// 获取RGB颜色 /// </summary> /// <param name="intR">红</param> /// <param name="intG">绿</param> /// <param name="intB">蓝</param> /// <returns></returns> private static IRgbColor GetRgbColor(int intR, int intG, int intB) { IRgbColor pRgbColor = null; if (intR < 0 || intR > 255 || intG < 0 || intG > 255 || intB < 0 || intB > 255) { return(pRgbColor); } pRgbColor = new RgbColorClass { Red = intR, Green = intG, Blue = intB }; return(pRgbColor); }
//简单渲染,点符号 public static void easy_point(string filename, IRgbColor point_rgb, int width) { //实例化ISimpleFillSysmbol变量, 提供简单的填充符号类型 ISimpleMarkerSymbol pSimplemarkerSymbol = new SimpleMarkerSymbol(); pSimplemarkerSymbol.Color = point_rgb; pSimplemarkerSymbol.OutlineSize = width; //实例化简单渲染变量 ISimpleRenderer pSimpleRender = new SimpleRenderer(); //设置pSimpleRender的符号样式 pSimpleRender.Symbol = pSimplemarkerSymbol as ISymbol; Render_tool(pSimpleRender, filename); }
/// <summary> /// 选择起止颜色。 /// </summary> /// <param name="FromIC">输出的起始颜色。</param> /// <param name="ToIC">输出的终止颜色。</param> /// <returns>操作是否成功。</returns> public static bool SelectColor(out IRgbColor FromIC, out IRgbColor ToIC) { FromIC = null; ToIC = null; ColorSelection CS = new ColorSelection(); if (CS.ShowDialog() != DialogResult.OK) { CS.Dispose(); return(false); } FromIC = CS.FromC; ToIC = CS.ToC; CS.Dispose(); return(true); }
//获取颜色 private void GetDecorationColor(IFrameDecoration pFrameDecoration, Button btn) { try { IRgbColor pRgbColor = null; Color pColor; pRgbColor = (IRgbColor)pFrameDecoration.Color; pColor = Color.FromArgb(pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); btn.BackColor = pColor; } catch { btn.BackColor = this.BackColor; } }
//yjl 20110827 add private System.Drawing.Color cWinColor(IColor incolor) { if (!(incolor is IRgbColor)) { return(System.Drawing.Color.AliceBlue); } IRgbColor color = incolor as IRgbColor; System.Drawing.Color rgb = System.Drawing.Color.FromArgb( color.Red, color.Green, color.Blue); //rgb. = Convert.ToByte(color.Red); //rgb.G = Convert.ToByte(color.Green); //rgb.B = Convert.ToByte(color.Blue); return(rgb); }
private void button_Apply_Click(object sender, EventArgs e) { int vID = int.Parse(treeView_Layers.SelectedNode.Name); LayerStruct vLayer = Layers.Where(m => m.ID == vID).FirstOrDefault(); string vLayerName = vLayer.Name; int vLayerColor = label_Color.Tag == null ? 0 : (int)label_Color.Tag; if (vLayerColor != 0) { VMainForm.ChangeLayerColor(vLayerName, vLayerColor); vLayer.Color = vLayerColor; treeView_Layers.SelectedNode.ForeColor = Color.FromArgb(vLayerColor); label_Color.BackColor = treeView_Layers.SelectedNode.ForeColor; } vLayer.ShowAnnotation = checkBox_Annotation.Checked; // string vAnnotationField = comboBox_Label.Text; string vAnnotationField = textBox_Express.Text; vLayer.AnnotationField = vAnnotationField; //改变颜色 int vAnnotationColor = label_AnnotationColor.Tag == null ? -1 : (int)label_AnnotationColor.Tag; vLayer.AnnotationFontColor = vAnnotationColor; IRgbColor vRgbColor = vAnnotationColor == -1 ? null : CommonUnit.ColorToIRgbColor(Color.FromArgb(vAnnotationColor)); int vFontSize = int.Parse(comboBox_FontSize.Text); vLayer.AnnotationFontSize = vFontSize; if (vLayer.ShowAnnotation) { VMainForm.EnableFeatureLayerLabel(vLayerName, vAnnotationField, vRgbColor, vFontSize); } else { VMainForm.DisableFeatureLayerLabel(vLayerName); } //改变图层透明度 short vTransparency = Convert.ToInt16(trackBar_Transparency.Value); vLayer.Transparency = vTransparency; VMainForm.ChangeLayerTransparency(vLayerName, vTransparency); button_Apply.Enabled = false; }
///<summary>Draw a specified graphic on the map using the supplied colors.</summary> /// ///<param name="map">An IMap interface.</param> ///<param name="geometry">An IGeometry interface. It can be of the geometry type: esriGeometryPoint, esriGeometryPolyline, or esriGeometryPolygon.</param> ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param> ///<param name="outlineRgbColor">An IRgbColor interface. For those geometry's with an outline it will be this color.</param> /// ///<remarks>Calling this function will not automatically make the graphics appear in the map area. Refresh the map area after after calling this function with Methods like IActiveView.Refresh or IActiveView.PartialRefresh.</remarks> public void AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast IElement element = null; if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint) { // Marker symbols ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = outlineRgbColor; simpleMarkerSymbol.Size = 15; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = (IElement)markerElement; // Explicit Cast } else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolyline) { // Line elements ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 5; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; element = (IElement)lineElement; // Explicit Cast } else if ((geometry.GeometryType) == esriGeometryType.esriGeometryPolygon) { // Polygon elements ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = rgbColor; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; element = (IElement)fillShapeElement; // Explicit Cast } if (!(element == null)) { element.Geometry = geometry; graphicsContainer.AddElement(element, 0); } }
private IElement PointElementRenderer(IGeometry geo, IRgbColor color) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); simpleMarkerSymbol.Color = color; simpleMarkerSymbol.Outline = false; simpleMarkerSymbol.Size = 5; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; IMarkerElement pMarkerElement = new MarkerElementClass(); pMarkerElement.Symbol = simpleMarkerSymbol; IElement pElement = pMarkerElement as IElement; pElement.Geometry = geo; return(pElement); }
private static List <IColor> CreateDoDColorRamp() { List <IColor> lColors = new List <IColor>(); IRgbColor rgbColor = CreateRGBColor(230, 0, 0); lColors.Add(rgbColor); rgbColor = CreateRGBColor(235, 45, 23); lColors.Add(rgbColor); rgbColor = CreateRGBColor(240, 67, 41); lColors.Add(rgbColor); rgbColor = CreateRGBColor(242, 88, 61); lColors.Add(rgbColor); rgbColor = CreateRGBColor(245, 108, 81); lColors.Add(rgbColor); rgbColor = CreateRGBColor(245, 131, 105); lColors.Add(rgbColor); rgbColor = CreateRGBColor(245, 151, 130); lColors.Add(rgbColor); rgbColor = CreateRGBColor(242, 171, 155); lColors.Add(rgbColor); rgbColor = CreateRGBColor(237, 190, 180); lColors.Add(rgbColor); rgbColor = CreateRGBColor(230, 208, 207); lColors.Add(rgbColor); rgbColor = CreateRGBColor(218, 218, 224); lColors.Add(rgbColor); rgbColor = CreateRGBColor(197, 201, 219); lColors.Add(rgbColor); rgbColor = CreateRGBColor(176, 183, 214); lColors.Add(rgbColor); rgbColor = CreateRGBColor(155, 166, 207); lColors.Add(rgbColor); rgbColor = CreateRGBColor(135, 150, 201); lColors.Add(rgbColor); rgbColor = CreateRGBColor(110, 131, 194); lColors.Add(rgbColor); rgbColor = CreateRGBColor(92, 118, 189); lColors.Add(rgbColor); rgbColor = CreateRGBColor(72, 105, 184); lColors.Add(rgbColor); rgbColor = CreateRGBColor(49, 91, 176); lColors.Add(rgbColor); rgbColor = CreateRGBColor(2, 77, 168); lColors.Add(rgbColor); return(lColors); }
public void AddCallout(IPoint pPoint, string strText) { DF2DApplication app = DF2DApplication.Application; m_ActiveView = app.Current2DMapControl.ActiveView; IGraphicsContainer pGraphicsContainer = m_ActiveView.GraphicsContainer; IPoint pPointText = new PointClass(); pPointText.PutCoords(pPoint.X + 1.5, pPoint.Y + 1.5); ITextElement pTextElement = new TextElementClass(); IFormattedTextSymbol pTextSymbol = new TextSymbolClass(); IElement pElement = pTextElement as IElement; pTextElement.Text = strText; pTextElement.ScaleText = true; pElement.Geometry = pPointText; IRgbColor pRgbColor = GetRGBColor(255, 255, 0); ISimpleFillSymbol pSmplFill = new SimpleFillSymbolClass(); pSmplFill.Color = pRgbColor; pSmplFill.Style = esriSimpleFillStyle.esriSFSHollow; IBalloonCallout pBalloonCallout = new BalloonCalloutClass(); pBalloonCallout.Symbol = pSmplFill; pBalloonCallout.Style = esriBalloonCalloutStyle.esriBCSOval; pBalloonCallout.AnchorPoint = pPointText; pBalloonCallout.LeaderTolerance = 5; pRgbColor = GetRGBColor(255, 0, 0); pTextSymbol.Background = pBalloonCallout as ITextBackground; pTextSymbol.Color = pRgbColor; pTextSymbol.Size = (app.Current2DMapControl.MapScale / 100) * 5; //pTextSymbol.Size = 25; pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; pTextElement.Symbol = pTextSymbol; pGraphicsContainer.AddElement(pElement, 1); }
private void SetLineStyle(ILayer pLayer, double lineWidth, IRgbColor pColor) { //MessageBox.Show(pLayer.Name); IGeoFeatureLayer pGeoFeatureLayer = pLayer as IGeoFeatureLayer; ISimpleRenderer pSimpleRender = new SimpleRenderer(); ISimpleLineSymbol lineSymbol = new SimpleLineSymbol(); lineSymbol.Width = lineWidth; lineSymbol.Color = pColor; pSimpleRender.Symbol = lineSymbol as ISymbol; if (pGeoFeatureLayer != null) { pGeoFeatureLayer.Renderer = pSimpleRender as IFeatureRenderer; } _mxDocument.ActiveView.Refresh(); _mxDocument.CurrentContentsView.Refresh(null); }
private void DrawLineOnActiveView(int intFromLinkID, List <int> arrToLinks, double[,] arrXYCoord, IActiveView pActiveView) { try { IGraphicsContainer pGraphicContainer = pActiveView.GraphicsContainer; //pGraphicContainer.DeleteAllElements(); IRgbColor pRgbColor = m_pSnippet.getRGB(0, 255, 255); ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pSimpleLineSymbol.Color = pRgbColor; int intFromIdx = intFromLinkID; ESRI.ArcGIS.Geometry.IPoint FromP = new PointClass(); FromP.X = arrXYCoord[intFromIdx, 0]; FromP.Y = arrXYCoord[intFromIdx, 1]; int intArrLengthCnt = arrToLinks.Count; for (int i = 0; i < intArrLengthCnt; i++) { int intToIdx = arrToLinks[i] - 1; ESRI.ArcGIS.Geometry.IPoint ToP = new PointClass(); ToP.X = arrXYCoord[intToIdx, 0]; ToP.Y = arrXYCoord[intToIdx, 1]; IPolyline polyline = new PolylineClass(); IPointCollection pointColl = polyline as IPointCollection; pointColl.AddPoint(FromP); pointColl.AddPoint(ToP); IElement pElement = new LineElementClass(); ILineElement pLineElement = (ILineElement)pElement; pLineElement.Symbol = pSimpleLineSymbol; pElement.Geometry = polyline; pGraphicContainer.AddElement(pElement, 0); } pActiveView.Refresh(); } catch (Exception ex) { frmErrorLog pfrmErrorLog = new frmErrorLog(); pfrmErrorLog.ex = ex; pfrmErrorLog.ShowDialog(); return; } }
//CartographicLineSymbol private void button7_Click(object sender, EventArgs e) { 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; IRgbColor rgbColor = getRGB(0, 255, 0); cartographicLineSymbol.Color = rgbColor; IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(cartographicLineSymbol as ISymbol); activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry); activeView.ScreenDisplay.FinishDrawing(); activeView.ScreenDisplay.FinishDrawing(); }
//MarkerFillSymbol private void button14_Click(object sender, EventArgs e) { IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); IRgbColor rgbColor = getRGB(255, 0, 0); arrowMarkerSymbol.Color = rgbColor as IColor; arrowMarkerSymbol.Length = 10; arrowMarkerSymbol.Width = 10; arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain; IMarkerFillSymbol markerFillSymbol = new MarkerFillSymbolClass(); markerFillSymbol.MarkerSymbol = arrowMarkerSymbol; rgbColor = getRGB(0, 255, 0); markerFillSymbol.Color = rgbColor; markerFillSymbol.Style = esriMarkerFillStyle.esriMFSGrid; IFillProperties fillProperties = markerFillSymbol as IFillProperties; fillProperties.XOffset = 2; fillProperties.YOffset = 2; fillProperties.XSeparation = 15; fillProperties.YSeparation = 20; object Missing = Type.Missing; IPolygon polygon = new PolygonClass(); IPointCollection pointCollection = polygon as IPointCollection; IPoint point = new PointClass(); point.PutCoords(5, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(5, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 10); pointCollection.AddPoint(point, ref Missing, ref Missing); point.PutCoords(10, 5); pointCollection.AddPoint(point, ref Missing, ref Missing); polygon.SimplifyPreserveFromTo(); IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(markerFillSymbol as ISymbol); activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry); activeView.ScreenDisplay.FinishDrawing(); }
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 override void OnMouseDown(int Button, int Shift, int X, int Y) { try { if (Button == 2) { CreateContextMenu(m_application); return; } IMap map = GetMapFromArcMap(m_application); IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; activeView = (IActiveView)map; point = GetPointFromMouseClicks(activeView); IRgbColor rgbColor = GetColor(frmOptions.colorOfPoints.R, frmOptions.colorOfPoints.B, frmOptions.colorOfPoints.G); AddGraphicToMap(map, point, rgbColor, rgbColor); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); Variables.s_NumberOfPoints += 1; Variables.s_LstPoints.Add(point); if (Variables.s_LstPoints.Count == 3) { Variables.s_polyline = new PolylineClass(); IPointCollection pc = (IPointCollection)Variables.s_polyline; for (int i = 0; i < Variables.s_LstPoints.Count; i++) { pc.AddPoint(Variables.s_LstPoints[i]); } Variables.s_polyline.SpatialReference = map.SpatialReference; rgbColor = GetColor(frmOptions.colorOfLines.R, frmOptions.colorOfLines.B, frmOptions.colorOfLines.G); AddGraphicToMap(map, Variables.s_polyline, rgbColor, rgbColor); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } //ShowFrom(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
public static ISimpleFillSymbol CreateSimpleFillSymbol(IRgbColor fillColor, esriSimpleFillStyle fillStyle, IRgbColor borderColor, esriSimpleLineStyle borderStyle, System.Double borderWidth) { if (fillColor == null || fillStyle == null || borderColor == null || borderStyle == null) { return null; } ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Width = borderWidth; simpleLineSymbol.Color = borderColor; simpleLineSymbol.Style = borderStyle; ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Outline = simpleLineSymbol; simpleFillSymbol.Style = fillStyle; simpleFillSymbol.Color = fillColor; return simpleFillSymbol; }
/// <summary> /// This function takes in two ESRI.ArcGIS.Display.IRgbColor object for the color and outline, then returns a marker element /// </summary> /// <param name="color">the color to make the marker element</param> /// <param name="outline">the outline color of the marker element</param> /// <returns>a simple marker symbol as a marker element</returns> public static IMarkerElement ReturnMarkerElement(IRgbColor color, IRgbColor outline) { ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass { Color = color, Outline = true, OutlineColor = outline, Size = 30, Style = esriSimpleMarkerStyle.esriSMSCircle }; IMarkerElement markerElement = new MarkerElementClass { Symbol = simpleMarkerSymbol }; return(markerElement); }
public HouseShowcaseManager(AxMapControl mc) { mapControl = mc; outerColor = new RgbColor(); outerColor.Red = 206; outerColor.Green = 206; outerColor.Blue = 206; innerColor = new RgbColor(); innerColor.Red = 250; innerColor.Green = 247; innerColor.Blue = 201; textColor = new RgbColor(); textColor.Red = 255; textColor.Green = 0; textColor.Blue = 0; }
public IArrowMarkerSymbol CreateArrowMarkerSymbol(IRgbColor color = null, double length = 5, int angle = 90, double width = 1) { IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbol(); arrowMarkerSymbol.Angle = angle; arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain; if (color == null) { color = getRGB(50, 96, 220) as IRgbColor; } arrowMarkerSymbol.Color = color; arrowMarkerSymbol.Width = width; arrowMarkerSymbol.Length = length; return(arrowMarkerSymbol); }
/// <summary> /// 根据传入的点集合绘制符号 /// </summary> /// <param name="points">传入的点集合</param> /// <param name="symbolStyle">符号样式</param> /// <param name="symbolColor">符号颜色</param> /// <param name="symbolSize">符号大小</param> public static void AddGraphics(IScene pScene, IPoint point, string name) { try { esriSimple3DMarkerStyle symbolStyle = esriSimple3DMarkerStyle.esriS3DMSSphere; IRgbColor symbolColor = GetRGBColor(255, 0, 0); int symbolSize = 1; ISimpleMarker3DSymbol pSimpleMarker3DSymbol; pSimpleMarker3DSymbol = new SimpleMarker3DSymbolClass(); pSimpleMarker3DSymbol.Style = symbolStyle; pSimpleMarker3DSymbol.ResolutionQuality = 0.1; IMarker3DPlacement pMarker3DPlacement; pMarker3DPlacement = (IMarker3DPlacement)pSimpleMarker3DSymbol; pMarker3DPlacement.Color = symbolColor; pMarker3DPlacement.Width = 1; pMarker3DPlacement.Size = symbolSize; pMarker3DPlacement.Depth = 1; pMarker3DPlacement.SetRotationAngles(0, 0, 0); IGraphicsContainer3D pGC3D; pGC3D = pScene.BasicGraphicsLayer as IGraphicsContainer3D; MarkerElementClass pElement = new MarkerElementClass(); IMarkerElement pPointElement; pPointElement = (IMarkerElement)pElement; IMarkerSymbol pMarkerSymbol; pMarkerSymbol = (IMarkerSymbol)pSimpleMarker3DSymbol; pMarkerSymbol.Color = symbolColor; pPointElement.Symbol = pMarkerSymbol; (pPointElement as IElementProperties).Name = name; pElement.Geometry = point; pGC3D.AddElement(pElement); } catch (Exception ex) { Console.WriteLine(ex.Message + ex.StackTrace); } }
private void DrawLineOnActiveView(List <int> lstIndices, double[][] arrValue, IActiveView pActiveView) { int intLstCnt = lstIndices.Count; IGraphicsContainer pGraphicContainer = pActiveView.GraphicsContainer; pGraphicContainer.DeleteAllElements(); IRgbColor pRgbColor = m_pSnippet.getRGB(0, 255, 255); ISimpleLineSymbol pSimpleLineSymbol = new SimpleLineSymbolClass(); pSimpleLineSymbol.Width = 2; pSimpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; pSimpleLineSymbol.Color = pRgbColor; for (int i = 0; i < intLstCnt; i++) { int intIdx = lstIndices[i]; double[] arrSelValue = arrValue[intIdx]; //drawing a polyline IPoint FromP = new PointClass(); FromP.X = arrSelValue[0]; FromP.Y = arrSelValue[1]; IPoint ToP = new PointClass(); ToP.X = arrSelValue[2]; ToP.Y = arrSelValue[3]; IPolyline polyline = new PolylineClass(); IPointCollection pointColl = polyline as IPointCollection; pointColl.AddPoint(FromP); pointColl.AddPoint(ToP); IElement pElement = new LineElementClass(); ILineElement pLineElement = (ILineElement)pElement; pLineElement.Symbol = pSimpleLineSymbol; pElement.Geometry = polyline; pGraphicContainer.AddElement(pElement, 0); } pActiveView.Refresh(); }
/// <summary> /// CreateSimpleFillSymbol /// </summary> /// <param name="color">color</param> /// <param name="outline">outline</param> /// <param name="style">style</param> /// <returns>IFillSymbol</returns> public IFillSymbol CreateSimpleFillSymbol(IRgbColor color = null, ILineSymbol outline = null, esriSimpleFillStyle style = esriSimpleFillStyle.esriSFSCross) { ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); if (color == null) { color = getRGB(63, 99, 150) as IRgbColor; } if (outline == null) { outline = CreateSimpleLineSymbol(getRGB(99, 99, 240) as IRgbColor, 2); } simpleFillSymbol.Style = style; simpleFillSymbol.Color = color; simpleFillSymbol.Outline = outline; return(simpleFillSymbol); }
public static IRasterLayer SetStretchRenderer(IRaster pRaster) { try { //创建着色类和QI栅格着色 IRasterStretchColorRampRenderer pStretchRen = new RasterStretchColorRampRenderer(); IRasterRenderer pRasRen = pStretchRen as IRasterRenderer; //为着色和更新设置栅格数据 pRasRen.Raster = pRaster; pRasRen.Update(); //定义起点和终点颜色 IColor pFromColor = new RgbColor(); IRgbColor pRgbColor = pFromColor as IRgbColor; pRgbColor.Red = 255; pRgbColor.Green = 0; pRgbColor.Blue = 0; IColor pToColor = new RgbColor(); pRgbColor = pToColor as IRgbColor; pRgbColor.Red = 0; pRgbColor.Green = 255; pRgbColor.Blue = 0; //创建颜色分级 IAlgorithmicColorRamp pRamp = new AlgorithmicColorRamp(); pRamp.Size = 255; pRamp.FromColor = pFromColor; pRamp.ToColor = pToColor; bool ok = true; pRamp.CreateRamp(out ok); //把颜色分级插入着色中并选择一个波段 pStretchRen.BandIndex = 0; pStretchRen.ColorRamp = pRamp; pRasRen.Update(); IRasterLayer pRLayer = new RasterLayer(); pRLayer.CreateFromRaster(pRaster); pRLayer.Renderer = pStretchRen as IRasterRenderer; return(pRLayer); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public static string ColorToHex(IRgbColor color) { string theReturn = Convert.ToString(color.Red, 16) + Convert.ToString(color.Green, 16) + Convert.ToString(color.Blue, 16); return theReturn; }
private static ITextSymbol SetUpTextSymbol(System.Drawing.Font font, IRgbColor rgbColor) { ITextSymbol textSymbol = new TextSymbolClass(); stdole.IFontDisp fontDisp = ESRI.ArcGIS.ADF.COMSupport.OLE.GetIFontDispFromFont(font) as stdole.IFontDisp; textSymbol.Font = fontDisp; textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHALeft; textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABottom; textSymbol.Angle = 0; textSymbol.Color = rgbColor; return textSymbol; }
public static void drawText(string text, IPoint pt, IRgbColor color, AxMapControl mapControl) { ITextSymbol pTextSymbol = new TextSymbolClass(); pTextSymbol.Size = 10; pTextSymbol.Color = color; ITextElement pTextElement = new TextElementClass(); pTextElement.Text = text; pTextElement.ScaleText = false; pTextElement.Symbol = pTextSymbol; IElement pElement = pTextElement as IElement; pElement.Geometry = pt; IGraphicsContainer pGraphicsContainer = mapControl.Map as IGraphicsContainer; IActiveView pActiveView = mapControl.ActiveView; pGraphicsContainer.AddElement(pElement, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); }
private void DrawLine(DataSet ds, IRgbColor color) { IMxDocument doc = ArcMap.Document; IMap map = doc.FocusMap; IActiveView activeView = doc.ActiveView.FocusMap as IActiveView; IPoint pPoint = new PointClass(); //线样式 ISimpleLineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = color; lineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot; lineSymbol.Width = 2; //线元素 ILineElement lineElement = new LineElementClass(); lineElement.Symbol = lineSymbol; //创建线 IPolyline m_Polyline = new PolylineClass(); //点集合 IPointCollection m_PointCollection = new PolylineClass(); //点数组 ArrayList arrPoint = new ArrayList(); object missing = Type.Missing; //while (sqlread.Read()) //前进一条纪录 //{ // int i = sqlread.GetInt32(0); // double x = sqlread.GetDouble(1); // double y = sqlread.GetDouble(2); // int index = sqlread.GetInt32(3); // //标记 // IPoint pPoints = new PointClass(); // //调用GetProject2方法经纬度转换成米 // pPoints = GetProject(x, y); // CreateTextElment(pPoints.X, pPoints.Y, index); // pPoint.PutCoords(Convert.ToDouble(pPoints.X), Convert.ToDouble(pPoints.Y)); // m_PointCollection.AddPoint(pPoint, ref missing, ref missing); //} if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { //画线 double dx = Convert.ToDouble(ds.Tables[0].Rows[i]["GISLongitude"]); double dy = Convert.ToDouble(ds.Tables[0].Rows[i]["GISLatitude"]); int index = Convert.ToInt32(ds.Tables[0].Rows[i]["Seq"]); IPoint pPoints = new PointClass(); //调用GetProject2方法经纬度转换成米 pPoints = GetProject(dx, dy); pPoint.PutCoords(Convert.ToDouble(pPoints.X), Convert.ToDouble(pPoints.Y)); m_PointCollection.AddPoint(pPoint, ref missing, ref missing); } } m_Polyline = m_PointCollection as IPolyline; //折线范围 IEnvelope pEnvelope = m_Polyline.Envelope; //折线区域 IArea pArea = pEnvelope as IArea; pPoint = pArea.Centroid; IElement element = lineElement as IElement; element.Geometry = m_Polyline; //加载线元素到地图 activeView.GraphicsContainer.AddElement(element, 0); activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); activeView.Refresh(); if (ds != null && ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { int index = Convert.ToInt32(ds.Tables[0].Rows[i]["Seq"]); double dx = Convert.ToDouble(ds.Tables[0].Rows[i]["GISLongitude"]); double dy = Convert.ToDouble(ds.Tables[0].Rows[i]["GISLatitude"]); //画标记 IPoint pPoints = new PointClass(); //调用GetProject2方法经纬度转换成米 pPoints = GetProject(dx, dy); if (!check_DatailInformation.Checked) { CreateTextElment(pPoints.X, pPoints.Y, index); } } } if (check_DatailInformation.Checked) { ShowInformation(ds); } activeView.Refresh(); }
private void OnActiveViewEventsAfterDraw(ESRI.ArcGIS.Display.IDisplay display, ESRI.ArcGIS.Carto.esriViewDrawPhase phase) { ESRI.ArcGIS.Carto.esriViewDrawPhase m_phase = phase; //if the drawing pahse geography, find all feature layer and selected feature and draw them on screen if they are polygons. Please note don't call display::StartDrawing as it is already started by the system. if (m_phase == ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeography) { IMap m_Map = m_MxDoc.FocusMap; ESRI.ArcGIS.esriSystem.UID m_UID = new ESRI.ArcGIS.esriSystem.UID(); m_UID.Value = "{40A9E885-5533-11d0-98BE-00805F7CED21}"; IEnumLayer m_EnumLayer = m_Map.Layers[m_UID]; ILayer m_Layer = m_EnumLayer.Next(); //if you want to change the selection color you can change it here. ISimpleFillSymbol m_FillSymbol = new SimpleFillSymbol(); m_Rgb = new RgbColor(); m_Rgb.Red = 255; m_FillSymbol.Color = m_Rgb; display.SetSymbol(m_FillSymbol as ISymbol); do { if (m_Layer is IFeatureLayer) { if (m_Layer != null) { IFeatureSelection m_FeatureSelection = (IFeatureSelection)m_Layer; ISelectionSet m_SelSet = m_FeatureSelection.SelectionSet; IFeatureCursor m_FeatCur; ICursor m_Cursor; m_SelSet.Search(null, false, out m_Cursor); m_FeatCur = (IFeatureCursor) m_Cursor; IFeature m_Feature; m_Feature = m_FeatCur.NextFeature(); do { if (m_Feature != null) { if (m_Feature.Shape is IPolygon) { display.DrawPolygon(m_Feature.Shape); } } m_Feature = m_FeatCur.NextFeature(); } while (m_Feature != null); } } m_Layer = m_EnumLayer.Next(); } while (m_Layer != null); } #endregion }
/// <summary> /// 设置点元素的样式 /// </summary> /// <param name="rgbColor">颜色</param> /// <param name="OutLineColor">轮廓颜色</param> private IElement createElement(IRgbColor rgbColor, IRgbColor OutLineColor) { ISimpleMarkerSymbol pSimpleMarkerSymbol = new SimpleMarkerSymbol(); pSimpleMarkerSymbol.Color = rgbColor; pSimpleMarkerSymbol.Outline = true; pSimpleMarkerSymbol.OutlineColor = OutLineColor; pSimpleMarkerSymbol.Size = 15; pSimpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement pMElement = new MarkerElement() as IMarkerElement; pMElement.Symbol = pSimpleMarkerSymbol; IElement ele = (IElement)pMElement; return ele; }
/// <summary> /// 设置标注的样式外观 /// </summary> /// <param name="size">缩放比例 1.5</param> /// <param name="pColor">颜色</param> /// <param name="pEle">要改变的颜色</param> /// <param name="direction">true为改变,false为还原</param> /// <returns></returns> private static IElement setElementStyle(double size, IRgbColor pColor, IElement pEle,bool direction) { IMarkerElement pMarEle = pEle as IMarkerElement; ISimpleMarkerSymbol pMarSymbol = pMarEle.Symbol as ISimpleMarkerSymbol; //axMapControl1.FlashShape(pEle.Geometry, 1, 300, pMarEle.Symbol); //element闪烁,symbol没有则闪烁Geometry if (direction) { pMarSymbol.Size *= size; } else { pMarSymbol.Size /= size; } pMarSymbol.Color = pColor; pMarEle.Symbol = pMarSymbol; pEle = pMarEle as IElement; return pEle; }
///<summary>Draw a specified graphic on the map using the supplied colors.</summary> ///<param name="map">An IMap interface.</param> ///<param name="geometry">An IPoint interface. It can be of the geometry type esriGeometryPoint</param> ///<param name="rgbColor">An IRgbColor interface. The color to draw the geometry.</param> ///<param name="outlineRgbColor">An IRgbColor interface. For marker anfd polygons the outline it will be this color, for lines this is ignored</param> ///<param name="size">size in pixel as integer linewidth of outLine or of intire marker if point</param> ///<param name="userLock">locked from editing by user?</param> public static IElement AddGraphicToMap(IMap map, IGeometry geometry, IRgbColor rgbColor, IRgbColor outlineRgbColor, int size = 5, bool userLock = false) { IGraphicsContainer graphicsContainer = (IGraphicsContainer)map; // Explicit Cast IElement element = null; if ((geometry.GeometryType) == esriGeometryType.esriGeometryPoint) { // Marker symbols ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Color = rgbColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = outlineRgbColor; simpleMarkerSymbol.Size = size; simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond; IMarkerElement markerElement = new MarkerElementClass(); markerElement.Symbol = simpleMarkerSymbol; element = (IElement)markerElement; // Explicit Cast } else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline) { // Line elements ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = rgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = size; ILineElement lineElement = new LineElementClass(); lineElement.Symbol = simpleLineSymbol; element = (IElement)lineElement; // Explicit Cast } else if ((geometry.GeometryType) == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon) { // Polygon elements ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = outlineRgbColor; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = size; ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Color = rgbColor; simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSForwardDiagonal; simpleFillSymbol.Outline = simpleLineSymbol; IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; element = (IElement)fillShapeElement; // Explicit Cast } if (!(element == null)) { element.Geometry = geometry; element.Locked = userLock; graphicsContainer.AddElement(element, 0); } return element; }
public Color ConvertIRgbColorToColor(IRgbColor pRgbColor) { return ColorTranslator.FromOle(pRgbColor.RGB); }
private void SymbolizeData(ILayer layer, double dWidth, IRgbColor colorLine, IRgbColor colorFill) { //Create a line symbol and get the ILineSymbol interface ILineSymbol lineSymbol = new SimpleLineSymbolClass(); //Set the line symbol properties lineSymbol.Width = dWidth; lineSymbol.Color = colorLine; //Create a fill symbol and get the IFillSymbol interface ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); //Set the fill symbol properties fillSymbol.Outline = lineSymbol; fillSymbol.Color = colorFill; //Create a simple renderer and get the ISimpleRenderer interface ISimpleRenderer simpleRenderer = new SimpleRendererClass(); //Set the simple renderer properties simpleRenderer.Symbol = (ISymbol) fillSymbol; //QI for the IGeoFeatureLayer interface from the ILayer2 interface IGeoFeatureLayer geoFeatureLayer = (IGeoFeatureLayer) layer; //Set the GeoFeatureLayer properties geoFeatureLayer.Renderer = (IFeatureRenderer) simpleRenderer; }
private void ChangeIllumination(IRgbColor prgb) { IGlobeDisplayRendering pglbDispRend = (IGlobeDisplayRendering) axGlobeControl1.GlobeDisplay; double platitude=0; double plongitude=0; Single pSunred; Single pSungreen; Single pSunblue; Single pAmbientLght; if ((pglbDispRend.IsSunEnabled == true) & (chkSun.Checked == true)) { //get the Default position and color... pglbDispRend.GetSunPosition(out platitude, out plongitude); pglbDispRend.GetSunColor(out pSunred, out pSungreen, out pSunblue); //Set AmbientLght string sVal = TxtAmbient.Text; if (Convert.ToSingle(sVal) > 1) sVal = "1"; if (Convert.ToSingle(sVal) < 0) sVal = "0"; pglbDispRend.AmbientLight = Convert.ToSingle(sVal); //update textbox TxtAmbient.Text = sVal; pAmbientLght = pglbDispRend.AmbientLight; IColor pIcolor = prgb; IGlobeDisplay pglbDisp = EnableSetSun(pAmbientLght, platitude, plongitude, pIcolor); axGlobeControl1.GlobeDisplay = pglbDisp; axGlobeControl1.GlobeDisplay.RefreshViewers(); } }
/// <summary> /// Draws the input geometry using the specified colors. /// </summary> /// <param name="geometry">The input IGeometry to draw. Supported geometry types are GeometryBag, Polygon, Polyline, Point and Multipoint.</param> /// <param name="fillColor">An IRgbColor reference for the fill color</param> /// <param name="lineColor">An IRgbColor reference for the line or outline color</param> /// <param name="display">An IDisplay reference</param> /// <param name="cancelTracker">An ITrackCancel reference</param> private static void DrawGeometry(IGeometry geometry, IRgbColor fillColor, IRgbColor lineColor, IDisplay display, ITrackCancel cancelTracker) { bool continueDrawing = true; switch (geometry.GeometryType) { case esriGeometryType.esriGeometryBag: { IEnumGeometry enumGeometry = (IEnumGeometry)geometry; IGeometry innerGeometry = enumGeometry.Next(); while (innerGeometry != null && continueDrawing == true) { DrawGeometry(innerGeometry, fillColor, lineColor, display, cancelTracker); // Recursive method call innerGeometry = enumGeometry.Next(); if (cancelTracker != null) { continueDrawing = cancelTracker.Continue(); } } break; } case esriGeometryType.esriGeometryPolygon: { // Set the input polygon geometry's symbol. ISimpleFillSymbol fillSymbol = new SimpleFillSymbolClass(); fillSymbol.Color = (IColor)fillColor; ILineSymbol lineSymbol = new SimpleLineSymbolClass(); lineSymbol.Color = lineColor; fillSymbol.Outline = lineSymbol; // Draw the input polygon geometry. display.SetSymbol((ISymbol)fillSymbol); display.DrawPolygon(geometry); break; } case esriGeometryType.esriGeometryPolyline: { // Set the input polyline geometry's symbol. IMultiLayerLineSymbol multiLineSymbol = new MultiLayerLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol1 = new SimpleLineSymbolClass(); ISimpleLineSymbol simpleLineSymbol2 = new SimpleLineSymbolClass(); simpleLineSymbol1.Width = 3; simpleLineSymbol1.Color = fillColor; simpleLineSymbol2.Width = 5; simpleLineSymbol2.Color = lineColor; multiLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol2); multiLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol1); // Draw the input polyline geometry. display.SetSymbol((ISymbol)multiLineSymbol); display.DrawPolyline(geometry); break; } case esriGeometryType.esriGeometryPoint: { // Set the input point geometry's symbol. ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 12; simpleMarkerSymbol.Color = fillColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = lineColor; // Draw the input point geometry. display.SetSymbol((ISymbol)simpleMarkerSymbol); display.DrawPoint(geometry); break; } case esriGeometryType.esriGeometryMultipoint: { // Set the input multipoint geometry's symbol. ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbolClass(); simpleMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle; simpleMarkerSymbol.Size = 8; simpleMarkerSymbol.Color = fillColor; simpleMarkerSymbol.Outline = true; simpleMarkerSymbol.OutlineColor = lineColor; // Draw the input multipoint geometry. display.SetSymbol((ISymbol)simpleMarkerSymbol); display.DrawMultipoint(geometry); break; } } }
public static void drawPolygon(IGeometry geom, AxMapControl mapControl, IRgbColor color = null) { ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass(); simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid; if(color != null) { simpleFillSymbol.Color = color; } else { simpleFillSymbol.Color = GetDefaultRgbColor(); } IFillShapeElement fillShapeElement = new PolygonElementClass(); fillShapeElement.Symbol = simpleFillSymbol; IElement element = fillShapeElement as IElement; element.Geometry = geom; IGraphicsContainer pGraphics = mapControl.Map as IGraphicsContainer; IActiveView pActiveView = mapControl.ActiveView; try { pGraphics.UpdateElement(element); } catch (Exception updateExp) { pGraphics.AddElement(element, 0); } pActiveView.Refresh(); }
private void com_Color_Click(object sender, EventArgs e) { if (this.colorDialog1.ShowDialog() == DialogResult.OK) { // 将先中的颜色设置为窗体的背景色 //this.BackColor = colorDialog1.Color; this.com_Color.BackColor = colorDialog1.Color; //pColor = GetRGB(colorDialog1.Color); colors = GetRGB(colorDialog1.Color); } }