示例#1
0
        public void TestSetTextInTransaction()
        {
            TextBoxBlock name = new TextBoxBlock();

            Root.Add(name);

            name.MyTextBox.MinWidth = 30;

            name.Text = "A";             // takes effect immediately
            Assert(name.Text == "A");

            using (Transaction t = Transaction.Create(Root))
            {
                // takes effect only after
                // the transaction is committed (disposed)
                name.Text = "B";
                Assert(name.Text == "A");
            }

            // "B", because the transaction was committed
            // after exiting the using statement
            Assert(name.Text == "B");

            name.Delete();
        }
 public SetCaretPositionAction(
     RootBlock root,
     TextBoxBlock toFocus,
     SetFocusOptions options,
     int caretPosition)
     : base(toFocus, options)
 {
     CaretPosition = caretPosition;
     Text          = toFocus;
 }
示例#3
0
        public static ParameterList ParseParameters(TextBoxBlock parametersText)
        {
            LanguageService ls = Get(parametersText);

            if (ls != null && ls.Parser != null)
            {
                return(ls.Parser.ParseParameters(parametersText.Text));
            }
            return(null);
        }
示例#4
0
        public TutorialRootBlock3() : base()
        {
            HContainerBlock con = new HContainerBlock();

            this.Add(con);

            TextBoxBlock text = new TextBoxBlock();

            con.Add(text);
            con.Add("// here the TextBox ends");

            text.MyTextBox.MinWidth = 40;
        }
示例#5
0
        public TutorialRootBlock4()
            : base()
        {
            HContainerBlock con = new HContainerBlock();

            this.Add(con);

            button = new ButtonBlock("Hide the text");
            text   = new TextBoxBlock();
            con.Add(button);
            con.Add(text);

            button.Pushed += button_Pushed;
        }
示例#6
0
        public NodeBlock()
        {
            NameBlock  = new TextBoxBlock();
            Attributes = new AttributeList();

            this.HMembers.Add(NameBlock);
            this.HMembers.Add(Attributes);

            this.VMembers.Add(new EmptyNodeBlock());
            this.VMembers.AddAcceptableBlockTypes <NodeBlock>();
            this.VMembers.AddAcceptableBlockTypes <EmptyNodeBlock>();

            this.Draggable     = true;
            this.CanMoveUpDown = true;
        }
示例#7
0
        public override void Click(CompletionFunctionality hostItemList)
        {
            Parent = hostItemList.HostBlock as TextBoxBlock;
            Param.CheckNotNull(Parent, "Parent");

            int toDel = NumOfCharsToDelete();

            if (toDel > 0)
            {
                Parent.MyTextBox.CaretPosition -= toDel;
                Parent.MyTextBox.InsertText(this.Text);
                return;
            }
            Parent.MyTextBox.InsertText(GetSuffixToAdd());
        }
        public InterfaceAccessorsBlock()
        {
            Empty = new TextBoxBlock();
            Empty.MyTextBox.MinWidth = 1;
            Empty.MyTextBox.Box.Margins.SetLeftAndRight(ShapeStyle.DefaultFontSize / 2);
            Empty.MyTextBox.Box.SetMouseSensitivityToMargins();
            this.MyControl.Focusable = true;
            this.MyControl.Stretch   = GuiLabs.Canvas.Controls.StretchMode.None;
            this.MyControl.Box.Margins.SetLeftAndRight(ShapeStyle.DefaultFontSize);
            this.MyControl.Box.SetMouseSensitivityToMargins();

            InternalContainer = new HContainerBlock();
            this.Add("{");
            this.Add(InternalContainer);
            this.Add("}");

            InternalContainer.Add(Empty);
        }
        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);
            }
        }
示例#10
0
        protected bool CanCtrlEnter()
        {
            Block        ParentParentNext    = ParentParent != null ? ParentParent.Next : null;
            TextBoxBlock NextText            = ParentParentNext as TextBoxBlock;
            bool         shouldDeleteCurrent = LastCtrlReturn && this.Text == "" && this.Prev != null;

            if (this.Next != null || ParentParent == null)
            {
                return(false);
            }

            if ((NextText != null && NextText.Text == "") ||
                LastCtrlReturn ||
                ParentParent is IControlStructure)
            {
                return(true);
            }

            return(false);
        }
示例#11
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);
        }
示例#12
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());
                    }
                }
            }
        }
示例#13
0
 private void InitField(TextBoxBlock field)
 {
     field.MyTextBox.MinWidth = 16;
 }