[longomatch/redesign: 23/47] Fix import/export projects



commit fdcccc091d99420e0f5b2be1abc3811165ddebe9
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Nov 21 20:31:23 2010 +0100

    Fix import/export projects

 LongoMatch/DB/ProjectDescription.cs |    1 +
 LongoMatch/Time/Category.cs         |   18 +++++++++++++++++-
 2 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/LongoMatch/DB/ProjectDescription.cs b/LongoMatch/DB/ProjectDescription.cs
index e6dfc6c..acccefd 100644
--- a/LongoMatch/DB/ProjectDescription.cs
+++ b/LongoMatch/DB/ProjectDescription.cs
@@ -28,6 +28,7 @@ namespace LongoMatch.DB
 	/// 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>
+	[Serializable]
 	public class ProjectDescription :  IComparable
 	{
 		
diff --git a/LongoMatch/Time/Category.cs b/LongoMatch/Time/Category.cs
index 77d6eab..f6442a6 100644
--- a/LongoMatch/Time/Category.cs
+++ b/LongoMatch/Time/Category.cs
@@ -42,6 +42,22 @@ namespace LongoMatch.TimeNodes
 		public Category (){
 			_UUID = System.Guid.NewGuid();
 		}
+		// this constructor is automatically called during deserialization
+		public Category(SerializationInfo info, StreamingContext context) {
+			_UUID = (Guid)info.GetValue("uuid", typeof(Guid));
+			Name = info.GetString("name");
+			Start = (Time)info.GetValue("start", typeof(Time));
+			Stop = (Time)info.GetValue("stop", typeof(Time));
+			HotKey = (HotKey)info.GetValue("hotkey", typeof(HotKey));
+			Position = info.GetInt32("position");
+			SortMethod = (SortMethodType)info.GetValue("sort_method", typeof(SortMethodType));
+			// read 'red', 'blue' and 'green' values and convert it to Gdk.Color
+			Color c = new Color();
+			c.Red = (ushort)info.GetValue("red", typeof(ushort));
+			c.Green = (ushort)info.GetValue("green", typeof(ushort));
+			c.Blue = (ushort)info.GetValue("blue", typeof(ushort));
+			Color = c;
+		}
 		#region  Properties
 		
 		/// <summary>
@@ -119,7 +135,6 @@ namespace LongoMatch.TimeNodes
 		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);
@@ -127,6 +142,7 @@ namespace LongoMatch.TimeNodes
 			info.AddValue("red", Color.Red);
 			info.AddValue("green", Color.Green);
 			info.AddValue("blue", Color.Blue);
+			info.AddValue("sort_method", SortMethod);
 		}
 		#endregion	
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]