本文整理汇总了C#中System.Windows.Documents.List.Take方法的典型用法代码示例。如果您正苦于以下问题:C# List.Take方法的具体用法?C# List.Take怎么用?C# List.Take使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Take方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get3Elements
private IEnumerable<UIElement> Get3Elements(List<UIElement> ordered, bool swap)
{
if (ordered.Count == 0) return null;
List<UIElement> result = ordered.Take(3).ToList();
if (ordered.Count > 0) ordered.RemoveAt(0);
if (ordered.Count > 0) ordered.RemoveAt(0);
if (ordered.Count > 0) ordered.RemoveAt(0);
while (result.Count < 3) result.Add(null);
if (swap) result.Reverse();
return result;
}
示例2: NewGameContext
public NewGameContext(GameTableContext gameTableContext, IEnumerable<Player> players)
{
if (players == null)
throw new ArgumentNullException("players");
if (gameTableContext == null)
throw new ArgumentNullException("gameTableContext");
GameTableContext = gameTableContext;
WinnerScore = 9;
TableSize = 7;
Open();
Players = new List<ChoosablePlayer>(players.Select(player => new ChoosablePlayer(player)));
foreach (var player in Players.Take(2)) {
player.IsChoosen = true;
}
}
示例3: GetMatchModels
public List<MatchModel> GetMatchModels(List<MatchedFileSystemItem> folderMatches)
{
if (ListUtility.IsNullOrEmpty(folderMatches))
{
return new List<MatchModel> {new MatchModel(this, Resources.NoMatchesFound)};
}
folderMatches.Sort(Compare);
List<MatchModel> matchRepresentations = folderMatches
.Take(Constants.MaxMatchesToDisplay)
.Select(GetMatchModel)
.ToList();
if (folderMatches.Count > Constants.MaxMatchesToDisplay)
{
matchRepresentations.Add(new MatchModel(this, Resources.TooManyMatchesText));
}
return matchRepresentations;
}
示例4: InitializeTestCaseExecutionTimesToolTip
/// <summary>
/// Initializes the test case execution times tool tip.
/// </summary>
/// <param name="testCaseRunResults">The test case run results.</param>
/// <returns>test case tooltip</returns>
private string InitializeTestCaseExecutionTimesToolTip(List<TestCaseRunResult> testCaseRunResults)
{
StringBuilder sb = new StringBuilder();
int count = 1;
testCaseRunResults.Reverse();
var lastTenRunResults = testCaseRunResults.Take(10);
foreach (TestCaseRunResult testCaseRunResult in lastTenRunResults)
{
sb.AppendLine(string.Format("{0}. StartDate {1} | EndDate- {2} | Duration- {3} | RunBy- {4}",
count++,
testCaseRunResult.StartDate.ToShortDateString(),
testCaseRunResult.EndDate.ToShortDateString(),
testCaseRunResult.Duration.ToString(TimeSpanFormats.HourFormat),
testCaseRunResult.RunBy));
}
return sb.ToString();
}
示例5: srv_GameRecord_GetReportDetailCompleted
public void srv_GameRecord_GetReportDetailCompleted(object sender, GetReportDetailCompletedEventArgs e)
{
gridLoading.Visibility = Visibility.Collapsed;
currentPos = 0;
obReportDetail = e.Result.ToList();
//obReportDetail.Add(DPageSum);
//obReportDetail.Add(DTotalSum);
if (e.Result.Count != 0)
{
DTotalSum = new ReportDetail();
DTotalSum.RecordID = "总合计";
DTotalSum.IsWin = -1;
DTotalSum.Direction = -1;
DTotalSum.ResultStatus = -1;
DTotalSum.BetMoney = obReportDetail.Sum(p => p.BetMoney);
DTotalSum.WinMoney = obReportDetail.Sum(p => p.WinMoney);
if (e.Result.Count < 18)
{
obReportDetail = e.Result.ToList();
DPageSum = new ReportDetail();
DPageSum.RecordID = "本页合计";
DPageSum.IsWin = -1;
DPageSum.Direction = -1;
DPageSum.ResultStatus = -1;
DPageSum.BetMoney = obReportDetail.Take(18).Sum(p => p.BetMoney);
DPageSum.WinMoney = obReportDetail.Take(18).Sum(p => p.WinMoney);
obReportDetail.Add(DPageSum);
obReportDetail.Add(DTotalSum);
currentPos = 0;
PagedCollectionView pageView = new PagedCollectionView(obReportDetail);
pageView.PageSize = 20;
dpRecord.PageSize = 20;
dpRecord.Source = pageView;
dgRecord.ItemsSource = pageView;
}
else
{
int page = int.Parse(Math.Ceiling(double.Parse(e.Result.Count.ToString()) / 18).ToString());
for (int i = 0; i < page; i++)
{
int stayNum = obReportDetail.Count - (i * 20);
if (stayNum > 18)
{
DPageSum = new ReportDetail();
DPageSum.RecordID = "本页合计";
DPageSum.IsWin = -1;
DPageSum.Direction = -1;
DPageSum.ResultStatus = -1;
//DPageSum.BetMoney = obReportDetail.Skip(i * 20).Take(18).Sum(p => p.BetMoney);
//DPageSum.WinMoney = obReportDetail.Skip(i * 20).Take(18).Sum(p => p.WinMoney);
DPageSum.BetMoney = obReportDetail.GetRange(i * 20, 18).Sum(p => p.BetMoney);
DPageSum.WinMoney = obReportDetail.GetRange(i * 20, 18).Sum(p => p.WinMoney);
obReportDetail.Insert(i * 20 + 18, DPageSum);
obReportDetail.Insert(i * 20 + 19, DTotalSum);
}
else
{
DPageSum = new ReportDetail();
DPageSum.RecordID = "本页合计";
DPageSum.IsWin = -1;
DPageSum.Direction = -1;
DPageSum.ResultStatus = -1;
//DPageSum.BetMoney = obReportDetail.Skip(i * 20).Take(stayNum).Sum(p => p.BetMoney);
//DPageSum.WinMoney = obReportDetail.Skip(i * 20).Take(stayNum).Sum(p => p.WinMoney);
DPageSum.BetMoney = obReportDetail.GetRange(i * 20, stayNum).Sum(p => p.BetMoney);
DPageSum.WinMoney = obReportDetail.GetRange(i * 20, stayNum).Sum(p => p.WinMoney);
obReportDetail.Insert(i * 20 + stayNum, DPageSum);
obReportDetail.Insert(i * 20 + stayNum + 1, DTotalSum);
}
}
currentPos = 0;
PagedCollectionView pageView = new PagedCollectionView(obReportDetail);
pageView.PageSize = 20;
dpRecord.PageSize = 20;
dpRecord.Source = pageView;
dgRecord.ItemsSource = pageView;
}
}
else
{
PagedCollectionView pageView = new PagedCollectionView(obReportDetail);
pageView.PageSize = 20;
dpRecord.PageSize = 20;
dpRecord.Source = pageView;
dgRecord.ItemsSource = pageView;
}
BindStatReportList(user.ID);
}
示例6: ListUserRoleAuthCompleted
void ListUserRoleAuthCompleted(List<UserRoleAuth> userRoleAuthList)
{
uiUserRoleAuthList.Items.Clear();
//userRoleAuthList = (from u in userRoleAuthList
// join role in _aspRoles on u.RoleId equals role.RoleId
// select u).ToList();
userRoleAuthList = userRoleAuthList.Take(_nbrItemsShowed).ToList();
foreach (UserRoleAuth dataItem in userRoleAuthList)
{
OneUserRoleAuth control = new OneUserRoleAuth();
control.UserRoleAuthData = dataItem;
control.AspRoles = _aspRoles;
control.AspUsers = _aspUsers;
control.SiteGroups = _siteGroup;
control.IsUserView = true;
control.RebindCombobox();
control.DeleteButtonClicked += new EventHandler(control_DeleteButtonClicked);
uiUserRoleAuthList.Items.Add(control);
}
_roleComponentItemSource.Clear();
var roleList = (from i in userRoleAuthList
select i.RoleId).Distinct();
_roleCount = roleList.Count();
foreach (Guid roleId in roleList)
{
DataServiceHelper.ListRoleComponentPermissionAsync(roleId, null, ListRoleComponentCompleted);
}
Globals.IsBusy = false;
}
示例7: RemoveExtraBarcodes
private void RemoveExtraBarcodes(ref List<string> barcodes)
{
int i = barcodes.Count -1;
for(; i>0; i--)
{
if (barcodes[i] !="$$$")
break;
}
if(i != barcodes.Count -1) //some tube missing
{
barcodes = barcodes.Take(i + 1).ToList();
}
}
示例8: Run2
/// <summary>
/// 過去のもの。頑張りすぎた。
/// </summary>
/// <returns></returns>
ClusteringResult Run2()
{
List<ClusteringResult> tmpResult = new List<ClusteringResult>();
OnReport("開始");
for (int i = 0; i < wideCount; i++)
{
ClusteringResult cr = new ClusteringResult() { Parent = this };
cr.CreateRandom(ClusterTable, random.Next());
tmpResult.Add(cr);
}
int loopCount = 0;
int sameCount = 0;
double sameRate = 0;
while (true)
{
loopCount++;
if (tmpResult.First().GetLockRate() == sameRate)
{
sameCount++;
}
else
{
sameRate = tmpResult.First().GetLockRate();
sameCount = 0;
}
OnReport(loopCount + "回目開始");
foreach (var item in tmpResult)
{
item.Run();
}
OnReport("計算終了");
var baseResult = tmpResult.OrderByDescending(n => n.GetPerformanceIndex()).First();
foreach (var item in tmpResult)
{
item.CategorySort(baseResult);
}
tmpResult = tmpResult.OrderByDescending(n => n.GetPerformanceIndex()).ToList();
List<ClusteringResult> list = new List<ClusteringResult>();
foreach (var item in tmpResult.Take(tmpResult.Count / 2))
{
var clone = item.Clone();
list.Add(clone);
}
if (tmpResult.Count > 3)
{
foreach (var item in tmpResult.Skip(tmpResult.Count / 2).ToArray())
{
tmpResult.Remove(item);
}
foreach (var item in list)
{
tmpResult.Add(item.Clone());
}
}
if (tmpResult.First().GetLockRate() < 0.9 && loopCount < 100 && sameCount < 10)
{
int c = 0;
OnReport("マージ・ランダム振り開始");
foreach (var item in tmpResult)
{
var count = item.CreateMargeData(list, true);
// lock (this)
{
c += count;
}
}
OnReport("レポート開始");
OnReport(tmpResult.First().View());
if (c == 0) break;
}
else
{
foreach (var item in tmpResult)
{
var count = item.CreateMargeData(list, false);
}
tmpResult.First().Run();
break;
}
if (tmpResult.First().DivideCategory())
{
OnReport("クラスタ分割発生");
var r = tmpResult.First();
tmpResult.Clear();
for (int i = 0; i < TryCount; i++)
{
tmpResult.Add(r.Clone());
}
}
//.........这里部分代码省略.........
示例9: SurfaceMode
private void SurfaceMode(HandCollection data)
{
this.Dispatcher.Invoke(new Action(() =>
{
if (isNew)
{
if (this.selectedVideo != null)
{
this.selectedVideo.IsSelected = false;
}
this.selectedVideo = new VideoSurface(this.videoPaths[this.videoPointer++]);
this.videos.Add(this.selectedVideo);
this.selectedVideo.RequestRemove += new EventHandler(videoSurface_RequestRemove);
if (videoPointer >= this.videoPaths.Length)
{
videoPointer = 0;
}
this.viewPort.Children.Add(selectedVideo.ModelVisual3D);
this.selectedVideo.Play();
this.selectedVideo.Opacity = 0.8;
isNew = false;
}
if (selectedVideo.IsPaused)
{
selectedVideo.Play();
}
var points = new List<CCT.NUI.Core.Point>();
var hand1 = data.Hands[0];
var hand2 = data.Hands[1];
points.Add(hand1.FingerPoints[0].Fingertip);
points.Add(hand1.FingerPoints[1].Fingertip);
points.Add(hand2.FingerPoints[0].Fingertip);
points.Add(hand2.FingerPoints[1].Fingertip);
points = points.OrderBy((p) => p.X).ToList();
var leftPoints = points.Take(2).ToList();
var rightPoints = points.Skip(2).Take(2).ToList();
leftPoints = leftPoints.OrderByDescending(p => p.Y).ToList();
rightPoints = rightPoints.OrderByDescending(p => p.Y).ToList();
this.selectedVideo.SetPoints(Map(leftPoints[0]), Map(rightPoints[0]), Map(rightPoints[1]), Map(leftPoints[1]));
}));
moveMode = false;
}