Example #1
0
        public ForBlock() : base("for")
        {
            ForInitializer   = new StatementLine();
            ForCondition     = new ExpressionBlock();
            ForIncrementStep = new ExpressionBlock();

            const int c = ShapeStyle.DefaultFontSize;

            ForInitializer.MyControl.Box.Margins.Left = c;
            ForInitializer.MyControl.Box.Margins.SetTopAndBottom(0);
            ForInitializer.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            ForInitializer.Draggable = false;
            InitField(ForInitializer);

            ForCondition.MyControl.Box.Margins.Left = c;
            ForCondition.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            InitField(ForCondition);

            ForIncrementStep.MyControl.Box.Margins.SetLeftAndRight(c);
            ForIncrementStep.MyControl.Box.MouseSensitivityArea.SetLeftAndRight(c);
            InitField(ForIncrementStep);

            LabelBlock firstSep = new LabelBlock(";");

            firstSep.MyControl.Enabled = false;
            LabelBlock secondSep = new LabelBlock(";");

            secondSep.MyControl.Enabled = false;

            this.HMembers.Add(ForInitializer);
            this.HMembers.Add(firstSep);
            this.HMembers.Add(ForCondition);
            this.HMembers.Add(secondSep);
            this.HMembers.Add(ForIncrementStep);
        }
Example #2
0
        private static void AddAccessibleVariableDeclaration(
            IList <Variable> vars,
            Block node)
        {
            StatementLine varDecl = node as StatementLine;

            if (varDecl != null && varDecl.LocalVariableDeclaration != null)
            {
                foreach (Variable var in varDecl.LocalVariableDeclaration)
                {
                    vars.Add(var);
                }
            }

            ForeachBlock fe = node as ForeachBlock;

            if (fe != null)
            {
                vars.Add(fe.IterationVariable);
            }

            ForBlock fb = node as ForBlock;

            if (fb != null)
            {
                AddAccessibleVariableDeclaration(vars, fb.ForInitializer);
            }
        }
 protected override void OnKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
 {
     if (Strings.CanBeStartOfVariableName(e.KeyChar))
     {
         StatementLine s = new StatementLine();
         this.Replace(s);
         s.MyTextBox.OnKeyPress(e);
     }
 }
Example #4
0
        public override void AddChildren(IEnumerable <Block> restoredChildren)
        {
            StatementLine firstStatement = this.VMembers.Children.Head as StatementLine;

            if (this.VMembers.Children.Count == 1 &&
                firstStatement != null)
            {
                this.VMembers.Children.Delete(firstStatement);
            }
            foreach (Block child in restoredChildren)
            {
                this.VMembers.Children.Add(child);
            }
        }