当前位置: 首页>>代码示例>>C#>>正文


C# Block.AddBlock方法代码示例

本文整理汇总了C#中Block.AddBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Block.AddBlock方法的具体用法?C# Block.AddBlock怎么用?C# Block.AddBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Block的用法示例。


在下文中一共展示了Block.AddBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnAdd_Click

 private void btnAdd_Click(object sender, EventArgs e)
 {
     int count=0;
     int discardCount=0;
     bool Good;
     Block newBlock;
     do
     {
         do
         {
             newBlock = new Block(trackBar1.Value);
             Good = true;
             foreach (Block value in blockList)
             {
                 if (newBlock.Equals(value)&&discardCount<1000)
                 {
                     Good = false;
                     discardCount++;
                     ProgressBar1.Value = discardCount;
                     ProgressBar1.Refresh();
                 }
             }
         }
         while(!Good);
         if (discardCount < 1000)
         {
             blockList.Add(newBlock);
             newBlock.AddBlock();
             count++;
             Block.blockSwitch = false;
         }
     }
     while (count < 25 && discardCount <1000);
 }
开发者ID:Bondranx,项目名称:CMPE2300,代码行数:34,代码来源:Form1.cs

示例2: CloneObjectRecursive

 /// <summary>
 /// Clone object (blocks)
 /// </summary>
 /// <param name="newSuperBlock">New block</param>
 /// <param name="oldSuperBlock">Old block</param>
 void CloneObjectRecursive(Block newSuperBlock, Block oldSuperBlock)
 {
     foreach (var b in oldSuperBlock.SubBlocks)
     {
         if (b is Constructor)
         {
             newSuperBlock.AddBlock(new Constructor(newSuperBlock, (b as Constructor).Parameters));
             CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b);
         }
         else if (b is Method)
         {
             newSuperBlock.AddBlock(new Method(newSuperBlock, (b as Method).Name, (b as Method).ReturnType, (b as Method).Parameters));
             CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b);
         }
         else if (b is VariableDeclarationStatement)
         {
             newSuperBlock.AddBlock(new VariableDeclarationStatement(newSuperBlock, (b as VariableDeclarationStatement).Name, (b as VariableDeclarationStatement).Type));
         }
         else if (b is AssignStatement)
         {
             List<IExpression> newExpressions = CloneExpressions((b as AssignStatement).Expressions, newSuperBlock);
             newSuperBlock.AddBlock(new AssignStatement(newSuperBlock, (b as AssignStatement).Name, (b as AssignStatement).Type, newExpressions));
         }
         else if (b is PrintStatement)
         {
             List<IExpression> newExpressions = CloneExpressions((b as PrintStatement).Expressions, newSuperBlock);
             newSuperBlock.AddBlock(new PrintStatement(newSuperBlock, newExpressions));
         }
         else if (b is ConditionStatement)
         {
             List<IExpression> newLeft = CloneExpressions((b as ConditionStatement).Left, newSuperBlock);
             List<IExpression> newRight = CloneExpressions((b as ConditionStatement).Right, newSuperBlock);
             newSuperBlock.AddBlock(new ConditionStatement(newSuperBlock, newLeft, newRight, (b as ConditionStatement).OperatorType));
             CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b);
         }
         else if (b is ElseIfStatement)
         {
             List<IExpression> newLeft = CloneExpressions((b as ElseIfStatement).Left, newSuperBlock);
             List<IExpression> newRight = CloneExpressions((b as ElseIfStatement).Right, newSuperBlock);
             newSuperBlock.AddBlock(new ElseIfStatement(newSuperBlock, newLeft, newRight, (b as ElseIfStatement).OperatorType));
             CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b);
         }
         else if (b is ElseStatement)
         {
             newSuperBlock.AddBlock(new ElseStatement(newSuperBlock));
             CloneObjectRecursive(newSuperBlock.SubBlocks.Last(), b);
         }
     }
 }
开发者ID:PlatypusLanguage,项目名称:PlatypusSharp,代码行数:54,代码来源:Constructor.cs


注:本文中的Block.AddBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。