本文整理汇总了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);
}
示例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;
}
示例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
//.........这里部分代码省略.........
示例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)
//.........这里部分代码省略.........
示例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;
//.........这里部分代码省略.........
示例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;
}
}
示例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>();
//.........这里部分代码省略.........