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


C# BindingList.AddRange方法代码示例

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


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

示例1: AddRangeTest

 public void AddRangeTest()
 {
     BindingList<string> b1 = new BindingList<string>() { "a", "b" };
     BindingList<string> b2 = new BindingList<string>();
     b2.AddRange(b1);
     Assert.AreEqual(2, b2.Count);
 }
开发者ID:austriapro,项目名称:e-zustellung-privat-word-addin,代码行数:7,代码来源:BindingListExtensionTests.cs

示例2: UpdateDataGridVersions

 /// <summary>
 /// Gets a list of <see cref="SelectionCandidate"/>s from the <see cref="ISolver"/> to populate <see cref="dataGridVersions"/>.
 /// </summary>
 private void UpdateDataGridVersions()
 {
     var candidates = checkBoxShowAllVersions.Checked ? _candidates : _candidates.Where(candidate => candidate.IsSuitable);
     var list = new BindingList<SelectionCandidate> {AllowEdit = true, AllowNew = false};
     list.AddRange(candidates);
     dataGridVersions.DataSource = list;
 }
开发者ID:modulexcite,项目名称:0install-win,代码行数:10,代码来源:InterfaceDialog.cs

示例3: 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

示例4: SpiderGame

        public SpiderGame(CardInfo.SuitEnum[] level)
        {
            Width = DefaultWidth;
            Height = DefaultHeight;

            //this.ClipTo(0, 0, DefaultWidth, DefaultHeight);

            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!";
            };


            // add autoscroll ?
            this.MyDeck.SizeTo(DefaultWidth, DefaultHeight);
            this.MyDeck.AttachContainerTo(this);
            this.MyDeck.GetRank = e => (int)RankMapping[e];
            this.MyDeck.CardCustomBackgroundSource = new Abstractatech.Avalon.Cards.Avalon.Images.spider().Source;


            //this.MyDeck.Overlay.Opacity = 0.6;

            MyStatus = new StatusControl().AttachContainerTo(this).MoveContainerTo(
                (DefaultWidth - StatusControl.Width) / 2,
                (DefaultHeight - StatusControl.Height)
            );
            MyStatus.Container.Hide();

            System.Console.WriteLine("--- spider ---");






            System.Console.WriteLine("adding card infos... ");

            MyDeck.UnusedCards.AddRange(CardInfo.By(2, level));




            System.Console.WriteLine("creating stacklists... ");

            DealStacks = MyDeck.CreateStackList();
            PlayStacks = MyDeck.CreateStackList();
            DeadStacks = MyDeck.CreateStackList();

            PlayStacks.ListChanged +=
                (sender, args) =>
                {
                    if (args.ListChangedType == ListChangedType.ItemAdded)
                    {
                        var s = PlayStacks[args.NewIndex];


                    }

                };



            DeadStacks.ListChanged +=
                (sender, args) =>
                {
                    if (args.ListChangedType == ListChangedType.ItemAdded)
                    {
                        var s = DeadStacks[args.NewIndex];

                        //s.Control.Hide();

                        s.CardMargin = new Vector { X = 2, Y = 0 };

                        s.Cards.ListChanged +=
                            (sender2, args2) =>
                            {
                                if (args2.ListChangedType == ListChangedType.ItemAdded)
                                {
                                    //s[args2.NewIndex].Enabled = false;
                                }

                            };

                    }
                };


            #region drag rules
            MyDeck.ApplyCardRules += delegate(Card c)
//.........这里部分代码省略.........
开发者ID:dcarter16,项目名称:avaloncardgames,代码行数:101,代码来源:SpiderGame.cs

示例5: 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

