Beispiel #1
0
        /// <summary>
        /// Changes the height of the town's event list expando. Normally limited to 4-5 rows, when
        /// expanded will autosize to display all rows. (Unrelated to the Expando collapsed
        /// state.)
        /// </summary>
        /// <param name="expChokePoint">The Expando to modify.</param>
        /// <param name="expand">True to expand or update expanded height, false to collapse.</param>
        private void SetListExpanded(Expando expChokePoint, bool expand)
        {
            Expando    expCurrentAttacks      = (Expando)this.Parent;
            CAControls controls               = (CAControls)expChokePoint.Tag;
            const int  eventListDefaultHeight = 128;

            if (expand)
            {
                // remove scrollbar to get correct PreferredSize, and also to
                // prevent it flickering visible when adding a new events
                controls.dgvEventList.ScrollBars = ScrollBars.None;

                int offset  = (EXPANDO_DEFAULT_HEIGHT - eventListDefaultHeight);
                int newsize = controls.dgvEventList.PreferredSize.Height + offset;
                if (newsize <= EXPANDO_DEFAULT_HEIGHT)
                {
                    controls.dgvEventList.ScrollBars = ScrollBars.Vertical;
                    return;
                }

                expCurrentAttacks.SuspendLayout();
                expChokePoint.ExpandedHeight = newsize;
                expCurrentAttacks.Height    += 1; // workaround for bug in tskMain ScrollableControl:
                expCurrentAttacks.Height    -= 1; // force the correct scroll height
                controls.dgvEventList.Height = newsize - offset;
                controls.picExpandTown.Image = Resources.icon_up;
                expCurrentAttacks.ResumeLayout();
            }
            else
            {
                expCurrentAttacks.SuspendLayout();
                expChokePoint.ExpandedHeight     = EXPANDO_DEFAULT_HEIGHT;
                expCurrentAttacks.Height        += 1; // workaround for bug in tskMain ScrollableControl:
                expCurrentAttacks.Height        -= 1; // force the correct scroll height
                controls.dgvEventList.Height     = eventListDefaultHeight;
                controls.picExpandTown.Image     = Resources.icon_down;
                controls.dgvEventList.ScrollBars = ScrollBars.Vertical;
                expCurrentAttacks.ResumeLayout();
            }

            expCurrentAttacks.CalcAnimationHeights();
        }