Esempio n. 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();
        }
Esempio n. 2
0
        /// <summary>
        /// Returns an Expando that contains the deserialized ExpandoSurrogate data
        /// </summary>
        /// <returns>An Expando that contains the deserialized ExpandoSurrogate data</returns>
        public Expando Save()
        {
            Expando expando = new Expando();

            ((ISupportInitialize)expando).BeginInit();
            expando.SuspendLayout();

            expando.Name     = this.Name;
            expando.Text     = this.Text;
            expando.Size     = this.Size;
            expando.Location = this.Location;

            expando.BackColor      = Tools.Drawing.ConvertStringToColor(this.BackColor);
            expando.ExpandedHeight = this.ExpandedHeight;

            expando.CustomSettings               = this.CustomSettings.Save();
            expando.CustomSettings.Expando       = expando;
            expando.CustomHeaderSettings         = this.CustomHeaderSettings.Save();
            expando.CustomHeaderSettings.Expando = expando;

            expando.TitleImage = this.TitleImage.ToImage();
            expando.Watermark  = this.Watermark.ToImage();

            expando.Animate       = this.Animate;
            expando.ShowFocusCues = this.ShowFocusCues;
            expando.Collapsed     = this.Collapsed;
            expando.CanCollapse   = this.CanCollapse;
            expando.SpecialGroup  = this.SpecialGroup;

            expando.Enabled    = this.Enabled;
            expando.Visible    = this.Visible;
            expando.AutoLayout = this.AutoLayout;

            expando.Anchor = this.Anchor;
            expando.Dock   = this.Dock;

            expando.Font = new Font(this.FontName, this.FontSize, this.FontDecoration);

            expando.Tag = this.Tag.SerializeToByteArray();

            foreach (Object o in this.Items)
            {
                TaskItem ti = ((TaskItemSurrogate)o).Save();

                expando.Items.Add(ti);
            }

            ((ISupportInitialize)expando).EndInit();
            expando.ResumeLayout(false);

            return(expando);
        }
        /// <summary>
        /// Adjust the height of the parent expando to fit the full tree in.
        /// </summary>
        private void ResizeWidget()
        {
            if (!tvwOrbat._suspendUpdate)
            {
                int tvwHeight = tvwOrbat.RowCount * tvwOrbat.RowHeight;
                this.Height = tvwHeight + 20;

                Expando expOrderOfBattle = (Expando)this.Parent;
                expOrderOfBattle.SuspendLayout();
                expOrderOfBattle.ExpandedHeight = tvwHeight + 46;
                expOrderOfBattle.Height        += 1; // workaround for bug in tskMain ScrollableControl:
                expOrderOfBattle.Height        -= 1; // force the correct scroll height
                expOrderOfBattle.ResumeLayout();
            }
        }
        /// <summary>
        /// Resizes the widget and various controls to fit the current contents.
        /// </summary>
        private void UpdateWidgetHeight()
        {
            Expando expServerStatus = (Expando)this.Parent;

            int newHeight = 23 + 4;

            if (this.configExpanded)
            {
                newHeight += dgvConfig.Bottom;
            }
            else
            {
                newHeight += lnkConfig.Bottom;
            }

            if (expServerStatus.ExpandedHeight != newHeight)
            {
                expServerStatus.SuspendLayout();
                expServerStatus.ExpandedHeight = newHeight;
                expServerStatus.Height        += 1; // workaround for bug in tskMain ScrollableControl:
                expServerStatus.Height        -= 1; // force the correct scroll height
                expServerStatus.ResumeLayout();
            }
        }
        /// <summary>
        /// Updates the various controls to display information about the given ChokePoint.
        /// </summary>
        /// <param name="cp">The ChokePoint to display, or null to clear.</param>
        private void DisplayChokePointInfo(ChokePoint cp)
        {
            this.selectedChokePoint = cp;


            // if null, clear everything

            if (cp == null)
            {
                picCPFlag.Image = null;

                GameStatus.ToolTip.SetToolTip(picCPFlag, null);
                lblCPName.Text    = null;
                lnkEvents.Visible = lnkMap.Visible = false;

                picCPInfo.Image = null;
                picCPInfo.RemoveAll(); // remove previous tooltips

                return;
            }


            // hide start tip

            if (lblStartTip.Visible)
            {
                lblStartTip.Visible = false;
            }


            // flag

            picCPFlag.Image = cp.FlagImage;
            GameStatus.ToolTip.SetToolTip(picCPFlag, cp.FlagTooltip);


            // title

            lblCPName.Text = cp.Name;


            // info

            picCPInfo.Image  = GenerateInfoImage(cp, picCPInfo);
            picCPInfo.Height = picCPInfo.Image.Height;


            // event link

            int displayedEventCount = CurrentAttacks_NumEvents(cp);

            int actualEventCount = 0;

            foreach (GameEvent gameEvent in cp.Events)
            {
                actualEventCount++;
            }

            if (displayedEventCount > 0)
            {
                lnkEvents.Text    = String.Format(displayedEventCount == 1 ? Language.TownStatus_Event : Language.TownStatus_Events, displayedEventCount);
                lnkEvents.Visible = true;
                LnkEventsEnabled  = true;
            }
            else if (actualEventCount > 0) // events exist but not present in CurrentAttacks
            {
                lnkEvents.Text    = String.Format(actualEventCount == 1 ? Language.TownStatus_Event : Language.TownStatus_Events, actualEventCount);
                lnkEvents.Visible = true;
                LnkEventsEnabled  = false;
            }
            else
            {
                lnkEvents.Visible = false;
            }


            // map link

            lnkMap.Visible = true;


            // resize parent expando

            Expando expTownStatus = (Expando)this.Parent;

            if (expTownStatus.ExpandedHeight != 151 + picCPInfo.Height)
            {
                expTownStatus.SuspendLayout();
                expTownStatus.ExpandedHeight = 151 + picCPInfo.Height;
                expTownStatus.Height        += 1; // workaround for bug in tskMain ScrollableControl:
                expTownStatus.Height        -= 1; // force the correct scroll height
                expTownStatus.ResumeLayout();
            }
        }