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

          });
  • 相关阅读:
    第2课 有符号与无符号
    第1课 基本数据类型
    HDU 5821 Ball
    Codeforces Round #228 (Div. 2) C. Fox and Box Accumulation
    HDU 5810 Balls and Boxes
    HDU 5818 Joint Stacks
    HDU 5813 Elegant Construction
    Codeforces Round #357 (Div. 2)C. Heap Operations
    Codeforces Round #364 (Div. 2) C. They Are Everywhere
    HDU5806 NanoApe Loves Sequence Ⅱ
  • 原文地址:https://www.cnblogs.com/gisoracle/p/12629364.html
Copyright © 2011-2022 走看看