1. 功能簡介ide
在數據的處理中會用到線元素的繪製,目前PIE SDK支持ILineSymbol的線元素的繪製,LineSymbol對象是用於修飾線狀對象的符號,它包括CartographicLineSymbol(製圖形式的線符號)、MarkerLineSymbol(由點狀符號造成的線符號)、MultiLayerLineSymbol(多個符號疊加生成的新的線符號)、PictureLineSymbol(以圖片爲背景的線符號)、SimpleLineSymbol(簡單類型的線符號)這5個不一樣類型線符號的子類。spa
2. 功能實現說明3d
2.1. SimpleLineSymbol類型的線元素的繪製code
第一步視頻 |
設置點的Geometry信息對象 |
第二步blog |
設置線的符號教程 |
第三步接口 |
繪製元素圖片 |
接口/類 |
方法/屬性 |
說明 |
ILineElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
ISimpleLineSymbol |
Style屬性 |
線樣式 |
IsDrawOutline |
是否繪製輪廓線 |
|
ILineSymbol |
Color屬性 |
獲取或設置線的顏色 |
Width屬性 |
獲取或設置線的寬度 |
|
Cap屬性 |
獲取或設置線帽的樣式 |
|
Join屬性 |
獲取或設置線的鏈接樣式 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/02線的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/02線的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 繪製簡單樣式線符號的線元素 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 7 private void toolStripButton_DrawSimpleSyLine_Click(object sender, EventArgs e) 8 { //IPolyline polyline = mapControl1.TrackLine(); 9 //定義空間位置 10 IPointCollection polyLine = new Polyline(); 11 polyLine.AddPoint(100, 100, 0); 12 polyLine.AddPoint(500, 400, 0); 13 //定義線元素 14 ILineElement lineElement = new PIE.Carto.LineElement(); 15 lineElement.Geometry = polyLine as IGeometry; 16 17 ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol(); 18 simpleLineSymbol.Style = SimpleLineStyle.SLSDashDot; 19 20 //設置符號的顏色,線寬,線帽樣式,鏈接樣式,偏移大小 21 ILineSymbol lineSymbol = simpleLineSymbol as ILineSymbol; 22 lineSymbol.Color = Color.Green; 23 lineSymbol.Width = 2; 24 lineSymbol.Cap = LineCapStyle.LCSRound; 25 lineSymbol.Join = LineJoinStyle.LJSBevel; 26 // lineSymbol.Offset = 20; 27 28 lineElement.Symbol = lineSymbol; 29 mapControlMain.ActiveView.GraphicsContainer.AddElement(lineElement); 30 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 31 } |
2.2. MarkerLineSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置線的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
ILineElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IMarkerLineSymbol |
Interval屬性 |
獲取或設置線的間距 |
IMarkerSymbol |
Color,Size,XOffset,YOffset |
顏色大小等屬性 |
ILineSymbol |
Color屬性 |
獲取或設置線的顏色 |
Width屬性 |
獲取或設置線的寬度 |
|
Cap屬性 |
獲取或設置線帽的樣式 |
|
Join屬性 |
獲取或設置線的鏈接樣式 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/02線的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/02線的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 點狀填充的線繪製 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawMarkerSyLine_Click(object sender, EventArgs e) 7 { 8 //IPolyline polyline = mapControl1.TrackLine(); 9 //定義空間位置 10 IPointCollection polyLine = new Polyline(); 11 polyLine.AddPoint(100, 100, 0); 12 polyLine.AddPoint(500, 400, 0); 13 //定義線元素 14 ILineElement lineElement = new PIE.Carto.LineElement(); 15 lineElement.Geometry = polyLine as IGeometry; 16 17 IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbol(); 18 markerLineSymbol.Interval = 3; 19 //設置線狀符號IMarkerLineSymbol的點符號樣式 20 21 ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); 22 simpleMarkerSymbol.IsDrawOutline = true; 23 simpleMarkerSymbol.Style = SimpleMarkerStyle.SMSX; 24 IMarkerSymbol markerSymbol = simpleMarkerSymbol as IMarkerSymbol; 25 markerSymbol.Color = System.Drawing.Color.Green; 26 markerSymbol.Size = 5; 27 markerSymbol.XOffset = 0; 28 markerSymbol.YOffset = 0; 29 markerLineSymbol.MarkerSymbol = markerSymbol; 30 31 ILineSymbol lineSymbol = markerLineSymbol as ILineSymbol; 32 lineElement.Symbol = lineSymbol; 33 mapControlMain.ActiveView.GraphicsContainer.AddElement(lineElement); 34 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 35 } |
2.3. CartographicLineSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置線的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
ILineElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
ICartographicLineSymbol |
DashPattern屬性 |
獲取或設置制線圖規則 |
Width |
獲取或設置製圖線的寬度 |
|
Interval |
獲取或設置線的間隔 |
|
ILineSymbol |
Color屬性 |
獲取或設置線的顏色 |
Width屬性 |
獲取或設置線的寬度 |
|
Cap屬性 |
獲取或設置線帽的樣式 |
|
Join屬性 |
獲取或設置線的鏈接樣式 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/02線的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/02線的繪製.avi |
示例代碼 |
|
![]() 1 /// </summary> 2 /// <param name="sender"></param> 3 /// <param name="e"></param> 4 private void toolStripButton_DrawCartoSyLine_Click(object sender, EventArgs e) 5 { 6 //IPolyline polyline = mapControl1.TrackLine(); 7 //定義空間位置 8 IPointCollection polyLine = new Polyline(); 9 polyLine.AddPoint(100, 100, 0); 10 polyLine.AddPoint(500, 400, 0); 11 //定義線元素 12 ILineElement lineElement = new PIE.Carto.LineElement(); 13 lineElement.Geometry = polyLine as IGeometry; 14 15 ICartographicLineSymbol cartoLineSymbol = new CartographicLineSymbol(); 16 IList<double> IList = new List<double>(); 17 IList.Add(1); 18 IList.Add(2); 19 IList.Add(3); 20 cartoLineSymbol.DashPattern = IList;//製圖線規則 21 cartoLineSymbol.Width = 4; 22 cartoLineSymbol.Interval = 3; 23 ///設置符號顏色,偏移量,線帽樣式,鏈接樣式 24 ILineSymbol lineSymbol = cartoLineSymbol as ILineSymbol; 25 lineSymbol.Color = Color.Green; 26 lineSymbol.Offset = 20; 27 lineSymbol.Cap = LineCapStyle.LCSRound; 28 lineSymbol.Join = LineJoinStyle.LJSRound; 29 30 lineElement.Symbol = lineSymbol; 31 mapControlMain.ActiveView.GraphicsContainer.AddElement(lineElement); 32 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 33 } |
2.4. PictureLineSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置線的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
ILineElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IPictureLineSymbol |
CreateFromFile() |
從文件建立 |
XScale() |
獲取或者設置X方向縮放比例 |
|
YScale() |
獲取或者設置Y方向縮放比例 |
|
ILineSymbol |
Color屬性 |
獲取或設置線的顏色 |
Width屬性 |
獲取或設置線的寬度 |
|
Cap屬性 |
獲取或設置線帽的樣式 |
|
Join屬性 |
獲取或設置線的鏈接樣式 |
|
MiterLimit |
獲取或設置線的MiterLimit |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/02線的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/02線的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 圖片爲填充背景的線繪製 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawPicSyLine_Click(object sender, EventArgs e) 7 { 8 //IPolyline polyline = mapControl1.TrackLine(); 9 //定義空間位置 10 IPointCollection polyLine = new Polyline(); 11 polyLine.AddPoint(100, 100, 0); 12 polyLine.AddPoint(500, 400, 0); 13 //定義線元素 14 ILineElement lineElement = new PIE.Carto.LineElement(); 15 lineElement.Geometry = polyLine as IGeometry; 16 17 IPictureLineSymbol picLineSymbol = new PictureLineSymbol(); 18 OpenFileDialog openFileDialog = new OpenFileDialog(); 19 openFileDialog.Filter = "Picture File|*.bmp"; 20 openFileDialog.Title = "請選擇一整圖片:"; 21 if (openFileDialog.ShowDialog() != DialogResult.OK) return; 22 bool ok = picLineSymbol.CreateFromFile(openFileDialog.FileName); 23 if (ok) 24 { 25 picLineSymbol.XScale = 0.5; 26 picLineSymbol.YScale = 0.5; 27 28 ILineSymbol lineSymbol = picLineSymbol as ILineSymbol; 29 lineSymbol.Width = 50; 30 lineSymbol.Offset = 3; 31 lineSymbol.MiterLimit = 4; 32 lineElement.Symbol = lineSymbol; 33 mapControlMain.ActiveView.GraphicsContainer.AddElement(lineElement); 34 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 35 } 36 } |
2.5. MultiLayerLineSymbol類型的點元素的繪製
第一步 |
設置點的Geometry信息 |
第二步 |
設置線的符號 |
第三步 |
繪製元素 |
接口/類 |
方法/屬性 |
說明 |
ILineElement |
Geometry屬性 |
獲取或設置Geometry |
Symbol屬性 |
獲取或設置符號樣式 |
|
IGraphicsContainer |
AddElement(IElement element) |
添加元素 |
IMultiLayerLineSymbol |
AddLayer() |
添加線符號樣式圖層 |
ILineSymbol |
Color屬性 |
獲取或設置線的顏色 |
Width屬性 |
獲取或設置線的寬度 |
|
Cap屬性 |
獲取或設置線帽的樣式 |
|
Join屬性 |
獲取或設置線的鏈接樣式 |
項目路徑 |
百度雲盤地址下/PIE示例程序/08元素繪製/02線的繪製 |
視頻路徑 |
百度雲盤地址下/PIE視頻教程/08元素繪製/02線的繪製.avi |
示例代碼 |
|
![]() 1 /// <summary> 2 /// 多個符號疊加生成的線樣式的線繪製 3 /// </summary> 4 /// <param name="sender"></param> 5 /// <param name="e"></param> 6 private void toolStripButton_DrawMultiSyLine_Click(object sender, EventArgs e) 7 { 8 //定義空間位置 9 IPointCollection polyLine = new Polyline(); 10 polyLine.AddPoint(100, 100, 0); 11 polyLine.AddPoint(500, 400, 0); 12 //定義線元素 13 ILineElement lineElement = new PIE.Carto.LineElement(); 14 lineElement.Geometry = polyLine as IGeometry; 15 16 #region IMultiLayerLineSymbol多個符號生成的線組成的符號 17 IMultiLayerLineSymbol mulLayerLineSymbol = new MultiLayerLineSymbol(); 18 //IPictureLineSymbol圖片符號 19 IPictureLineSymbol picLineSymbol = new PictureLineSymbol(); 20 OpenFileDialog openFileDialog = new OpenFileDialog(); 21 openFileDialog.Filter = "Picture File|*.bmp"; 22 openFileDialog.Title = "請選擇一整圖片:"; 23 if (openFileDialog.ShowDialog() != DialogResult.OK) return; 24 bool ok = picLineSymbol.CreateFromFile(openFileDialog.FileName); 25 ILineSymbol lineSymbol = picLineSymbol as ILineSymbol; 26 if (ok) 27 { 28 picLineSymbol.XScale = 0.5; 29 picLineSymbol.YScale = 0.5; 30 lineSymbol.Width = 60; 31 lineSymbol.Offset = 3; 32 lineSymbol.MiterLimit = 4; 33 } 34 35 //IMarkLineSymbol 36 ISimpleMarkerSymbol simpleMarkerSymbol = new SimpleMarkerSymbol(); 37 simpleMarkerSymbol.Style = SimpleMarkerStyle.SMSCircle; 38 simpleMarkerSymbol.IsDrawOutline = true; 39 IMarkerSymbol markerSymbol = simpleMarkerSymbol as IMarkerSymbol; 40 markerSymbol.Size = 10; 41 markerSymbol.Color = Color.Green; 42 43 IMarkerLineSymbol markerLineSymbol = new MarkerLineSymbol(); 44 markerLineSymbol.MarkerSymbol = markerSymbol; 45 46 ILineSymbol lineSymbol2 = markerLineSymbol as ILineSymbol; 47 mulLayerLineSymbol.AddLayer(lineSymbol, false); 48 mulLayerLineSymbol.AddLayer(lineSymbol2, false); 49 50 lineElement.Symbol = mulLayerLineSymbol as ILineSymbol; 51 mapControlMain.ActiveView.GraphicsContainer.AddElement(lineElement); 52 mapControlMain.PartialRefresh(ViewDrawPhaseType.ViewAll); 53 #endregion 54 } |