本文整理汇总了C#中BindingList.ForEach方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.ForEach方法的具体用法?C# BindingList.ForEach怎么用?C# BindingList.ForEach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindingList
的用法示例。
在下文中一共展示了BindingList.ForEach方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FreeCellGame
public FreeCellGame()
{
Width = DefaultWidth;
Height = DefaultHeight;
var Margin = (DefaultWidth - CardInfo.Width * 8) / 9;
var GameOverBox = new TextBox
{
Width = DefaultWidth,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
IsReadOnly = true,
FontSize = 24,
}.MoveTo(0, DefaultHeight / 2).AttachTo(this);
GameOver += delegate
{
GameOverBox.Text = "Congratulations! You Won!";
};
#region king
var KingCanvas = new Canvas
{
Width = 96,
Height = 96
}.AttachTo(this).MoveTo(
(DefaultWidth - 32) / 2,
Margin * 2 + (CardInfo.Height - 32) / 2
);
var KingRight = new kingbitm().AttachTo(KingCanvas);
var KingLeft = new kingleft().AttachTo(KingCanvas);
var KingSmile = new kingsmil().AttachTo(KingCanvas);
KingSmile.Hide();
#endregion
this.MyDeck.Overlay.MouseMove +=
(sender, args) =>
{
var p = args.GetPosition(this.MyDeck.Overlay);
if (p.X < DefaultWidth / 2)
{
KingLeft.Show();
KingRight.Hide();
}
else
{
KingLeft.Hide();
KingRight.Show();
}
};
this.MyStatus = new StatusControl().AttachContainerTo(this).MoveContainerTo(
(DefaultWidth - StatusControl.Width) / 2,
(DefaultHeight - StatusControl.Height)
);
//this.MyStatus.Container.Hide();
// add autoscroll ?
this.MyDeck.SizeTo(DefaultWidth, DefaultHeight);
this.MyDeck.AttachContainerTo(this);
this.MyDeck.GetRank = e => (int)RankMapping[e];
System.Console.WriteLine("--- freecell ---");
System.Console.WriteLine("adding card infos... ");
MyDeck.UnusedCards.AddRange(CardInfo.FullDeck());
this.MyStatus.CardsLeft = MyDeck.UnusedCards.Count;
this.MyStatus.Score = -1;
this.MyStatus.Update();
System.Console.WriteLine("creating stacklists... ");
PlayStacks = MyDeck.CreateStackList();
PlayStacks.ForEachNewItem(
k =>
{
k.CardMargin = new Vector { Y = 20 };
k.Update();
}
);
TempStacks = MyDeck.CreateStackList();
Func<bool> Rule_WinConditionMet =
delegate
//.........这里部分代码省略.........
示例2: SpiderGame
//.........这里部分代码省略.........
return false;
}
return false;
};
};
#endregion
System.Console.WriteLine("creating playstack... ");
var Margin = (DefaultWidth - CardInfo.Width * 10) / 11;
PlayStacks.AddRange(
Enumerable.Range(0, 10).ToArray(
i =>
new CardStack
{
Name = "PlayStack " + i,
CardMargin = new Vector { Y = 20 }
}.MoveTo(
Margin + i * (CardInfo.Width + Margin),
Margin + 40
).Apply(
s =>
{
if (i < 4)
s.Cards.AddRange(MyDeck.FetchCards(5));
else
s.Cards.AddRange(MyDeck.FetchCards(4));
if (Cheat)
s.Cards.ForEach(k => k.VisibleSide = Card.SideEnum.TopSide);
}
)
)
);
PlayStacks.ForEach(
delegate(CardStack s)
{
s.Cards.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemDeleted)
//if (MyStatus.Ready)
s.RevealLastCard();
};
}
);
DealStacks.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemAdded)
{
var s = DealStacks[args.NewIndex];
s.CardMargin = new Vector { Y = 0, X = 0 };
s.Update();
示例3: Spider
//.........这里部分代码省略.........
{
if (CheatNoValidation)
return;
if (Predicate.Invoke(p.Target, c, IsFitForPlayStack))
{
return;
}
p.Target = null;
};
};
#endregion
System.Console.WriteLine("creating playstack... ");
PlayStacks.Add(
new CardStack(new Point(50, top), MyDeck.FetchCards(5)),
new CardStack(new Point(150, top), MyDeck.FetchCards(5)),
new CardStack(new Point(250, top), MyDeck.FetchCards(5)),
new CardStack(new Point(350, top), MyDeck.FetchCards(5)),
new CardStack(new Point(450, top), MyDeck.FetchCards(4)),
new CardStack(new Point(550, top), MyDeck.FetchCards(4)),
new CardStack(new Point(650, top), MyDeck.FetchCards(4)),
new CardStack(new Point(750, top), MyDeck.FetchCards(4)),
new CardStack(new Point(850, top), MyDeck.FetchCards(4)),
new CardStack(new Point(950, top), MyDeck.FetchCards(4))
);
PlayStacks.ForEach(
(System.Action<CardStack>)
delegate(CardStack s)
{
s.Cards.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemDeleted)
if (MyStatus.Ready)
s.RevealLastCard();
};
s.CardsMovedToStack +=
delegate
{
if (MyStatus.Ready)
{
MyStatus.Score--;
MyStatus.Moves++;
MyStatus.Update();
}
};
}
);
DealStacks.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemAdded)
示例4: SolitaireGame
public SolitaireGame()
{
Width = DefaultWidth;
Height = DefaultHeight;
System.Console.WriteLine("--- solitare ---");
this.MyStatus = new StatusControl().AttachContainerTo(this).MoveContainerTo(
(DefaultWidth - StatusControl.Width) / 2,
(DefaultHeight - StatusControl.Height)
);
var GameOverBox = new TextBox
{
Width = DefaultWidth,
TextAlignment = System.Windows.TextAlignment.Center,
Foreground = Brushes.White,
Background = Brushes.Transparent,
BorderThickness = new Thickness(0),
IsReadOnly = true,
FontSize = 24,
}.MoveTo(0, DefaultHeight / 2).AttachTo(this);
// add autoscroll ?
this.MyDeck.SizeTo(DefaultWidth, DefaultHeight);
this.MyDeck.AttachContainerTo(this);
this.MyDeck.GetRank = e => (int)RankMapping[e];
System.Console.WriteLine("adding card infos... ");
MyDeck.UnusedCards.AddRange(CardInfo.FullDeck());
this.MyStatus.Score = -1;
this.MyStatus.CardsLeft = this.MyDeck.UnusedCards.Count;
this.MyStatus.Update();
MyDeck.Stacks.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemAdded)
{
// fixme: dynamically set backside for this card
//var s = MyDeck.Stacks[args.NewIndex];
//s.SetBackground(MyDeck.GfxPath + "/spider.empty.png");
}
};
System.Console.WriteLine("creating stacklists... ");
PlayStacks = MyDeck.CreateStackList();
TempStacks = MyDeck.CreateStackList();
GoalStacks = MyDeck.CreateStackList();
PlayStacks.ForEachNewItem(
delegate(CardStack s)
{
s.CardMargin = new Vector { Y = 20 };
s.Update();
s.Cards.ListChanged +=
(sender, args) =>
{
if (args.ListChangedType == ListChangedType.ItemDeleted)
s.RevealLastCard();
};
}
);
GameOver += delegate
{
GameOverBox.Text = "Congratulations! You Won!";
};
System.Console.WriteLine("creating goalstack... ");
var Margin = (DefaultWidth - CardInfo.Width * 7) / 8;
var ReserveStack = new CardStack().MoveTo(Margin, Margin);
var UsedChoiceStack = new CardStack().MoveTo(Margin + CardInfo.Width + Margin, Margin);
var ChoiceStack = new CardStack().MoveTo(Margin + CardInfo.Width + Margin, Margin);
TempStacks.AddRange(
ReserveStack,
UsedChoiceStack,
ChoiceStack
);
ReserveStack.CardMargin.X = 0;
//.........这里部分代码省略.........
示例5: LoadTorrentQueryModels
private async Task LoadTorrentQueryModels()
{
var result = (await TorrentsQuery.GetTorrentQueryModelsAsync());
Torrents = new BindingList<TorrentQueryModel>(result);
var totalFileSize = new FileSize();
Torrents.ForEach(it => { totalFileSize += it.FileSize; });
TotalSize = totalFileSize.RawValue;
}