Exemple #1
0
        /// <summary>
        /// Make sure the cloned polygon does not share any data references with the
        /// original polygon.
        /// </summary>
        /// <param name="env"></param>
        /// <returns></returns>
        public override GoObject CopyObject(GoCopyDictionary env)
        {
            GoPolygon goPolygon = (GoPolygon)base.CopyObject(env);

            if (goPolygon != null)
            {
                goPolygon.myPoints = (PointF[])myPoints.Clone();
            }
            return(goPolygon);
        }
Exemple #2
0
        /// <summary>
        /// Make sure the background polygon is moved along with the text label
        /// and shaped so that it points at the anchor.
        /// </summary>
        /// <param name="childchanged"></param>
        public override void LayoutChildren(GoObject childchanged)
        {
            if (base.Initializing)
            {
                return;
            }
            GoText label = Label;

            if (label == null)
            {
                return;
            }
            GoPolygon goPolygon = Background as GoPolygon;

            if (goPolygon != null && childchanged != goPolygon)
            {
                SizeF      topLeftMargin     = TopLeftMargin;
                SizeF      bottomRightMargin = BottomRightMargin;
                RectangleF rectangleF        = new RectangleF(label.Left - topLeftMargin.Width, label.Top - topLeftMargin.Height, label.Width + topLeftMargin.Width + bottomRightMargin.Width, label.Height + topLeftMargin.Height + bottomRightMargin.Height);
                SizeF      corner            = Corner;
                float      num = corner.Width;
                if (num > rectangleF.Width / 2f)
                {
                    num = rectangleF.Width / 2f;
                }
                float num2 = corner.Height;
                if (num2 > rectangleF.Height / 2f)
                {
                    num2 = rectangleF.Height / 2f;
                }
                float      x               = rectangleF.X;
                float      y               = rectangleF.Y;
                float      x2              = x + num;
                float      y2              = y + num2;
                float      num3            = x + rectangleF.Width / 2f;
                float      num4            = y + rectangleF.Height / 2f;
                float      x3              = x + rectangleF.Width - num;
                float      y3              = y + rectangleF.Height - num2;
                float      num5            = x + rectangleF.Width;
                float      num6            = y + rectangleF.Height;
                RectangleF bounds          = goPolygon.Bounds;
                bool       suspendsUpdates = goPolygon.SuspendsUpdates;
                if (!suspendsUpdates)
                {
                    goPolygon.Changing(1412);
                }
                goPolygon.SuspendsUpdates = true;
                goPolygon.ClearPoints();
                float  num7   = Math.Min(rectangleF.Width - num, BaseWidth);
                float  num8   = Math.Min(rectangleF.Height - num2, BaseWidth);
                float  left   = label.Left;
                float  top    = label.Top;
                float  right  = label.Right;
                float  bottom = label.Bottom;
                PointF center = label.Center;
                PointF pointF = (myTemporaryAnchor == null) ? ComputeAnchorPoint() : myTemporaryAnchor.Center;
                label.GetNearestIntersectionPoint(pointF, center, out PointF result);
                if (result.Y <= top && result.X < num3)
                {
                    goPolygon.AddPoint(x, y);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(x + num7, y);
                }
                else
                {
                    goPolygon.AddPoint(x2, y);
                }
                if (result.Y <= top && result.X >= num3)
                {
                    goPolygon.AddPoint(num5 - num7, y);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(num5, y);
                }
                else
                {
                    goPolygon.AddPoint(x3, y);
                }
                if ((result.X >= right) & (result.Y < num4))
                {
                    goPolygon.AddPoint(num5, y);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(num5, y + num8);
                }
                else
                {
                    goPolygon.AddPoint(num5, y2);
                }
                if ((result.X >= right) & (result.Y >= num4))
                {
                    goPolygon.AddPoint(num5, num6 - num8);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(num5, num6);
                }
                else
                {
                    goPolygon.AddPoint(num5, y3);
                }
                if (result.Y >= bottom && result.X >= num3)
                {
                    goPolygon.AddPoint(num5, num6);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(num5 - num7, num6);
                }
                else
                {
                    goPolygon.AddPoint(x3, num6);
                }
                if (result.Y >= bottom && result.X < num3)
                {
                    goPolygon.AddPoint(x + num7, num6);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(x, num6);
                }
                else
                {
                    goPolygon.AddPoint(x2, num6);
                }
                if (result.X <= left && result.Y >= num4)
                {
                    goPolygon.AddPoint(x, num6);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(x, num6 - num8);
                }
                else
                {
                    goPolygon.AddPoint(x, y3);
                }
                if (result.X <= left && result.Y < num4)
                {
                    goPolygon.AddPoint(x, y + num8);
                    goPolygon.AddPoint(pointF);
                    goPolygon.AddPoint(x, y);
                }
                else
                {
                    goPolygon.AddPoint(x, y2);
                }
                goPolygon.SuspendsUpdates = suspendsUpdates;
                if (!suspendsUpdates)
                {
                    goPolygon.Changed(1412, 0, null, bounds, 0, null, goPolygon.Bounds);
                }
            }
        }