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


C# ICollection.ElementAt方法代码示例

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


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

示例1: ProcessNewFrame

    public override TypingStatus ProcessNewFrame(Point3D cursor, ICollection<TypingGesture> gestures, Microsoft.Kinect.Skeleton stableSkeleton, double deltaTimeMilliseconds, TypingDexterity dexterity)
    {
      double columnData = cursor.X;
      double rowData = cursor.Y;
      double constraintData = cursor.Z;

      if (cursor.IsFrozen)
      {
        columnData = cursor.FrozenX;
        rowData = cursor.FrozenY;
        constraintData = cursor.FrozenZ;
      }

      if (columnData < 0 || rowData < 0)
        return new TypingStatus();
      double stepX = 1.0 / layoutCols;
      double stepY = 1.0 / layoutRows;

      int col = (int)(columnData / stepX);
      int row = (int)(rowData / stepY);

      TypingStatus status = new TypingStatus();
      status.HighlightedKey = layout[row * layoutCols + col];
      if (gestures != null && gestures.Count > 0 && gestures.ElementAt(0).Type == GestureType.Tap)
      {
        TypingGesture gesture = gestures.ElementAt(0);
        col = (int)(gesture.Position.X / stepX);
        row = (int)(gesture.Position.Y / stepY);
        status.SelectedKey = layout[row * layoutCols + col];
      }

      return status;
    }
开发者ID:JangoBoogaloo,项目名称:Some-HCI,代码行数:33,代码来源:SeatoTypingMethod.cs

示例2: Add

        public JsonResult Add(int encounterId, ICollection<int> newTurnOrder, string description)
        {
            // This is because the LINQ can't translate this command, it needs a flat int.
            var actorId = newTurnOrder.First();

            var encounter = context.Encounters.First(e => e.Id.Equals(encounterId));
            var actingCharacter = context.Characters.First(p => p.Id.Equals(actorId));

            var feedEntry = new EncounterFeedEntry
            {
                ActingCharacter = actingCharacter,
                Description = description
            };
            context.Actions.Add(feedEntry);

            encounter.Initiatives.First(p => p.Character.Id.Equals(newTurnOrder.ElementAt(0)))
                .TurnOrder = newTurnOrder.Count()-1;

            for(var i=1; i<newTurnOrder.Count(); ++i)
            {
                encounter.Initiatives.First(p => p.Character.Id.Equals(newTurnOrder.ElementAt(i)))
                    .TurnOrder = i-1;
            }

            encounter.FeedEntries.Add(feedEntry);
            context.SaveChanges();

            return Json("Successfully posted");
        }
开发者ID:etkirsch,项目名称:The-DM-Screen,代码行数:29,代码来源:FeedEntryController.cs

示例3: Unify

        public static ReportRow Unify(ICollection<ReportRow> reportRows)
        {
            if (reportRows == null || reportRows.Count == 0)
            {
                throw new ArgumentException("reportRows");
            }

            var newRow = new ReportRow
            {
                Name = reportRows.First().Name,
                MaxValue = reportRows.First().MaxValue,
                Results = new List<int>()
            };

            for (var i = 0; i < reportRows.Count; i++)
            {
                if (newRow.Name != reportRows.ElementAt(i).Name)
                {
                    throw new Exception("Rows discrepancy");
                }

                newRow.Results.AddRange(reportRows.ElementAt(i).Results);
            }

            return newRow;
        }
开发者ID:v-zubritsky,项目名称:MilitaryFaculty,代码行数:26,代码来源:ReportRow.cs

示例4: DetectGesture

        public ICollection<IGestureEvent> DetectGesture(ICollection<ITouch> touches)
        {
            List<IGestureEvent> flicks = new List<IGestureEvent>();
            List<ITouch> usedTouch = new List<ITouch>(touches.Count);

            for (int i = 0; i < touches.Count; i++)
            {
                ITouch touch1 = touches.ElementAt(i);
                for (int j = i + 1; j < touches.Count; j++)
                {
                    ITouch touch2 = touches.ElementAt(j);

                    // Khong su dung lai cac touch da bat
                    if (usedTouch.Contains(touch1) || usedTouch.Contains(touch2))
                        continue;
                    float angle = (float)(GMath.Angle(touch1.Positions.Delta, touch2.Positions.Delta) * 180 / Math.PI); // Degree

                    if (angle < minAngle &&
                        (touch1.SystemTouch.State == TouchLocationState.Released || touch2.SystemTouch.State == TouchLocationState.Released))
                    {

                        flicks.Add(new DoubleFlick(touch1, touch2));
                        usedTouch.Add(touch1);
                        usedTouch.Add(touch2);
                    }
                }
            }

            return null;
        }
