public static void MoveBlock(ContainerBlock newParent, Block blockToMove) { using (newParent.Transaction()) { blockToMove.Delete(); newParent.AppendBlocks(blockToMove); } }
protected bool CtrlEnter(bool shouldDeleteCurrent) { Block ParentParentNext = ParentParent != null ? ParentParent.Next : null; TextBoxBlock NextText = ParentParentNext as TextBoxBlock; shouldDeleteCurrent = shouldDeleteCurrent && this.Text == "" && this.Prev != null; if (this.Next != null || ParentParent == null) { return(false); } if (NextText != null && NextText.Text == "") { using (Redrawer r = new Redrawer(this.Root)) { NextText.SetFocus(); if (shouldDeleteCurrent) { this.Delete(); } } return(true); } else { ContainerBlock containingControlStructure = FindNearestControlStructureParent(); if (shouldDeleteCurrent) { this.MoveAfterBlock(ParentParent); return(true); } else if (containingControlStructure != null) { containingControlStructure.AppendBlocks(CreateNewTextLine()); return(true); } } return(false); }
public void JumpOut() { ContainerBlock p = this.ParentParent; if (p != null && p.Parent != Root) { TextBoxBlock next = p.Next as TextBoxBlock; if (next != null && string.IsNullOrEmpty(next.Text)) { next.SetFocus(); } else { using (Root.Transaction()) { if (string.IsNullOrEmpty(this.Text) && this.Next == null && this.Prev != null) { this.Delete(); } p.AppendBlocks(new EmptyNodeBlock()); } } } }