Esempio n. 1
0
        /// <summary>
        /// Shrinks the grid to match its non-null content boundaries.
        /// </summary>
        /// <param name="mode"></param>
        public void ShrinkToFit(ShrinkMode mode = ShrinkMode.Both)
        {
            if (mode == ShrinkMode.None)
            {
                return;
            }
            Rectangle bounds = this.GetContentBoundaries();

            this.AssumeRect(
                mode.HasFlag(ShrinkMode.X) ? bounds.X : 0,
                mode.HasFlag(ShrinkMode.Y) ? bounds.Y : 0,
                mode.HasFlag(ShrinkMode.X) ? bounds.Width : this.width,
                mode.HasFlag(ShrinkMode.Y) ? bounds.Height : this.height);
        }
Esempio n. 2
0
        /// <summary>
        /// Shrinks the grid to match its non-null content boundaries.
        /// </summary>
        /// <param name="mode"></param>
        public void ShrinkToFit(ShrinkMode mode = ShrinkMode.Both)
        {
            if (mode == ShrinkMode.None)
            {
                return;
            }
            Point2 topLeft;
            Point2 size;

            this.GetContentBoundaries(out topLeft, out size);
            this.AssumeRect(
                mode.HasFlag(ShrinkMode.X) ? topLeft.X : 0,
                mode.HasFlag(ShrinkMode.Y) ? topLeft.Y : 0,
                mode.HasFlag(ShrinkMode.X) ? size.X : this.width,
                mode.HasFlag(ShrinkMode.Y) ? size.Y : this.height);
        }