Esempio n. 1
0
        /// <summary>
        /// 添加
        /// </summary>
        private void InitAdd()
        {
            int    top         = this.PParser.GetSelectPartPoint[0].Y;
            string spaceString = " ".PadLeft(this.PParser.PLanguageMode.TabSpaceCount);
            int    width       = FontContainer.GetSpaceWidth(this.PParser.PIEdit.GetGraphics);

            while (top <= this.PParser.GetSelectPartPoint[1].Y)
            {
                var ls = this.PParser.PLineString[top / FontContainer.FontHeight];
                ls.SetText(ls.Text.Insert(0, spaceString));
                ls.Width += width * this.PParser.PLanguageMode.TabSpaceCount;
                for (var i = 0; i < this.PParser.PLanguageMode.TabSpaceCount; i++)
                {
                    ls.PWord.Insert(0, new Word()
                    {
                        Text       = " ",
                        PEWordType = EWordType.Space,
                        Width      = width,
                    });
                }
                top += FontContainer.FontHeight;
            }

            width = width * this.PParser.PLanguageMode.TabSpaceCount;
            this.PParser.GetSelectPartPoint[0].LineStringIndex += this.PParser.PLanguageMode.TabSpaceCount;
            this.PParser.GetSelectPartPoint[0].LineWidth       += width;
            this.PParser.GetSelectPartPoint[1].LineStringIndex += this.PParser.PLanguageMode.TabSpaceCount;
            this.PParser.GetSelectPartPoint[1].LineWidth       += width;
            this.PParser.GetSelectPartPoint[1].X += width;
        }
Esempio n. 2
0
        /// <summary>
        /// 获取文本的宽度
        /// </summary>
        /// <param name="w"></param>
        /// <param name="g"></param>
        /// <param name="f"></param>
        /// <param name="tagSpaceCount"></param>
        /// <returns></returns>
        public static int GetWrodWidth(Word w, Graphics g, Font f, int tabSpaceCount)
        {
            switch (w.PEWordType)
            {
            case EWordType.Tab:
                return(FontContainer.GetSpaceWidth(g) * tabSpaceCount);

            case EWordType.Space:
                return(FontContainer.GetSpaceWidth(g));

            default:
                return(CharCommand.GetCharWidth(g, w.Text, f ?? FontContainer.DefaultFont));
            }
        }