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


C# BindingList.ForEach方法代码示例

本文整理汇总了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
//.........这里部分代码省略.........
开发者ID:dcarter16,项目名称:avaloncardgames,代码行数:101,代码来源:FreeCellGame.cs

示例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();
开发者ID:dcarter16,项目名称:avaloncardgames,代码行数:67,代码来源:SpiderGame.cs

示例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)
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:67,代码来源:Spider.cs

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

示例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;
        }
开发者ID:klym1,项目名称:Toloka-Archive,代码行数:12,代码来源:vm.cs


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