[longomatch/redesign3: 1/156] Start redesing of LongoMatch with the base elements
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch/redesign3: 1/156] Start redesing of LongoMatch with the base elements
- Date: Wed, 17 Aug 2011 22:16:16 +0000 (UTC)
commit 19370e06feee57795e586c4af8632ea07ba138c3
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sun Nov 21 15:33:42 2010 +0100
Start redesing of LongoMatch with the base elements
LongoMatch/Time/Category.cs | 133 +++++++++++++
LongoMatch/Time/Drawing.cs | 36 ++--
LongoMatch/Time/DrawingsList.cs | 69 ++++++-
LongoMatch/Time/HotKey.cs | 25 ++--
LongoMatch/Time/MediaTimeNode.cs | 367 -----------------------------------
LongoMatch/Time/PixbufTimeNode.cs | 33 +---
LongoMatch/Time/Play.cs | 295 ++++++++++++++++++++++++++++
LongoMatch/Time/PlayListPlay.cs | 68 +++++++
LongoMatch/Time/PlayListTimeNode.cs | 105 ----------
LongoMatch/Time/Player.cs | 125 +++---------
LongoMatch/Time/SectionsTimeNode.cs | 165 ----------------
LongoMatch/Time/Tag.cs | 28 +--
LongoMatch/Time/Time.cs | 71 +++-----
LongoMatch/Time/TimeNode.cs | 93 ++-------
14 files changed, 672 insertions(+), 941 deletions(-)
---
diff --git a/LongoMatch/Time/Category.cs b/LongoMatch/Time/Category.cs
new file mode 100644
index 0000000..77d6eab
--- /dev/null
+++ b/LongoMatch/Time/Category.cs
@@ -0,0 +1,133 @@
+// SectionsTimeNode.cs
+//
+// 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.Runtime.Serialization;
+using Gdk;
+using Mono.Unix;
+using LongoMatch.Common;
+
+namespace LongoMatch.TimeNodes
+{
+
+ /// <summary>
+ /// Tag category for the analysis. Contains the default values to creates plays
+ /// tagged in this category
+ /// </summary>
+ [Serializable]
+ public class Category:TimeNode, ISerializable
+ {
+
+ private Guid _UUID;
+
+ #region Constructors
+ #endregion
+ public Category (){
+ _UUID = System.Guid.NewGuid();
+ }
+ #region Properties
+
+ /// <summary>
+ /// Unique ID for this category
+ /// </summary>
+ public Guid UUID{
+ get {
+ return _UUID;
+ }
+ }
+
+ /// <summary>
+ /// A key combination to create plays in this category
+ /// </summary>
+ public HotKey HotKey {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// A color to identify plays in this category
+ /// </summary>
+ public Color Color {
+ get;
+ set;
+ }
+
+ //// <summary>
+ /// Sort method used to sort plays for this category
+ /// </summary>
+ public SortMethodType SortMethod{
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Position of the category in the list of categories
+ /// </summary>
+ public int Position{
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Sort method string used for the UI
+ /// </summary>
+ public string SortMethodString{
+ get{
+ switch (SortMethod){
+ case SortMethodType.SortByName:
+ return Catalog.GetString("Sort by name");
+ case SortMethodType.SortByStartTime:
+ return Catalog.GetString("Sort by start time");
+ case SortMethodType.SortByStopTime:
+ return Catalog.GetString("Sort by stop time");
+ case SortMethodType.SortByDuration:
+ return Catalog.GetString("Sort by duration");
+ default:
+ return Catalog.GetString("Sort by name");
+ }
+ }
+ set{
+ if (value == Catalog.GetString("Sort by start time"))
+ SortMethod = SortMethodType.SortByStartTime;
+ else if (value == Catalog.GetString("Sort by stop time"))
+ SortMethod = SortMethodType.SortByStopTime;
+ else if (value == Catalog.GetString("Sort by duration"))
+ SortMethod = SortMethodType.SortByDuration;
+ else
+ SortMethod = SortMethodType.SortByName;
+ }
+ }
+
+ // this method is automatically called during serialization
+ public void GetObjectData(SerializationInfo info, StreamingContext context) {
+ info.AddValue("uuid", UUID);
+ info.AddValue("name", Name);
+ info.AddValue("name", Name);
+ info.AddValue("start", Start);
+ info.AddValue("stop", Stop);
+ info.AddValue("hotkey", HotKey);
+ info.AddValue("position", Position);
+ info.AddValue("red", Color.Red);
+ info.AddValue("green", Color.Green);
+ info.AddValue("blue", Color.Blue);
+ }
+ #endregion
+ }
+}
diff --git a/LongoMatch/Time/Drawing.cs b/LongoMatch/Time/Drawing.cs
index 6b8ffb9..b0c568c 100644
--- a/LongoMatch/Time/Drawing.cs
+++ b/LongoMatch/Time/Drawing.cs
@@ -21,28 +21,24 @@ using Gdk;
namespace LongoMatch.TimeNodes
{
- /* Represent a drawing in the database using a { Gdk Pixbuf} stored
- in a bytes array in PNG format for serialization. { Drawings}
- are used by { MediaTimeNodes} to store the key frame drawing
- which stop time time is stored in a int value
- */
-
+
[Serializable]
public class Drawing
{
private byte[] drawingBuf;
- private readonly int stopTime;
-
+ /// <summary>
+ /// Represent a drawing in the database using a { Gdk Pixbuf} stored
+ /// in a bytes array in PNG format for serialization. { Drawings}
+ /// are used by { MediaTimeNodes} to store the key frame drawing
+ /// which stop time is stored in a int value
+ /// </summary>
public Drawing() {
}
- public Drawing(Pixbuf drawing,int stopTime)
- {
- Pixbuf = drawing;
- this.stopTime = stopTime;
- }
-
+ /// <summary>
+ /// Pixbuf with the drawing
+ /// </summary>
public Pixbuf Pixbuf {
get {
if (drawingBuf != null)
@@ -56,11 +52,13 @@ namespace LongoMatch.TimeNodes
drawingBuf = null;
}
}
-
- public int StopTime {
- get {
- return stopTime;
- }
+
+ /// <summary>
+ /// Render time of the drawing
+ /// </summary>
+ public int RenderTime {
+ get;
+ set;
}
}
}
diff --git a/LongoMatch/Time/DrawingsList.cs b/LongoMatch/Time/DrawingsList.cs
index 8bb0cba..f9a2659 100644
--- a/LongoMatch/Time/DrawingsList.cs
+++ b/LongoMatch/Time/DrawingsList.cs
@@ -25,53 +25,102 @@ namespace LongoMatch.TimeNodes
public class DrawingsList
{
+
private SortedList<int,Drawing> drawingsList;
public DrawingsList()
{
drawingsList = new SortedList<int,Drawing>();
}
-
+
+ /// <summary>
+ /// Adds a new drawing to the list
+ /// </summary>
+ /// <param name="drawing">
+ /// The <see cref="Drawing"/> to add
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>: true if the frawing was added
+ /// </returns>
public bool Add(Drawing drawing) {
- int stopTime = drawing.StopTime;
- if (!drawingsList.ContainsKey(stopTime)) {
- drawingsList.Add(stopTime,drawing);
+ int renderTime = drawing.RenderTime;
+ if (!drawingsList.ContainsKey(renderTime)) {
+ drawingsList.Add(renderTime,drawing);
return true;
}
else return false;
}
+ /// <summary>
+ /// Removes a drawing from the list
+ /// </summary>
+ /// <param name="drawing">
+ /// A <see cref="Drawing"/> to remove
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>: true if was removed correctly
+ /// </returns>
public bool Remove(Drawing drawing) {
- int stopTime = drawing.StopTime;
- return drawingsList.Remove(stopTime);
+ int renderTime = drawing.RenderTime;
+ return drawingsList.Remove(renderTime);
}
+ /// <summary>
+ /// Clear the drawing list
+ /// </summary>
protected void Clear() {
drawingsList.Clear();
}
+ /// <summary>
+ /// The count of drawings
+ /// </summary>
public int Count {
get {
return drawingsList.Count;
}
}
- public IList<int> StopTimes {
+ /// <summary>
+ /// A list with all the render times
+ /// </summary>
+ public IList<int> RenderTime {
get {
return drawingsList.Keys;
}
}
- public int GetStopTime(int index) {
+ /// <summary>
+ /// Gets the render time for a drawing at a position in the list
+ /// </summary>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/> with the index
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Int32"/> with the render time
+ /// </returns>
+ public int GetRenderTime(int index) {
return drawingsList.Keys[index];
}
- public Drawing GetStopDrawing(int index) {
+ /// <summary>
+ /// Get the drawing for an the drawing at a position in the list
+ /// </summary>
+ /// <param name="index">
+ /// A <see cref="System.Int32"/> with the index
+ /// </param>
+ /// <returns>
+ /// A <see cref="Drawing"/> with the render time
+ /// </returns>
+ public Drawing GetRenderDrawing(int index) {
return drawingsList.Values[index];
}
+ /// <summary>
+ /// A list with all the drawings ordered by render time
+ /// </summary>
public SortedList<int,Drawing> List {
- get {
+ get{
return drawingsList;
}
}
diff --git a/LongoMatch/Time/HotKey.cs b/LongoMatch/Time/HotKey.cs
index a00c34a..2915a47 100644
--- a/LongoMatch/Time/HotKey.cs
+++ b/LongoMatch/Time/HotKey.cs
@@ -31,10 +31,9 @@ namespace LongoMatch.TimeNodes
{
/// <summary>
- /// I am key combination used to tag plays using the keyboard. <see cref="LongoMatch.TimeNodes.SectionsTimeNodes"/>
- /// uses me to create plays without using the mouse. I can only be used with Shith and Alt
- /// modifiers to avoid interfering with ohter shortcuts. In case I'am not associated to any
- /// key combinatio 'key' and 'modifier' will be set to -1
+ /// A key combination used to tag plays using the keyboard. <see cref="LongoMatch.TimeNodes.SectionsTimeNodes"/>
+ /// It can only be used with the Shith and Alt modifiers to avoid interfering with ohter shortcuts.
+ /// 'key' and 'modifier' are set to -1 when it's initialized
/// </summary>
[Serializable]
public class HotKey : IEquatable<HotKey>
@@ -54,9 +53,9 @@ namespace LongoMatch.TimeNodes
#endregion
#region Properties
- /// <value>
- /// My keyboard key
- /// </value>
+ /// <summary>
+ /// Gdk Key
+ /// </summary>
public Gdk.Key Key {
get {
return (Gdk.Key)key;
@@ -66,9 +65,9 @@ namespace LongoMatch.TimeNodes
}
}
- /// <value>
- /// My keyboard modifier. Only Alt and Shift can be used
- /// </value>
+ /// <summary>
+ /// Key modifier. Only Alt and Shift can be used
+ /// </summary>
public Gdk.ModifierType Modifier {
get {
return (Gdk.ModifierType)modifier;
@@ -78,9 +77,9 @@ namespace LongoMatch.TimeNodes
}
}
- /// <value>
- /// Whether I am defined or not
- /// </value>
+ /// <summary>
+ /// Get whether the hotkey is defined or not
+ /// </summary>
public Boolean Defined {
get {
return (key!=-1 && modifier != -1);
diff --git a/LongoMatch/Time/PixbufTimeNode.cs b/LongoMatch/Time/PixbufTimeNode.cs
index ab02b3d..8cf1544 100644
--- a/LongoMatch/Time/PixbufTimeNode.cs
+++ b/LongoMatch/Time/PixbufTimeNode.cs
@@ -25,8 +25,8 @@ namespace LongoMatch.TimeNodes
{
/// <summary>
- /// I am the base class for all the video segments.
- /// I have a <see cref="Pixbuf"/> with a thumbnail of the video segment I represent
+ /// Base class for all the video segments containing a snapshot
+ /// It has a <see cref="Gdk.Pixbuf"/> with a thumbnail of the video segment.
/// </summary>
[Serializable]
public class PixbufTimeNode : TimeNode
@@ -37,36 +37,12 @@ namespace LongoMatch.TimeNodes
#region Contructors
public PixbufTimeNode() {
}
-
- /// <summary>
- /// Creates a new PixbufTimeNode object
- /// </summary>
- /// <param name="name">
- /// A <see cref="System.String"/> with my name
- /// </param>
- /// <param name="start">
- /// A <see cref="Time"/> with my start time
- /// </param>
- /// <param name="stop">
- /// A <see cref="Time"/> with my stop time
- /// </param>
- /// <param name="thumbnail">
- /// A <see cref="Pixbuf"/> with my preview
- /// </param>
- public PixbufTimeNode(string name, Time start, Time stop, Pixbuf thumbnail): base(name,start,stop)
- {
- if (thumbnail != null) {
- this.thumbnailBuf = thumbnail.SaveToBuffer("png");
- thumbnail.Dispose();
- }
- else thumbnailBuf = null;
- }
#endregion
#region Properties
- /// <value>
+ /// <summary>
/// Segment thumbnail
- /// </value>
+ /// </summary>
public Pixbuf Miniature {
get {
if (thumbnailBuf != null)
@@ -78,7 +54,6 @@ namespace LongoMatch.TimeNodes
else thumbnailBuf = null;
}
}
-
#endregion
private void ScaleAndSave(Pixbuf pixbuf) {
diff --git a/LongoMatch/Time/Play.cs b/LongoMatch/Time/Play.cs
new file mode 100644
index 0000000..59b8087
--- /dev/null
+++ b/LongoMatch/Time/Play.cs
@@ -0,0 +1,295 @@
+// MediaTimeNode.cs
+//
+// 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;
+using System.Linq;
+using Mono.Unix;
+using Gdk;
+using LongoMatch.Common;
+
+namespace LongoMatch.TimeNodes
+{
+
+ /// <summary>
+ /// Represents a Play in the game.
+ /// </summary>
+
+ [Serializable]
+ public class Play : PixbufTimeNode
+ {
+
+ #region Constructors
+ public Play(){
+ Players = new List<Player>();
+ Tags = new List<Tag>();
+ }
+ #endregion
+
+ #region Properties
+
+ /// <summary>
+ /// Category in which this play is tagged
+ /// </summary>
+ public Category Category {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// A strng with the play's notes
+ /// </summary>
+ public string Notes {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// The <see cref="LongoMatch.TimeNode.Team"/> associated to this play
+ /// </summary>
+ public Team Team {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Video framerate in frames per second. This value is taken from the
+ /// video file properties and used to translate from seconds
+ /// to frames: second 100 is equivalent to frame 100*fps
+ /// </summary>
+ public uint Fps {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Start frame number
+ /// </summary>
+ public uint StartFrame {
+ get {
+ return (uint) (Start.MSeconds * Fps / 1000);
+ }
+ set {
+ Start = new Time {MSeconds = (int)(1000 * value / Fps)};
+ }
+ }
+
+ /// <summary>
+ /// Stop frame number
+ /// </summary>
+ public uint StopFrame {
+ get {
+ return (uint) (Stop.MSeconds * Fps / 1000);
+ }
+ set {
+ Stop = new Time {MSeconds = (int)(1000 * value / Fps)};
+ }
+ }
+
+ /// <summary>
+ /// Get the key frame number if this play as key frame drawing or 0
+ /// </summary>
+ public uint KeyFrame {
+ get {
+ if (HasKeyFrame)
+ return (uint) KeyFrameDrawing.RenderTime * Fps / 1000;
+ else return 0;
+ }
+ }
+
+ /// <summary>
+ /// Get/Set wheter this play is actually loaded. Used in <see cref="LongoMatch.Gui.Component.TimeScale">
+ /// </summary>
+ public bool Selected {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Get/Set a list of the players tagged to this play
+ /// </summary>
+ public List<Player> Players {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets a list of players for the local team
+ /// </summary>
+ public List<Player> LocalPlayers {
+ get{
+ return
+ (from player in Players
+ where player.Team == Team.LOCAL
+ select player
+ ).ToList();
+ }
+ /* FIXME: should an array for each team */
+ set {
+ var l = VisitorPlayers;
+ l.AddRange(value);
+ Players = l;
+ }
+ }
+
+ /// <summary>
+ /// Gets a list of players for the visitor team
+ /// </summary>
+ public List<Player> VisitorPlayers {
+ get{
+ return
+ (from player in Players
+ where player.Team == Team.VISITOR
+ select player
+ ).ToList();
+ }
+
+ set {
+ var l = LocalPlayers;
+ l.AddRange(value);
+ Players = l;
+ }
+ }
+
+ /// <summary>
+ /// Get/Set the key frame's <see cref="LongoMatch.TimeNodes.Drawing"/>
+ /// </summary>
+ public Drawing KeyFrameDrawing {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Get wether the play has defined a key frame
+ /// </summary>
+ public bool HasKeyFrame {
+ get {
+ return KeyFrameDrawing != null;
+ }
+ }
+
+ /// <summary>
+ /// Central frame number using (stopFrame-startFrame)/2
+ /// </summary>
+ public uint CentralFrame {
+ get {
+ return StopFrame-((TotalFrames)/2);
+ }
+ }
+
+ /// <summary>
+ /// Number of frames inside the play's boundaries
+ /// </summary>
+ public uint TotalFrames {
+ get {
+ return StopFrame-StartFrame;
+ }
+ }
+
+ //// <summary>
+ /// Play's tags
+ /// </summary>
+ public List<Tag> Tags{
+ get;
+ set;
+ }
+ #endregion
+
+ #region Public methods
+ /// <summary>
+ /// Check if the frame number is inside the play boundaries
+ /// </summary>
+ /// <param name="frame">
+ /// A <see cref="System.Int32"/> with the frame number
+ /// </param>
+ /// <returns>
+ /// A <see cref="System.Boolean"/>
+ /// </returns>
+ public bool HasFrame(int frame) {
+ return (frame>=StartFrame && frame<StopFrame);
+ }
+
+ public bool HasPlayer(Player player){
+ return Players.Contains(player);
+ }
+
+ /// <summary>
+ /// Add a player to the player's list
+ /// </summary>
+ /// <param name="player">
+ /// The <see cref="LongoMatch.TimeNode.Player"/> to add
+ /// </param>
+ public void AddPlayer(Player player) {
+ Players.Add(player);
+ }
+
+ /// <summary>
+ /// Removes a player from the player's list
+ /// </summary>
+ /// <param name="player">
+ /// The <see cref="LongoMatch.TimeNode.Player"/> to remove
+ /// </param>
+ public void RemovePlayer(Player Player) {
+ Players.Remove(Player);
+ }
+
+ /// <summary>
+ /// Adds a new tag to the play
+ /// </summary>
+ /// <param name="tag">
+ /// A <see cref="Tag"/>: the tag to add
+ /// </param>
+ public void AddTag(Tag tag){
+ if (!Tags.Contains(tag))
+ Tags.Add(tag);
+ }
+
+ /// <summary>
+ /// Removes a tag to the play
+ /// </summary>
+ /// <param name="tag">
+ /// A <see cref="Tag"/>: the tag to remove
+ /// </param>
+ public void RemoveTag(Tag tag){
+ if (Tags.Contains(tag))
+ Tags.Remove(tag);
+ }
+
+ public string ToString (string team)
+ {
+ String[] tags = new String[Tags.Count];
+
+ for (int i=0; i<Tags.Count; i++)
+ tags[i] = Tags[i].Value;
+
+ return "<b>"+Catalog.GetString("Name")+": </b>"+Name+"\n"+
+ "<b>"+Catalog.GetString("Team")+": </b>"+team+"\n"+
+ "<b>"+Catalog.GetString("Start")+": </b>"+Start.ToMSecondsString()+"\n"+
+ "<b>"+Catalog.GetString("Stop")+": </b>"+Stop.ToMSecondsString()+"\n"+
+ "<b>"+Catalog.GetString("Tags")+": </b>"+ String.Join(" ; ", tags);
+ }
+
+ public override string ToString(){
+ return ToString(Team.ToString());
+ }
+
+ #endregion
+ }
+}
diff --git a/LongoMatch/Time/PlayListPlay.cs b/LongoMatch/Time/PlayListPlay.cs
new file mode 100644
index 0000000..b6e8e72
--- /dev/null
+++ b/LongoMatch/Time/PlayListPlay.cs
@@ -0,0 +1,68 @@
+// PlayListTimeNode.cs
+//
+// 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 Gdk;
+using LongoMatch.Video.Utils;
+
+namespace LongoMatch.TimeNodes
+{
+ /// <summary>
+ /// Represents a video segment used by <see cref="LongoMatch.Playlist.Playlist"/>.
+ /// It stores the information of the video file so that it can be used outside a project.
+ /// </summary>
+ [Serializable]
+ public class PlayListPlay : TimeNode
+ {
+ private PreviewMediaFile mediaFile;
+
+ #region Constructors
+ public PlayListPlay()
+ {
+ }
+ #endregion
+
+ #region Properties
+ /// <summary>
+ /// Video file with snapshot preview
+ /// </value>
+ public PreviewMediaFile MediaFile {
+ set;
+ get;
+ }
+
+ /// <summary>
+ /// Play rate
+ /// </summary>
+ public float Rate {
+ get;
+ set;
+ }
+
+ //// <value>
+ /// Defines it the file exists and thus, it can be used in the playlist
+ /// </value>
+ public bool Valid {
+ get;
+ set;
+ }
+ #endregion
+ }
+}
diff --git a/LongoMatch/Time/Player.cs b/LongoMatch/Time/Player.cs
index e6b2a3f..45a17fd 100644
--- a/LongoMatch/Time/Player.cs
+++ b/LongoMatch/Time/Player.cs
@@ -18,6 +18,7 @@
using System;
using Gdk;
+using LongoMatch.Common;
namespace LongoMatch.TimeNodes
{
@@ -27,59 +28,11 @@ namespace LongoMatch.TimeNodes
[Serializable]
public class Player
{
- private string name;
- private string position;
- private int number;
private byte[] photo;
- /* Added in 0.16.1 */
- private float height;
- private int weight;
- private DateTime birthday;
- private String nationality;
- /* Added in 0.16.4 */
- private bool discarded;
- /// <summary>
- /// Creates a new player
- /// </summary>
- /// <param name="name">
- /// A <see cref="System.String"/> with my name
- /// </param>
- /// <param name="birthday">
- /// A <see cref="DateTime"/> with my name
- /// </param>
- /// <param name="nationality">
- /// A <see cref="System.String"/> with my nationality
- /// </param>
- /// <param name="height">
- /// A <see cref="System.Float"/> with my height
- /// </param>
- /// <param name="weight">
- /// A <see cref="System.Int32"/> with my weight
- /// </param>
- /// <param name="position">
- /// A <see cref="System.String"/> with my position in the field
- /// </param>
- /// <param name="number">
- /// A <see cref="System.Int32"/> with my number
- /// </param>
- /// <param name="photo">
- /// A <see cref="Pixbuf"/> with my photo
- /// </param>
#region Constructors
- public Player(string name, DateTime birthday, String nationality,
- float height, int weight, string position,
- int number, Pixbuf photo, bool discarded)
+ public Player()
{
- this.name = name;
- this.birthday = birthday;
- this.nationality = nationality;
- this.height = height;
- this.weight = weight;
- this.position = position;
- this.number = number;
- this.discarded = discarded;
- Photo = photo;
}
#endregion
@@ -88,36 +41,29 @@ namespace LongoMatch.TimeNodes
/// My name
/// </value>
public string Name {
- get {
- return name;
- }
- set {
- name=value;
- }
+ get;
+ set;
+ }
+
+ public Team Team{
+ get;
+ set;
}
/// <value>
/// My position in the field
/// </value>
public string Position {
- get {
- return position;
- }
- set {
- position=value;
- }
+ get;
+ set;
}
/// <value>
/// My shirt number
/// </value>
public int Number {
- get {
- return number;
- }
- set {
- number=value;
- }
+ get;
+ set;
}
/// <value>
@@ -142,48 +88,37 @@ namespace LongoMatch.TimeNodes
/// My birthdayt
/// </value>
public DateTime Birthday{
- get {
- return birthday;
- }
- set {
- birthday = value;
- }
+ get;
+ set;
}
/// <value>
/// My nationality
/// </value>
public String Nationality{
- get {
- return nationality;
- }
- set {
- nationality = value;
- }
+ get;
+ set;
}
/// <value>
/// My height
/// </value>
public float Height{
- get {
- return height;
- }
- set {
- height = value;
- }
+ get;
+ set;
}
/// <value>
/// My Weight
/// </value>
public int Weight{
- get {
- return weight;
- }
- set {
- weight = value;
- }
+ get;
+ set;
+ }
+
+ public bool Playing{
+ get;
+ set;
}
/// <value>
@@ -192,12 +127,8 @@ namespace LongoMatch.TimeNodes
/// template in a team, definning if this plays plays or not.
/// </value>
public bool Discarded{
- get {
- return discarded;
- }
- set {
- discarded = value;
- }
+ get;
+ set;
}
#endregion
}
diff --git a/LongoMatch/Time/Tag.cs b/LongoMatch/Time/Tag.cs
index 5214cf9..a48ad0f 100644
--- a/LongoMatch/Time/Tag.cs
+++ b/LongoMatch/Time/Tag.cs
@@ -24,27 +24,21 @@ namespace LongoMatch.TimeNodes
[Serializable]
public class Tag
{
- string text;
-
- public Tag(string text)
- {
- this.text=text;
+ public Tag() {
}
- public string Text {
- get {
- return text;
- }
- set {
- if (value == null)
- text="";
- else
- text=value;
- }
+ public string SubCategory {
+ get;
+ set;
+ }
+
+ public string Value {
+ get;
+ set;
}
public bool Equals(Tag tagComp) {
- return (text == tagComp.Text);
+ return (SubCategory == tagComp.SubCategory && Value == tagComp.Value);
}
public override bool Equals(object obj)
@@ -58,7 +52,7 @@ namespace LongoMatch.TimeNodes
public override int GetHashCode()
{
- return text.GetHashCode();
+ return SubCategory.GetHashCode() + Value.GetHashCode();
}
}
}
diff --git a/LongoMatch/Time/Time.cs b/LongoMatch/Time/Time.cs
index b7a2579..a22f777 100644
--- a/LongoMatch/Time/Time.cs
+++ b/LongoMatch/Time/Time.cs
@@ -24,52 +24,38 @@ namespace LongoMatch.TimeNodes
{
/// <summary>
- /// I represent a time instant. Other objects uses me to maintain time units consitency.
- /// I am expressed in miliseconds and I provide some helper methods for time conversion and representation
+ /// Represents a time instant. Other objects uses it to keep consistency in the time units consitency.
+ /// It's expressed in miliseconds and provide some helper methods for time conversion and representation
/// </summary>
[Serializable]
public class Time : IComparable
{
- private int time;
private const int MS = 1000000 ;
public const int SECONDS_TO_TIME = 1000;
-
+
#region Constructors
public Time() {
- this.time = 0;
- }
-
- /// <summary>
- /// Creates a new time instant
- /// </summary>
- /// <param name="time">
- /// A <see cref="System.Int32"/> with the time expressed in miliseconds
- /// </param>
- public Time(int time)
- {
- this.time = time;
}
#endregion
- //// <value>
+ //// <summary>
/// Time in miliseconds
- /// </value>
+ /// </summary>
#region Properties
public int MSeconds {
- get {
- return time;
- }
- set {
- time = value;
- }
+ get;
+ set;
}
- /// <value>
+ /// <summary>
/// Time in seconds
- /// </value>
+ /// </summary>
public int Seconds {
get {
- return time/SECONDS_TO_TIME;
+ return MSeconds/SECONDS_TO_TIME;
+ }
+ set {
+ MSeconds = value * SECONDS_TO_TIME;
}
}
#endregion
@@ -83,11 +69,12 @@ namespace LongoMatch.TimeNodes
/// </returns>
public string ToSecondsString()
{
- int _h, _m, _s;
+ int _h, _m, _s, _time;
- _h = (time / 3600);
- _m = ((time % 3600) / 60);
- _s = ((time % 3600) % 60);
+ _time = MSeconds / 1000;
+ _h = (_time / 3600);
+ _m = ((_time % 3600) / 60);
+ _s = ((_time % 3600) % 60);
if (_h > 0)
return String.Format("{0}:{1}:{2}", _h, _m.ToString("d2"),
@@ -104,18 +91,10 @@ namespace LongoMatch.TimeNodes
/// </returns>
public string ToMSecondsString()
{
- int _h, _m, _s,_ms,_time;
- _time = time / 1000;
- _h = (_time / 3600);
- _m = ((_time % 3600) / 60);
- _s = ((_time % 3600) % 60);
- _ms = ((time % 3600000)%60000)%1000;
-
- //if (_h > 0)
- return String.Format("{0}:{1}:{2},{3}", _h, _m.ToString("d2"),
- _s.ToString("d2"),_ms.ToString("d3"));
+ int _ms ;
+ _ms = ((MSeconds % 3600000)%60000)%1000;
- //return String.Format ("{0}:{1},{2}", _m, _s.ToString ("d2"),_ms.ToString("d3"));
+ return String.Format("{0},{1}", ToSecondsString(), _ms.ToString("d3"));
}
public override bool Equals(object o)
@@ -159,19 +138,19 @@ namespace LongoMatch.TimeNodes
}
public static Time operator +(Time t1,int t2) {
- return new Time(t1.MSeconds+t2);
+ return new Time {MSeconds = t1.MSeconds+t2};
}
public static Time operator +(Time t1,Time t2) {
- return new Time(t1.MSeconds+t2.MSeconds);
+ return new Time {MSeconds = t1.MSeconds+t2.MSeconds};
}
public static Time operator -(Time t1,Time t2) {
- return new Time(t1.MSeconds-t2.MSeconds);
+ return new Time {MSeconds = t1.MSeconds-t2.MSeconds};
}
public static Time operator -(Time t1,int t2) {
- return new Time(t1.MSeconds-t2);
+ return new Time {MSeconds = t1.MSeconds-t2};
}
#endregion
}
diff --git a/LongoMatch/Time/TimeNode.cs b/LongoMatch/Time/TimeNode.cs
index 08b8197..dc0e096 100644
--- a/LongoMatch/Time/TimeNode.cs
+++ b/LongoMatch/Time/TimeNode.cs
@@ -26,82 +26,45 @@ namespace LongoMatch.TimeNodes
{
/// <summary>
- /// I am the base class for the time span related objects in the database.
- /// I have a name that describe me and a start and stop <see cref="LongoMatch.TimeNodes.Time"/>
+ /// Base class for all the time span related objects in the database.
+ /// It has a name that describe it and a start and stop <see cref="LongoMatch.TimeNodes.Time"/>
/// </summary>
[Serializable]
public class TimeNode
{
- private string name;
-
- private Time start;
-
- private Time stop;
-
#region Constructors
public TimeNode() {
}
-
- /// <summary>
- /// Creates a TimeNode object
- /// </summary>
- /// <param name="name">
- /// A <see cref="System.String"/> with my name
- /// </param>
- /// <param name="start">
- /// A <see cref="Time"/> with my start time
- /// </param>
- /// <param name="stop">
- /// A <see cref="Time"/> with my stop time
- /// </param>
- public TimeNode(String name,Time start, Time stop)
- {
- this.name = name;
- this.start = start;
- this.stop = stop;
- }
#endregion
#region Properties
- /// <value>
- /// A short description of myself
- /// </value>
+ /// <summary>
+ /// A short description of the time node
+ /// </summary>
public string Name {
- get {
- return this.name;
- }
- set {
- this.name=value;
- }
+ get;
+ set;
}
- //// <value>
- /// My start time
- /// </value>
+ /// <summary>
+ /// Start Time
+ /// </summary>
public Time Start {
- get {
- return this.start;
- }
- set {
- this.start=value;
- }
+ get;
+ set;
}
- /// <value>
- /// My stop time
- /// </value>
+ /// <summary>
+ /// Stop time
+ /// </summary>
public Time Stop {
- get {
- return stop;
- }
- set {
- this.stop = value;
- }
+ get;
+ set;
}
- /// <value>
- /// My duration
- /// </value>
+ /// <summary>
+ /// Duration (stop_time - start_time)
+ /// </summary>
public Time Duration {
get {
return Stop-Start;
@@ -109,21 +72,5 @@ namespace LongoMatch.TimeNodes
}
#endregion
- #region Public methods
-
- /// <summary>
- /// Change my boundaries
- /// </summary>
- /// <param name="start">
- /// My new start <see cref="Time"/>
- /// </param>
- /// <param name="stop">
- /// My new stop <see cref="Time"/>
- /// </param>
- public void ChangeStartStop(Time start, Time stop) {
- this.start = start;
- this.stop = stop;
- }
- #endregion
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]