コード例 #1
0
ファイル: TextItText.cs プロジェクト: zhujingcheng/CP3
        /// <summary>
        /// updates longest_line_width_ to show the longest line width by iterating through
        /// all of the lines and finding the maximum. It is inefficient, but is also the safest method, and allows
        /// for the smallest amount of books. Since we won't be writing epics here, efficiency isn't incredibly important
        /// anyway.
        /// </summary>
        private void UpdateLongestLine()
        {
            ///change size of the TextItBox to reflect the change to the textut
            TextItBox parent = (TextItBox)this.Parent;

            if (parent == null)
            {
                return;
            }

            int limit = parent.viewer_.SlideWidth - kXMargin_ - parent.Location.X;

            for (int i = 0; i < this.Lines.Length; i++)
            {
                int width = TextRenderer.MeasureText(this.Lines[i], this.Font).Width;
                if (width > longest_line_width_)
                {
                    if (width < limit)
                    {
                        longest_line_width_ = width;
                    }
                    else
                    {
                        longest_line_width_ = limit;
                    }
                    index_of_longest_line_ = i;
                }
            }
            parent.SaveLongestWidthToSheet();
        }