开发者ID:doanhtdpl,项目名称:boom-game,代码行数:30,代码来源:DoubleFlickDetector.cs

示例5: DetectGesture

        public ICollection<IGestureEvent> DetectGesture(ICollection<ITouch> touches)
        {
            List<IGestureEvent> drags = new List<IGestureEvent>(touches.Count);

            List<ITouch> usedTouch = new List<ITouch>(touches.Count);
            for (int i = 0; i < touches.Count; i++ )
            {
                ITouch touch1 = touches.ElementAt(i);
                for (int j = i + 1; j < touches.Count; j++)
                {
                    ITouch touch2 = touches.ElementAt(j);

                    // Khong su dung lai cac touch da bat
                    if (usedTouch.Contains(touch1) || usedTouch.Contains(touch2))
                        continue;
                    float angle = (float)(GMath.Angle(touch1.Positions.Delta, touch2.Positions.Delta) * 180 / Math.PI); // Degree

                    if (angle < minAngle)
                    {
                        drags.Add(new DoubleDrag(touch1, touch2));
                        usedTouch.Add(touch1);
                        usedTouch.Add(touch2);
                    }
                }
            }

            return drags;
        }
开发者ID:doanhtdpl,项目名称:boom-game,代码行数:28,代码来源:DoubleDragDetector.cs

示例6: IsBigger

 static bool IsBigger(ICollection<int> arr ,int position)
 {
     if (position <= 0 || position >= arr.Count-1)
     {
         throw new IndexOutOfRangeException("THE NUMBER AT SPECIFIED INDEX DOES NOT HAVE TWO NEIGHBORS OR INDEX IS OUT OF RANGE!");
     }
     return (arr.ElementAt(position) > arr.ElementAt(position - 1) && arr.ElementAt(position) > arr.ElementAt(position + 1));
 }
开发者ID:GenoGenov,项目名称:TelerikAcademyAssignments,代码行数:8,代码来源:CheckNeighbors.cs

示例7: clearOrder

 private void clearOrder(ICollection<order> orders)
 {
     for (int i = 0; i < orders.Count;i++ )
     {
         orders.ElementAt(i).waiter_id = null;
         orders.ElementAt(i).version = orders.ElementAt(i).version + 1;
         db.Entry(orders.ElementAt(i)).State = EntityState.Modified;
     }
 }
开发者ID:pmoda,项目名称:TFFCode,代码行数:9,代码来源:WaiterOM.cs

示例8: CheckBoxList

        public static MvcHtmlString CheckBoxList(this HtmlHelper html, string name, ICollection<SelectListItem> list)
        {
            StringBuilder htmlTags = new StringBuilder();

            if (list == null)
            {
                return new MvcHtmlString("");
            }

            for (int i = 0; i < list.Count; i++)
            {
                TagBuilder hiddenTextTag = new TagBuilder("input");
                hiddenTextTag.Attributes.Add(new KeyValuePair<string, string>("name", name + "[" + i + "].Text"));
                hiddenTextTag.Attributes.Add(new KeyValuePair<string, string>("value", list.ElementAt<SelectListItem>(i).Text));
                hiddenTextTag.Attributes.Add(new KeyValuePair<string, string>("type", "hidden"));
                htmlTags.Append(hiddenTextTag.ToString());

                TagBuilder hiddenValueTag = new TagBuilder("input");
                hiddenValueTag.Attributes.Add(new KeyValuePair<string, string>("name", name + "[" + i + "].Value"));
                hiddenValueTag.Attributes.Add(new KeyValuePair<string, string>("value", list.ElementAt<SelectListItem>(i).Value));
                hiddenValueTag.Attributes.Add(new KeyValuePair<string, string>("type", "hidden"));
                htmlTags.Append(hiddenValueTag.ToString());

                TagBuilder checkBoxDiv = new TagBuilder("div");
                checkBoxDiv.AddCssClass("checkbox");

                TagBuilder checkBoxlabel = new TagBuilder("label");

                if (list.ElementAt<SelectListItem>(i).Selected)
                {
                    TagBuilder checkedTag = new TagBuilder("input");
                    checkedTag.Attributes.Add(new KeyValuePair<string, string>("name", name + "[" + i + "].Selected"));
                    checkedTag.Attributes.Add(new KeyValuePair<string, string>("value", "true"));
                    checkedTag.Attributes.Add(new KeyValuePair<string, string>("type", "checkbox"));
                    checkedTag.Attributes.Add(new KeyValuePair<string, string>("checked", "checked"));
                    //htmlTags.Append(checkedTag.ToString() + " " + list.ElementAt<SelectListItem>(i).Text);

                    checkBoxlabel.InnerHtml += checkedTag.ToString() + " " + list.ElementAt<SelectListItem>(i).Text;
                    checkBoxDiv.InnerHtml += checkBoxlabel.ToString();
                    htmlTags.Append(checkBoxDiv.ToString());
                }
                else
                {
                    TagBuilder unCheckedTag = new TagBuilder("input");
                    unCheckedTag.Attributes.Add(new KeyValuePair<string, string>("name", name + "[" + i + "].Selected"));
                    unCheckedTag.Attributes.Add(new KeyValuePair<string, string>("value", "true"));
                    unCheckedTag.Attributes.Add(new KeyValuePair<string, string>("type", "checkbox"));
                    //htmlTags.Append(unCheckedTag.ToString() + " " + list.ElementAt<SelectListItem>(i).Text);

                    checkBoxlabel.InnerHtml += unCheckedTag.ToString() + " " + list.ElementAt<SelectListItem>(i).Text;
                    checkBoxDiv.InnerHtml += checkBoxlabel.ToString();
                    htmlTags.Append(checkBoxDiv.ToString());
                }
            }

            return new MvcHtmlString(htmlTags.ToString());
        }
