C#操作Styline二次开发实现画线功能


本文摘自PHP中文网,作者黄舟,侵删。

c#操作styline模型左键点击模型获取坐标,完成画线操作。

1:鼠标点击模型事件


1

2

3

4

5

6

7

8

9

10

11

12

List<IPosition66> pos = new List<IPosition66>();

       private bool Sgworld_OnLButtonClicked(int Flags, int X, int Y)

       {

           

           var sgworld = new SGWorld66();

           var postioninfo = sgworld.Window.PixelToWorld(X, Y);

           IPosition66 ss = postioninfo.Position;

           ss.X = postioninfo.Position.X;

           ss.Y = postioninfo.Position.Y;

           pos.Add(ss);

           return false;

       } 

2:操作画线


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

string tMsg = String.Empty;

          ILinearRing cRing = null;

          IGeometry cPolygonGeometry = null;

          ITerrainPolyline66 cpolyo = null;

          //创建实例

          //MessageBox.Show(String.Format("X:{0}\r\nY:{1}", posl[i].PosX, posl[i].PosX));

          var sgworld = new SGWorld66();

          List<IPosition66> posl = pos;

          int sin = 0;

          sin = posl.Count*3;

          double[] cVerticesArray = new double[sin];

          //获取坐标值

          for (int i = 0; i < posl.Count; i++)

          {

              cVerticesArray[i*3] = posl[i].X;

              cVerticesArray[i*3+1] = posl[i].Y;

              cVerticesArray[i * 3 + 2] = posl[i].Altitude;

          }

          {

              cRing = sgworld.Creator.GeometryCreator.CreateLinearRingGeometry(cVerticesArray);

              cPolygonGeometry = sgworld.Creator.GeometryCreator.CreateLinearRingGeometry(cRing);

          }

          {

              uint nLineColor = 0xFF00FF00; //颜色样式

              AltitudeTypeCode AltitudeType = AltitudeTypeCode.ATC_ON_TERRAIN;

              // D2. Create polygon

              cpolyo = sgworld.Creator.CreatePolyline(cPolygonGeometry, nLineColor, AltitudeType, string.Empty, "Polygon");

              ///注意坐标

              sgworld.Window.PixelToWorld(sgworld.Window.Rect.Left, sgworld.Window.Rect.Top, WorldPointType.WPT_TERRAIN);

          }

以上就是C#操作Styline二次开发实现画线功能的详细内容!

相关阅读 >>

c#多线程之semaphore的使用详解

c# 数组作为参数传递出现的问题解决

c#编写windows服务程序的图文详解

c#中关于list<t>的并集与交集以及差集解析

c# 加密类工具实例分析

c#中datetime与时间戳转换的实例代码

c#中匿名委托以及lambda表达式的实例详解

windows登录功能使用c#实现的示例

c# 利用委托进行异步处理实例代码

比较c#中值类型和引用类型的区别

更多相关阅读请进入《Styline》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...