private void ChangeLineSymbol() { ILineSymbol pLineSymbol = grpSymbol.Tag as ILineSymbol; if (pLineSymbol == null) { return; } Color pColor = colorLine.Color; pLineSymbol.Color = PublicClass.GetRGBColor(colorLine); pLineSymbol.Width = (double)numLineWidth.Value; ILineProperties pLineProp = pLineSymbol as ILineProperties; if (pLineProp != null) { pLineProp.Offset = (double)numLineOffSet.Value; } grpSymbol.Tag = pLineSymbol; IStyleGalleryItem item = new ServerStyleGalleryItemClass(); item.Name = "tempSymbol"; item.Item = pLineSymbol; PreviewImage(item); m_styleGalleryItem = item; }
private ISymbol CreateBikeRouteSymbol() { IColor color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 90, 250)); ICharacterMarkerSymbol charMarkerSymbol = new CharacterMarkerSymbolClass(); charMarkerSymbol.Color = color; charMarkerSymbol.Font = ESRI.ArcGIS.ADF.Connection.Local.Converter.ToStdFont(new Font("ESRI Default Marker", 17.0f, FontStyle.Bold)); charMarkerSymbol.CharacterIndex = 189; charMarkerSymbol.Size = 17; IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass(); markerLineSymbol.Color = color; markerLineSymbol.Width = 17.0; markerLineSymbol.MarkerSymbol = (IMarkerSymbol)charMarkerSymbol; // Makes a new Cartographic Line symbol and sets its properties ICartographicLineSymbol cartographicLineSymbol = markerLineSymbol as ICartographicLineSymbol; // In order to set additional properties like offsets and dash patterns we must create an ILineProperties object ILineProperties lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; // Here's how to do a template for the pattern of marks and gaps double[] hpe = new double[4]; hpe[0] = 0; hpe[1] = 39; hpe[2] = 1; hpe[3] = 0; ITemplate template = new TemplateClass(); template.Interval = 1; for (int i = 0; i < hpe.Length; i = i + 2) { template.AddPatternElement(hpe[i], hpe[i + 1]); } lineProperties.Template = template; // Set the basic and cartographic line properties cartographicLineSymbol.Color = color; color = (IColor)ESRI.ArcGIS.ADF.Connection.Local.Converter.ToRGBColor(Color.FromArgb(0, 220, 100)); // create a simple line ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass(); simpleLineSymbol.Color = color; simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSSolid; simpleLineSymbol.Width = 1.2; IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass(); multiLayerLineSymbol.AddLayer((ILineSymbol)cartographicLineSymbol); multiLayerLineSymbol.AddLayer((ILineSymbol)simpleLineSymbol); return(multiLayerLineSymbol as ISymbol); }
private ICartographicLineSymbol CreateCartographicLineSymbol(IRgbColor rgbColor) { if (rgbColor == null) { return(null); } ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbol(); ILineProperties lineProperties = cartographicLineSymbol as ILineProperties; lineProperties.Offset = 0; // Here's how to do a template for the pattern of marks and gaps Double[] hpe = new Double[6]; hpe[0] = 0; hpe[1] = 7; hpe[2] = 1; hpe[3] = 1; hpe[4] = 1; hpe[5] = 0; /* hpe[0] = 1; * hpe[1] = 0; * hpe[2] = 1; * hpe[3] = 0; * hpe[4] = 1; * hpe[5] = 0; * hpe[6] = 1; * hpe[7] = 0; * hpe[11] = 0;*/ ITemplate template = new Template(); template.Interval = 1; /* for (Int32 i = 0; i < hpe.Length; i = i + 2) * { * template.AddPatternElement(hpe[i], hpe[i + 1]); * }*/ for (int i = 0; i < 4; i += 2) { template.AddPatternElement(i, 0); } lineProperties.Template = template; // Set the basic and cartographic line properties cartographicLineSymbol.Width = 1; cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt; cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSRound; cartographicLineSymbol.Color = rgbColor; return(cartographicLineSymbol); }
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(); }
//HashLineSymbol private void button9_Click(object sender, EventArgs e) { IHashLineSymbol hashLineSymbol = new HashLineSymbolClass(); ILineProperties lineProperties = hashLineSymbol 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; hashLineSymbol.Width = 2; hashLineSymbol.Angle = 45; IRgbColor hashColor = new RgbColor(); hashColor = getRGB(0, 0, 255); hashLineSymbol.Color = hashColor; IPolyline polyline = new PolylineClass(); IPoint point = new PointClass(); point.PutCoords(1, 1); polyline.FromPoint = point; point.PutCoords(10, 10); polyline.ToPoint = point; IActiveView activeView = this.axMapControl1.ActiveView; activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache); activeView.ScreenDisplay.SetSymbol(hashLineSymbol as ISymbol); activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry); activeView.ScreenDisplay.FinishDrawing(); activeView.ScreenDisplay.FinishDrawing(); }
private static ILineSymbol DefineProfileLineSymbol(MilSpaceGraphicsTypeEnum graphicsType) { //TODO: Get symbol from ESRITools IRgbColor rgbColor = grapchucsTypeColors[graphicsType](); //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = rgbColor; arrowMarkerSymbol.Size = 6; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 6; //Add an offset to make sure the square end of the line is hidden arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = rgbColor; cartographicLineSymbol.Width = 1; //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line (the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(simpleLineDecorationElement); //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; return(cartographicLineSymbol); }
private ILineSymbol _GetZingerSymbol() { // Create a color Color color = Color.Green; IRgbColor symbolColor = new RgbColorClass(); symbolColor.Red = color.R; symbolColor.Green = color.G; symbolColor.Blue = color.B; // Create an arrow marker IArrowMarkerSymbol arrowMarker = new ArrowMarkerSymbolClass(); arrowMarker.Color = symbolColor; arrowMarker.Length = 6.125; arrowMarker.Width = 7.0; // Create an decoration element from arrow marker to be positioned on the line ISimpleLineDecorationElement decorationElement = new SimpleLineDecorationElementClass(); decorationElement.MarkerSymbol = arrowMarker; decorationElement.AddPosition(0.5); decorationElement.PositionAsRatio = true; // Create a line decoration to be added to the line ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(decorationElement); // Create the line symbol with decoration ICartographicLineSymbol lineSymbol = new CartographicLineSymbolClass(); lineSymbol.Color = symbolColor; ILineProperties lineProperties = (ILineProperties)lineSymbol; lineProperties.LineDecoration = lineDecoration; return(lineSymbol); }
private static ILineSymbol DefineProfileDecorationLineSymbol(MilSpaceGraphicsTypeEnum graphicsType, IRgbColor color, int width = 2, LineType lineType = LineType.Arrow) { //TODO: Get symbol from ESRITools //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = color; cartographicLineSymbol.Width = width; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); if (lineType == LineType.Arrow || lineType == LineType.DefaultLine) { //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line(the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = color; arrowMarkerSymbol.Size = 5; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 5 + width; //Add an offset to make sure the square end of the line is hidden arrowMarkerSymbol.XOffset = 0.8; simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; lineDecoration.AddElement(simpleLineDecorationElement); } if (lineType == LineType.Point || lineType == LineType.DefaultLine) { //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); simpleLineDecorationElement.AddPosition(0); SimpleMarkerSymbol circleMarkerSymbol = new SimpleMarkerSymbol() { Color = color, Size = 5, Style = esriSimpleMarkerStyle.esriSMSCircle, }; //Add an offset to make sure the square end of the line is hidden circleMarkerSymbol.XOffset = 0.8; simpleLineDecorationElement.MarkerSymbol = circleMarkerSymbol; lineDecoration.AddElement(simpleLineDecorationElement); } //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; return(cartographicLineSymbol); }
public static void DrawArrow(IActiveView pActiveView, CPoint frcpt, CPoint tocpt, double dblArrowLength = 6, double dblArrowWidth = 6, int intRed = 0, int intGreen = 0, int intBlue = 0) { var iColor = CHelpFunc.GenerateIRgbColor(intRed, intGreen, intBlue) as IColor; //Define an arrow marker IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = iColor; //arrowMarkerSymbol.Size = 6; //it seems size has no effect arrowMarkerSymbol.Length = dblArrowLength; arrowMarkerSymbol.Width = dblArrowWidth; //Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); cartographicLineSymbol.Color = iColor; cartographicLineSymbol.Width = 1; //Define simple line decoration ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); //Place the arrow at the end of the line (the "To" point in the geometry below) simpleLineDecorationElement.AddPosition(1); simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; //Define line decoration ILineDecoration lineDecoration = new LineDecorationClass(); lineDecoration.AddElement(simpleLineDecorationElement); //Set line properties ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; lineProperties.LineDecoration = lineDecoration; //Define line element ILineElement lineElement = new LineElementClass(); lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; var cpl = new CPolyline(-1, frcpt, tocpt); //Cast to Element and set geometry var element = (IElement)lineElement; element.Geometry = cpl.JudgeAndSetPolyline(); //Set the name //IElementProperties3 elementProperties3.Name = elementName; //Add element to graphics container pActiveView.GraphicsContainer.AddElement(element, 0); pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); #region a useful example https://community.esri.com/thread/69395 ////Set the element name //string elementName = "ArrowTest"; ////Get the graphics container from the page layout (set elsewhere) //IActiveView activeView = (IActiveView)pageLayout; //IGraphicsContainer graphicsContainer = (IGraphicsContainer)pageLayout; ////Find all existing elements with specified name ////Build a list of elements and then loop over the list to delete them //List<IElement> elementsToDelete = new List<IElement>(); //graphicsContainer.Reset(); //IElementProperties3 elementProperties3 = null; //IElement element = null; //while ((element = graphicsContainer.Next()) != null) //{ // elementProperties3 = (IElementProperties3)element; // if (elementProperties3.Name == elementName) // { // elementsToDelete.Add(element); // } //} //foreach (IElement elementToDelete in elementsToDelete) //{ // graphicsContainer.DeleteElement(elementToDelete); //} ////Define color //IRgbColor rgbColor = new RgbColorClass(); //rgbColor.RGB = Color.Black.ToArgb(); ////Define an arrow marker //IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); //arrowMarkerSymbol.Color = rgbColor; //arrowMarkerSymbol.Size = 6; //arrowMarkerSymbol.Length = 8; //arrowMarkerSymbol.Width = 6; ////Add an offset to make sure the square end of the line is hidden //arrowMarkerSymbol.XOffset = 0.8; ////Create cartographic line symbol //ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass(); //cartographicLineSymbol.Color = rgbColor; //cartographicLineSymbol.Width = 1; ////Define simple line decoration //ISimpleLineDecorationElement simpleLineDecorationElement = new SimpleLineDecorationElementClass(); ////Place the arrow at the end of the line (the "To" point in the geometry below) //simpleLineDecorationElement.AddPosition(1); //simpleLineDecorationElement.MarkerSymbol = arrowMarkerSymbol; ////Define line decoration //ILineDecoration lineDecoration = new LineDecorationClass(); //lineDecoration.AddElement(simpleLineDecorationElement); ////Set line properties //ILineProperties lineProperties = (ILineProperties)cartographicLineSymbol; //lineProperties.LineDecoration = lineDecoration; ////Define line element //ILineElement lineElement = new LineElementClass(); //lineElement.Symbol = (ILineSymbol)cartographicLineSymbol; ////Create the line geometry //IPoint fromPoint = new PointClass(); //fromPoint.X = 4.0; //fromPoint.Y = 0.8; //IPoint toPoint = new PointClass(); //toPoint.X = 5.0; //toPoint.Y = 0.8; //IPolyline polyline = new PolylineClass(); //polyline.FromPoint = fromPoint; //polyline.ToPoint = toPoint; ////Cast to Element and set geometry //element = (IElement)lineElement; //element.Geometry = polyline; ////Set the name //elementProperties3.Name = elementName; ////Add element to graphics container //graphicsContainer.AddElement(element, 0); ////Clear the graphics selection (graphics are selected when added) //IGraphicsContainerSelect graphicsContainerSelect = (IGraphicsContainerSelect)graphicsContainer; //graphicsContainerSelect.UnselectAllElements(); //activeView.Refresh(); #endregion }
//线 设计 private void colorLine_SelectedColorChanged(object sender, EventArgs e) { if (pStyleGalleryItem == null) { MessageBox.Show("请选择线样式", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ILineSymbol pLineSymbol = pStyleGalleryItem.Item as ILineSymbol; if (pLineSymbol == null) { return; } pLineSymbol.Color = ClsGDBDataCommon.ColorToIColor(colorLine.SelectedColor); //新添加,用于更改线修饰颜色 if (pLineSymbol is IMultiLayerLineSymbol) { IMultiLayerLineSymbol pMultiLyerLine = pLineSymbol as IMultiLayerLineSymbol; int nLCount = pMultiLyerLine.LayerCount; for (int j = 0; j < nLCount; j++) { ILineSymbol Psymbol = pMultiLyerLine.get_Layer(j); ILineProperties pLineProp = Psymbol as ILineProperties; List <ILineDecorationElement> Linedeclist = new List <ILineDecorationElement>(); if (pLineProp != null) { ILineDecoration pLineDec = pLineProp.LineDecoration; if (pLineDec != null) { int ncount = pLineDec.ElementCount; for (int i = 0; i < ncount; i++) { ILineDecorationElement pLineDecEle = pLineDec.get_Element(i); Linedeclist.Add(pLineDecEle); } if (Linedeclist.Count > 0) { for (int i = 0; i < ncount; i++) { ISimpleLineDecorationElement pSLDecEle = Linedeclist[i] as ISimpleLineDecorationElement; ISimpleLineDecorationElement pnewele = new SimpleLineDecorationElementClass(); if (pSLDecEle != null) { IMarkerSymbol pMSymbol = pSLDecEle.MarkerSymbol; pMSymbol.Color = ClsGDBDataCommon.ColorToIColor(colorLine.SelectedColor); pnewele.AddPosition(pSLDecEle.get_Position(i)); pnewele.MarkerSymbol = pMSymbol; pLineDec.DeleteElement(i); pLineDec.AddElement(pnewele); } } } } } } } PreviewImage(); }
public void RefreshLayer() { if (pGraphicsLayer != null) { IGraphicsContainer pGC = pGraphicsLayer as IGraphicsContainer; int nCount = m_IMUFeatureList.Count; pGC.DeleteAllElements(); for (int i = 0; i < nCount; i++) { IPolyline ppl = new PolylineClass(); ppl.FromPoint = m_IMUFeatureList[i].Shape as IPoint; ppl.ToPoint = m_CenterlinePointFeatureList[i].Shape as IPoint; IRgbColor pColor = new RgbColorClass(); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbolClass(); pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecorationClass(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElementClass(); pSimpleLineDecoElem.AddPosition(1); IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbolClass(); pArrowMarkerSym.Size = 8; pArrowMarkerSym.Color = pColor; pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol; pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; pLineSymbol.Color = pColor; pLineSymbol.Width = 1; ILineElement pLineElem = new LineElementClass(); pLineElem.Symbol = pLineSymbol; IElement pElem = pLineElem as IElement; pElem.Geometry = ppl; pGC.AddElement(pElem, 0); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); // IGraphicsContainerSelect pGCS = pGC as IGraphicsContainerSelect; // pGCS.SelectAllElements(); //bool bbb = pGCS.ElementSelected(pElement); //pGC.UpdateElement(pElement); //pElement = new MarkerElementClass(); //pElement.Geometry = m_OriginPoints.get_Point(i); //ISimpleMarkerSymbol sms = new SimpleMarkerSymbolClass(); //sms.Style = esriSimpleMarkerStyle.esriSMSSquare; //sms.Size = 9; //IMarkerElement im = pElement as IMarkerElement; //im.Symbol = sms ; // IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; // pGraphicsContainer.AddElement(pElement, 0); //pGC.AddElement(pElement,0); //pGC.UpdateElement(pElement); //IMarkerElement pMarkerEle = new MarkerElementClass(); //IPictureMarkerSymbol pPictureMarkerSymbol = new PictureMarkerSymbol(); ////pPictureMarkerSymbol.Color = sitecolor as IColor; //pPictureMarkerSymbol.Size = 10; //pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, // GetParentPathofExe() + @"Resource\Globe.bmp"); //IElement pEle = pMarkerEle as IElement; //pEle.Geometry = ppl.FromPoint; //pMarkerEle.Symbol = pPictureMarkerSymbol; //IGraphicsContainer pGraphicsContainer = m_pMapCtr.Map.BasicGraphicsLayer as IGraphicsContainer; ////site.pEle = pEle; //pGraphicsContainer.AddElement(pEle, 0); } IMapControl2 pMapCtr = (((IToolbarControl)m_hookHelper.Hook).Buddy) as IMapControl2; if (pMapCtr != null) { if (m_IMUFeatureList.Count == 0) { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewAll, null, null); } else { pMapCtr.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null); } } } }
/// <summary> /// 带箭头的线段 /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="fillColor"></param> public static void TrackLine(IPoint start, IPoint end, Color fillColor) { //将线段打断生成两条线段 以实现线段中间箭头显示 IPoint middle = new PointClass(); middle.PutCoords((end.X + start.X) / 2, (end.Y + start.Y) / 2); IActiveView pActiveView = Program.myMap.ActiveView; IGraphicsContainer pGraphicsContainer = pActiveView.GraphicsContainer; IPolyline pLine = new PolylineClass(); IPolyline pLine1 = new PolylineClass(); pLine.FromPoint = start; pLine.ToPoint = middle; pLine1.FromPoint = middle; pLine1.ToPoint = end; pLine.Project(pActiveView.FocusMap.SpatialReference); pLine1.Project(pActiveView.FocusMap.SpatialReference); ICartographicLineSymbol pCartoLineSymbol = new CartographicLineSymbol(); pCartoLineSymbol.Cap = esriLineCapStyle.esriLCSRound; ILineProperties pLineProp = pCartoLineSymbol as ILineProperties; pLineProp.DecorationOnTop = true; ILineDecoration pLineDecoration = new LineDecoration(); ISimpleLineDecorationElement pSimpleLineDecoElem = new SimpleLineDecorationElement(); pSimpleLineDecoElem.AddPosition(1); IArrowMarkerSymbol pArrowMarkerSym = new ArrowMarkerSymbol(); pArrowMarkerSym.Size = 12; pArrowMarkerSym.Color = GetColor(fillColor.R, fillColor.G, fillColor.B); pSimpleLineDecoElem.MarkerSymbol = pArrowMarkerSym as IMarkerSymbol; pLineDecoration.AddElement(pSimpleLineDecoElem as ILineDecorationElement); pLineProp.LineDecoration = pLineDecoration; ILineSymbol pLineSymbol = pCartoLineSymbol as ILineSymbol; pLineSymbol.Color = GetColor(fillColor.R, fillColor.G, fillColor.B);; pLineSymbol.Width = 2; ILineElement pLineElem = new LineElementClass(); ILineElement pLineElem1 = new LineElementClass(); pLineElem.Symbol = pLineSymbol; pLineElem1.Symbol = pLineSymbol; IElement pElem = pLineElem as IElement; IElement pElem1 = pLineElem1 as IElement; pElem.Geometry = pLine; pElem1.Geometry = pLine1; pGraphicsContainer.AddElement(pElem, 0); pGraphicsContainer.AddElement(pElem1, 0); pActiveView.Refresh(); }
private void btnRender_Click(object sender, EventArgs e) { IGeoFeatureLayer geoLayer = GetLayerByName(cboLayer.Text); MessageBox.Show(geoLayer.FeatureClass.ShapeType.ToString()); switch (m_strOption) { // case "Simple": IRgbColor rgbColor = new RgbColor(); rgbColor.Red = Convert.ToInt32(cboRed.Text); rgbColor.Green = Convert.ToInt32(cboGreen.Text); rgbColor.Blue = Convert.ToInt32(cboGreen.Text); //only used to Polygon Layer ISymbol sym = null; //Acording the shape type, use different sympol if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon) { //Polygon Feature //Orginate Code // ISimpleFillSymbol fillSym = new SimpleFillSymbol() ; //sym.style // fillSym.Style = esriSimpleFillStyle.esriSFSSolid; //sym.color // fillSym.Color = rgbColor; //new Code for IGradientFillSymbol by jin IGradientFillSymbol fillSym = new GradientFillSymbol(); fillSym.Style = esriGradientFillStyle.esriGFSBuffered; IRgbColor fromColor = new RgbColor(); fromColor.Red = 255; fromColor.Green = 0; fromColor.Blue = 0; IRgbColor toColor = new RgbColor(); toColor.Red = 0; toColor.Green = 0; toColor.Blue = 255; IAlgorithmicColorRamp ramp = new AlgorithmicColorRamp(); ramp.Size = 16; ramp.FromColor = fromColor; ramp.ToColor = toColor; fillSym.ColorRamp = ramp; sym = fillSym as ISymbol; } else if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolyline) { //Line Feature // ISimpleLineSymbol lineSym = new SimpleLineSymbol(); // lineSym.Style = esriSimpleLineStyle.esriSLSSolid; // lineSym.Color = rgbColor; // sym = lineSym as ISymbol; // ICartographicLineSymbol cartLineSym = new CartographicLineSymbol(); cartLineSym.Color = rgbColor; cartLineSym.Cap = esriLineCapStyle.esriLCSSquare; cartLineSym.Join = esriLineJoinStyle.esriLJSMitre; ISimpleLineDecorationElement pSimpleLineDecoEle = new SimpleLineDecorationElement(); pSimpleLineDecoEle.FlipAll = true; pSimpleLineDecoEle.FlipFirst = true; ILineDecoration pLineDeco = new LineDecoration(); pLineDeco.AddElement(pSimpleLineDecoEle); // //QI ILineProperties pLinePro = cartLineSym as ILineProperties; pLinePro.LineDecoration = pLineDeco; sym = cartLineSym as ISymbol; } else if (geoLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint) { //Point Feature ISimpleMarkerSymbol marketSym = new SimpleMarkerSymbol(); marketSym.Style = esriSimpleMarkerStyle.esriSMSCircle; //;esriSMSX;cross marketSym.Color = rgbColor; sym = marketSym as ISymbol; } ApplySimple(geoLayer, sym); break; case "Unique": ApplyUniqueValue(geoLayer, cboUniqueVals.Text); break; case "Chart": ApplyBarChartValue(geoLayer, cbxProp1.Text); break; case "Breaks": ApplyClsssBreaks(geoLayer, cboNumericVals.Text, long.Parse(cboBreaks.Text)); break; default: break; } }
// ********************* // Author: Erika Kamptner // Created Date: 3/10/2017 // Description: This method takes several parameters from the BuildMap method to connect to geodatabase, load layer, // place in appropriate group layer, style, and label. Only Address points, Cadastral, Building, and Centerline layers // have specified labels and symbology. // // ************************** public static void LoadCSCLFeatureClass(bool isCSCL, string strFCName, IGroupLayer pGroupLayer, string strGeodatabase) { //Point to map document IMxDocument pMxDoc; pMxDoc = (IMxDocument)ArcMap.Application.Document; IMap pMap; pMap = pMxDoc.FocusMap; //Set up shapefile Workspace connection IWorkspaceFactory pWorkspaceFactory; pWorkspaceFactory = new ShapefileWorkspaceFactoryClass(); //If connecting to SDE, set up SDE workspace connection //IWorkspaceFactory pWorkspaceFactory; //pWorkspaceFactory = new SdeWorkspaceFactoryClass(); IWorkspace pWorkspace; pWorkspace = pWorkspaceFactory.OpenFromFile(strGeodatabase, 0); IFeatureWorkspace pFeatureWorkspace; pFeatureWorkspace = (IFeatureWorkspace)pWorkspace; IFeatureClass pFeatureClass; pFeatureClass = pFeatureWorkspace.OpenFeatureClass(strFCName); IFeatureLayer pFeatureLayer; pFeatureLayer = new FeatureLayer(); pFeatureLayer.FeatureClass = pFeatureClass; pFeatureLayer.Name = pFeatureClass.AliasName; //Add layer to group if CSCL map type. Otherwise, just add layer. if (isCSCL) { pGroupLayer.Add((ILayer)pFeatureLayer); } else { pMap.AddLayer((ILayer)pFeatureLayer); } //Symbolize Address points based if the address has subaddresses if (pFeatureLayer.Name == "AddressPoint") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayAnnotation = true; //Create unique symbology based on subaddress flag using unique value renderer ISimpleMarkerSymbol pAddressSymbolDefault; pAddressSymbolDefault = new SimpleMarkerSymbolClass(); pAddressSymbolDefault.Color = SetColor(230, 0, 0); pAddressSymbolDefault.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolDefault.Size = 4; IUniqueValueRenderer pUniqueValueRenderer; pUniqueValueRenderer = new UniqueValueRendererClass(); pUniqueValueRenderer.FieldCount = 1; pUniqueValueRenderer.set_Field(0, "SUBADDRESS"); pUniqueValueRenderer.UseDefaultSymbol = false; //Create unique symbology for different values ISimpleMarkerSymbol pAddressSymbolYES; pAddressSymbolYES = new SimpleMarkerSymbolClass(); pAddressSymbolYES.Color = SetColor(230, 0, 0); pAddressSymbolYES.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolYES.Size = 8; pAddressSymbolYES.OutlineSize = 2; pAddressSymbolYES.OutlineColor = SetColor(255, 255, 0); pAddressSymbolYES.Outline = true; ISimpleMarkerSymbol pAddressSymbolNO; pAddressSymbolNO = new SimpleMarkerSymbolClass(); pAddressSymbolNO.Color = SetColor(230, 0, 0); pAddressSymbolNO.Style = esriSimpleMarkerStyle.esriSMSCircle; pAddressSymbolNO.Size = 4; pUniqueValueRenderer.AddValue("YES", "SUBADDRESS", pAddressSymbolYES as ISymbol); pUniqueValueRenderer.set_Label("YES", "YES"); pUniqueValueRenderer.set_Symbol("YES", pAddressSymbolYES as ISymbol); pUniqueValueRenderer.AddValue("NO", "SUBADDRESS", pAddressSymbolNO as ISymbol); pUniqueValueRenderer.set_Label("NO", "NO"); pUniqueValueRenderer.set_Symbol("NO", pAddressSymbolNO as ISymbol); //Create Label LabelFeatures(pGeoFeatureLayer, "\"ADDRESSID: \" + [ADDRESS_ID]"); pGeoFeatureLayer.Renderer = (IFeatureRenderer)pUniqueValueRenderer; } else if (pFeatureLayer.Name == "Building") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "BIN"; pGeoFeatureLayer.DisplayAnnotation = true; //Create ouline element ISimpleLineSymbol pOutline; pOutline = new SimpleLineSymbolClass(); pOutline.Color = SetColor(0, 0, 255); pOutline.Width = 2; //Create polygon with outline element ISimpleFillSymbol pBuildingSymbol; pBuildingSymbol = new SimpleFillSymbolClass(); pBuildingSymbol.Style = esriSimpleFillStyle.esriSFSHollow; pBuildingSymbol.Outline = pOutline; //Create Label LabelFeatures(pGeoFeatureLayer, "\"BIN : \" + [BIN]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pBuildingSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else if (pFeatureLayer.Name == "StreetCenterline") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "ST_NAME"; pGeoFeatureLayer.DisplayAnnotation = true; //Create arrow element to place at end of line segment IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass(); arrowMarkerSymbol.Color = SetColor(0, 0, 0); arrowMarkerSymbol.Size = 6; arrowMarkerSymbol.Length = 8; arrowMarkerSymbol.Width = 6; arrowMarkerSymbol.XOffset = 0.8; //Create cartographic line symbol ICartographicLineSymbol pCartographicLineSymbol; pCartographicLineSymbol = new CartographicLineSymbolClass(); pCartographicLineSymbol.Color = SetColor(0, 0, 0); pCartographicLineSymbol.Width = 2; //Place arrow at end of line ISimpleLineDecorationElement pCenterlineDecoration; pCenterlineDecoration = new SimpleLineDecorationElementClass(); pCenterlineDecoration.AddPosition(1); pCenterlineDecoration.MarkerSymbol = arrowMarkerSymbol; pCenterlineDecoration.Rotate = true; //set line decoration ILineDecoration pLineDecoration; pLineDecoration = new LineDecorationClass(); pLineDecoration.AddElement(pCenterlineDecoration); //Set line properties ILineProperties lineProperties = (ILineProperties)pCartographicLineSymbol; lineProperties.LineDecoration = pLineDecoration; lineProperties.Flip = false; //Create Label LabelFeatures(pGeoFeatureLayer, "[L_LOW_HN] + \" - \" + [L_HIGH_HN]+ \" \" +[ST_NAME] + vbCrLf + [PHYSICALID]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pCartographicLineSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else if (pFeatureLayer.Name == "Cadastral") { ILayer pLayer; pLayer = (ILayer)pFeatureLayer; IGeoFeatureLayer pGeoFeatureLayer; pGeoFeatureLayer = (IGeoFeatureLayer)pLayer; pGeoFeatureLayer.DisplayField = "BBL"; pGeoFeatureLayer.DisplayAnnotation = true; //Create ouline element ISimpleLineSymbol pOutline; pOutline = new SimpleLineSymbolClass(); pOutline.Color = SetColor(76, 230, 0); pOutline.Width = 2; //Create polygon with outline element ISimpleFillSymbol pTaxLotSymbol; pTaxLotSymbol = new SimpleFillSymbolClass(); pTaxLotSymbol.Style = esriSimpleFillStyle.esriSFSHollow; pTaxLotSymbol.Outline = pOutline; //Create label LabelFeatures(pGeoFeatureLayer, "\"BBL: \" + [BBL]"); //Render features ISimpleRenderer pSimpleRenderer; pSimpleRenderer = new SimpleRenderer(); pSimpleRenderer.Symbol = (ISymbol)pTaxLotSymbol; pGeoFeatureLayer.Renderer = (IFeatureRenderer)pSimpleRenderer; } else { pFeatureLayer.Visible = false; } }
public void CopyFrom(ILineProperties line) { LineStyle = line.LineStyle; LineStyleWidth = line.LineStyleWidth; ShadowVisible = line.ShadowVisible; }
private void PreviewColorSet() { PreviewImage(m_styleGalleryItem); grpSymbol.Tag = m_styleGalleryItem.Item; Color pColor; IRgbColor pRgbColor; if (m_styleGalleryItem.Item is IMarkerSymbol) { IMarkerSymbol pMrkSymbol = (IMarkerSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pMrkSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorPoint.Color = pColor; colorPoint.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorPoint.Color = Color.Transparent; colorPoint.ForeColor = Color.Transparent; } numPtSize.Value = (decimal)pMrkSymbol.Size; numPtXOffSet.Value = (decimal)pMrkSymbol.XOffset; numPtYOffSet.Value = (decimal)pMrkSymbol.YOffset; SetGroupVisible(1); } else if (m_styleGalleryItem.Item is ILineSymbol) { ILineSymbol pLineSymbol = (ILineSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pLineSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorLine.Color = pColor; colorLine.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorLine.Color = Color.Transparent; colorLine.ForeColor = Color.Transparent; } numLineWidth.Value = (decimal)pLineSymbol.Width; ILineProperties pLineProp = pLineSymbol as ILineProperties; if (pLineProp != null) { numLineOffSet.Value = (decimal)pLineProp.Offset; } else { numLineOffSet.Value = 0; } SetGroupVisible(2); } else if (m_styleGalleryItem.Item is IFillSymbol) { IFillSymbol pFillSymbol = (IFillSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pFillSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorPolygon.Color = pColor; colorPolygon.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorPolygon.Color = Color.Transparent; colorPolygon.ForeColor = Color.Transparent;; } if (pFillSymbol.Outline != null) { ILineSymbol pOutLine = pFillSymbol.Outline; pRgbColor = PublicClass.GetRGBColor(pOutLine.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorBorder.Color = pColor; colorBorder.ForeColor = pColor; if (pRgbColor.Transparency == 0) { colorBorder.Color = Color.Transparent; colorBorder.ForeColor = Color.Transparent; } numOutLineWidth.Value = (decimal)pOutLine.Width; } else { btnOutLineColor.BackColor = this.BackColor; numOutLineWidth.Value = 0; } SetGroupVisible(3); } else if (m_styleGalleryItem.Item is ITextSymbol) { ITextSymbol pTextSymbol = (ITextSymbol)m_styleGalleryItem.Item; pRgbColor = PublicClass.GetRGBColor(pTextSymbol.Color); pColor = Color.FromArgb(pRgbColor.Transparency, pRgbColor.Red, pRgbColor.Green, pRgbColor.Blue); colorAnno.Color = pColor; colorAnno.ForeColor = pColor; SetGroupVisible(4); stdole.IFontDisp pFontDisp = pTextSymbol.Font; toolBarStyle.Buttons["toolBlod"].Pushed = pFontDisp.Bold; toolBarStyle.Buttons["toolItalic"].Pushed = pFontDisp.Italic; toolBarStyle.Buttons["toolUnderline"].Pushed = pFontDisp.Underline; ToolBarButton btn; for (int i = 0; i < toolBarAlign.Buttons.Count; i++) { btn = toolBarAlign.Buttons[i]; btn.Pushed = false; } if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHALeft) { btn = toolBarAlign.Buttons["toolLeft"]; btn.Pushed = true; } else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHACenter) { btn = toolBarAlign.Buttons["toolCenter"]; btn.Pushed = true; } else if (pTextSymbol.HorizontalAlignment == esriTextHorizontalAlignment.esriTHARight) { btn = toolBarAlign.Buttons["toolRight"]; btn.Pushed = true; } else { btn = toolBarAlign.Buttons["toolFull"]; btn.Pushed = true; } cmbTextFont.Text = pFontDisp.Name; numTextSize.Value = (decimal)pTextSymbol.Size; anGle.Value = (decimal)pTextSymbol.Angle; IFormattedTextSymbol pFTextSymbol = pTextSymbol as IFormattedTextSymbol; if (pFTextSymbol != null) { if (pFTextSymbol.Background != null) { if (pFTextSymbol.Background is IBalloonCallout) { fillGroup.Visible = true; IBalloonCallout pBallCallout = pFTextSymbol.Background as IBalloonCallout; IFillSymbol pFillSymbol = pBallCallout.Symbol; if (pFillSymbol != null) { pRgbColor = pFillSymbol.Color as IRgbColor; l_ColorForPolygon.BackColor = ColorTranslator.FromOle(pRgbColor.RGB); ILineSymbol pLineSymbol = pFillSymbol.Outline; if (pLineSymbol != null) { pRgbColor = pLineSymbol.Color as IRgbColor; l_ColorForLine.ForeColor = ColorTranslator.FromOle(pRgbColor.RGB); txt_LineWidth.Text = pLineSymbol.Width.ToString(); } } } } } } else { SetGroupVisible(5); } cmbTextFont.SelectedIndexChanged += new EventHandler(cmbTextFont_SelectedIndexChanged); numTextSize.ValueChanged += new EventHandler(numTextSize_ValueChanged); txt_LineWidth.TextChanged += new EventHandler(txt_LineWidth_TextChanged); anGle.ValueChanged += new EventHandler(anGle_ValueChanged); }