开发者ID:joelmccune,项目名称:MediaManagerv2,代码行数:57,代码来源:CustomHelper.cs

示例9: GetIndex

 static int GetIndex(ICollection<int> arr)
 {
     for (int i = 1; i < arr.Count-1; i++)
     {
         if (arr.ElementAt(i) > arr.ElementAt(i - 1) && arr.ElementAt(i) > arr.ElementAt(i + 1))
         {
             return i;
         }
     }
     return -1;
 }
开发者ID:GenoGenov,项目名称:TelerikAcademyAssignments,代码行数:11,代码来源:CheckWholeArray.cs

示例10: Call

        public static void Call(ICollection<ITerminal> terminals, ICollection<PhoneNumber> PhoneNumbers)
        {
            Random r = new Random();

            var t1 = terminals.ElementAt(r.Next(0, terminals.Count ));
            var t2 = terminals.ElementAt(r.Next(0, terminals.Count));
            t1.Call(t2.PhoneNumber);
            t2.Answer();
            Thread.Sleep(500);
            t1.Reset();
        }
开发者ID:ADudar,项目名称:EpamSystemsTraining,代码行数:11,代码来源:Program.cs

示例11: GetMax

 static int GetMax(int start, ICollection<int> arr)
 {
     int result = int.MinValue;
     for (int i = start; i < arr.Count; i++)
     {
         if (result < arr.ElementAt(i))
         {
             result = arr.ElementAt(i);
         }
     }
     return result;
 }
开发者ID:GenoGenov,项目名称:TelerikAcademyAssignments,代码行数:12,代码来源:MaxAndSort.cs

示例12: MatchesActionArguments

		private static bool MatchesActionArguments(this TRoute route, ICollection<Type> actionArguments)
		{
			if (actionArguments == null)
			{
				return true;
			}

			// When specifying arguments, it must be an action level attribute route with a single action descriptor
			TActionDescriptor actionDescriptor = ((TActionDescriptor[])route.DataTokens[RouteDataTokenKeys.Actions]).Single();

			ICollection<TParameterDescriptor> parameterInfos = actionDescriptor.GetParameters();

			if (parameterInfos.Count() != actionArguments.Count)
			{
				return false;
			}

			for (int i = 0; i < actionArguments.Count; i++)
			{
				if (actionArguments.ElementAt(i) != parameterInfos.ElementAt(i).ParameterType)
				{
					return false;
				}
			}

			return true;
		}
开发者ID:NishiGulnaz,项目名称:RouteLocalization,代码行数:27,代码来源:RouteEntryCollectionExtensions.cs

