Beispiel #1
0
        public bool PutElement(ArgumentPlaceholder p, DraggableControl el)
        {
            if (!CanPutElement(p, el))
            {
                return(false);
            }

            if (p == condPlaceholder)
            {
                SetCondElement(el);
                return(true);
            }

            var pos = placeholders.IndexOf(p);

            controlStatements.Insert(pos, el);

            el.Parent  = this;
            el.EParent = this;

            placeholders.Insert(pos, new ArgumentPlaceholder(this)
            {
                Parent = this
            });

            return(true);
        }
Beispiel #2
0
        public bool CanPutElement(ArgumentPlaceholder p, DraggableControl el)
        {
            if (p == condPlaceholder)
            {
                return(el is IExpression);
            }

            return(el is IStatement && placeholders.IndexOf(p) >= 0);
        }
Beispiel #3
0
 public bool PutElement(ArgumentPlaceholder p, DraggableControl el)
 {
     if (!CanPutElement(p, el))
     {
         return(false);
     }
     SetRetExpression(el);
     return(true);
 }
Beispiel #4
0
        public VReturnStatement()
        {
            BackColor = ColorSettings.Get("ReturnStatement");
            Size      = new Size(100, Const.EXPR_HEIGHT);

            argPlaceHolder        = new ArgumentPlaceholder(this);
            argPlaceHolder.Parent = this;
            retLabel = new CustomLabel("вернуть ", BackColor);
            Controls.Add(retLabel);

            UpdateSize();
        }
Beispiel #5
0
        public VSetVariable()
        {
            BackColor = ColorSettings.Get("SetVariable");
            Size      = new Size(100, Const.EXPR_HEIGHT);

            argPlaceHolder        = new ArgumentPlaceholder(this);
            argPlaceHolder.Parent = this;
            varPlaceHolder        = new ArgumentPlaceholder(this);
            varPlaceHolder.Parent = this;

            eqLabel = new CustomLabel(" = ", BackColor);
            Controls.Add(eqLabel);

            UpdateSize();
        }
Beispiel #6
0
        public bool PutElement(ArgumentPlaceholder p, DraggableControl el)
        {
            if (!CanPutElement(p, el))
            {
                return(false);
            }

            if (p == argPlaceHolder)
            {
                SetExpression(el);
            }
            else
            {
                SetVariableRef(el);
            }
            return(true);
        }
Beispiel #7
0
        public VBinaryOp(IFunctionDeclaration functionDeclaration)
        {
            function = functionDeclaration;
            symbol   = functionDeclaration.name;

            firstArgPlaceHolder  = new ArgumentPlaceholder(this);
            secondArgPlaceHolder = new ArgumentPlaceholder(this);

            firstArgPlaceHolder.Parent  = this;
            secondArgPlaceHolder.Parent = this;

            OpSymbol        = new CustomLabel(symbol, BackColor);
            OpSymbol.Parent = this;

            UpdateSize();

            BackColor = ColorSettings.Get("BinaryOp");
        }
Beispiel #8
0
        public bool CanPutElement(ArgumentPlaceholder p, DraggableControl el)
        {
            if (!(el is IExpression))
            {
                return(false);
            }

            if (p == firstArgPlaceHolder && firstArg == null)
            {
                return(true);
            }

            if (p == secondArgPlaceHolder && secondArg == null)
            {
                return(true);
            }

            return(false);
        }
Beispiel #9
0
        /// <summary>
        ///     Вызывается плейсхолдером p при попытке заменить плейсходер выражением el
        /// </summary>
        public bool PutElement(ArgumentPlaceholder p, DraggableControl el)
        {
            if (!CanPutElement(p, el))
            {
                return(false);
            }

            if (p == firstArgPlaceHolder && firstArg == null)
            {
                SetFirstArg(el);
                return(true);
            }

            if (p == secondArgPlaceHolder && secondArg == null)
            {
                SetSecondArg(el);
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        public VCondStatement(string condType)
        {
            condTypeLabel = new CustomLabel(condType, ColorSettings.Get("CondLabel"))
            {
                Parent   = this,
                Location = new Point(5, 5)
            };

            controlStatements = new List <DraggableControl>();
            placeholders      = new List <ArgumentPlaceholder>
            {
                new ArgumentPlaceholder(this).With(_ => { _.Parent = this; })
            };

            condPlaceholder = new ArgumentPlaceholder(this)
            {
                Parent   = this,
                Location = new Point(25, 5)
            };

            UpdateSize();
        }
Beispiel #11
0
 public bool PutElement(ArgumentPlaceholder p, DraggableControl el)
 {
     return(true);
 }
Beispiel #12
0
 public bool CanPutElement(ArgumentPlaceholder p, DraggableControl el)
 {
     return(!IsMainFun(el));
 }
Beispiel #13
0
 public bool CanPutElement(ArgumentPlaceholder p, DraggableControl el)
 {
     return(el is IStatement && placeholders.Contains(p));
 }
Beispiel #14
0
 public bool CanPutElement(ArgumentPlaceholder p, DraggableControl el)
 {
     return(p == argPlaceHolder && el is IExpression ||
            p == varPlaceHolder && el is VVariableRef);
 }
Beispiel #15
0
 protected void Hide(ArgumentPlaceholder h)
 {
     h.Location = new Point(-100, -100);
 }