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


C# List.First方法代码示例

本文整理汇总了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());
            }
        }
开发者ID:hippo811028,项目名称:Dynamo,代码行数:24,代码来源:dynRevitUtils.cs

示例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);
//.........这里部分代码省略.........
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:101,代码来源:WorkspaceModel.cs


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