Server.Misc.ShardPollOption.ComputeHeight C# (CSharp) Méthode

ComputeHeight() public méthode

public ComputeHeight ( ) : int
Résultat int
		public int ComputeHeight()
		{
			int height = m_LineBreaks * 18;

			if ( height > 30 )
				return height;

			return 30;
		}

Usage Example

Exemple #1
0
        public ShardPollGump(Mobile from, ShardPoller poller, bool editing, Queue <ShardPoller> polls) : base(50, 50)
        {
            m_From    = from;
            m_Poller  = poller;
            m_Editing = editing;
            m_Polls   = polls;

            Closable = false;

            AddPage(0);

            int totalVotes        = 0;
            int totalOptionHeight = 0;

            for (int i = 0; i < poller.Options.Length; ++i)
            {
                totalVotes        += poller.Options[i].Votes;
                totalOptionHeight += poller.Options[i].ComputeHeight() + 5;
            }

            bool isViewingResults = editing && poller.Active;
            bool isCompleted      = totalVotes > 0 && !poller.Active;

            if (editing && !isViewingResults)
            {
                totalOptionHeight += 35;
            }

            int height = 115 + totalOptionHeight;

            AddBackground(1, 1, 398, height - 2, 3600);
            AddAlphaRegion(16, 15, 369, height - 31);

            AddItem(308, 30, 0x1E5E);

            string title;

            if (editing)
            {
                title = (isCompleted ? "Poll Completed" : "Poll Editor");
            }
            else
            {
                title = "Shard Poll";
            }

            AddHtml(22, 22, 294, 20, Color(Center(title), LabelColor32), false, false);

            if (editing)
            {
                AddHtml(22, 22, 294, 20, Color(String.Format("{0} total", totalVotes), LabelColor32), false, false);
                AddButton(287, 23, 0x2622, 0x2623, 2, GumpButtonType.Reply, 0);
            }

            AddHtml(22, 50, 294, 40, Color(poller.Title, 0x99CC66), false, false);

            AddImageTiled(32, 88, 264, 1, 9107);
            AddImageTiled(42, 90, 264, 1, 9157);

            int y = 100;

            for (int i = 0; i < poller.Options.Length; ++i)
            {
                ShardPollOption option = poller.Options[i];
                string          text   = option.Title;

                if (editing && totalVotes > 0)
                {
                    double perc = option.Votes / (double)totalVotes;

                    text = String.Format("[{1}: {2}%] {0}", text, option.Votes, (int)(perc * 100));
                }

                int optHeight = option.ComputeHeight();

                y += optHeight / 2;

                if (isViewingResults)
                {
                    AddImage(24, y - 15, 0x25FE);
                }
                else
                {
                    AddRadio(24, y - 15, 0x25F9, 0x25FC, false, 1 + i);
                }

                AddHtml(60, y - (9 * option.LineBreaks), 250, 18 * option.LineBreaks, Color(text, LabelColor32), false, false);

                y += optHeight / 2;
                y += 5;
            }

            if (editing && !isViewingResults)
            {
                AddRadio(24, y + 15 - 15, 0x25F9, 0x25FC, false, 1 + poller.Options.Length);
                AddHtml(60, y + 15 - 9, 250, 18, Color("Create new option.", 0x99CC66), false, false);
            }

            AddButton(314, height - 73, 247, 248, 1, GumpButtonType.Reply, 0);
            AddButton(314, height - 47, 242, 241, 0, GumpButtonType.Reply, 0);
        }