zoukankan      html  css  js  c++  java
  • CreatePolygonGraphicElement

    QueuedTask.Run( () => {
            var layout = Project.Current.GetItems<LayoutProjectItem>().FirstOrDefault().GetLayout();
            var element = layout.Elements.OfType<GraphicElement>().FirstOrDefault();
            if (element == null) return;
            //Get the element's X, Y, Width and height
            var x = element.GetX();
            var y = element.GetY();
            var width = element.GetWidth();
            var height = element.GetHeight();

            //Create a polygon using the Graphic elements X, Y, Width and Height.
            MapPoint pt1 = MapPointBuilder.CreateMapPoint(x, y); //Anchor pt - lower left
            MapPoint pt2 = MapPointBuilder.CreateMapPoint(x + width, y); //lower right
            MapPoint pt3 = MapPointBuilder.CreateMapPoint(x + width, y + height );//upper right
            MapPoint pt4 = MapPointBuilder.CreateMapPoint(x, y + height);//upper left

            List<MapPoint> list = new List<MapPoint>() { pt1, pt2, pt3, pt4 };

            Polygon polygon = PolygonBuilder.CreatePolygon(list, null);

            //Rotate the polygon by the same angle the graphic element is rotated by
            var polygonRotate = GeometryEngine.Instance.Rotate(polygon, pt1, element.GetRotation() * (Math.PI / 180)) as Polygon; //Angle should be in radians.

            //Use polygonRotate to get the bounds of the rotated text element
            System.Diagnostics.Debug.WriteLine($"Width: {polygonRotate.Extent.Width}, Height: {polygonRotate.Extent.Height}");

            //Create another graphic element that envelops the original element
            Envelope env = polygonRotate.Extent;
            CIMStroke lineStroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 1, SimpleLineStyle.DashDotDot);
            LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Null, lineStroke));

          });
  • 相关阅读:
    异常之*** buffer overflow detected ***
    多媒体开发之视频回放---dm642 做rtsp 视频回放功能
    理财---炒股之kdj
    多媒体开发之rtp 打包发流--- 从h264中获取分辨率
    多媒体开发之rtsp 实现rtsp over tcp/http/udp---rtsp发送
    tomcat 简介
    tomcat 的安装
    rsync + inotify-tools实现文件的实时同步
    python 生成器
    ansible 常用模块
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12629364.html
Copyright © 2011-2022 走看看