Пример #1
0
        /// <summary>
        /// Size the background to fit the text, and position the ports at the edges
        /// of the background object.
        /// </summary>
        /// <param name="childchanged"></param>
        /// <remarks>
        /// This method uses the <see cref="P:Northwoods.Go.GoTextNode.TopLeftMargin" /> and <see cref="P:Northwoods.Go.GoTextNode.BottomRightMargin" />
        /// properties to decide how much bigger the background should be than the text label.
        /// This method does nothing if there is no <see cref="P:Northwoods.Go.GoTextNode.Label" />.
        /// If <see cref="P:Northwoods.Go.GoTextNode.AutoResizes" /> is false, the <see cref="P:Northwoods.Go.GoTextNode.Background" /> object is
        /// not resized, but the <see cref="P:Northwoods.Go.GoTextNode.Label" />'s bounds and
        /// <see cref="P:Northwoods.Go.GoText.WrappingWidth" /> are updated according to how much room is
        /// left inside the <see cref="P:Northwoods.Go.GoTextNode.Background" /> after subtracting the margins.
        /// </remarks>
        public override void LayoutChildren(GoObject childchanged)
        {
            if (base.Initializing)
            {
                return;
            }
            GoText label = Label;

            if (label == null)
            {
                return;
            }
            GoObject goObject = Background;

            if (goObject != null)
            {
                SizeF topLeftMargin     = TopLeftMargin;
                SizeF bottomRightMargin = BottomRightMargin;
                if (AutoResizes)
                {
                    goObject.Bounds = new RectangleF(label.Left - topLeftMargin.Width, label.Top - topLeftMargin.Height, label.Width + topLeftMargin.Width + bottomRightMargin.Width, label.Height + topLeftMargin.Height + bottomRightMargin.Height);
                }
                else
                {
                    float num  = Math.Max(goObject.Width - (topLeftMargin.Width + bottomRightMargin.Width), 0f);
                    float num2 = Math.Max(goObject.Height - (topLeftMargin.Height + bottomRightMargin.Height), 0f);
                    label.Width         = num;
                    label.WrappingWidth = num;
                    label.UpdateSize();
                    float num3 = Math.Min(label.Height, num2);
                    float x    = goObject.Left + topLeftMargin.Width;
                    float y    = goObject.Top + topLeftMargin.Height + (num2 - num3) / 2f;
                    label.Bounds = new RectangleF(x, y, num, num3);
                }
            }
            if (goObject == null && AutoResizes)
            {
                goObject = label;
            }
            if (goObject != null)
            {
                if (TopPort != null)
                {
                    TopPort.SetSpotLocation(32, goObject, 32);
                }
                if (RightPort != null)
                {
                    RightPort.SetSpotLocation(64, goObject, 64);
                }
                if (BottomPort != null)
                {
                    BottomPort.SetSpotLocation(128, goObject, 128);
                }
                if (LeftPort != null)
                {
                    LeftPort.SetSpotLocation(256, goObject, 256);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Position all of the left and right port objects at the sides of each of the items.
 /// </summary>
 /// <param name="childchanged"></param>
 /// <remarks>
 /// When <see cref="P:Northwoods.Go.GoObject.Initializing" /> is true, this method does nothing.
 /// </remarks>
 public override void LayoutChildren(GoObject childchanged)
 {
     if (!base.Initializing && myListGroup != null)
     {
         base.Initializing = true;
         if (TopPort != null)
         {
             TopPort.SetSpotLocation(128, myListGroup, 32);
         }
         if (BottomPort != null)
         {
             BottomPort.SetSpotLocation(32, myListGroup, 128);
         }
         int num = 0;
         foreach (GoObject item in myListGroup)
         {
             if (item != null && num < myLeftPorts.Count)
             {
                 GoObject goObject = myLeftPorts[num];
                 if (goObject != null)
                 {
                     if (item.Visible)
                     {
                         PointF spotLocation = item.GetSpotLocation(256);
                         spotLocation.X = myListGroup.Left;
                         goObject.SetSpotLocation(64, spotLocation);
                     }
                     else
                     {
                         goObject.SetSpotLocation(64, new PointF(myListGroup.Left, item.Top));
                     }
                 }
             }
             if (item != null && num < myRightPorts.Count)
             {
                 GoObject goObject2 = myRightPorts[num];
                 if (goObject2 != null)
                 {
                     if (item.Visible)
                     {
                         PointF spotLocation2 = item.GetSpotLocation(64);
                         spotLocation2.X = myListGroup.Right;
                         goObject2.SetSpotLocation(256, spotLocation2);
                     }
                     else
                     {
                         goObject2.SetSpotLocation(256, new PointF(myListGroup.Right, item.Top));
                     }
                 }
             }
             num = checked (num + 1);
         }
         base.Initializing = false;
     }
 }