[longomatch] Document LongoMatch.DB and fix code style
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [longomatch] Document LongoMatch.DB and fix code style
- Date: Wed, 18 Nov 2009 20:53:32 +0000 (UTC)
commit 1fa481436f634e67f23442c4cdf9171b47603470
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Nov 18 21:48:02 2009 +0100
Document LongoMatch.DB and fix code style
LongoMatch/DB/DataBase.cs | 239 +++++++++++-------
LongoMatch/DB/Project.cs | 488 ++++++++++++++++++++++++++---------
LongoMatch/DB/ProjectDescription.cs | 145 +++++++----
LongoMatch/DB/Sections.cs | 249 ++++++++++++++----
LongoMatch/DB/Tag.cs | 42 ++--
LongoMatch/DB/TagsTemplate.cs | 24 +-
LongoMatch/DB/TeamTemplate.cs | 75 +++---
7 files changed, 872 insertions(+), 390 deletions(-)
---
diff --git a/LongoMatch/DB/DataBase.cs b/LongoMatch/DB/DataBase.cs
index 42562a6..56c9a70 100644
--- a/LongoMatch/DB/DataBase.cs
+++ b/LongoMatch/DB/DataBase.cs
@@ -11,7 +11,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -30,216 +30,281 @@ using LongoMatch.TimeNodes;
namespace LongoMatch.DB
{
-
-
+
+ /// <summary>
+ /// I am a proxy for the db4o database. I can store,retrieve, update and search
+ /// <see cref="LongoMatch.DB.Projects"/>.
+ /// Projects are uniquely indentified by their filename, assuming that you can't
+ /// create two projects for the same video file.
+ /// </summary>
public sealed class DataBase
{
// File path of the database
private string file;
- // Lock object
+ // Lock object
private object locker;
-
+
private Version dbVersion;
-
+
private const int MAYOR=0;
-
+
private const int MINOR=1;
-
+
+ /// <summary>
+ /// Creates a proxy for the database
+ /// </summary>
+ /// <param name="file">
+ /// A <see cref="System.String"/> with the database file path
+ /// </param>
public DataBase(string file)
{
this.file = file;
- if (!System.IO.File.Exists(file)){
+ if (!System.IO.File.Exists(file)) {
// Create new DB and add version
IObjectContainer db = Db4oFactory.OpenFile(file);
- try{
+ try {
dbVersion= new Version(MAYOR,MINOR);
db.Set(dbVersion);
}
- finally{
+ finally {
db.Close();
}
- }
- else{
+ }
+ else {
IObjectContainer db = Db4oFactory.OpenFile(file);
- try {
+ try {
IQuery query = db.Query();
query.Constrain(typeof(Version));
IObjectSet result = query.Execute();
- if (result.HasNext()){
- dbVersion = (Version)result.Next();
- }
- else{
+ if (result.HasNext()) {
+ dbVersion = (Version)result.Next();
+ }
+ else {
dbVersion = new Version (0,0);
}
- }
+ }
finally
{
db.Close();
-
+
}
}
locker = new object();
}
-
- public Version Version{
- get{return dbVersion;}
+
+ //// <value>
+ /// The database version
+ /// </value>
+ public Version Version {
+ get {
+ return dbVersion;
+ }
}
- public List<ProjectDescription> GetAllProjects(){
- lock(this.locker){
+ /// <summary>
+ /// Retrieve all the projects from the database. This method don't return the
+ /// the whole <see cref="LongoMatch.DB.Project"/> but the projects fields to
+ /// create a <see cref="LongoMatch.DB.ProjectDescription"/> to make the seek
+ /// faster.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="List"/>
+ /// </returns>
+ public List<ProjectDescription> GetAllProjects() {
+ lock (this.locker) {
List<ProjectDescription> list = new List<ProjectDescription>();
IObjectContainer db = Db4oFactory.OpenFile(file);
db.Ext().Configure().ActivationDepth(1);
- try {
+ try {
IQuery query = db.Query();
query.Constrain(typeof(Project));
IObjectSet result = query.Execute();
- while (result.HasNext()){
+ while (result.HasNext()) {
Project p = (Project)result.Next();
db.Activate(p.File,3);
ProjectDescription pd = new ProjectDescription(p.File.FilePath,
- p.LocalName, p.VisitorName,
- p.Season,p.Competition,
- p.LocalGoals,p.VisitorGoals,
- p.MatchDate,p.File.Preview);
- list.Add(pd);
- }
- return list;
- }
+ p.LocalName, p.VisitorName,
+ p.Season,p.Competition,
+ p.LocalGoals,p.VisitorGoals,
+ p.MatchDate,p.File.Preview);
+ list.Add(pd);
+ }
+ return list;
+ }
finally
{
CloseDB(db);
- }
+ }
}
}
-
- public Project GetProject(String filename){
+
+ /// <summary>
+ /// Search and return a project in the database. Returns null if the
+ /// project is not found
+ /// </summary>
+ /// <param name="filename">
+ /// A <see cref="System.String"/> with the project's video file name
+ /// </param>
+ /// <returns>
+ /// A <see cref="LongoMatch.DB.Project"/>
+ /// </returns>
+ public Project GetProject(String filename) {
Project ret;
- lock(this.locker){
+ lock (this.locker) {
IObjectContainer db = Db4oFactory.OpenFile(file);
- try {
+ try {
IQuery query = db.Query();
query.Constrain(typeof(Project));
query.Descend("file").Descend("filePath").Constrain(filename);
IObjectSet result = query.Execute();
ret = (Project) db.Ext().PeekPersisted(result.Next(),10,true);
return ret;
- }
+ }
finally
{
CloseDB(db);
}
}
}
-
- public void AddProject (Project project){
- lock(this.locker){
- IObjectContainer db = Db4oFactory.OpenFile(file);
- try
+
+ /// <summary>
+ /// Add a project to the databse
+ /// </summary>
+ /// <param name="project">
+ /// A <see cref="Project"/> to add
+ /// </param>
+ public void AddProject (Project project) {
+ lock (this.locker) {
+ IObjectContainer db = Db4oFactory.OpenFile(file);
+ try
{
- if (!this.Exists(project.File.FilePath,db)){
+ if (!this.Exists(project.File.FilePath,db)) {
db.Set (project);
db.Commit();
}
else throw new Exception (Catalog.GetString("The Project for this video file already exists.")+"\n"+Catalog.GetString("Try to edit it whit the Database Manager"));
- }
+ }
finally {
CloseDB(db);
}
- }
+ }
}
-
- public void RemoveProject(string filePath){
- lock(this.locker){
+
+ /// <summary>
+ /// Delete a project from the database
+ /// </summary>
+ /// <param name="filePath">
+ /// A <see cref="System.String"/> with the project's video file path
+ /// </param>
+ public void RemoveProject(string filePath) {
+ lock (this.locker) {
SetDeleteCascadeOptions();
IObjectContainer db = Db4oFactory.OpenFile(file);
- try {
+ try {
IQuery query = db.Query();
query.Constrain(typeof(Project));
query.Descend("file").Descend("filePath").Constrain(filePath);
IObjectSet result = query.Execute();
Project project = (Project)result.Next();
- db.Delete(project);
+ db.Delete(project);
db.Commit();
- }
+ }
finally
{
CloseDB(db);
}
}
}
-
- public void UpdateProject(Project project, string previousFileName){
- lock(this.locker){
- bool error = false;
+
+ /// <summary>
+ /// Updates a project in the database. Because a <see cref="LongoMatch.DB.Project"/> has
+ /// many objects associated, a simple update would leave in the databse many orphaned objects.
+ /// Therefore we need to delete the old project a replace it with the changed one. We need to
+ /// now the old file path associate to this project in case it has been changed in the update
+ /// </summary>
+ /// <param name="project">
+ /// A <see cref="Project"/> to update
+ /// </param>
+ /// <param name="previousFileName">
+ /// A <see cref="System.String"/> with the old file path
+ /// </param>
+ public void UpdateProject(Project project, string previousFileName) {
+ lock (this.locker) {
+ bool error = false;
// Configure db4o to cascade on delete for each one of the objects stored in a Project
SetDeleteCascadeOptions();
IObjectContainer db = Db4oFactory.OpenFile(file);
try {
// We look for a project with the same filename
- if (!Exists(project.File.FilePath,db)){
+ if (!Exists(project.File.FilePath,db)) {
IQuery query = db.Query();
query.Constrain(typeof(Project));
query.Descend("file").Descend("filePath").Constrain(previousFileName);
- IObjectSet result = query.Execute();
+ IObjectSet result = query.Execute();
//Get the stored project and replace it with the new one
Project fd = (Project)result.Next();
- db.Delete(fd);
+ db.Delete(fd);
// Add the updated project
- db.Set(project);
+ db.Set(project);
db.Commit();
}
- else
- error = true;
+ else
+ error = true;
}
- finally{
+ finally {
CloseDB(db);
if (error)
throw new Exception();
}
- }
+ }
}
-
- public void UpdateProject(Project project){
- lock(this.locker){
- SetDeleteCascadeOptions();
+
+ /// <summary>
+ /// Updates a project in the databse whose file path hasn't changed
+ /// </summary>
+ /// <param name="project">
+ /// A <see cref="Project"/> to update
+ /// </param>
+ public void UpdateProject(Project project) {
+ lock (this.locker) {
+ SetDeleteCascadeOptions();
IObjectContainer db = Db4oFactory.OpenFile(file);
- try {
+ try {
IQuery query = db.Query();
query.Constrain(typeof(Project));
query.Descend("file").Descend("filePath").Constrain(project.File.FilePath);
- IObjectSet result = query.Execute();
+ IObjectSet result = query.Execute();
//Get the stored project and replace it with the new one
Project fd = (Project)result.Next();
- db.Delete(fd);
- db.Set(project);
+ db.Delete(fd);
+ db.Set(project);
db.Commit();
- }
+ }
finally
{
- CloseDB(db);
+ CloseDB(db);
}
- }
+ }
}
-
- private void CloseDB(IObjectContainer db){
+
+ private void CloseDB(IObjectContainer db) {
db.Ext().Purge();
db.Close();
}
-
- private void SetDeleteCascadeOptions(){
+
+ private void SetDeleteCascadeOptions() {
Db4oFactory.Configure().ObjectClass(typeof(Project)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(Sections)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(TimeNode)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(Time)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(Team)).CascadeOnDelete(true);
- Db4oFactory.Configure().ObjectClass(typeof(HotKey)).CascadeOnDelete(true);
+ Db4oFactory.Configure().ObjectClass(typeof(HotKey)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(Player)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(TeamTemplate)).CascadeOnDelete(true);
Db4oFactory.Configure().ObjectClass(typeof(Drawing)).CascadeOnDelete(true);
}
-
- private void SetUpdateCascadeOptions(){
+
+ private void SetUpdateCascadeOptions() {
Db4oFactory.Configure().ObjectClass(typeof(Project)).CascadeOnUpdate(true);
Db4oFactory.Configure().ObjectClass(typeof(Sections)).CascadeOnUpdate(true);
Db4oFactory.Configure().ObjectClass(typeof(TimeNode)).CascadeOnUpdate(true);
@@ -250,8 +315,8 @@ namespace LongoMatch.DB
Db4oFactory.Configure().ObjectClass(typeof(TeamTemplate)).CascadeOnUpdate(true);
Db4oFactory.Configure().ObjectClass(typeof(Drawing)).CascadeOnUpdate(true);
}
-
- private bool Exists(string filename, IObjectContainer db){
+
+ private bool Exists(string filename, IObjectContainer db) {
IQuery query = db.Query();
query.Constrain(typeof(Project));
query.Descend("file").Descend("filePath").Constrain(filename);
diff --git a/LongoMatch/DB/Project.cs b/LongoMatch/DB/Project.cs
index 5e99c95..f518204 100644
--- a/LongoMatch/DB/Project.cs
+++ b/LongoMatch/DB/Project.cs
@@ -11,7 +11,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -29,15 +29,26 @@ using LongoMatch.Video.Utils;
namespace LongoMatch.DB
{
-
+
+ /// <summary>
+ /// I hold the information needed by a project and provide persistency using
+ /// the db4o database.
+ /// I'm structured in the following way:
+ /// -Project Description (<see cref="LongoMatch.Utils.PreviewMediaFile"/>
+ /// -1 Categories Template
+ /// -1 Local Team Template
+ /// -1 Visitor Team Template
+ /// -1 list of <see cref="LongoMatch.TimeNodes.MediaTimeNode"/> for each category
+ /// </summary>
+ ///
[Serializable]
public class Project : IComparable
{
-
+
private PreviewMediaFile file;
-
+
private string title;
-
+
private string localName;
private string visitorName;
@@ -45,130 +56,292 @@ namespace LongoMatch.DB
private int localGoals;
private int visitorGoals;
-
+
private DateTime matchDate;
-
+
private string season;
-
+
private string competition;
-
+
private Sections sections;
private List<List<MediaTimeNode>> sectionPlaysList;
-
+
private TeamTemplate visitorTeamTemplate;
-
+
private TeamTemplate localTeamTemplate;
//Keep this fiel for DB retrocompatibility
- private List<MediaTimeNode>[] dataSectionArray;
-
-
- public Project(PreviewMediaFile file, String localName, String visitorName, String season, String competition, int localGoals,
- int visitorGoals, DateTime matchDate, Sections sections, TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate) {
-
+ private List<MediaTimeNode>[] dataSectionArray;
+
+ /// <summary>
+ /// Creates a new project
+ /// </summary>
+ /// <param name="file">
+ /// A <see cref="PreviewMediaFile"/>: video file information
+ /// </param>
+ /// <param name="localName">
+ /// A <see cref="System.String"/>: local team's name
+ /// </param>
+ /// <param name="visitorName">
+ /// A <see cref="System.String"/>: visitor team's name
+ /// </param>
+ /// <param name="season">
+ /// A <see cref="System.String"/>: season information
+ /// </param>
+ /// <param name="competition">
+ /// A <see cref="System.String"/>: competition information
+ /// </param>
+ /// <param name="localGoals">
+ /// A <see cref="System.Int32"/>: local team's goals
+ /// </param>
+ /// <param name="visitorGoals">
+ /// A <see cref="System.Int32"/>: visitor team's goals
+ /// </param>
+ /// <param name="matchDate">
+ /// A <see cref="DateTime"/>: game date
+ /// </param>
+ /// <param name="sections">
+ /// A <see cref="Sections"/>: categories template
+ /// </param>
+ /// <param name="localTeamTemplate">
+ /// A <see cref="TeamTemplate"/>: local team template
+ /// </param>
+ /// <param name="visitorTeamTemplate">
+ /// A <see cref="TeamTemplate"/>: visitor team template
+ /// </param>
+ #region Constructors
+ public Project(PreviewMediaFile file, String localName, String visitorName,
+ String season, String competition, int localGoals,
+ int visitorGoals, DateTime matchDate, Sections sections,
+ TeamTemplate localTeamTemplate, TeamTemplate visitorTeamTemplate) {
+
this.file = file;
this.localName = localName;
this.visitorName = visitorName;
this.localGoals = localGoals;
this.visitorGoals = visitorGoals;
- this.matchDate = matchDate;
+ this.matchDate = matchDate;
this.season = season;
this.competition = competition;
this.localTeamTemplate = localTeamTemplate;
this.visitorTeamTemplate = visitorTeamTemplate;
this.sections = sections;
- this.sectionPlaysList = new List<List<MediaTimeNode>>();
-
- for (int i=0;i<sections.Count;i++){
+ this.sectionPlaysList = new List<List<MediaTimeNode>>();
+
+ for (int i=0;i<sections.Count;i++) {
sectionPlaysList.Add(new List<MediaTimeNode>());
- }
-
- this.Title = System.IO.Path.GetFileNameWithoutExtension(this.file.FilePath);
- }
-
- public void Clear(){
- //Help the GC freeing objects
- foreach (List<MediaTimeNode> list in sectionPlaysList)
- list.Clear();
- sectionPlaysList.Clear();
- Sections.Clear();
- visitorTeamTemplate.Clear();
- localTeamTemplate.Clear();
- sectionPlaysList=null;
- Sections=null;
- visitorTeamTemplate=null;
- localTeamTemplate=null;
+ }
+
+ this.Title = System.IO.Path.GetFileNameWithoutExtension(this.file.FilePath);
}
-
+ #endregion
+
+ #region Properties
+ /// <value>
+ /// Video File
+ /// </value>
public PreviewMediaFile File {
- get{return file;}
- set{file=value;}
- }
+ get {
+ return file;
+ }
+ set {
+ file=value;
+ }
+ }
+ /// <value>
+ /// Project title
+ /// </value>
public String Title {
- get{return title;}
- set{title=value;}
+ get {
+ return title;
+ }
+ set {
+ title=value;
+ }
}
-
- public String Season{
- get{return season;}
- set{season = value;}
+
+ /// <value>
+ /// Season description
+ /// </value>
+ public String Season {
+ get {
+ return season;
+ }
+ set {
+ season = value;
+ }
}
-
- public String Competition{
- get{return competition;}
- set{competition= value;}
+
+ /// <value>
+ /// Competition description
+ /// </value>
+ public String Competition {
+ get {
+ return competition;
+ }
+ set {
+ competition= value;
+ }
}
-
+
+ /// <value>
+ /// Local team name
+ /// </value>
public String LocalName {
- get{ return localName;}
- set{localName=value;}
+ get {
+ return localName;
+ }
+ set {
+ localName=value;
+ }
}
-
+
+ /// <value>
+ /// Visitor team name
+ /// </value>
public String VisitorName {
- get{ return visitorName;}
- set{visitorName=value;}
+ get {
+ return visitorName;
+ }
+ set {
+ visitorName=value;
+ }
}
-
+
+ /// <value>
+ /// Local team goals
+ /// </value>
public int LocalGoals {
- get{ return localGoals;}
- set{localGoals=value;}
+ get {
+ return localGoals;
+ }
+ set {
+ localGoals=value;
+ }
}
-
+
+ /// <value>
+ /// Visitor team goals
+ /// </value>
public int VisitorGoals {
- get{ return visitorGoals;}
- set{visitorGoals=value;}
- }
-
+ get {
+ return visitorGoals;
+ }
+ set {
+ visitorGoals=value;
+ }
+ }
+
+ /// <value>
+ /// Game date
+ /// </value>
public DateTime MatchDate {
- get{ return matchDate;}
- set{ matchDate=value;}
+ get {
+ return matchDate;
+ }
+ set {
+ matchDate=value;
+ }
}
-
- public Sections Sections{
- get{ return this.sections;}
- set {this.sections = value;}
+
+ /// <value>
+ /// Categories template
+ /// </value>
+ public Sections Sections {
+ get {
+ return this.sections;
+ }
+ set {
+ this.sections = value;
+ }
}
-
- public TeamTemplate LocalTeamTemplate{
- get{return localTeamTemplate;}
- set{localTeamTemplate=value;}
+
+ /// <value>
+ /// Local team template
+ /// </value>
+ public TeamTemplate LocalTeamTemplate {
+ get {
+ return localTeamTemplate;
+ }
+ set {
+ localTeamTemplate=value;
+ }
}
-
- public TeamTemplate VisitorTeamTemplate{
- get{return visitorTeamTemplate;}
- set{visitorTeamTemplate=value;}
+
+ /// <value>
+ /// Visitor team template
+ /// </value>
+ public TeamTemplate VisitorTeamTemplate {
+ get {
+ return visitorTeamTemplate;
+ }
+ set {
+ visitorTeamTemplate=value;
+ }
+ }
+ #endregion
+
+ #region Public Methods
+ /// <summary>
+ /// Frees all the project's resources helping the GC
+ /// </summary>
+ public void Clear() {
+ //Help the GC freeing objects
+ foreach (List<MediaTimeNode> list in sectionPlaysList)
+ list.Clear();
+ sectionPlaysList.Clear();
+ Sections.Clear();
+ visitorTeamTemplate.Clear();
+ localTeamTemplate.Clear();
+ sectionPlaysList=null;
+ Sections=null;
+ visitorTeamTemplate=null;
+ localTeamTemplate=null;
}
- public void AddSection(SectionsTimeNode tn){
+ /// <summary>
+ /// Adds a new analysis category to the project
+ /// </summary>
+ /// <param name="tn">
+ /// A <see cref="SectionsTimeNode"/>
+ /// </param>
+ public void AddSection(SectionsTimeNode tn) {
AddSectionAtPos(tn,sections.Count);
}
-
- public void AddSectionAtPos(SectionsTimeNode tn,int sectionIndex){
+
+ /// <summary>
+ /// Add a new category to the project at a given position
+ /// </summary>
+ /// <param name="tn">
+ /// A <see cref="SectionsTimeNode"/>: category default values
+ /// </param>
+ /// <param name="sectionIndex">
+ /// A <see cref="System.Int32"/>: position index
+ /// </param>
+ public void AddSectionAtPos(SectionsTimeNode tn,int sectionIndex) {
sectionPlaysList.Insert(sectionIndex,new List<MediaTimeNode>());
sections.AddSectionAtPos(tn,sectionIndex);
}
-
+
+ /// <summary>
+ /// Adds a new play to a given category
+ /// </summary>
+ /// <param name="dataSection">
+ /// A <see cref="System.Int32"/>: category index
+ /// </param>
+ /// <param name="start">
+ /// A <see cref="Time"/>: start time of the play
+ /// </param>
+ /// <param name="stop">
+ /// A <see cref="Time"/>: stop time of the play
+ /// </param>
+ /// <param name="thumbnail">
+ /// A <see cref="Pixbuf"/>: snapshot of the play
+ /// </param>
+ /// <returns>
+ /// A <see cref="MediaTimeNode"/>: created play
+ /// </returns>
public MediaTimeNode AddTimeNode(int dataSection, Time start, Time stop,Pixbuf thumbnail) {
MediaTimeNode tn ;
List<MediaTimeNode> playsList= sectionPlaysList[dataSection];
@@ -176,93 +349,156 @@ namespace LongoMatch.DB
string name = sections.GetName(dataSection) + " " +count;
tn = new MediaTimeNode(name, start, stop,"",file.Fps,thumbnail);
- playsList.Add(tn);
+ playsList.Add(tn);
return tn;
}
+ /// <summary>
+ /// Delete a play from the project
+ /// </summary>
+ /// <param name="tNode">
+ /// A <see cref="MediaTimeNode"/>: play to be deleted
+ /// </param>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: category the play belongs to
+ /// </param>
public void DeleteTimeNode(MediaTimeNode tNode,int section) {
- sectionPlaysList[section].Remove(tNode);
+ sectionPlaysList[section].Remove(tNode);
}
-
- public void DeleteSection(int sectionIndex){
+
+ /// <summary>
+ /// Delete a category
+ /// </summary>
+ /// <param name="sectionIndex">
+ /// A <see cref="System.Int32"/>: category index
+ /// </param>
+ public void DeleteSection(int sectionIndex) {
if (sections.Count == 1)
throw new Exception ("You can't remove the last Section");
sections.RemoveSection(sectionIndex);
- sectionPlaysList.RemoveAt(sectionIndex);
+ sectionPlaysList.RemoveAt(sectionIndex);
}
-
- public string[] GetSectionsNames(){
- return sections.GetSectionsNames();
+
+ /// <summary>
+ /// Return an array of strings with the categories names
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
+ public string[] GetSectionsNames() {
+ return sections.GetSectionsNames();
}
- public Time[] GetSectionsStartTimes(){
+ /// <summary>
+ /// Return an array of <see cref="LongoMatch.TimeNodes.Time"/> with
+ /// the categories default lead time
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public Time[] GetSectionsStartTimes() {
return sections.GetSectionsStartTimes();
- }
-
- public Time[] GetSectionsStopTimes(){
+ }
+
+ /// <summary>
+ /// Return an array of <see cref="LongoMatch.TimeNodes.Time"/> with
+ /// the categories default lag time
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public Time[] GetSectionsStopTimes() {
return sections.GetSectionsStopTimes();
- }
-
- public TreeStore GetModel (){
+ }
+
+ /// <summary>
+ /// Returns a <see cref="Gtk.TreeStore"/> in which project categories are
+ /// root nodes and their respectives plays child nodes
+ /// </summary>
+ /// <returns>
+ /// A <see cref="TreeStore"/>
+ /// </returns>
+ public TreeStore GetModel () {
Gtk.TreeStore dataFileListStore = new Gtk.TreeStore (typeof (MediaTimeNode));
- for (int i=0;i<sections.Count;i++){
+ for (int i=0;i<sections.Count;i++) {
Gtk.TreeIter iter = dataFileListStore.AppendValues (sections.GetTimeNode(i));
- foreach(MediaTimeNode tNode in sectionPlaysList[i]){
- dataFileListStore.AppendValues (iter,tNode);
- }
+ foreach (MediaTimeNode tNode in sectionPlaysList[i]) {
+ dataFileListStore.AppendValues (iter,tNode);
+ }
}
return dataFileListStore;
}
-
- public TreeStore GetLocalTeamModel (){
+
+ /// <summary>
+ /// Returns a <see cref="Gtk.TreeStore"/> for the local team in which players
+ /// are root nodes and their respectives tagged plays child nodes
+ /// </summary>
+ /// <returns>
+ /// A <see cref="TreeStore"/>
+ /// </returns>
+ public TreeStore GetLocalTeamModel () {
List<TreeIter> itersList = new List<TreeIter>();
Gtk.TreeStore dataFileListStore = new Gtk.TreeStore (typeof (object));
- for (int i=0;i<localTeamTemplate.PlayersCount;i++){
- itersList.Add(dataFileListStore.AppendValues (localTeamTemplate.GetPlayer(i)));
+ for (int i=0;i<localTeamTemplate.PlayersCount;i++) {
+ itersList.Add(dataFileListStore.AppendValues (localTeamTemplate.GetPlayer(i)));
}
- for (int i=0;i<sections.Count;i++){
- foreach(MediaTimeNode tNode in sectionPlaysList[i]){
- foreach (int player in tNode.LocalPlayers)
+ for (int i=0;i<sections.Count;i++) {
+ foreach (MediaTimeNode tNode in sectionPlaysList[i]) {
+ foreach (int player in tNode.LocalPlayers)
dataFileListStore.AppendValues (itersList[player],tNode);
- }
+ }
}
return dataFileListStore;
}
-
- public TreeStore GetVisitorTeamModel (){
+
+ /// <summary>
+ /// Returns a <see cref="Gtk.TreeStore"/> for the visitor team in which players
+ /// are root nodes and their respectives tagged plays child nodes
+ /// </summary>
+ /// <returns>
+ /// A <see cref="TreeStore"/>
+ /// </returns>
+ public TreeStore GetVisitorTeamModel () {
List<TreeIter> itersList = new List<TreeIter>();
Gtk.TreeStore dataFileListStore = new Gtk.TreeStore (typeof (object));
- for (int i=0;i<visitorTeamTemplate.PlayersCount;i++){
- itersList.Add(dataFileListStore.AppendValues (visitorTeamTemplate.GetPlayer(i)));
+ for (int i=0;i<visitorTeamTemplate.PlayersCount;i++) {
+ itersList.Add(dataFileListStore.AppendValues (visitorTeamTemplate.GetPlayer(i)));
}
- for (int i=0;i<sections.Count;i++){
- foreach(MediaTimeNode tNode in sectionPlaysList[i]){
- foreach (int player in tNode.VisitorPlayers)
+ for (int i=0;i<sections.Count;i++) {
+ foreach (MediaTimeNode tNode in sectionPlaysList[i]) {
+ foreach (int player in tNode.VisitorPlayers)
dataFileListStore.AppendValues (itersList[player],tNode);
- }
+ }
}
return dataFileListStore;
}
-
+
+ /// <summary>
+ /// Returns a list of plays' lists. Actually used by the timeline
+ /// </summary>
+ /// <returns>
+ /// A <see cref="List"/>
+ /// </returns>
public List<List<MediaTimeNode>> GetDataArray() {
return sectionPlaysList;
}
-
- public bool Equals(Project project){
+
+ public bool Equals(Project project) {
if (project == null)
return false;
else
- return this.File.FilePath.Equals(project.File.FilePath);
+ return this.File.FilePath.Equals(project.File.FilePath);
}
-
+
public int CompareTo(object obj) {
- if(obj is Project) {
+ if (obj is Project) {
Project project = (Project) obj;
return this.File.FilePath.CompareTo(project.File.FilePath);
}
else
- throw new ArgumentException("object is not a Project and cannot be compared");
+ throw new ArgumentException("object is not a Project and cannot be compared");
}
+ #endregion
}
}
diff --git a/LongoMatch/DB/ProjectDescription.cs b/LongoMatch/DB/ProjectDescription.cs
index ffd5a94..f774a23 100644
--- a/LongoMatch/DB/ProjectDescription.cs
+++ b/LongoMatch/DB/ProjectDescription.cs
@@ -1,32 +1,35 @@
-//
+//
// Copyright (C) 2009 Andoni Morales Alastruey
-//
+//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
+//
using System;
using Gdk;
namespace LongoMatch.DB
{
-
-
+
+ /// <summary>
+ /// I'm used like a presentation card for projects. I speed up the retrieval
+ /// from the database be using only the field required to describe a project
+ /// </summary>
public class ProjectDescription : IComparable
{
private string file;
-
+
private string localName;
private string visitorName;
@@ -34,87 +37,125 @@ namespace LongoMatch.DB
private int localGoals;
private int visitorGoals;
-
+
private DateTime matchDate;
-
+
private string season;
-
+
private string competition;
-
+
private Pixbuf preview;
-
+
public ProjectDescription(string file, String localName, String visitorName, String season, String competition, int localGoals,
- int visitorGoals, DateTime matchDate,Pixbuf preview)
+ int visitorGoals, DateTime matchDate,Pixbuf preview)
{
this.file = file;
this.localName = localName;
this.visitorName = visitorName;
this.localGoals = localGoals;
this.visitorGoals = visitorGoals;
- this.matchDate = matchDate;
+ this.matchDate = matchDate;
this.season = season;
this.competition = competition;
this.preview = preview;
}
-
+
public String Title {
- get{return System.IO.Path.GetFileNameWithoutExtension(file);}
+ get {
+ return System.IO.Path.GetFileNameWithoutExtension(file);
+ }
}
-
- public String File{
- get{return file;}
- set{file = value;}
+
+ public String File {
+ get {
+ return file;
+ }
+ set {
+ file = value;
+ }
}
-
- public String Season{
- get{return season;}
- set{season = value;}
+
+ public String Season {
+ get {
+ return season;
+ }
+ set {
+ season = value;
+ }
}
-
- public String Competition{
- get{return competition;}
- set{competition= value;}
+
+ public String Competition {
+ get {
+ return competition;
+ }
+ set {
+ competition= value;
+ }
}
-
+
public String LocalName {
- get{ return localName;}
- set{localName=value;}
+ get {
+ return localName;
+ }
+ set {
+ localName=value;
+ }
}
-
+
public String VisitorName {
- get{ return visitorName;}
- set{visitorName=value;}
+ get {
+ return visitorName;
+ }
+ set {
+ visitorName=value;
+ }
}
-
+
public int LocalGoals {
- get{ return localGoals;}
- set{localGoals=value;}
+ get {
+ return localGoals;
+ }
+ set {
+ localGoals=value;
+ }
}
-
+
public int VisitorGoals {
- get{ return visitorGoals;}
- set{visitorGoals=value;}
+ get {
+ return visitorGoals;
+ }
+ set {
+ visitorGoals=value;
+ }
}
-
-
+
+
public DateTime MatchDate {
- get{ return matchDate;}
- set{ matchDate=value;}
+ get {
+ return matchDate;
+ }
+ set {
+ matchDate=value;
+ }
}
-
- public Pixbuf Preview{
- get{return this.preview;}
- set{preview = value;}
+
+ public Pixbuf Preview {
+ get {
+ return this.preview;
+ }
+ set {
+ preview = value;
+ }
}
-
+
public int CompareTo(object obj) {
- if(obj is ProjectDescription) {
+ if (obj is ProjectDescription) {
ProjectDescription project = (ProjectDescription) obj;
return this.File.CompareTo(project.File);
}
else
- throw new ArgumentException("object is not a ProjectDescription and cannot be compared");
+ throw new ArgumentException("object is not a ProjectDescription and cannot be compared");
}
}
}
diff --git a/LongoMatch/DB/Sections.cs b/LongoMatch/DB/Sections.cs
index 7a94b69..aa6b5b8 100644
--- a/LongoMatch/DB/Sections.cs
+++ b/LongoMatch/DB/Sections.cs
@@ -11,7 +11,7 @@
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
@@ -24,129 +24,266 @@ using LongoMatch.TimeNodes;
namespace LongoMatch.DB
{
-
-
+
+ /// <summary>
+ /// I am a template for the analysis categories used in a project.
+ /// I describe each one of the categories and provide the default values
+ /// to use to create plys in a specific category.
+ /// The position of the category in the index is very important and should
+ /// respect the same index used in the plays list inside a project.
+ /// The <see cref="LongoMatch.DB.Project"/> must handle all the changes
+ /// </summary>
public class Sections
{
private List<SectionsTimeNode> sectionsList;
-
+
//These fields are not used but must be kept for DataBase compatiblity
private Color[] colorsArray;
private SectionsTimeNode[] timeNodesArray;
-
+
+ /// <summary>
+ /// Creates a new template
+ /// </summary>
public Sections()
{
- this.sectionsList = new List<SectionsTimeNode>();
+ this.sectionsList = new List<SectionsTimeNode>();
}
-
- public void Clear(){
+
+ /// <summary>
+ /// Clear the template
+ /// </summary>
+ public void Clear() {
sectionsList.Clear();
}
-
- public void AddSection(SectionsTimeNode tn){
+
+ /// <summary>
+ /// Adds a new analysis category to the template
+ /// </summary>
+ /// <param name="tn">
+ /// A <see cref="SectionsTimeNode"/>: category to add
+ /// </param>
+ public void AddSection(SectionsTimeNode tn) {
sectionsList.Add(tn);
- }
-
- public void AddSectionAtPos(SectionsTimeNode tn, int index){
+ }
+
+ /// <summary>
+ /// Adds a new category to the template at a given position
+ /// </summary>
+ /// <param name="tn">
+ /// A <see cref="SectionsTimeNode"/>: category to add
+ /// </param>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/>: position
+ /// </param>
+ public void AddSectionAtPos(SectionsTimeNode tn, int index) {
sectionsList.Insert(index,tn);
- }
-
- public void RemoveSection(int index){
+ }
+
+ /// <summary>
+ /// Delete a category from the templates using the it's index
+ /// </summary>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/>: position of the category to delete
+ /// </param>
+ public void RemoveSection(int index) {
sectionsList.RemoveAt(index);
}
-
- public int Count{
- get{return sectionsList.Count;}
+
+ //// <value>
+ /// Number of categories
+ /// </value>
+ public int Count {
+ get {
+ return sectionsList.Count;
+ }
}
-
- public List<SectionsTimeNode> SectionsTimeNodes{
- set{
+
+ //// <value>
+ /// Ordered list with all the categories
+ /// </value>
+ public List<SectionsTimeNode> SectionsTimeNodes {
+ set {
sectionsList.Clear();
sectionsList = value;
- }
- get{return sectionsList;}
+ }
+ get {
+ return sectionsList;
+ }
}
-
- public SectionsTimeNode GetSection(int section){
+
+ /// <summary>
+ /// Retrieves a category at a given index
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position of the category to retrieve
+ /// </param>
+ /// <returns>
+ /// A <see cref="SectionsTimeNode"/>: category retrieved
+ /// </returns>
+ public SectionsTimeNode GetSection(int section) {
return sectionsList[section];
}
-
- public string[] GetSectionsNames(){
+
+ /// <summary>
+ /// Returns an array if strings with the categories names
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String"/>
+ /// </returns>
+ public string[] GetSectionsNames() {
int count = sectionsList.Count;
string[] names = new string[count];
SectionsTimeNode tNode;
- for (int i=0; i<count; i++){
+ for (int i=0; i<count; i++) {
tNode = sectionsList[i];
names[i]=tNode.Name;
}
- return names;
+ return names;
}
-
- public Color[] GetColors(){
+
+ /// <summary>
+ /// Returns an array of the categories' color
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Color"/>
+ /// </returns>
+ public Color[] GetColors() {
int count = sectionsList.Count;
Color[] colors = new Color[count];
SectionsTimeNode tNode;
- for (int i=0; i<count; i++){
+ for (int i=0; i<count; i++) {
tNode = sectionsList[i];
colors[i]=tNode.Color;
}
return colors;
}
-
- public HotKey[] GetHotKeys(){
+
+ /// <summary>
+ /// Return an array of the hotkeys for this template
+ /// </summary>
+ /// <returns>
+ /// A <see cref="HotKey"/>
+ /// </returns>
+ public HotKey[] GetHotKeys() {
int count = sectionsList.Count;
HotKey[] hotkeys = new HotKey[count];
SectionsTimeNode tNode;
- for (int i=0; i<count; i++){
+ for (int i=0; i<count; i++) {
tNode = sectionsList[i];
hotkeys[i]=tNode.HotKey;
}
return hotkeys;
}
-
- public Time[] GetSectionsStartTimes(){
+
+ /// <summary>
+ /// Returns an array with the default start times
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public Time[] GetSectionsStartTimes() {
int count = sectionsList.Count;
Time[] startTimes = new Time[count];
SectionsTimeNode tNode;
- for (int i=0; i<count; i++){
+ for (int i=0; i<count; i++) {
tNode = sectionsList[i];
startTimes[i]=tNode.Start;
}
return startTimes;
}
-
- public Time[] GetSectionsStopTimes(){
+
+ /// <summary>
+ /// Returns an array with the defaul stop times
+ /// </summary>
+ /// <returns>
+ /// A <see cref="Time"/>
+ /// </returns>
+ public Time[] GetSectionsStopTimes() {
int count = sectionsList.Count;
Time[] stopTimes = new Time[count];
SectionsTimeNode tNode;
- for (int i=0; i<count; i++){
+ for (int i=0; i<count; i++) {
tNode = sectionsList[i];
stopTimes[i]=tNode.Start;
}
- return stopTimes;
- }
-
- public SectionsTimeNode GetTimeNode (int section){
+ return stopTimes;
+ }
+
+ /// <summary>
+ /// Returns a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="SectionsTimeNode"/>
+ /// </returns>
+ public SectionsTimeNode GetTimeNode (int section) {
return sectionsList [section];
}
-
- public string GetName ( int section){
+
+ /// <summary>
+ /// Returns the name for a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.String"/>: name of the category
+ /// </returns>
+ public string GetName (int section) {
return sectionsList[section].Name;
}
-
- public Time GetStartTime ( int section){
+
+ /// <summary>
+ /// Returns the start time for a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="Time"/>: start time
+ /// </returns>
+ public Time GetStartTime (int section) {
return sectionsList[section].Start;
}
-
- public Time GetStopTime ( int section){
+
+ /// <summary>
+ /// Returns the stop time for a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="Time"/>: stop time
+ /// </returns>
+ public Time GetStopTime (int section) {
return sectionsList[section].Stop;
}
-
- public Color GetColor (int section){
+
+ /// <summary>
+ /// Return the color for a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="Color"/>: color
+ /// </returns>
+ public Color GetColor (int section) {
return sectionsList[section].Color;
}
-
- public HotKey GetHotKey (int section){
+
+ /// <summary>
+ /// Returns the hotckey for a category at a given position
+ /// </summary>
+ /// <param name="section">
+ /// A <see cref="System.Int32"/>: position in the list
+ /// </param>
+ /// <returns>
+ /// A <see cref="HotKey"/>: hotkey for this category
+ /// </returns>
+ public HotKey GetHotKey (int section) {
return sectionsList[section].HotKey;
}
}
diff --git a/LongoMatch/DB/Tag.cs b/LongoMatch/DB/Tag.cs
index 1c2d822..1bca051 100644
--- a/LongoMatch/DB/Tag.cs
+++ b/LongoMatch/DB/Tag.cs
@@ -1,27 +1,27 @@
-//
+//
// Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
+//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//
using System;
namespace LongoMatch.DB
{
-
-
+
+
public class Tag
{
string text;
@@ -29,25 +29,29 @@ namespace LongoMatch.DB
{
this.text=text;
}
-
- public string Text{
- get{return text;}
- set{text=value;}
+
+ public string Text {
+ get {
+ return text;
+ }
+ set {
+ text=value;
+ }
}
-
- public bool Equals(Tag tagComp){
+
+ public bool Equals(Tag tagComp) {
return (this.text == tagComp.Text);
}
-
+
public override bool Equals (object obj)
{
Tag tag= obj as Tag;
- if (tag != null)
- return Equals(tag);
- else
- return false;
+ if (tag != null)
+ return Equals(tag);
+ else
+ return false;
}
-
+
public override int GetHashCode ()
{
return text.CompareTo("XXXXX") ^ 3 ;
diff --git a/LongoMatch/DB/TagsTemplate.cs b/LongoMatch/DB/TagsTemplate.cs
index 40ca257..df2cd52 100644
--- a/LongoMatch/DB/TagsTemplate.cs
+++ b/LongoMatch/DB/TagsTemplate.cs
@@ -1,28 +1,28 @@
-//
+//
// Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
+//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//
using System;
using System.Collections.Generic;
namespace LongoMatch.DB
{
-
-
+
+
public class TagsTemplate
{
List<Tag> tagsList;
@@ -30,16 +30,16 @@ namespace LongoMatch.DB
{
tagsList = new List<Tag>();
}
-
- public bool AddTag (Tag tag){
+
+ public bool AddTag (Tag tag) {
if (tagsList.Contains(tag))
- return false;
+ return false;
else
tagsList.Add(tag);
return true;
}
-
- public bool removeTag (Tag tag){
+
+ public bool removeTag (Tag tag) {
return tagsList.Remove(tag);
}
}
diff --git a/LongoMatch/DB/TeamTemplate.cs b/LongoMatch/DB/TeamTemplate.cs
index ff6c0ed..61feca2 100644
--- a/LongoMatch/DB/TeamTemplate.cs
+++ b/LongoMatch/DB/TeamTemplate.cs
@@ -1,20 +1,20 @@
-//
-// Copyright (C) 2007-2009 Andoni Morales Alastruey 2009
-//
+//
+// Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
-//
+//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
-//
+//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//
using System;
using System.Collections.Generic;
@@ -26,67 +26,66 @@ using LongoMatch.TimeNodes;
namespace LongoMatch.DB
{
[Serializable]
-
+
public class TeamTemplate
{
private List<Player> playersList;
-
-
-
- public TeamTemplate()
- {
- playersList = new List<Player>();
-
+
+ public TeamTemplate() {
+ playersList = new List<Player>();
}
-
- public void Clear(){
+
+ public void Clear() {
playersList.Clear();
}
-
- public int PlayersCount{
- get {return playersList.Count;}
+
+ public int PlayersCount {
+ get {
+ return playersList.Count;
+ }
}
-
- public void CreateDefaultTemplate(int playersCount){
- for (int i=0; i<playersCount;i++){
+
+ public void CreateDefaultTemplate(int playersCount) {
+ for (int i=0; i<playersCount;i++) {
playersList.Add(new Player("Player "+i,"",i,null));
}
}
-
- public void AddPlayer(Player player){
+
+ public void AddPlayer(Player player) {
playersList.Add(player);
}
-
- public void SetPlayersList(List<Player> playersList){
- this.playersList = playersList;
+
+ public void SetPlayersList(List<Player> playersList) {
+ this.playersList = playersList;
}
-
- public Player GetPlayer(int index){
+
+ public Player GetPlayer(int index) {
if (index >= PlayersCount)
- throw new Exception(String.Format("The actual team template doesn't have so many players. Requesting player {0} but players count is {1}",index, PlayersCount));
+ throw new Exception(String.Format("The actual team template doesn't have so many players. Requesting player {0} but players count is {1}",
+ index, PlayersCount));
return playersList[index];
}
-
- public List<Player> GetPlayersList(){
+
+ public List<Player> GetPlayersList() {
return playersList;
}
-
- public void Save(string filepath){
+
+ public void Save(string filepath) {
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(filepath, FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(stream, this);
stream.Close();
}
-
- public static TeamTemplate LoadFromFile(string filepath){
+
+ public static TeamTemplate LoadFromFile(string filepath) {
IFormatter formatter = new BinaryFormatter();
Stream stream = new FileStream(filepath, FileMode.Open, FileAccess.Read, FileShare.Read);
TeamTemplate obj = (TeamTemplate) formatter.Deserialize(stream);
stream.Close();
return obj;
}
-
- public static TeamTemplate DefautlTemplate(int playersCount){
+
+ public static TeamTemplate DefautlTemplate(int playersCount) {
TeamTemplate defaultTemplate = new TeamTemplate();
defaultTemplate.CreateDefaultTemplate(playersCount);
return defaultTemplate;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]