Symbol对象
GIS中的離散實體有三種:點、線、面,在ArcEngine中用三種符號對應表示,分別是:MarkSymbol、LineSymbol和FillSymbol。此外還有TextSymbol用于文字標注,3DChart用來顯示餅圖等三維對象。
所有符號都實現ISymbol和IMapLevel接口,ISymbol定義一個符號對象的基本屬性和方法,IMapLevel定義屬性可以確定符號顯示的圖層,和圖層類似,用于確定符號的疊加順序。
一、MarkerSymbol對象
MarkerSymbol對象用于修飾點對象符號,擁有12個子類:
| ArrowMarkerSymbol | 箭頭形式符號,箭頭的樣式只有一個:esriAMSPlain |
| BarChartSymbol | Defines a bar chart symbol. |
| CharacterMarker3DSymbol (3DAnalyst) | 3D Character Marker Symbol component. |
| CharacterMarkerSymbol | 字符形式符號,用于將一個點要素顯示為字符狀。Characterindex屬性用來確定顯示的字符 |
| Marker3DSymbol (3DAnalyst) | 3D Marker Symbol component. |
| MultiLayerMarkerSymbol | 使用多個符號進行疊加生成新符號。 |
| PictureMarkerSymbol | 以圖片為背景的符號,把一個點對象的外形表示為一個位圖,可以指定Picture或者使用CreateMarkSymbolFromFile獲取一張位圖 |
| PieChartSymbol | Defines a pie chart symbol. |
| SimpleMarker3DSymbol (3DAnalyst) | Simple 3D Marker Symbol component. |
| SimpleMarkerSymbol | 簡單類型點符號,有五種類型(esriSMSCircle、esriSMSSquare、esriSMSCross、esriSMSX和esriSMSDiamond) |
| StackedChartSymbol | Defines a stacked chart symbol. |
| TextMarkerSymbol (TrackingAnalyst) | Class used to create a text marker symbol used to symbolize point geometries. |
都實現IMarkerSymbol接口,定義了Angle、Color、Size、Xoffset、Yoffset。
private void simpleMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e){ISimpleMarkerSymbol iMarkerSymbol;ISymbol iSymbol;IRgbColor iRgbColor;iMarkerSymbol = new SimpleMarkerSymbol();iMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSCircle;iRgbColor = new RgbColor();iRgbColor = getRGB(100, 100, 100);iMarkerSymbol.Color = iRgbColor;iSymbol = (ISymbol)iMarkerSymbol;iSymbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;//Raster operation code for pixel drawingIPoint point1 = new PointClass();IPoint point2 = new PointClass();point1.PutCoords(5, 5);point2.PutCoords(5, 10);this.axMapControl1.FlashShape(point1 as IGeometry, 3, 200, iSymbol);//閃爍this.axMapControl1.FlashShape(point2);}private void arrowMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e){IArrowMarkerSymbol arrowMarkerSymbol = new ArrowMarkerSymbolClass();IRgbColor iRgbColor;iRgbColor = new RgbColor();iRgbColor = getRGB(100, 100, 100);arrowMarkerSymbol.Angle = 90;arrowMarkerSymbol.Color = iRgbColor;arrowMarkerSymbol.Length = 30;arrowMarkerSymbol.Width = 20;arrowMarkerSymbol.XOffset = 0;arrowMarkerSymbol.YOffset = 0;arrowMarkerSymbol.Style = esriArrowMarkerStyle.esriAMSPlain;IPoint point1 = new PointClass();IPoint point2 = new PointClass();point1.PutCoords(5, 5);point2.PutCoords(5, 10);this.axMapControl1.FlashShape(point1 as IGeometry, 3, 500, arrowMarkerSymbol);this.axMapControl1.FlashShape(point2 as IGeometry);}//定義字體符號private void chartMarkerSymbolToolStripMenuItem_Click(object sender, EventArgs e){ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbol();stdole.IFontDisp fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());IRgbColor rgbColor = new RgbColor();rgbColor = getRGB(100, 100, 100);fontDisp.Name = "arial";fontDisp.Size = 12;fontDisp.Italic = true;//斜體 characterMarkerSymbol.Angle = 0;characterMarkerSymbol.CharacterIndex = 97;characterMarkerSymbol.Color = rgbColor;characterMarkerSymbol.Font = fontDisp;characterMarkerSymbol.Size = 24;characterMarkerSymbol.XOffset = 0;characterMarkerSymbol.YOffset = 0;IPoint point1 = new PointClass();IPoint point2 = new PointClass();point1.PutCoords(5, 5);point2.PutCoords(5, 10);this.axMapControl1.FlashShape(point1 as IGeometry, 3, 500, characterMarkerSymbol);this.axMapControl1.FlashShape(point2 as IGeometry);}private void pictureMarkerSmpolToolStripMenuItem_Click(object sender, EventArgs e){IRgbColor rgbColor = new RgbColorClass();IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();//string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";string path = Directory.GetCurrentDirectory();string fileName = path + @"Images\00_43.gif";pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);pictureMarkerSymbol.Angle = 0;pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;pictureMarkerSymbol.Size = 20;pictureMarkerSymbol.XOffset = 0;pictureMarkerSymbol.YOffset = 0;IPoint point1 = new PointClass();IPoint point2 = new PointClass();point1.PutCoords(5, 5);point2.PutCoords(5, 10);this.axMapControl1.FlashShape(point1 as IGeometry, 3, 200, pictureMarkerSymbol);this.axMapControl1.FlashShape(point2 as IGeometry);}private void multiLayerMarkerSmbolToolStripMenuItem_Click(object sender, EventArgs e){IMultiLayerMarkerSymbol multiLayerMarkerSymbol = new MultiLayerMarkerSymbolClass();IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();ICharacterMarkerSymbol characterMarkerSymbol = new CharacterMarkerSymbol();stdole.IFontDisp fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());IRgbColor rgbColor = new RgbColor();rgbColor = getRGB(0, 0, 0);fontDisp.Name = "arial";fontDisp.Size = 12;fontDisp.Italic = true;//創建字符符號characterMarkerSymbol.Angle = 0;characterMarkerSymbol.CharacterIndex = 97;characterMarkerSymbol.Color = rgbColor;characterMarkerSymbol.Font = fontDisp;characterMarkerSymbol.Size = 24;characterMarkerSymbol.XOffset = 0;characterMarkerSymbol.YOffset = 0;//創建圖片符號//string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";string path = Directory.GetCurrentDirectory();string fileName = path + @"Images\00_43.gif";pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);pictureMarkerSymbol.Angle = 0;pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;pictureMarkerSymbol.Size = 30;pictureMarkerSymbol.XOffset = 0;pictureMarkerSymbol.YOffset = 0;//添加圖片、字符符號到組合符號中 multiLayerMarkerSymbol.AddLayer(pictureMarkerSymbol);multiLayerMarkerSymbol.AddLayer(characterMarkerSymbol);multiLayerMarkerSymbol.Angle = 0;multiLayerMarkerSymbol.Size = 30;multiLayerMarkerSymbol.XOffset = 0;multiLayerMarkerSymbol.YOffset = 0;IPoint point1 = new PointClass();IPoint point2 = new PointClass();point1.PutCoords(5, 5);point2.PutCoords(5, 10);this.axMapControl1.FlashShape(point1 as IGeometry, 3, 200, multiLayerMarkerSymbol);this.axMapControl1.FlashShape(point2 as IGeometry);}?
二、LineSymbol對象
用于修飾線性幾何對象符號。Color和Width屬性為兩個唯一公共屬性。
子類有:
| CartographicLineSymbol | 制圖線符號,實現ICatographicLineSymbol(主要設置線符號的節點屬性,Join:設置線要素轉折處的樣式)和ILineProperties接口 |
| HashLineSymbol | 離散線符號 |
| MarkerLineSymbol | A line symbol composed of repeating markers.點線符號 |
| MultiLayerLineSymbol | A line symbol that contains one or more layers.使用重疊符號方法產生新符號 |
| PictureLineSymbol | A line symbol composed of either a BMP or an EMF picture.比如火車線路符號 |
| SimpleLine3DSymbol (3DAnalyst) | Simple 3D Line Symbol component. |
| SimpleLineSymbol | 簡單線符號 |
| TextureLineSymbol (3DAnalyst) | Texture Line Symbol component.(紋理貼圖線符號) |
?
private void simpleLineSymbolToolStripMenuItem_Click(object sender, EventArgs e){ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;IPolyline polyline = new PolylineClass();IPoint point = new PointClass();point.PutCoords(1, 1);polyline.FromPoint = point;point.PutCoords(10, 10);polyline.ToPoint = point;simpleLineSymbol.Width = 10;IRgbColor rgbColor = getRGB(255, 0, 0);simpleLineSymbol.Color = rgbColor;ISymbol symbol = simpleLineSymbol as ISymbol;symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;IActiveView activeView = this.axMapControl1.ActiveView;//用activeView.ScreenDisplay進行畫圖activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);activeView.ScreenDisplay.SetSymbol(symbol);activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);activeView.ScreenDisplay.FinishDrawing();activeView.ScreenDisplay.FinishDrawing();//釋放資源 }private void cartographicLineSymbolToolStripMenuItem_Click(object sender, EventArgs e){ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();//制圖線符號cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;//連接方式cartographicLineSymbol.Width = 10;cartographicLineSymbol.MiterLimit = 4;//Size threshold(閾值) for showing mitered line joins. 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();}private void multiLayerLineSymbolToolStripMenuItem_Click(object sender, EventArgs e){IMultiLayerLineSymbol multiLayerLineSymbol = new MultiLayerLineSymbolClass();ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;simpleLineSymbol.Width = 10;IRgbColor rgbColor = getRGB(255, 0, 0);simpleLineSymbol.Color = rgbColor;ISymbol symbol = simpleLineSymbol as ISymbol;symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;ICartographicLineSymbol cartographicLineSymbol = new CartographicLineSymbolClass();cartographicLineSymbol.Cap = esriLineCapStyle.esriLCSButt;cartographicLineSymbol.Join = esriLineJoinStyle.esriLJSBevel;cartographicLineSymbol.Width = 10;cartographicLineSymbol.MiterLimit = 4;ILineProperties lineProperties;lineProperties = cartographicLineSymbol as ILineProperties;lineProperties.Offset = 0;double[] dob = new double[6];dob[0] = 0;dob[1] = 1;dob[2] = 2;dob[3] = 3;dob[4] = 4;dob[5] = 5;ITemplate template = new TemplateClass();template.Interval = 1;for (int i = 0; i < dob.Length; i += 2){template.AddPatternElement(dob[i], dob[i + 1]);}lineProperties.Template = template;IPolyline polyline = new PolylineClass();IPoint point = new PointClass();point.PutCoords(1, 1);polyline.FromPoint = point;point.PutCoords(10, 10);polyline.ToPoint = point;rgbColor = getRGB(0, 255, 0);cartographicLineSymbol.Color = rgbColor;multiLayerLineSymbol.AddLayer(simpleLineSymbol);multiLayerLineSymbol.AddLayer(cartographicLineSymbol);IActiveView activeView = this.axMapControl1.ActiveView;activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);activeView.ScreenDisplay.SetSymbol(multiLayerLineSymbol as ISymbol);activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);activeView.ScreenDisplay.FinishDrawing();activeView.ScreenDisplay.FinishDrawing();}private void hashLineSymbolToolStripMenuItem_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 void markerLineSymbolToolStripMenuItem_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;IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbolClass();markerLineSymbol.MarkerSymbol = arrowMarkerSymbol;rgbColor = getRGB(0, 255, 0);markerLineSymbol.Color = rgbColor;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(markerLineSymbol as ISymbol);activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);activeView.ScreenDisplay.FinishDrawing();activeView.ScreenDisplay.FinishDrawing();}private void pictureLineSymbolToolStripMenuItem_Click(object sender, EventArgs e){IPictureLineSymbol pictureLineSymbol = new PictureLineSymbolClass();//創建圖片符號//string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";string path = Directory.GetCurrentDirectory();string fileName = path + @"\qq.bmp";pictureLineSymbol.CreateLineSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);IRgbColor rgbColor = getRGB(0, 255, 0);pictureLineSymbol.Color = rgbColor;pictureLineSymbol.Offset = 0;pictureLineSymbol.Width = 10;pictureLineSymbol.Rotate = false;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(pictureLineSymbol as ISymbol);activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);activeView.ScreenDisplay.FinishDrawing();activeView.ScreenDisplay.FinishDrawing();}?
三、FillSymbol對象
用來修飾多邊形等具有面積的幾何形體的符號對象。只定義Color和OutLine兩個屬性。
| ColorRampSymbol (Carto) | ESRI ColorRampSymbol for raster rendering. |
| ColorSymbol (Carto) | ESRI ColorSymbol for raster rendering. |
| DotDensityFillSymbol | Defines a dot density fill symbol, a data driven symbol commonly used with the DotDensityRenderer對象. |
| GradientFillSymbol | 漸變顏色填充符號,IntervalCount屬性來設置用戶所需要的顏色梯度。 |
| LineFillSymbol | 線填充符號,表現為重復的線條,可以設置線的角度,偏移量和線之間的間隔距離。 |
| MarkerFillSymbol | 點填充符號,使用一個Marker符號作為背景填充符號,實現了IMarkerFillSymbol和IFillProperties兩個接口 |
| MultiLayerFillSymbol | 多層填充符號,使用多個填充符號進行疊加 |
| PictureFillSymbol | A fill symbol based on either a BMP or an EMF picture. |
| RasterRGBSymbol (Carto) | ESRI RasterRGBSymbol for raster rendering. |
| SimpleFillSymbol | A fill symbol comprised from a predefined set of styles. |
| TextureFillSymbol (3DAnalyst) | Texture Fill Symbol component. |
?
private void simpleFillSymbolToolStripMenuItem_Click(object sender, EventArgs e){//簡單填充符號ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;simpleFillSymbol.Color = getRGB(255, 0, 0);//創建邊線符號ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;simpleLineSymbol.Color = getRGB(0, 255, 0);simpleLineSymbol.Width = 10;ISymbol symbol = simpleLineSymbol as ISymbol;symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;simpleFillSymbol.Outline = simpleLineSymbol;//創建面對象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(simpleFillSymbol as ISymbol);activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);activeView.ScreenDisplay.FinishDrawing();}private void lineFillSymbolToolStripMenuItem_Click(object sender, EventArgs e){ICartographicLineSymbol cartoLine = new CartographicLineSymbol();cartoLine.Cap = esriLineCapStyle.esriLCSButt;cartoLine.Join = esriLineJoinStyle.esriLJSMitre;cartoLine.Color = getRGB(255, 0, 0);cartoLine.Width = 2;//Create the LineFillSymboILineFillSymbol lineFill = new LineFillSymbol();lineFill.Angle = 45;lineFill.Separation = 10;lineFill.Offset = 5;lineFill.LineSymbol = cartoLine;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(lineFill as ISymbol);activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);activeView.ScreenDisplay.FinishDrawing();}private void markerFillSymbolToolStripMenuItem_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();}private void gradientFillSymbolToolStripMenuItem_Click(object sender, EventArgs e){IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass();IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();algorithcColorRamp.FromColor = getRGB(255, 0, 0);algorithcColorRamp.ToColor = getRGB(0, 255, 0);algorithcColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;gradientFillSymbol.ColorRamp = algorithcColorRamp;gradientFillSymbol.GradientAngle = 45;gradientFillSymbol.GradientPercentage = 0.9;gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;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(gradientFillSymbol as ISymbol);activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);activeView.ScreenDisplay.FinishDrawing();}private void pictureFillSymbolToolStripMenuItem_Click(object sender, EventArgs e){IPictureFillSymbol pictureFillSymbol = new PictureFillSymbolClass();//創建圖片符號//string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";string path = Directory.GetCurrentDirectory();string fileName = path + @"\qq.bmp";pictureFillSymbol.CreateFillSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);pictureFillSymbol.Color = getRGB(0, 255, 0);ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbolClass();simpleLineSymbol.Style = esriSimpleLineStyle.esriSLSDashDotDot;simpleLineSymbol.Color = getRGB(255, 0, 0);ISymbol symbol = pictureFillSymbol as ISymbol;symbol.ROP2 = esriRasterOpCode.esriROPNotXOrPen;pictureFillSymbol.Outline = simpleLineSymbol;pictureFillSymbol.Angle = 45;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(pictureFillSymbol as ISymbol);activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);activeView.ScreenDisplay.FinishDrawing();}private void multilayerFillSymbolToolStripMenuItem_Click(object sender, EventArgs e){IMultiLayerFillSymbol multiLayerFillSymbol = new MultiLayerFillSymbolClass();IGradientFillSymbol gradientFillSymbol = new GradientFillSymbolClass();IAlgorithmicColorRamp algorithcColorRamp = new AlgorithmicColorRampClass();algorithcColorRamp.FromColor = getRGB(255, 0, 0);algorithcColorRamp.ToColor = getRGB(0, 255, 0);algorithcColorRamp.Algorithm = esriColorRampAlgorithm.esriHSVAlgorithm;gradientFillSymbol.ColorRamp = algorithcColorRamp;gradientFillSymbol.GradientAngle = 45;gradientFillSymbol.GradientPercentage = 0.9;gradientFillSymbol.Style = esriGradientFillStyle.esriGFSLinear;ICartographicLineSymbol cartoLine = new CartographicLineSymbol();cartoLine.Cap = esriLineCapStyle.esriLCSButt;cartoLine.Join = esriLineJoinStyle.esriLJSMitre;cartoLine.Color = getRGB(255, 0, 0);cartoLine.Width = 2;//Create the LineFillSymboILineFillSymbol lineFill = new LineFillSymbol();lineFill.Angle = 45;lineFill.Separation = 10;lineFill.Offset = 5;lineFill.LineSymbol = cartoLine;multiLayerFillSymbol.AddLayer(gradientFillSymbol);multiLayerFillSymbol.AddLayer(lineFill);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(multiLayerFillSymbol as ISymbol);activeView.ScreenDisplay.DrawPolygon(polygon as IGeometry);activeView.ScreenDisplay.FinishDrawing();}?
?
?
四、TextSymbol對象
用于修飾文字元素,實現ITextSymbol,ISimpleTextSymbol,IFormattedTextSymbol接口。
ITextSymbol是定義文本字符對象的主要接口,通過IFontDisp接口來設置字體的大小、粗體、斜體等。
ISimpleTextSymbol
?
? BezierTextPath對象可以讓文字的路徑按照貝塞爾曲線設置。
ITextPath接口提供用來計算每個字符文字路徑的位置。
IFormattedTextSymbol接口用來設置背景對象、陰影等屬性
private void textSybmolToolStripMenuItem_Click(object sender, EventArgs e)
??????? {
??????????? ITextSymbol textSymbol = new TextSymbolClass();
??????????? System.Drawing.Font drawFont = new System.Drawing.Font("宋體", 16, FontStyle.Bold);
??????????? stdole.IFontDisp fontDisp = (stdole.IFontDisp)(new stdole.StdFontClass());
??????????? textSymbol.Font = fontDisp;
??????????? textSymbol.Color = getRGB(0, 255, 0);
??????????? textSymbol.Size = 20;
??????????? IPolyline polyline = new PolylineClass();
??????????? IPoint point = new PointClass();
??????????? point.PutCoords(1, 1);
??????????? polyline.FromPoint = point;
??????????? point.PutCoords(10, 10);
??????????? polyline.ToPoint = point;
??????????? ITextPath textPath = new BezierTextPathClass();
??????????? //創建簡單標注
??????????? ILineSymbol lineSymbol = new SimpleLineSymbolClass();
??????????? lineSymbol.Color = getRGB(255, 0, 0);
??????????? lineSymbol.Width = 5;
??????????? ISimpleTextSymbol simpleTextSymbol = textSymbol as ISimpleTextSymbol;
??????????? simpleTextSymbol.TextPath = textPath;
??????????? object oLineSymbol = lineSymbol;
??????????? object oTextSymbol = textSymbol;
??????????? IActiveView activeView = this.axMapControl1.ActiveView;
??????????? activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
??????????? activeView.ScreenDisplay.SetSymbol(oLineSymbol as ISymbol);
??????????? activeView.ScreenDisplay.DrawPolyline(polyline as IGeometry);
??????????? activeView.ScreenDisplay.SetSymbol(oTextSymbol as ISymbol);
??????????? activeView.ScreenDisplay.DrawText(polyline as IGeometry, "簡單標注"); ;
??????????? activeView.ScreenDisplay.FinishDrawing();
??????????? //創建氣泡標注(兩中風格,一種是有錨點,一種是marker方式)
??????????? //錨點方式
??????????? ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbolClass();
??????????? simpleFillSymbol.Color = getRGB(0, 255, 0);
??????????? simpleFillSymbol.Style = esriSimpleFillStyle.esriSFSSolid;
??????????? IBalloonCallout balloonCallout = new BalloonCalloutClass();
??????????? balloonCallout.Style = esriBalloonCalloutStyle.esriBCSRectangle;
??????????? balloonCallout.Symbol = simpleFillSymbol;
??????????? balloonCallout.LeaderTolerance = 10;
??????????? point.PutCoords(5, 5);
??????????? balloonCallout.AnchorPoint = point;
??????????? IGraphicsContainer graphicsContainer = activeView as IGraphicsContainer;
??????????? IFormattedTextSymbol formattedTextSymbol = new TextSymbolClass();
??????????? formattedTextSymbol.Color = getRGB(0, 0, 255);
??????????? point.PutCoords(10, 5);
??????????? ITextBackground textBackground = balloonCallout as ITextBackground;
??????????? formattedTextSymbol.Background = textBackground;
??????????? activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
??????????? activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
??????????? activeView.ScreenDisplay.DrawText(point as IGeometry, "氣泡1");
??????????? activeView.ScreenDisplay.FinishDrawing();
??????????? //marker方式
??????????? textSymbol = new TextSymbolClass();
??????????? textSymbol.Color = getRGB(255, 0, 0);
??????????? textSymbol.Angle = 0;
??????????? textSymbol.RightToLeft = false;
??????????? textSymbol.VerticalAlignment = esriTextVerticalAlignment.esriTVABaseline;
??????????? textSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull;
??????????? IMarkerTextBackground markerTextBackground = new MarkerTextBackgroundClass();
??????????? markerTextBackground.ScaleToFit = true;
??????????? markerTextBackground.TextSymbol = textSymbol;
??????????? IRgbColor rgbColor = new RgbColorClass();
??????????? IPictureMarkerSymbol pictureMarkerSymbol = new PictureMarkerSymbolClass();
??????????? //string fileName = @"E:\vs2005\第五章\lesson2\lesson2\data\qq.bmp";
??????????? string path = Directory.GetCurrentDirectory();
??????????? string fileName = path + @"\qq.bmp";
??????????? pictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictureBitmap, fileName);
??????????? pictureMarkerSymbol.Angle = 0;
??????????? pictureMarkerSymbol.BitmapTransparencyColor = rgbColor;
??????????? pictureMarkerSymbol.Size = 20;
??????????? pictureMarkerSymbol.XOffset = 0;
??????????? pictureMarkerSymbol.YOffset = 0;
??????????? markerTextBackground.Symbol = pictureMarkerSymbol as IMarkerSymbol;
??????????? formattedTextSymbol = new TextSymbolClass();
??????????? formattedTextSymbol.Color = getRGB(255, 0, 0);
??????????? fontDisp.Size = 10;
??????????? fontDisp.Bold = true;
??????????? formattedTextSymbol.Font = fontDisp;
??????????? point.PutCoords(15, 5);
??????????? formattedTextSymbol.Background = markerTextBackground;
??????????? activeView.ScreenDisplay.StartDrawing(activeView.ScreenDisplay.hDC, (short)esriScreenCache.esriNoScreenCache);
??????????? activeView.ScreenDisplay.SetSymbol(formattedTextSymbol as ISymbol);
??????????? activeView.ScreenDisplay.DrawText(point as IGeometry, "氣泡2");
??????????? activeView.ScreenDisplay.FinishDrawing();
??????? }
?五、3DChartSymbol對象
是一個抽象類,有三個子類:BarChart(用來著色)、PieChart、StaekedChart。
它實現多個接口:IChartSymbol、IBarChartSymbol、IPieChartSymbol和IStackedSymbol等。
IChartSymbol接口主要用于計算一個ChartSymbol對象中的柱狀和餅狀部分的尺寸,其中Maximum值是創建3DChartSymbol對象后必須設置的一個屬性,著色一般在一個要素圖層上進行,因而可以從它的要素類中獲得一系列的數值統計值。如果有三個數值參與著色,系統則必須對三個數值進行大小比較,找出最大的那個賦值給Maximum。Value屬性用數組來設置柱狀高度或餅狀寬度。可以用ISymbolArray來管理多個參與著色的符號對象。
BarChartSymbol對象實現IBarChartSymbol接口,用不同類型的柱子代表一個要素中的不同屬性,高度取決于屬性值得大小。
PieChartSymbol對象實現IPieChartSymbol接口,用一個餅圖來顯示一個要素中的不同屬性,不同屬性按照他們的數值大小,占有不同比例的扇形區域。
StackedSymbol對象實現IStackedSymbol接口,堆積的柱子表示一個要素中的不同屬性,Fixed屬性為true時,每個柱子的高度都一樣,false時,柱子尺寸根據要素類的屬性來計算得出。
轉載于:https://www.cnblogs.com/jerfer/archive/2012/08/07/2626180.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
- 上一篇: IOS开发之手势—UIGestureRe
- 下一篇: 【Asp.Net】:如何处理大量页面的身