本文整理汇总了C#中Canvas.AddNode方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.AddNode方法的具体用法?C# Canvas.AddNode怎么用?C# Canvas.AddNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.AddNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNode
private static void AddNode(Canvas canvas, NodePort parentInput, ExpressionTreeNode expressionNode, List<NumberParam> variables, Point location, Int32 levelStep, Int32 minY, Int32 maxY)
{
Int32 leafs = (expressionNode.LeftNode != null ? 1 : 0) + (expressionNode.RightNode != null ? 1 : 0);
NodeBase node = null;
if (expressionNode.Token.IsNumber)
{
node = new VisiTypes.Number(Double.Parse(expressionNode.Token.TokenBody));
canvas.AddNode(node, location);
}
if (expressionNode.Token.IsVariable)
{
Boolean exist = false;
foreach (NumberParam param in variables)
{
if (param.Name == expressionNode.Token.TokenBody)
{
exist = true;
node = param;
break;
}
}
if (!exist)
{
node = new NumberParam();
((NumberParam)node).Name = expressionNode.Token.TokenBody;
((NumberParam)node).Header = expressionNode.Token.TokenBody;
variables.Add((NumberParam)node);
canvas.AddNode(node, location);
}
}
if (expressionNode.Token.IsOperator)
{
node = new Operator(expressionNode.Token.OperatorDescriptor);
canvas.AddNode(node, location);
switch (leafs)
{
case 1:
{
AddNode(canvas, node.GetInput(0), expressionNode.LeftNode, variables, new Point(location.X - levelStep, location.Y), levelStep, minY, maxY);
break;
}
case 2:
{
Int32 y2 = (maxY - minY) / 2;
AddNode(canvas, node.GetInput(0), expressionNode.LeftNode, variables, new Point(location.X - levelStep, minY + y2 / 2), levelStep, minY, minY + y2);
AddNode(canvas, node.GetInput(1), expressionNode.RightNode, variables, new Point(location.X - levelStep, maxY - y2 / 2), levelStep, maxY - y2, maxY);
break;
}
}
}
if (parentInput != null && node != null)
{
parentInput.Connection = node.GetOutput(0);
}
}