[longomatch/redesign2: 20/140] Add property to retrieve only players that plays
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign2: 20/140] Add property to retrieve only players that plays
- Date: Tue, 24 May 2011 21:57:48 +0000 (UTC)
commit 4e97a4cbd8d45a3dd74720490972ee042775671d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat Nov 20 21:29:47 2010 +0100
Add property to retrieve only players that plays
LongoMatch/DB/TeamTemplate.cs | 11 +++++++++++
LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs | 21 ++++++++++-----------
2 files changed, 21 insertions(+), 11 deletions(-)
---
diff --git a/LongoMatch/DB/TeamTemplate.cs b/LongoMatch/DB/TeamTemplate.cs
index 4dc73db..9da016d 100644
--- a/LongoMatch/DB/TeamTemplate.cs
+++ b/LongoMatch/DB/TeamTemplate.cs
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Linq;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using LongoMatch.TimeNodes;
@@ -46,6 +47,16 @@ namespace LongoMatch.DB
return playersList;
}
}
+
+ public List<Player> PlayingPlayersList{
+ get {
+ var players =
+ from player in playersList
+ where player.Playing == true
+ select player;
+ return players.ToList() as List<Player>;
+ }
+ }
public void Clear() {
playersList.Clear();
diff --git a/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs b/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
index fb5b010..3070af8 100644
--- a/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
+++ b/LongoMatch/Gui/Dialog/PlayersSelectionDialog.cs
@@ -39,33 +39,32 @@ namespace LongoMatch.Gui.Dialog
public void SetPlayersInfo(TeamTemplate template) {
CheckButton button;
- int playersCount=0;
+ List<Player> playersList;
+ int i=0;
if (this.template != null)
return;
this.template = template;
-
- table1.NColumns =(uint)(template.PlayersCount/10);
+ playersList = template.PlayingPlayersList;
+
+ table1.NColumns =(uint)(playersList.Count/10);
table1.NRows =(uint) 10;
- foreach (Player player in template.PlayersList) {
- if (!player.Playing)
- continue;
-
+ foreach (Player player in playersList) {
button = new CheckButton();
button.Label = player.Number + "-" + player.Name;
- button.Name = playersCount.ToString();
+ button.Name = i.ToString();
button.Show();
- uint row_top =(uint)(playersCount%table1.NRows);
+ uint row_top =(uint)(i%table1.NRows);
uint row_bottom = (uint) row_top+1 ;
- uint col_left = (uint) playersCount/table1.NRows;
+ uint col_left = (uint) i/table1.NRows;
uint col_right = (uint) col_left+1 ;
table1.Attach(button,col_left,col_right,row_top,row_bottom);
checkButtonsDict.Add(button, player);
- playersCount++;
+ i++;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]