Ejemplo n.º 1
0
        protected override void OnKeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
        {
            if (e.KeyCode == System.Windows.Forms.Keys.Return)
            {
                if (!e.Control)
                {
                    this.PrependBlocks(new StatementLine());
                    e.Handled = true;
                }
                else
                {
                    if (this.ParentParent is IControlStructure)
                    {
                        TextBoxBlock next = this.ParentParent.Next as TextBoxBlock;
                        if (next != null)
                        {
                            next.SetFocus();
                        }
                        else
                        {
                            this.ParentParent.AppendBlocks(new StatementLine());
                        }
                    }
                    else
                    {
                        this.RemoveFocus(MoveFocusDirection.SelectNextInChain);
                    }
                }
            }
            // Don't need this because can't have any statements
            // immediately after break or continue
            //if (e.KeyCode == System.Windows.Forms.Keys.Insert
            //    || (e.KeyCode == System.Windows.Forms.Keys.Return && e.Control))
            //{
            //    this.AppendBlocks(new StatementLine());
            //    e.Handled = true;
            //}

            if (!e.Handled)
            {
                base.OnKeyDown(sender, e);
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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());
                    }
                }
            }
        }