示例6: ScrapeTitle

        /// <summary>
        /// Scrapes the Title value
        /// </summary>
        /// <param name="id">The MovieUniqueId for the scraper.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="output">The scraped Title value.</param>
        /// <param name="alternatives">Alternative namings found for a title.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>Scrape succeeded [true/false]</returns>
        public new bool ScrapeTitle(string id, int threadID, out string output, out BindingList<string> alternatives, string logCatagory)
        {
            output = string.Empty;
            alternatives = new BindingList<string>();

            try
            {
                var html = this.GetHtml("main", threadID, id);
                var releaseInfoHtml = this.GetHtml("releaseinfo", threadID, id);

                output = YRegex.Match("(<title>)(.*)( [(].*</title>)", html, 2, true);

                var titleAltHtml = YRegex.Match(
                    @"\(AKA\)</a></h5><table\sborder=""0""\scellpadding=""2"">(?<html>.*?)</tr></table>",
                    releaseInfoHtml, 
                    "html");

                var altTitles = YRegex.Matches(
                    @"<td>(?<name>.*?)</td><td>(?<details>.*?)</td>",
                    titleAltHtml,
                    "name",
                    "details",
                    true);

                alternatives.AddRange(from s in altTitles where !s.Value.ToLower().Contains(new[] { "imax ", "working ", "fake " }) select s.Key);

                if (html.Contains("title-extra"))
                {
                    var origTitle =
                        YRegex.Match(
                            @"class=""title-extra"">(?<title>.*?) <i>\(original title\)</i>",
                            html,
                            "title");

                    if (origTitle.Trim().Length > 0)
                    {
                        output = origTitle;
                    }
                }

                output = Regex.Replace(output, @"\(\d{4}\)", string.Empty);

                output = Tools.Clean.Text.ValidizeResult(output);

                return output.IsFilled();
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
开发者ID:rsanch1,项目名称:YANFOE.v2,代码行数:61,代码来源:IMDB.cs

示例7: MineMapLoader

        public MineMapLoader(BindingList<MineFieldButton> Context)
        {
            this.Context = Context;

            const int ProgressbarWidth = 16;

            var Progressbar = Enumerable.Range(0, ProgressbarWidth).ToArray(
                i =>
                {
                    var k = new MineFieldButton
                    {
                        IndexX = i - ProgressbarWidth / 2,
                        IndexY = 0,
                        IsEnabled = false,
                        BackgroundColor = Colors.Gray
                    };

                    Context.Add(k);

                    return k;
                }
            );

            var Gradient = new[] {
                Colors.Red,
                Colors.Gray,
                Colors.Gray
            }.ToGradient(Progressbar.Length);

            var ProgressbarTimer = (1000 / 24).AtIntervalWithCounter(
                c =>
                {
                    for (int i = 0; i < Progressbar.Length; i++)
                    {
                        Progressbar[Progressbar.Length - 1 - i].BackgroundColor = Gradient.AtModulus(c + i);
                    }
                }
            );

            Action<double, Color> SetPercentage =
                (value, color) =>
                {
                    var k = Math.Ceiling(ProgressbarWidth * value);

                    for (int i = 0; i < Progressbar.Length; i++)
                    {
                        if (i < k)
                            Progressbar[i].BackgroundColor = color;
                        else
                            Progressbar[i].BackgroundColor = Colors.Gray;
                    }
                };

            const int ChunkLoad = 8;

            Action<MineFieldButton[], Action> PrepareCache =
                (a, done) =>
                {
                    var n = new List<MineFieldButton>();
                    a.ForEach(
                        (j, next) =>
                        {
                            j.CachedNeighbours = j.Neighbours.ToArray();
                            j.CachedRegion = j.Region.ToArray();

                            n.Add(j);
                            SetPercentage((double)n.Count / (double)a.Length, Colors.Red);

                            if (n.Count % ChunkLoad == 0)
                                1.AtDelay(next);
                            else
                                next();
                        }
                    )(
                        delegate
                        {
                            foreach (var k in Progressbar)
                            {
                                Context.Remove(k);
                            }

                            Context.AddRange(a.ToArray());

                            done();
                        }
                    );
                };

            this.Prepare =
                (i, done) =>
                {
                    ProgressbarTimer.Stop();

                    foreach (var k in Progressbar)
                    {
                        k.BackgroundColor = Colors.Gray;
                    }

                    var a = i.ToArray();
                    var n = new List<MineFieldButton>();
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zproxygames-svn-to-git,代码行数:101,代码来源:MineMapLoader.cs


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