示例#1
0
        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();
                }
            }
        }
示例#2
0
        public static void AppendLineBelowToCurrentLine(Block higherSeparator)
        {
            if (higherSeparator == null ||
                higherSeparator.Parent == null ||
                higherSeparator.Parent.Next == null ||
                higherSeparator.Next != null)
            {
                return;
            }

            ContainerBlock newParent = higherSeparator.Parent;
            ContainerBlock oldParent = newParent.Next as ContainerBlock;
            Block          newFocus  = null;

            if (oldParent == null)
            {
                return;
            }
            else
            {
                newFocus = oldParent.FindFirstFocusableBlock();
            }

            ActionBuilder a = new ActionBuilder(higherSeparator.Root);

            a.DeleteBlock(higherSeparator);

            foreach (Block child in oldParent.Children)
            {
                a.MoveBlock(newParent, child);
            }

            a.DeleteBlock(oldParent);

            a.RunWithoutRedraw();

            if (newFocus != null)
            {
                newFocus.SetFocus(true);
            }
        }
示例#3
0
        public static void AppendSecondLineToFirst(Block lowerSeparator)
        {
            if (lowerSeparator == null ||
                lowerSeparator.Parent == null ||
                lowerSeparator.Parent.Prev == null ||
                lowerSeparator.Prev != null)
            {
                return;
            }

            ContainerBlock oldParent = lowerSeparator.Parent;
            ContainerBlock newParent = oldParent.Prev as ContainerBlock;
            Block          newFocus  = null;

            if (newParent == null)
            {
                return;
            }
            else
            {
                newFocus = newParent.FindLastFocusableBlock();
            }

            ActionBuilder a = new ActionBuilder(lowerSeparator.Root);

            if (lowerSeparator.Next != null)
            {
                foreach (Block child in oldParent.Children)
                {
                    if (child != lowerSeparator)
                    {
                        a.MoveBlock(newParent, child);
                    }
                }
            }

            a.DeleteBlock(oldParent);

            a.RunWithoutRedraw();

            if (newFocus != null)
            {
                newFocus.SetFocus(true);
            }
        }