• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

c# 搞代码 4年前 (2022-01-09) 12次浏览 已收录 0个评论

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

1:鼠标点击模型事件

 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:操作画线

  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;     <b>本文来源gao@!dai!ma.com搞$$代^@码5网@</b>       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二次开发实现画线功能的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:C#操作Styline二次开发实现画线功能
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址