コード例 #1
0
ファイル: TextLineWalker.cs プロジェクト: brezza92/PixelFarm
        public void AddCharacter(char c)
        {
            if (CurrentLine.IsBlankLine)
            {
                //TODO: review here, enable this feature or not
                //some char can't be a start char on blank line

                if (!TextFlowEditSession.CanCaretStopOnThisChar(c))
                {
                    return;
                }
                //

                //1. new
                var run = new TextRun(this.CurrentSpanStyle, new char[] { c });
                CurrentLine.AddLast(run);
                SetCurrentTextRun(run);
            }
            else
            {
                Run run = CurrentTextRun;
                if (run != null)
                {
                    if (run.IsInsertable)
                    {
                        run.InsertAfter(CurrentTextRunCharIndex, c);
                    }
                    else
                    {
                        AddTextSpan(new TextRun(CurrentSpanStyle, new char[] { c }));
                        return;
                    }
                }
                else
                {
                    throw new NotSupportedException();
                }
            }

            CurrentLine.TextLineReCalculateActualLineSize();
            CurrentLine.RefreshInlineArrange();
            SetCurrentCharStepRight();
        }