本文整理汇总了C#中Dynamo.Nodes.List.First方法的典型用法代码示例。如果您正苦于以下问题:C# List.First方法的具体用法?C# List.First怎么用?C# List.First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Nodes.List
的用法示例。
在下文中一共展示了List.First方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertAllResults
private static Value ConvertAllResults(List<object> results)
{
//if there are multiple items in the results list
//return a list type
if (results.Count > 1)
{
FSharpList<Value> lst = FSharpList<Value>.Empty;
//reverse the results list so our CONs list isn't backwards
results.Reverse();
lst = results.Aggregate(lst,
(current, result) =>
FSharpList<Value>.Cons(DynamoTypeConverter.ConvertToValue(result), current));
//the result will be a list of objects if any lists
return Value.NewList(lst);
}
//otherwise, return a single value
else
{
return DynamoTypeConverter.ConvertToValue(results.First());
}
}
示例2: GenerateCombinedGraph
/// <summary>
/// This method extracts all models from the workspace and puts them
/// into the combined graph object, LayoutSubgraphs.First()
/// <param name="isGroupLayout">True if all the selected models are groups.</param>
/// </summary>
private void GenerateCombinedGraph(bool isGroupLayout)
{
LayoutSubgraphs = new List<GraphLayout.Graph>();
LayoutSubgraphs.Add(new GraphLayout.Graph());
GraphLayout.Graph combinedGraph = LayoutSubgraphs.First();
SubgraphClusters = new List<List<GraphLayout.Node>>();
if (!isGroupLayout)
{
foreach (AnnotationModel group in Annotations)
{
// Treat a group as a graph layout node/vertex
combinedGraph.AddNode(group.GUID, group.Width, group.Height, group.X, group.Y,
group.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
}
}
foreach (NodeModel node in Nodes)
{
if (!isGroupLayout)
{
AnnotationModel group = Annotations.Where(
g => g.SelectedModels.Contains(node)).ToList().FirstOrDefault();
// Do not process nodes within groups
if (group == null)
{
combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
node.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
}
}
else
{
// Process all nodes inside the selection
combinedGraph.AddNode(node.GUID, node.Width, node.Height, node.X, node.Y,
node.IsSelected || DynamoSelection.Instance.Selection.Count == 0);
}
}
foreach (ConnectorModel edge in Connectors)
{
if (!isGroupLayout)
{
AnnotationModel startGroup = null, endGroup = null;
startGroup = Annotations.Where(
g => g.SelectedModels.Contains(edge.Start.Owner)).ToList().FirstOrDefault();
endGroup = Annotations.Where(
g => g.SelectedModels.Contains(edge.End.Owner)).ToList().FirstOrDefault();
// Treat a group as a node, but do not process edges within a group
if (startGroup == null || endGroup == null || startGroup != endGroup)
{
combinedGraph.AddEdge(
startGroup == null ? edge.Start.Owner.GUID : startGroup.GUID,
endGroup == null ? edge.End.Owner.GUID : endGroup.GUID,
edge.Start.Center.X, edge.Start.Center.Y, edge.End.Center.X, edge.End.Center.Y);
}
}
else
{
// Edges within a group are also processed
combinedGraph.AddEdge(edge.Start.Owner.GUID, edge.End.Owner.GUID,
edge.Start.Center.X, edge.Start.Center.Y, edge.End.Center.X, edge.End.Center.Y);
}
}
foreach (NoteModel note in Notes)
{
// Link a note to the nearest node
GraphLayout.Node nd = combinedGraph.Nodes.OrderBy(node =>
Math.Pow(node.X + node.Width / 2 - note.X - note.Width / 2, 2) +
Math.Pow(node.Y + node.Height / 2 - note.Y - note.Height / 2, 2)).FirstOrDefault();
if (nd != null)
{
nd.LinkNote(note, note.Width, note.Height);
}
}
if (!isGroupLayout)
{
// Add all nodes to one big cluster
List<GraphLayout.Node> bigcluster = new List<GraphLayout.Node>();
bigcluster.AddRange(combinedGraph.Nodes);
SubgraphClusters.Add(bigcluster);
}
else
{
// Each group becomes one cluster
foreach (AnnotationModel group in DynamoSelection.Instance.Selection.OfType<AnnotationModel>())
{
List<GraphLayout.Node> cluster = new List<GraphLayout.Node>();
cluster.AddRange(group.SelectedModels.Select(x => combinedGraph.FindNode(x.GUID)));
SubgraphClusters.Add(cluster);
//.........这里部分代码省略.........