本文整理汇总了C#中BindingList.ForEachNewItem方法的典型用法代码示例。如果您正苦于以下问题:C# BindingList.ForEachNewItem方法的具体用法?C# BindingList.ForEachNewItem怎么用?C# BindingList.ForEachNewItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BindingList
的用法示例。
在下文中一共展示了BindingList.ForEachNewItem方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
//.........这里部分代码省略.........