private void AcceptInputText(string text) { //todo:空格输入没有响应 List <CharactorBlock> inputCharactors = new List <CharactorBlock>(); foreach (var item in text) { var charactorBlock = FontManager.CreateNewCharactorBlock(item); if (!string.IsNullOrEmpty(InputParentId)) { charactorBlock.ParentId = InputParentId; } inputCharactors.Add(charactorBlock); } //这有一个想法是把插入的东西,放到兄弟节点后面,处理方式不当,指数,根式都可以找到不准确的brother var inputParentBlock = CurrentRow.Blocks.FindNodeById(InputParentId); var beforeBlock = inputParentBlock.GetCaretBrotherElement(true, GetCaretLocation()); if (null != beforeBlock) { var beforeBlockParentId = beforeBlock.GetParentId(); var block = CurrentRow.Blocks.FindParentNode(beforeBlockParentId); block.AddChildrenAfterBlock(beforeBlock, inputCharactors); } else { if (!string.IsNullOrEmpty(InputParentId)) { var parentNode = CurrentRow.Blocks.FindParentNode(InputParentId); parentNode.AddChildren(inputCharactors, GetCaretLocation(), InputParentId); } else { foreach (var item in inputCharactors) { item.ParentId = CurrentRow.Blocks.ID; } CurrentRow.Blocks.Children.AddRange(inputCharactors); } } RefreshRow(); /*输入完毕之后得 * 1.绘制整个currentRow * 2.管理输入文本框的位置 */ double offsetx = 0; foreach (var item in inputCharactors) { offsetx += item.GetSize().Width; } var charactorSize = inputCharactors.Last().GetSize(); ResetCaretLocation(offsetx); caretTextBox.Focus(); }