本文整理汇总了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);
}
示例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);
}
}
}