1. 功能簡介ide
在數據的處理中會用到線元素的繪製,目前PIE SDK支持IFillSymbol接口,FillSymbol對象是用於修飾填充面狀對象的符號,它包括MarkerFillSymbol(由點狀符號造成的填充面符號)、LineFillSymbol(由線狀符號造成的填充面符號)、MultiLayerFillSymbol(多個符號疊加生成的新的填充面符號)、PictureFillSymbol(以圖片爲背景的填充面符號)、SimpleFillSymbol(簡單類型的填充面符號)這5個不一樣類型填充面符號的子類。spa
2. 功能實現說明3d
2.1. SimpleFillSymbol類型的線元素的繪製code
第一步視頻 |
設置點的Geometry信息對象 |
第二步blog |
設置面的符號教程 |
第三步接口 |
繪製元素圖片 |
接口/類 |
方法/屬性 |
說明 |
IPolygonElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
ISimpleFillSymbol |
Style屬性 |
獲取或設置簡單的面樣式 |
IFillSymbol |
Color屬性 |
獲取或設置面的顏色 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/03面的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/03面的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 簡單填充樣式的面元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawSimpleFillSyPolygon_Click(object sender, EventArgs e) 7 { 8 //定義空間位置 9 IPointCollection polygon = new PIE.Geometry.Polygon(); 10 polygon.AddPoint(100, 100, 0); 11 polygon.AddPoint(100, 300, 0); 12 polygon.AddPoint(300, 300, 0); 13 polygon.AddPoint(300, 100, 0); 14 (polygon as IPolygon).CloseRings(); 15 //定義面元素 16 IPolygonElement polyElement = new PIE.Carto.PolygonElement(); 17 polyElement.Geometry = polygon as IGeometry; 18 19 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); 20 simpleFillSymbol.Style = SimpleFillStyle.SFSDense2Pattern; 21 IFillSymbol fillSybol = simpleFillSymbol as IFillSymbol; 22 fillSybol.Color = Color.Green; 23 24 polyElement.Symbol = fillSybol; mapControlMain.ActiveView.GraphicsContainer.AddElement(polyElement); mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 25 } |
2.2. MarkerFillSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置面的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
IPolygonElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IMarkerFillSymbol |
MarkerSymbol屬性 |
獲取或設置點的符號樣式 |
IFillSymbol |
Color屬性 |
獲取或設置面的顏色 |
IMarkerSymbol |
Size |
獲取或設置點的大小 |
Color |
獲取或設置顏色 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/03面的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/03面的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 由點狀符號填充的面符號的面元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawMarkerSyPolygon_Click(object sender, EventArgs e) 7 { 8 IPointCollection polygon = new PIE.Geometry.Polygon(); 9 polygon.AddPoint(100, 100, 0); 10 polygon.AddPoint(100, 300, 0); 11 polygon.AddPoint(300, 300, 0); 12 polygon.AddPoint(300, 100, 0); 13 (polygon as IPolygon).CloseRings(); 14 //定義面元素 15 IPolygonElement polyElement = new PIE.Carto.PolygonElement(); 16 polyElement.Geometry = polygon as IGeometry; 17 18 IMarkerFillSymbol markerFillSymbol = new MarkerFillSymbol(); 19 20 //ICharacterMarkerSymbol字符點狀符號 21 ICharacterMarkerSymbol characterMSymbol = new CharacterMarkerSymbol(); 22 characterMSymbol.CharacterIndex = 111;//飛機 23 System.Drawing.Font font = new Font("ESRI Default Marker", 20); 24 characterMSymbol.Font = font; 25 //設置符號的大小,顏色,偏移量 26 IMarkerSymbol markSymbol = characterMSymbol as IMarkerSymbol; 27 markSymbol.XOffset = 0; 28 markSymbol.YOffset = 0; 29 markSymbol.Size = 20; 30 markSymbol.Color = Color.Red; 31 32 markerFillSymbol.MarkerSymbol = markSymbol; 33 IFillSymbol fillSymbol = markerFillSymbol as IFillSymbol; 34 35 polyElement.Symbol = fillSymbol; 36 mapControlMain.ActiveView.GraphicsContainer.AddElement(polyElement); 37 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 38 } |
2.3. LineFillSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置面的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
IPolygonElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
ILineFillSymbol |
LineSymbol屬性 |
獲取或設置簡單的面樣式 |
Rotate |
獲取或設置旋轉角度 |
|
Separation |
獲取或設置間距 |
|
IFillSymbol |
Color屬性 |
獲取或設置面的顏色 |
ISimpleLineSymbol |
style |
獲取或設置簡單點的樣式 |
ILineSymbol |
Join |
獲取或設置線的鏈接方式 |
Color |
獲取或設置線的顏色 |
|
Cap |
獲取或設置線的線帽樣式 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/03面的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/03面的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 線狀填充樣式的面元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton3_DrawLineSyPolygon_Click(object sender, EventArgs e) 7 { 8 //設置空間信息 9 IPointCollection polygon = new PIE.Geometry.Polygon(); 10 polygon.AddPoint(100, 100, 0); 11 polygon.AddPoint(100, 300, 0); 12 polygon.AddPoint(300, 300, 0); 13 polygon.AddPoint(300, 100, 0); 14 (polygon as IPolygon).CloseRings(); 15 //定義面元素 16 IPolygonElement polyElement = new PIE.Carto.PolygonElement(); 17 polyElement.Geometry = polygon as IGeometry; 18 19 ILineFillSymbol lineFillSymbol = new LineFillSymbol(); 20 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); 21 simpleLineSymbol.Style = SimpleLineStyle.SLSDashDot; 22 ILineSymbol lineSymbol = simpleLineSymbol as ILineSymbol; 23 lineSymbol.Join = LineJoinStyle.LJSBevel; 24 lineSymbol.Color = Color.Green; 25 lineSymbol.Cap = LineCapStyle.LCSRound; 26 27 lineFillSymbol.LineSymbol = lineSymbol; 28 lineFillSymbol.Rotate = 20; 29 lineFillSymbol.Separation = 20; 30 31 IFillSymbol fillSymbol = lineFillSymbol as IFillSymbol; 32 polyElement.Symbol = fillSymbol; 33 mapControlMain.ActiveView.GraphicsContainer.AddElement(polyElement); 34 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 35 } |
2.4. PictureFillSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置面的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
IPolygonElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IPictureFillSymbol |
CreateFromFile(string path) |
獲取或設置簡單的面樣式 |
XSeparation |
獲取或設置X方向間距 |
|
YSeparation |
獲取或設置Y方向縮放比例 |
|
XScale |
獲取或設X方向縮放比例 |
|
YScale |
獲取或設Y方向縮放比例 |
|
IFillSymbol |
Color屬性 |
獲取或設置面的顏色 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/03面的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/03面的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 圖片填充樣式的面元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawPicSyPolygon_Click(object sender, EventArgs e) 7 { 8 //設置空間信息 9 IPointCollection polygon = new PIE.Geometry.Polygon(); 10 polygon.AddPoint(100, 100, 0); 11 polygon.AddPoint(100, 300, 0); 12 polygon.AddPoint(300, 300, 0); 13 polygon.AddPoint(300, 100, 0); 14 (polygon as IPolygon).CloseRings(); 15 //定義面元素 16 IPolygonElement polyElement = new PIE.Carto.PolygonElement(); 17 polyElement.Geometry = polygon as IGeometry; 18 19 IPictureFillSymbol picFillSymbol = new PictureFillSymbol(); 20 OpenFileDialog openFileDialog = new OpenFileDialog(); 21 openFileDialog.Filter = "Picture File|*.bmp"; 22 openFileDialog.Title = "選擇一張圖片:"; 23 if (openFileDialog.ShowDialog() != DialogResult.OK) return; 24 picFillSymbol.CreateFromFile(openFileDialog.FileName); 25 picFillSymbol.XOffset = 10; 26 picFillSymbol.YOffset = 10; 27 picFillSymbol.XSeparation = 10; 28 picFillSymbol.YSeparation = 10; 29 picFillSymbol.XScale = 3; 30 picFillSymbol.YScale = 3; 31 picFillSymbol.Rotate = 0; 32 33 IFillSymbol fillSymbol = picFillSymbol as IFillSymbol; 34 polyElement.Symbol = fillSymbol; mapControlMain.ActiveView.GraphicsContainer.AddElement(polyElement); mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 35 } 36 IFillSymbol fillSymbol = picFillSymbol as IFillSymbol; 37 polyElement.Symbol = fillSymbol; m_mapControl.ActiveView.GraphicsContainer.AddElement(polyElement); m_mapControl.PartialRefresh(ViewDrawPhaseType.ViewAll); |
2.5. MultiLayerFillSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置面的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
IPolygonElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IMultiLayerFillSymbol |
AddLayer(…) |
添加填充面符號圖層 |
IFillSymbol |
Color屬性 |
獲取或設置面的顏色 |
數據路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/03面的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/03面的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 多個符號疊加生成的樣式的面元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawMultiSyPolygon_Click(object sender, EventArgs e) 7 { 8 IPointCollection polygon = new PIE.Geometry.Polygon(); 9 polygon.AddPoint(100, 100, 0); 10 polygon.AddPoint(100, 300, 0); 11 polygon.AddPoint(300, 300, 0); 12 polygon.AddPoint(300, 100, 0); 13 (polygon as IPolygon).CloseRings(); 14 //定義面元素 15 IPolygonElement polyElement = new PIE.Carto.PolygonElement(); 16 polyElement.Geometry = polygon as IGeometry; 17 18 IMultiLayerFillSymbol multiLayerFillSymbol = new MultiLayerFillSymbol(); 19 20 //ISimpleFillSymbol簡單填充符號 21 ISimpleFillSymbol simpleFillSymbol = new SimpleFillSymbol(); 22 simpleFillSymbol.Style = SimpleFillStyle.SFSDense2Pattern; 23 IFillSymbol fillSybol = simpleFillSymbol as IFillSymbol; 24 fillSybol.Color = Color.Pink; 25 26 //ILineFillSymbol 線填充符號 27 ILineFillSymbol lineFillSymbol = new LineFillSymbol(); 28 29 //設置簡單的線符號 30 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); 31 simpleLineSymbol.Style = SimpleLineStyle.SLSDashDot; 32 ILineSymbol lineSymbol = simpleLineSymbol as ILineSymbol; 33 lineSymbol.Color = Color.Green; 34 lineSymbol.Join = LineJoinStyle.LJSMitre; 35 lineSymbol.Width = 4; 36 lineSymbol.Cap = LineCapStyle.LCSSquare; 37 38 lineFillSymbol.LineSymbol = lineSymbol; 39 IFillSymbol fillSymbol2 = lineFillSymbol as IFillSymbol; 40 41 multiLayerFillSymbol.AddLayer(fillSybol, false); 42 multiLayerFillSymbol.AddLayer(fillSymbol2, false); 43 polyElement.Symbol = multiLayerFillSymbol as IFillSymbol; mapControlMain.ActiveView.GraphicsContainer.AddElement(polyElement); mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 44 } |