C#操作Styline二次開發實現畫線功能

來源:互聯網
上載者:User
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;            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);            }
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.