• 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));

          });
  • 相关阅读:
    快捷键 Msg消息
    类 多态(迟绑定)
    DLL发布 matlab代码发布
    获取ini内容 GetPrivateProfileString GetPrivateProfileInt
    路径操作 getModuleFileName() 等
    事件高级
    JS事件基础
    运动框架
    运动小宗
    workman安装使用
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12629364.html
Copyright © 2020-2023  润新知