本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.AddControl方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.AddControl方法的具体用法?C# TableLayoutPanel.AddControl怎么用?C# TableLayoutPanel.AddControl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TableLayoutPanel
的用法示例。
在下文中一共展示了TableLayoutPanel.AddControl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetGames
public void SetGames(RecentGames games)
{
if (games == null || games.GameStatistics.Count < 1)
return;
if (InvokeRequired)
{
Invoke(new Action<RecentGames>(SetGames), games);
return;
}
RemoveAll(p => (p.Tag as string) == "Recent");
var layout = new TableLayoutPanel
{
Dock = DockStyle.Fill,
Margin = Padding.Empty,
};
const int rows = 5;
const int cols = 2;
var list = games.GameStatistics.OrderByDescending(p => p.GameId).ToList();
for (int x = 0; x < cols; x++)
{
for (int y = 0; y < rows; y++)
{
int idx = y + (x * rows);
if (idx >= list.Count)
break;
var game = list[idx];
if (game.ChampionId == 0)
continue;
var won = game.Statistics.GetInt(RawStat.WIN) != 0;
var kills = game.Statistics.GetInt(RawStat.CHAMPION_KILLS);
var deaths = game.Statistics.GetInt(RawStat.DEATHS);
var assists = game.Statistics.GetInt(RawStat.ASSISTS);
var left = game.Leaver;
var botgame = game.QueueType == "BOT";
bool ranked = false;
if (game.QueueType == "RANKED_SOLO_5x5")
{
ranked = true;
}
var wonlabel = CreateLabel(string.Format("{0}{1}{2}", left ? "[L] " : "", ranked ? "[RS] " : "", won ? "Won" : "Lost"));
wonlabel.ForeColor = won ? Color.Green : Color.Red;
var kdrlbl = CreateLabel(string.Format("({0}/{1}/{2})", kills, deaths, assists));
kdrlbl.ForeColor = GetKdrColor(kills, deaths);
var champicon = new PictureBox
{
Image = ChampIcons.Get(game.ChampionId),
Margin = Padding.Empty,
SizeMode = PictureBoxSizeMode.StretchImage,
Size = new Size(20, 20)
};
if (botgame)
wonlabel.ForeColor = kdrlbl.ForeColor = Color.Black;
var controls = new List<Control>
{
champicon,
wonlabel,
kdrlbl,
CreateSpellPicture(game.Spell1),
CreateSpellPicture(game.Spell2)
};
//Add a space between the last column in each set.
controls[controls.Count - 1].Margin = new Padding(0, 0, 5, 0);
for (int i = 0; i < controls.Count; i++)
{
layout.AddControl(controls[i], i + x * controls.Count, y);
}
}
}
var tab = new TabPage("Recent")
{
BackColor = this.BackColor,
Tag = "Recent"
};
tab.Controls.Add(layout);
InfoTabs.TabPages.Add(tab);
}