示例13: ModelProtoGroup

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="elements">Model element to create proto elements for.</param>
        /// <param name="operation">Operation.</param>
        public ModelProtoGroup(ICollection<ModelElement> elements, ModelProtoGroupOperation operation)
        {
            if (elements.Count == 0)
                throw new ArgumentNullException("elements");

            this.protoElements = new List<ModelProtoElement>(6000);
            this.protoRootElements = new List<ModelProtoElement>(6000);

            this.protoEmbeddingLinks = new List<ModelProtoLink>(6000);
            this.protoReferenceLinks = new List<ModelProtoLink>(6000);

            this.protoOperation = operation;

            foreach (ModelElement modelElement in elements)
            {
                if (modelElement is IModelMergeElements)
                {
                    ModelProtoElement root;
                    if( operation == ModelProtoGroupOperation.Copy )
                        root = (modelElement as IModelMergeElements).ModelCreateMergeCopy(this);
                    else
                        root = (modelElement as IModelMergeElements).ModelCreateMoveCopy(this);
                    if (root == null)
                        throw new ArgumentNullException("root");
                    this.protoRootElements.Insert(0, root);
                }
            }

            InitDictionaries(elements.ElementAt(0).Partition);
        }
开发者ID:apoorv-vijay-joshi,项目名称:FSE-2011-PDE,代码行数:35,代码来源:ModelProtoGroup.cs

示例14: recommend

 public ICollection<Film> recommend(ICollection<Film> precondition, ICollection<Film> yetRecommended, int Number)
 {
     if(precondition==null|| precondition.Count<1)
         return new List<Film>();
     var retList = new List<Film>();
     for (int i = 0; i < (Number>0?Number:10); i++)
     {
         var tmp_film = precondition.ElementAt(new Random().Next(0, precondition.Count()-1));
         if(tmp_film.actors!=null&&tmp_film.actors.Count()>0)
         {
             var tmp_actor = tmp_film.actors.ElementAt(new Random().Next(0, tmp_film.actors.Count()-1));
             if (tmp_actor != null)
             {
                 tmp_actor = actorsservice.getActorWithFilmsFromDAL(tmp_actor.ID);
                 if (tmp_actor != null&&tmp_actor.films.Count()>0)
                 {
                     var rec_film = tmp_actor.films.ElementAt(new Random().Next(0, tmp_actor.films.Count() - 1));
                     if (!yetRecommended.Contains(rec_film) && !retList.Contains(rec_film))
                         retList.Add(rec_film);
                 }
             }
         }
     }
     return retList;
 }
开发者ID:tscherkas,项目名称:filmsWebApp,代码行数:25,代码来源:MyFilmRecommendService.cs

示例15: GetDBValues

 public DataTable GetDBValues(ICollection<PactControlData> _controlData)
 {
     DataTable DbValues = BuildDBColumns(_controlData);
     DbValues.TableName = "UIVALUES";
     PactControlData objPactCtrl;
     PactTextBoxData objPactTB;
     PactComboBoxData objPactCmb;
     PactCheckBoxData objPactChk;
     PactDatePickerData objPactDp;
     DataRow dr = DbValues.NewRow();
     if (_controlData != null && _controlData.Count > 0)
     {
         for (int i = 0; i < _controlData.Count; i++)
         {
             objPactCtrl = _controlData.ElementAt<PactControlData>(i);
             if (objPactCtrl.GetType().Name.ToString().Equals("PactTextBoxData"))
             {
                 objPactTB = (PactTextBoxData)objPactCtrl;
                 if (objPactTB.DBColumnName != null)
                 {
                     if (objPactTB.Text != null)
                     {
                         dr[objPactTB.DBColumnName.Trim()] = objPactTB.Text.Trim();
                     }
                 }
             }
             else if (objPactCtrl.GetType().Name.ToString().Equals("PactComboBoxData"))
             {
                 objPactCmb = (PactComboBoxData)objPactCtrl;
                 if (objPactCmb.DBColumnName != null)
                 {
                     if (objPactCmb.SelectedValue != null)
                     {
                         dr[objPactCmb.DBColumnName.Trim()] = objPactCmb.SelectedValue.Trim();
                     }
                 }
             }
             else if (objPactCtrl.GetType().Name.ToString().Equals("PactCheckBoxData"))
             {
                 objPactChk = (PactCheckBoxData)objPactCtrl;
                 if (objPactChk.DBColumnName != null)
                 {
                     dr[objPactChk.DBColumnName.Trim()] = objPactChk.IsChecked;
                 }
             }
             else if (objPactCtrl.GetType().Name.ToString().Equals("PactDatePickerData"))
             {
                 objPactDp = (PactDatePickerData)objPactCtrl;
                 if (objPactDp.DBColumnName != null)
                 {
                     dr[objPactDp.DBColumnName.Trim()] = objPactDp.Date;
                 }
             }
         }
     }
     DbValues.Rows.Add(dr);
     return DbValues;
 }
开发者ID:merlin2504,项目名称:RD12,代码行数:58,代码来源:Util.cs


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