protected override void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { base.OnKeyPress(sender, e); if (e.KeyChar == ' ') { if (MyTextBox.CaretPosition == MyTextBox.Text.Length) { Block next = this.Next; if (next != null && next is SpaceBlock) { next.SetFocus(true); } } else if (MyTextBox.CaretPosition > 0) { string TextBeforeCaret = MyTextBox.TextBeforeCaret; string TextAfterCaret = MyTextBox.TextAfterCaret; using (ActionBuilder a = new ActionBuilder(this.Root)) { a.RenameItem(MyTextBox, TextBeforeCaret); a.AppendBlocks( this, new TokenSeparatorBlock(), new TokenBlock(TextAfterCaret) ); a.Run(); } } } }
public static void DeleteSeparatorAndJoinNeighbours(Block separator) { TokenBlock prev = separator.Prev as TokenBlock; TokenBlock next = separator.Next as TokenBlock; if (separator != null && separator.Root != null && prev != null && next != null ) { using (ActionBuilder a = new ActionBuilder(separator.Root)) { a.RenameItem(prev, prev.Text + next.Text); a.DeleteBlock(separator).BlockToFocus = prev; a.DeleteBlock(next); a.Run(); } } }