[longomatch] Make some changes to Core to implement better the MVC



commit 747718cda4ff482720c8af409208f2da20d6a2a4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Dec 9 19:46:15 2011 +0100

    Make some changes to Core to implement better the MVC
    
    * Remove dependency on Gdk and Gtk

 LongoMatch.Core/Common/Constants.cs                |    4 +
 LongoMatch.Core/Common/Enums.cs                    |   13 +
 LongoMatch.Core/Common/Image.cs                    |  130 +++++++++
 LongoMatch.Core/Common/PlayList.cs                 |    4 +-
 LongoMatch.Core/Handlers/Handlers.cs               |    2 +-
 LongoMatch.Core/Handlers/Multimedia.cs             |   43 +++
 .../{IPlaylistWidget.cs => GUI/IBusyDialog.cs}     |   13 +-
 .../{IPlaylistWidget.cs => GUI/ICapturer.cs}       |   26 ++-
 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs      |   70 +++++
 LongoMatch.Core/Interfaces/GUI/IMainWindow.cs      |   87 ++++++
 LongoMatch.Core/Interfaces/GUI/IPlayer.cs          |   74 +++++
 .../Interfaces/{ => GUI}/IPlaylistWidget.cs        |    2 +-
 .../IRenderingStateBar.cs}                         |   17 +-
 LongoMatch.Core/Interfaces/IPlayList.cs            |    3 -
 .../Interfaces/IRenderingJobsManager.cs            |    3 +-
 LongoMatch.Core/Interfaces/ITemplates.cs           |    8 +
 LongoMatch.Core/Interfaces/ITemplatesService.cs    |    8 +-
 .../Interfaces/Multimedia/IFramesCapturer.cs       |   38 +++
 .../IMultimediaToolkit.cs}                         |   17 +-
 .../Interfaces/Multimedia/IVideoEditor.cs          |   58 ++++
 LongoMatch.Core/LongoMatch.Core.mdp                |   27 ++-
 LongoMatch.Core/Store/Category.cs                  |   19 +-
 LongoMatch.Core/Store/Drawing.cs                   |   13 +-
 LongoMatch.Core/Store/HotKey.cs                    |   17 +-
 LongoMatch.Core/Store/MediaFile.cs                 |   12 +-
 LongoMatch.Core/Store/PixbufTimeNode.cs            |   10 +-
 LongoMatch.Core/Store/Play.cs                      |    1 -
 LongoMatch.Core/Store/PlayListPlay.cs              |    1 -
 LongoMatch.Core/Store/Player.cs                    |    7 +-
 LongoMatch.Core/Store/Project.cs                   |   73 +----
 .../Store/Templates/CategoriesTemplate.cs          |    5 +-
 LongoMatch.Core/Store/Templates/TeamTemplate.cs    |    8 +-
 .../Common => LongoMatch.GUI/Gui}/Cairo.cs         |    1 +
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |  307 ++++++++++++++++++++
 .../Images.cs => LongoMatch.GUI/Gui/Helpers.cs     |   64 +++--
 35 files changed, 992 insertions(+), 193 deletions(-)
---
diff --git a/LongoMatch.Core/Common/Constants.cs b/LongoMatch.Core/Common/Constants.cs
index 3c14bcf..b8905ac 100644
--- a/LongoMatch.Core/Common/Constants.cs
+++ b/LongoMatch.Core/Common/Constants.cs
@@ -17,7 +17,9 @@
 //
 
 using System;
+#if HAVE_GTK
 using Gdk;
+#endif
 
 
 namespace LongoMatch.Common
@@ -77,6 +79,7 @@ Xavier Queralt Mateu (ca)";
 
 		public const string MANUAL = "http://www.longomatch.ylatuya.es/documentation/manual.html";;
 
+#if HAVE_GTK
 		public const ModifierType STEP = Gdk.ModifierType.ShiftMask;
 
 		public const Key SEEK_BACKWARD = Gdk.Key.Left;
@@ -88,6 +91,7 @@ Xavier Queralt Mateu (ca)";
 		public const Key FRAMERATE_DOWN = Gdk.Key.Down;
 
 		public const Key TOGGLE_PLAY = Gdk.Key.space;
+#endif
 
 		public const string TEMPLATES_DIR = "templates";
 		public const string TEAMS_TEMPLATE_EXT = ".ltt";
diff --git a/LongoMatch.Core/Common/Enums.cs b/LongoMatch.Core/Common/Enums.cs
index afaa61a..e8cd836 100644
--- a/LongoMatch.Core/Common/Enums.cs
+++ b/LongoMatch.Core/Common/Enums.cs
@@ -29,6 +29,11 @@ namespace LongoMatch.Common
 		EditProject,
 		None,
 	}
+	
+	public enum CapturerType {
+		Fake,
+		Live,
+	}
 
 	public enum EndCaptureResponse {
 		Return = 234,
@@ -117,4 +122,12 @@ namespace LongoMatch.Common
 		Stop,
 		Cancel
 	}
+	
+	public enum EditorState
+	{
+		START = 0,
+		FINISHED = 1,
+		CANCELED = -1,
+		ERROR = -2
+	}
 }
diff --git a/LongoMatch.Core/Common/Image.cs b/LongoMatch.Core/Common/Image.cs
new file mode 100644
index 0000000..19273ca
--- /dev/null
+++ b/LongoMatch.Core/Common/Image.cs
@@ -0,0 +1,130 @@
+// 
+//  Copyright (C) 2011 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.
+// 
+
+namespace LongoMatch.Common
+{
+	using System;
+	using System.IO;
+#if HAVE_GTK
+	using SImage = Gdk.Pixbuf;
+#else
+	using System.Drawing.Imaging;
+	using SImage = System.Drawing.Image;
+#endif
+
+	public class Image
+	{
+		SImage image;
+		
+		public Image (SImage image)
+		{
+			this.image = image;
+		}
+		
+		public SImage Value {
+			get {
+				return image;
+			}
+		}
+		
+		public void Dispose() {
+			image.Dispose();
+		}
+		
+		
+#if HAVE_GTK
+		public byte[] Serialize () {
+			if (image == null)
+				return null;
+			return image.SaveToBuffer("png");
+		}
+		
+		public static Image Deserialize (byte[] ser) {
+			return new Image(new SImage(ser));
+		}
+		
+		public void Scale(int maxWidth, int maxHeight) {
+			SImage scalled;
+			int width, height;
+			
+			ComputeScale(image.Width, image.Height, maxWidth, maxHeight, out width, out height);
+			scalled= image.ScaleSimple(width, height, Gdk.InterpType.Bilinear);	
+			image.Dispose();
+			image = scalled;
+		}
+		
+		public void Save (string filename) {
+			image.Save(filename, "png");
+		}
+#else
+		public byte[] Serialize () {
+			if (image == null)
+				return null;
+			using (MemoryStream stream = new MemoryStream()) {
+				image.Save(stream, ImageFormat.Png);
+				byte[] buf = new byte[stream.Length - 1];
+				stream.Position = 0;
+				stream.Read(buf, 0, buf.Length);
+				return buf;
+			}
+		}
+		
+		public void Scale(int maxWidth, int maxHeight) {
+			SImage scalled;
+			int width, height;
+			
+			ComputeScale(image.Width, image.Height, maxWidth, maxHeight, out width, out height);
+			scalled = image.GetThumbnailImage(width, height, new SImage.GetThumbnailImageAbort(ThumbnailAbort), IntPtr.Zero);
+			image.Dispose();
+			image = scalled;
+		}
+		
+		public static Image Deserialize (byte[] ser) {
+			Image img = null;
+			using (MemoryStream stream = new MemoryStream(ser)) {
+				img = new Image(System.Drawing.Image.FromStream(stream));
+			}
+			return img;
+		}
+		
+		public void Save (string filename) {
+			image.Save(filename, ImageFormat.Png);
+		}
+		
+		bool ThumbnailAbort () {
+			return false;
+		}
+#endif
+
+		private void ComputeScale (int inWidth, int inHeight, int maxOutWidth, int maxOutHeight, out int outWidth, out int outHeight)
+		{
+			outWidth = maxOutWidth;
+			outHeight = maxOutHeight;
+
+			if(inWidth > maxOutWidth || inHeight > maxOutHeight) {
+				double par = (double)inWidth /(double)inHeight;
+				
+				if(inHeight>inWidth)
+					outWidth = (int)(outHeight * par);
+				else
+					outHeight = (int)(outWidth / par);
+			}
+		} 
+	}
+}
+
diff --git a/LongoMatch.Core/Common/PlayList.cs b/LongoMatch.Core/Common/PlayList.cs
index d4f100f..53db7e5 100644
--- a/LongoMatch.Core/Common/PlayList.cs
+++ b/LongoMatch.Core/Common/PlayList.cs
@@ -20,7 +20,6 @@
 
 using System;
 using System.Collections.Generic;
-using Gtk;
 using LongoMatch.Store;
 using LongoMatch.Common;
 using LongoMatch.Interfaces;
@@ -134,7 +133,7 @@ namespace LongoMatch.Common
 			return !indexSelection.Equals(0);
 		}
 
-		public ListStore GetModel() {
+/*		public ListStore GetModel() {
 			Gtk.ListStore listStore = new ListStore(typeof(PlayListPlay));
 			foreach(PlayListPlay plNode in this) {
 				listStore.AppendValues(plNode);
@@ -152,6 +151,7 @@ namespace LongoMatch.Common
 				listStore.IterNext(ref iter);
 			}
 		}
+*/
 
 		public IPlayList Copy() {
 			return (IPlayList)(MemberwiseClone());
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index acac2ad..f03b8eb 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -79,7 +79,7 @@ namespace LongoMatch.Handlers
 	/* Draw tool changed */
 	public delegate void DrawToolChangedHandler(DrawTool drawTool);
 	/* Paint color changed */
-	public delegate void ColorChangedHandler(Gdk.Color color);
+	public delegate void ColorChangedHandler(System.Drawing.Color color);
 	/* Paint line width changed */
 	public delegate void LineWidthChangedHandler(int width);
 	/* Toggle widget visibility */
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
new file mode 100644
index 0000000..2f2c0d7
--- /dev/null
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -0,0 +1,43 @@
+//
+//  Copyright (C) 2010 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 LongoMatch.Common;
+
+namespace LongoMatch.Handlers
+{
+	public delegate void PlayListSegmentDoneHandler();
+	public delegate void SegmentClosedHandler();
+	public delegate void SegmentDoneHandler();
+	public delegate void SeekEventHandler(long pos);
+	public delegate void VolumeChangedHandler(double level);
+	public delegate void NextButtonClickedHandler();
+	public delegate void PrevButtonClickedHandler();
+	public delegate void ProgressHandler(float progress);
+	public delegate void FramesProgressHandler(int actual, int total, Image frame);
+	public delegate void DrawFrameHandler(int time);
+	public delegate void EllpasedTimeHandler(int ellapsedTime);
+
+
+	public delegate void ErrorHandler(object o, string message);
+	public delegate void PercentCompletedHandler(object o, float percent);
+	public delegate void StateChangeHandler(object o, bool playing);
+	public delegate void TickHandler(object o, long currentTime, long streamLength,
+		float currentPosition, bool seekable);
+}
diff --git a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs b/LongoMatch.Core/Interfaces/GUI/IBusyDialog.cs
similarity index 76%
copy from LongoMatch.Core/Interfaces/IPlaylistWidget.cs
copy to LongoMatch.Core/Interfaces/GUI/IBusyDialog.cs
index 5a4051e..b846447 100644
--- a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IBusyDialog.cs
@@ -17,16 +17,13 @@
 // 
 using System;
 
-using LongoMatch.Interfaces;
-using LongoMatch.Store;
-
-namespace LongoMatch.Interfaces
+namespace LongoMatch.Interfaces.GUI
 {
-	public interface IPlaylistWidget
+	public interface IBusyDialog
 	{
-		void Load(IPlayList playlist);
-		void Add(PlayListPlay playlistPlay);
-		void SetActivePlay (PlayListPlay playlistplay, int index);
+		void Pulse();
+		void Destroy();
+		void Show();
 	}
 }
 
diff --git a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs b/LongoMatch.Core/Interfaces/GUI/ICapturer.cs
similarity index 64%
copy from LongoMatch.Core/Interfaces/IPlaylistWidget.cs
copy to LongoMatch.Core/Interfaces/GUI/ICapturer.cs
index 5a4051e..0dd159e 100644
--- a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs
+++ b/LongoMatch.Core/Interfaces/GUI/ICapturer.cs
@@ -17,16 +17,28 @@
 // 
 using System;
 
-using LongoMatch.Interfaces;
-using LongoMatch.Store;
+using LongoMatch.Common;
+using LongoMatch.Handlers;
 
-namespace LongoMatch.Interfaces
+namespace LongoMatch.Interfaces.GUI
 {
-	public interface IPlaylistWidget
+	public interface ICapturer
 	{
-		void Load(IPlayList playlist);
-		void Add(PlayListPlay playlistPlay);
-		void SetActivePlay (PlayListPlay playlistplay, int index);
+		event EventHandler CaptureFinished;
+		event ErrorHandler Error;
+		
+		CapturerType Type {set;}
+		string Logo {set;}
+		int CurrentTime {get;}
+		bool Capturing {get;}
+		CaptureSettings CaptureProperties {set;}
+		Image CurrentMiniatureFrame {get;}
+
+		void Start();
+		void TogglePause();
+		void Stop();
+		void Run();
+		void Close();
 	}
 }
 
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
new file mode 100644
index 0000000..ff307e3
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -0,0 +1,70 @@
+// 
+//  Copyright (C) 2011 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 LongoMatch.Interfaces;
+using LongoMatch.Common;
+using LongoMatch.Store;
+using LongoMatch.Store.Templates;
+
+namespace LongoMatch.Interfaces.GUI
+{
+	public interface IGUIToolkit
+	{
+		IMainWindow MainWindow {get;}
+	
+		/* Messages */
+		void InfoMessage(string message);
+		void WarningMessage(string message);
+		void ErrorMessage(string message);
+		bool QuestionMessage(string message, string title);
+		
+		/* Files/Folders IO */
+		string SaveFile(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter);
+		string OpenFile(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter);
+		string SelectFolder(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter);
+			
+		IBusyDialog BusyDialog(string message);
+			
+		Job ConfigureRenderingJob (IPlayList playlist);
+		void ExportFrameSeries(Project openenedProject, Play play, string snapshotDir);
+		
+		ProjectDescription SelectProject(List<ProjectDescription> projects);
+		ProjectType SelectNewProjectType();
+		
+		Project NewCaptureProject(IDatabase db, ITemplatesService ts,
+			List<LongoMatch.Common.Device> devices, out CaptureSettings captureSettings);
+		Project NewFakeProject(IDatabase db, ITemplatesService ts);
+		Project NewFileProject(IDatabase db, ITemplatesService ts);
+		Project EditFakeProject(IDatabase db, Project project, ITemplatesService ts);
+		
+		void OpenProjectsManager(Project openedProject, IDatabase db, ITemplatesService ts);
+		void OpenCategoriesTemplatesManager(ICategoriesTemplatesProvider tp);
+		void OpenTeamsTemplatesManager(ITeamTemplatesProvider tp);
+		
+		void ManageJobs(IRenderingJobsManager manager);
+		
+		void TagPlay(Play play, TeamTemplate local, TeamTemplate visitor);
+		void DrawingTool(Image pixbuf, Play play, int stopTime);
+	}
+}
+
diff --git a/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
new file mode 100644
index 0000000..a020798
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/GUI/IMainWindow.cs
@@ -0,0 +1,87 @@
+// 
+//  Copyright (C) 2011 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 LongoMatch.Common;
+using LongoMatch.Handlers;
+using LongoMatch.Store;
+using LongoMatch.Store.Templates;
+
+namespace LongoMatch.Interfaces.GUI
+{
+	public interface IMainWindow
+	{	
+		/* Tags */
+		event NewTagHandler NewTagEvent;
+		event NewTagStartHandler NewTagStartEvent;
+		event NewTagStopHandler NewTagStopEvent;
+		event PlaySelectedHandler PlaySelectedEvent;
+		event NewTagAtFrameHandler NewTagAtFrameEvent;
+		event TagPlayHandler TagPlayEvent;
+		event PlaysDeletedHandler PlaysDeletedEvent;
+		event TimeNodeChangedHandler TimeNodeChanged;
+		
+		/* Playlist */
+		event RenderPlaylistHandler RenderPlaylistEvent;
+		event PlayListNodeAddedHandler PlayListNodeAddedEvent;
+		event PlayListNodeSelectedHandler PlayListNodeSelectedEvent;
+		event OpenPlaylistHandler OpenPlaylistEvent;
+		event NewPlaylistHandler NewPlaylistEvent;
+		event SavePlaylistHandler SavePlaylistEvent; 
+		
+		/* Snapshots */
+		event SnapshotSeriesHandler SnapshotSeriesEvent;
+		
+		/* Projects */
+		event SaveProjectHandler SaveProjectEvent;
+		event NewProjectHandler NewProjectEvent;
+		event OpenProjectHandler OpenProjectEvent;
+		event CloseOpenendProjectHandler CloseOpenedProjectEvent;
+		event ImportProjectHandler ImportProjectEvent;
+		event ExportProjectHandler ExportProjectEvent;
+		
+		/* Managers */
+		event ManageJobsHandler ManageJobsEvent; 
+		event ManageTeamsHandler ManageTeamsEvent;
+		event ManageCategoriesHandler ManageCategoriesEvent;
+		event ManageProjects ManageProjectsEvent;
+		event ApplyCurrentRateHandler ApplyRateEvent;
+		
+		/* Game Units events */
+		event GameUnitHandler GameUnitEvent;
+		event UnitChangedHandler UnitChanged;
+		event UnitSelectedHandler UnitSelected;
+		event UnitsDeletedHandler UnitDeleted;
+		event UnitAddedHandler UnitAdded;
+		
+		void SetProject(Project project, ProjectType projectType, CaptureSettings props);
+		void AddPlay(Play play);
+		void UpdateSelectedPlay (Play play);
+		void UpdateCategories (Categories categories);
+		void DeletePlays (List<Play> plays);
+		void UpdateGameUnits (GameUnitsList gameUnits);
+		
+		IRenderingStateBar RenderingStateBar{get;}
+		IPlayer Player{get;}
+		ICapturer Capturer{get;}
+		IPlaylistWidget Playlist{get;}
+		
+	}
+}
+
diff --git a/LongoMatch.Core/Interfaces/GUI/IPlayer.cs b/LongoMatch.Core/Interfaces/GUI/IPlayer.cs
new file mode 100644
index 0000000..33d1aca
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/GUI/IPlayer.cs
@@ -0,0 +1,74 @@
+// 
+//  Copyright (C) 2011 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 LongoMatch.Common;
+using LongoMatch.Handlers;
+
+namespace LongoMatch.Interfaces.GUI
+{
+	public interface IPlayer
+	{
+		event SegmentClosedHandler SegmentClosedEvent;
+		event TickHandler Tick;
+		event ErrorHandler Error;
+		event StateChangeHandler PlayStateChanged;
+		event NextButtonClickedHandler Next;
+		event PrevButtonClickedHandler Prev;
+		event DrawFrameHandler DrawFrame;
+		event SeekEventHandler SeekEvent;
+		
+		long AccurateCurrentTime {get;}
+		long CurrentTime {get;}
+		long StreamLength {get;}
+		
+		Image CurrentMiniatureFrame {get;}
+		Image CurrentFrame {get;}
+		Image LogoPixbuf {set;}
+		Image DrawingPixbuf {set;}
+		bool DrawingMode {set;}
+		bool LogoMode {set;}
+		bool ExpandLogo {set; get;}
+		bool Opened {get;}
+		bool FullScreen {set;}
+		float Rate {get;set;}
+
+		void Open(string mrl);
+		void Play();
+		void Pause();
+		void TogglePlay();
+		void SetLogo(string filename);
+		void ResetGui();
+		void SetPlayListElement(string fileName,long start, long stop, float rate, bool hasNext);
+		void Close();
+		void SeekTo(long time, bool accurate);
+		void SeekInSegment(long pos);
+		void SeekToNextFrame(bool in_segment);
+		void SeekToPreviousFrame(bool in_segment);
+		void StepForward();
+		void StepBackward();
+		void FramerateUp();
+		void FramerateDown();
+		void UpdateSegmentStartTime(long start);
+		void UpdateSegmentStopTime(long stop);
+		void SetStartStop(long start, long stop);
+		void CloseActualSegment();
+		void SetSensitive();
+		void UnSensitive();
+	}
+}
+
diff --git a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs b/LongoMatch.Core/Interfaces/GUI/IPlaylistWidget.cs
similarity index 96%
copy from LongoMatch.Core/Interfaces/IPlaylistWidget.cs
copy to LongoMatch.Core/Interfaces/GUI/IPlaylistWidget.cs
index 5a4051e..b6bb4fc 100644
--- a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IPlaylistWidget.cs
@@ -20,7 +20,7 @@ using System;
 using LongoMatch.Interfaces;
 using LongoMatch.Store;
 
-namespace LongoMatch.Interfaces
+namespace LongoMatch.Interfaces.GUI
 {
 	public interface IPlaylistWidget
 	{
diff --git a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs b/LongoMatch.Core/Interfaces/GUI/IRenderingStateBar.cs
similarity index 76%
copy from LongoMatch.Core/Interfaces/IPlaylistWidget.cs
copy to LongoMatch.Core/Interfaces/GUI/IRenderingStateBar.cs
index 5a4051e..23dcec3 100644
--- a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IRenderingStateBar.cs
@@ -17,16 +17,17 @@
 // 
 using System;
 
-using LongoMatch.Interfaces;
-using LongoMatch.Store;
-
-namespace LongoMatch.Interfaces
+namespace LongoMatch.Interfaces.GUI
 {
-	public interface IPlaylistWidget
+	public interface IRenderingStateBar
 	{
-		void Load(IPlayList playlist);
-		void Add(PlayListPlay playlistPlay);
-		void SetActivePlay (PlayListPlay playlistplay, int index);
+		event EventHandler Cancel;
+		event EventHandler ManageJobs;
+		
+		bool JobRunning {set;}
+		string Text {set;}
+		string ProgressText {set;}
+		double Fraction {set; get;}
 	}
 }
 
diff --git a/LongoMatch.Core/Interfaces/IPlayList.cs b/LongoMatch.Core/Interfaces/IPlayList.cs
index 63a9ed5..0630420 100644
--- a/LongoMatch.Core/Interfaces/IPlayList.cs
+++ b/LongoMatch.Core/Interfaces/IPlayList.cs
@@ -20,7 +20,6 @@
 
 using System;
 using System.Collections;
-using Gtk;
 using LongoMatch.Store;
 
 namespace LongoMatch.Interfaces {
@@ -53,8 +52,6 @@ namespace LongoMatch.Interfaces {
 
 		bool HasPrev();
 
-		ListStore GetModel();
-
 		IPlayList Copy();
 	}
 }
diff --git a/LongoMatch.Core/Interfaces/IRenderingJobsManager.cs b/LongoMatch.Core/Interfaces/IRenderingJobsManager.cs
index a365cbc..e639b35 100644
--- a/LongoMatch.Core/Interfaces/IRenderingJobsManager.cs
+++ b/LongoMatch.Core/Interfaces/IRenderingJobsManager.cs
@@ -17,7 +17,6 @@
 // 
 using System;
 using System.Collections.Generic;
-using Gtk;
 using LongoMatch.Common;
 
 namespace LongoMatch.Interfaces
@@ -32,7 +31,7 @@ namespace LongoMatch.Interfaces
 		void CancelJob(Job job);
 		void CancelAllJobs();
 		void AddJob(Job job);
-		TreeStore Model {get;}
+		List<Job> Jobs {get;}
 	}
 }
 
diff --git a/LongoMatch.Core/Interfaces/ITemplates.cs b/LongoMatch.Core/Interfaces/ITemplates.cs
index bf3524b..3f0780d 100644
--- a/LongoMatch.Core/Interfaces/ITemplates.cs
+++ b/LongoMatch.Core/Interfaces/ITemplates.cs
@@ -18,6 +18,7 @@
 using System;
 using System.Collections.Generic;
 using LongoMatch.Store;
+using LongoMatch.Store.Templates;
 	
 namespace LongoMatch.Interfaces
 {
@@ -56,5 +57,12 @@ namespace LongoMatch.Interfaces
 		bool CanExport {get; set;}
 		Project Project {get; set;}
 	}
+	
+	public interface ICategoriesTemplatesProvider: ITemplateProvider<Categories, Category> {}
+	public interface ITeamTemplatesProvider: ITemplateProvider<TeamTemplate, Player> {}
+	public interface ISubcategoriesTemplatesProvider: ITemplateProvider<SubCategoryTemplate, string> {} 
+	
+	public interface ICategoriesTemplatesEditor: ITemplateWidget<Categories, Category> {}
+	public interface ITeamTemplatesEditor: ITemplateWidget<TeamTemplate, Player> {}
 }
 
diff --git a/LongoMatch.Core/Interfaces/ITemplatesService.cs b/LongoMatch.Core/Interfaces/ITemplatesService.cs
index aa1d61a..0dbf170 100644
--- a/LongoMatch.Core/Interfaces/ITemplatesService.cs
+++ b/LongoMatch.Core/Interfaces/ITemplatesService.cs
@@ -26,13 +26,11 @@ namespace LongoMatch.Interfaces
 	{
 		ITemplateProvider<T, U> GetTemplateProvider<T, U>() where T: ITemplate<U>;
 		
-		ITemplateWidget<T, U> GetTemplateEditor<T, U>() where T: ITemplate<U>;
+		ISubcategoriesTemplatesProvider SubCategoriesTemplateProvider {get;}
 		
-		ITemplateProvider<SubCategoryTemplate, string> SubCategoriesTemplateProvider {get;}
+		ITeamTemplatesProvider TeamTemplateProvider {get;}
 		
-		ITemplateProvider<TeamTemplate, Player> TeamTemplateProvider {get;}
-
-		ITemplateProvider<Categories, Category> CategoriesTemplateProvider {get;}
+		ICategoriesTemplatesProvider CategoriesTemplateProvider {get;}
 		
 		List<PlayerSubCategory> PlayerSubcategories {get;}
 		
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IFramesCapturer.cs b/LongoMatch.Core/Interfaces/Multimedia/IFramesCapturer.cs
new file mode 100644
index 0000000..05dd869
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/Multimedia/IFramesCapturer.cs
@@ -0,0 +1,38 @@
+// IFramesCapturer.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 LongoMatch.Common;
+
+namespace LongoMatch.Interfaces.Multimedia
+{
+
+
+	public interface IFramesCapturer
+	{
+		bool Open(string mrl);
+		bool SeekTime(long time, bool accurate);
+		void Pause();
+		void Dispose();
+		Image GetCurrentFrame(int outwidth, int outheight);
+		Image GetCurrentFrame();
+	}
+}
diff --git a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
similarity index 74%
rename from LongoMatch.Core/Interfaces/IPlaylistWidget.cs
rename to LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
index 5a4051e..1d00b24 100644
--- a/LongoMatch.Core/Interfaces/IPlaylistWidget.cs
+++ b/LongoMatch.Core/Interfaces/Multimedia/IMultimediaToolkit.cs
@@ -16,17 +16,22 @@
 //  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 // 
 using System;
+using System.Collections.Generic;
 
-using LongoMatch.Interfaces;
+using LongoMatch.Common;
 using LongoMatch.Store;
 
-namespace LongoMatch.Interfaces
+namespace LongoMatch.Interfaces.Multimedia
 {
-	public interface IPlaylistWidget
+	public interface IMultimediaToolkit
 	{
-		void Load(IPlayList playlist);
-		void Add(PlayListPlay playlistPlay);
-		void SetActivePlay (PlayListPlay playlistplay, int index);
+		IVideoEditor GetVideoEditor();
+		
+		IFramesCapturer GetFramesCapturer();
+		
+		MediaFile DiscoverFile(string path);
+		
+		List<Device> VideoDevices {get;}
 	}
 }
 
diff --git a/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs b/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs
new file mode 100644
index 0000000..f57f507
--- /dev/null
+++ b/LongoMatch.Core/Interfaces/Multimedia/IVideoEditor.cs
@@ -0,0 +1,58 @@
+// IVideoEditor.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 LongoMatch.Common;
+using LongoMatch.Handlers;
+
+namespace LongoMatch.Interfaces.Multimedia
+{
+
+	public interface IVideoEditor
+	{
+		event ProgressHandler Progress;
+
+		EncodingSettings EncodingSettings{
+			set;
+		}
+		
+		string TempDir {
+			set;
+		}
+
+		bool EnableTitle {
+			set;
+		}
+
+		bool EnableAudio {
+			set;
+		}
+
+		void AddSegment(string filePath, long start, long duration, double rate, string title, bool hasAudio) ;
+
+		void ClearList();
+
+		void Start();
+
+		void Cancel();
+
+	}
+}
diff --git a/LongoMatch.Core/LongoMatch.Core.mdp b/LongoMatch.Core/LongoMatch.Core.mdp
index 6536d9c..2f9001a 100644
--- a/LongoMatch.Core/LongoMatch.Core.mdp
+++ b/LongoMatch.Core/LongoMatch.Core.mdp
@@ -4,22 +4,20 @@
       <Output directory="../bin" assembly="LongoMatch" />
       <Build debugmode="True" target="Library" />
       <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
-      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="DEBUG HAVE_GTK" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
     </Configuration>
     <Configuration name="Release" ctype="DotNetProjectConfiguration">
       <Output directory="../bin" assembly="LongoMatch" />
       <Build debugmode="False" target="Library" />
       <Execution consolepause="False" runwithwarnings="True" runtime="MsNet" />
-      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
+      <CodeGeneration compiler="Mcs" warninglevel="4" optimize="False" unsafecodeallowed="False" generateoverflowchecks="False" definesymbols="HAVE_GTK" generatexmldocumentation="False" ctype="CSharpCompilerParameters" />
     </Configuration>
   </Configurations>
   <Contents>
-    <File subtype="Code" buildaction="Compile" name="Common/Cairo.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/Cloner.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/ConsoleCrayon.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/Constants.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/Enums.cs" />
-    <File subtype="Code" buildaction="Compile" name="Common/Images.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/Log.cs" />
     <File subtype="Code" buildaction="Compile" name="Common/SerializableObject.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/Category.cs" />
@@ -69,18 +67,35 @@
     <File subtype="Code" buildaction="Compile" name="Config.cs" />
     <File subtype="Code" buildaction="Compile" name="Interfaces/ITemplatesService.cs" />
     <File subtype="Code" buildaction="Compile" name="Interfaces/IDatabase.cs" />
-    <File subtype="Code" buildaction="Compile" name="Interfaces/IPlaylistWidget.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/GameUnit.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/GameUnitsList.cs" />
     <File subtype="Code" buildaction="Compile" name="Store/TimelineNode.cs" />
     <File subtype="Code" buildaction="Compile" name="Interfaces/ITimelineNode.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Interfaces/GUI" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IRenderingStateBar.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IPlayer.cs" />
+    <File subtype="Code" buildaction="Compile" name="Handlers/Multimedia.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IMainWindow.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/ICapturer.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IPlaylistWidget.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Interfaces" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IGUIToolkit.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Interfaces/Multimedia" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/IMultimediaToolkit.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/IVideoEditor.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Interfaces" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/GUI/IBusyDialog.cs" />
+    <File subtype="Code" buildaction="Compile" name="Interfaces/Multimedia/IFramesCapturer.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Common" />
+    <File subtype="Code" buildaction="Compile" name="Common/Image.cs" />
+    <File subtype="Directory" buildaction="Compile" name="Common" />
   </Contents>
   <References>
     <ProjectReference type="Gac" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
     <ProjectReference type="Gac" localcopy="True" refto="Mono.Posix, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
-    <ProjectReference type="Gac" localcopy="True" refto="Mono.Cairo, Version=4.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+    <ProjectReference type="Gac" localcopy="True" refto="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
     <ProjectReference type="Gac" localcopy="True" refto="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
     <ProjectReference type="Gac" localcopy="True" refto="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
   </References>
diff --git a/LongoMatch.Core/Store/Category.cs b/LongoMatch.Core/Store/Category.cs
index f1b745d..31a50b1 100644
--- a/LongoMatch.Core/Store/Category.cs
+++ b/LongoMatch.Core/Store/Category.cs
@@ -19,9 +19,9 @@
 //
 
 using System;
+using System.Drawing;
 using System.Collections.Generic;
 using System.Runtime.Serialization;
-using Gdk;
 using Mono.Unix;
 
 using LongoMatch.Common;
@@ -69,7 +69,7 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// A color to identify plays in this category
 		/// </summary>
-		public Color Color {
+		public  Color Color {
 			get;
 			set;
 		}
@@ -136,11 +136,10 @@ namespace LongoMatch.Store
 			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;
+			Color = Color.FromArgb(
+				(ushort)info.GetValue("red", typeof(ushort)),
+				(ushort)info.GetValue("green", typeof(ushort)),
+				(ushort)info.GetValue("blue", typeof(ushort)));
 		}
 
 		// this method is automatically called during serialization
@@ -152,9 +151,9 @@ namespace LongoMatch.Store
 			info.AddValue("hotkey", HotKey);
 			info.AddValue("position", Position);
 			info.AddValue("subcategories", SubCategories);
-			info.AddValue("red", Color.Red);
-			info.AddValue("green", Color.Green);
-			info.AddValue("blue", Color.Blue);
+			info.AddValue("red", Color.R);
+			info.AddValue("green", Color.G);
+			info.AddValue("blue", Color.B);
 			info.AddValue("sort_method", SortMethod);
 		}
 		#endregion
diff --git a/LongoMatch.Core/Store/Drawing.cs b/LongoMatch.Core/Store/Drawing.cs
index cae77a2..7a8c8a4 100644
--- a/LongoMatch.Core/Store/Drawing.cs
+++ b/LongoMatch.Core/Store/Drawing.cs
@@ -17,7 +17,9 @@
 //
 
 using System;
-using Gdk;
+using System.Drawing.Imaging;
+
+using LongoMatch.Common;
 
 namespace LongoMatch.Store
 {
@@ -39,17 +41,14 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// Pixbuf with the drawing
 		/// </summary>
-		public Pixbuf Pixbuf {
+		public Image Pixbuf {
 			get {
 				if(drawingBuf != null)
-					return new Pixbuf(drawingBuf);
+					return Image.Deserialize(drawingBuf);
 				else return null;
 			}
 			set {
-				if(value != null)
-					drawingBuf = value.SaveToBuffer("png");
-				else
-					drawingBuf = null;
+				drawingBuf = value.Serialize();
 			}
 		}
 
diff --git a/LongoMatch.Core/Store/HotKey.cs b/LongoMatch.Core/Store/HotKey.cs
index e58870d..5224684 100644
--- a/LongoMatch.Core/Store/HotKey.cs
+++ b/LongoMatch.Core/Store/HotKey.cs
@@ -23,7 +23,6 @@
 using System;
 using System.Collections.Generic;
 using System.Runtime.Serialization;
-using Gdk;
 using Mono.Unix;
 
 namespace LongoMatch.Store
@@ -55,24 +54,24 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// Gdk Key
 		/// </summary>
-		public Gdk.Key Key {
+		public int Key {
 			get {
-				return (Gdk.Key)key;
+				return key;
 			}
 			set {
-				key = (int)value;
+				key = value;
 			}
 		}
 
 		/// <summary>
 		/// Key modifier. Only Alt and Shift can be used
 		/// </summary>
-		public Gdk.ModifierType Modifier {
+		public int Modifier {
 			get {
-				return (Gdk.ModifierType)modifier;
+				return modifier;
 			}
 			set {
-				modifier= (int)value;
+				modifier = value;
 			}
 		}
 
@@ -123,9 +122,9 @@ namespace LongoMatch.Store
 			string modifierS;
 			if(!Defined)
 				return Catalog.GetString("Not defined");
-			if(Modifier == ModifierType.Mod1Mask)
+			if(Modifier == 3)//ModifierType.Mod1Mask)
 				modifierS = "<Alt>+";
-			else if(Modifier == ModifierType.ShiftMask)
+			else if(Modifier == 0)// ModifierType.ShiftMask)
 				modifierS = "<Shift>+";
 			else
 				modifierS = "";
diff --git a/LongoMatch.Core/Store/MediaFile.cs b/LongoMatch.Core/Store/MediaFile.cs
index 708e8e5..7afa9e1 100644
--- a/LongoMatch.Core/Store/MediaFile.cs
+++ b/LongoMatch.Core/Store/MediaFile.cs
@@ -20,7 +20,8 @@
 
 using System;
 using Mono.Unix;
-using Gdk;
+
+using LongoMatch.Common;
 
 namespace LongoMatch.Store
 {
@@ -52,7 +53,7 @@ namespace LongoMatch.Store
 		                 string audioCodec,
 		                 uint videoWidth,
 		                 uint videoHeight, 
-		                 Pixbuf preview)
+		                 Image preview)
 		{
 			this.filePath = filePath;
 			this.length = length;
@@ -155,16 +156,15 @@ namespace LongoMatch.Store
 			}
 		}
 		
-		public Pixbuf Preview {
+		public Image Preview {
 			get {
 				if(thumbnailBuf != null)
-					return new Pixbuf(thumbnailBuf);
+					return Image.Deserialize(thumbnailBuf);
 				return null;
 			}
 			set {
 				if(value != null) {
-					thumbnailBuf = value.SaveToBuffer("png");
-					value.Dispose();
+					thumbnailBuf = value.Serialize();
 				} else
 					thumbnailBuf = null;
 			}
diff --git a/LongoMatch.Core/Store/PixbufTimeNode.cs b/LongoMatch.Core/Store/PixbufTimeNode.cs
index a56bed2..7bcd93d 100644
--- a/LongoMatch.Core/Store/PixbufTimeNode.cs
+++ b/LongoMatch.Core/Store/PixbufTimeNode.cs
@@ -19,7 +19,7 @@
 //
 
 using System;
-using Gdk;
+using System.IO;
 
 using LongoMatch.Common;
 
@@ -45,16 +45,16 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// Segment thumbnail
 		/// </summary>
-		public Pixbuf Miniature {
+		public Image Miniature {
 			get {
 				if(thumbnailBuf != null)
-					return new Pixbuf(thumbnailBuf);
+					return Image.Deserialize(thumbnailBuf);
 				else return null;
 			} set {
-				var pix = ImageUtils.Scale(value, MAX_WIDTH, MAX_HEIGHT);
-				thumbnailBuf = ImageUtils.Serialize(pix);
+				thumbnailBuf = value.Serialize();
 			}
 		}
+		
 		#endregion
 	}
 }
diff --git a/LongoMatch.Core/Store/Play.cs b/LongoMatch.Core/Store/Play.cs
index 967aeef..a3eae96 100644
--- a/LongoMatch.Core/Store/Play.cs
+++ b/LongoMatch.Core/Store/Play.cs
@@ -22,7 +22,6 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using Mono.Unix;
-using Gdk;
 using LongoMatch.Common;
 using LongoMatch.Interfaces;
 
diff --git a/LongoMatch.Core/Store/PlayListPlay.cs b/LongoMatch.Core/Store/PlayListPlay.cs
index affb607..fbfd17a 100644
--- a/LongoMatch.Core/Store/PlayListPlay.cs
+++ b/LongoMatch.Core/Store/PlayListPlay.cs
@@ -20,7 +20,6 @@
 
 using System;
 using System.Collections.Generic;
-using Gdk;
 
 namespace LongoMatch.Store
 {
diff --git a/LongoMatch.Core/Store/Player.cs b/LongoMatch.Core/Store/Player.cs
index 896b605..ca0dd06 100644
--- a/LongoMatch.Core/Store/Player.cs
+++ b/LongoMatch.Core/Store/Player.cs
@@ -17,7 +17,6 @@
 //
 
 using System;
-using Gdk;
 using LongoMatch.Common;
 
 namespace LongoMatch.Store
@@ -64,16 +63,16 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// My photo
 		/// </summary>
-		public Pixbuf Photo {
+		public Image Photo {
 			get {
 				if(photo != null)
-					return new Pixbuf(photo);
+					return Image.Deserialize(photo);
 				else
 					return null;
 			}
 			set {
 				if(value != null)
-					photo = value.SaveToBuffer("png");
+					photo = value.Serialize();
 				else
 					photo = null;
 			}
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index fdb303b..a02069a 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -22,8 +22,7 @@ using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
-using Gdk;
-using Gtk;
+
 using LongoMatch.Common;
 using LongoMatch.Interfaces;
 using LongoMatch.Store;
@@ -115,6 +114,12 @@ namespace LongoMatch.Store
 				return Categories.GameUnits;
 			}
 		}
+		
+		public IEnumerable<IGrouping<Category, Play>> PlaysGroupedByCategory {
+			get {
+				return timeline.GroupBy(play => play.Category);
+			}
+		}
 		#endregion
 
 		#region Public Methods
@@ -147,7 +152,7 @@ namespace LongoMatch.Store
 		/// <returns>
 		/// A <see cref="MediaTimeNode"/>: created play
 		/// </returns>
-		public Play AddPlay(Category category, Time start, Time stop, Pixbuf miniature) {
+		public Play AddPlay(Category category, Time start, Time stop, Image miniature) {
 			string count= String.Format("{0:000}",timeline.Count+1);
 			string name = String.Format("{0} {1}",category.Name, count);
 
@@ -163,7 +168,7 @@ namespace LongoMatch.Store
 			timeline.Add(play);
 			return play;
 		}
-
+		
 		/// <summary>
 		/// Delete a play from the project
 		/// </summary>
@@ -223,34 +228,6 @@ namespace LongoMatch.Store
 			return timeline;
 		}
 
-		/// <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() {
-			Dictionary<Category, TreeIter> itersDic = new Dictionary<Category, TreeIter>();
-			Gtk.TreeStore dataFileListStore = new Gtk.TreeStore(typeof(Play));
-
-			foreach(Category cat in Categories) {
-				Gtk.TreeIter iter = dataFileListStore.AppendValues(cat);
-				itersDic.Add(cat, iter);
-			}
-			
-			var queryPlaysByCategory =
-				timeline.GroupBy(play => play.Category);
-			foreach(var playsGroup in queryPlaysByCategory) {
-				Category cat = playsGroup.Key;
-				if(!itersDic.ContainsKey(cat))
-					continue;
-				foreach(Play play in playsGroup) {
-					dataFileListStore.AppendValues(itersDic[cat],play);
-				}
-			}
-			return dataFileListStore;
-		}
 
 		public bool Equals(Project project) {
 			if(project == null)
@@ -284,37 +261,5 @@ namespace LongoMatch.Store
 			}
 		}
 		#endregion
-
-		public void GetPlayersModel(out TreeStore localTeam, out TreeStore visitorTeam) {
-			Dictionary<Player, TreeIter> localDict = new Dictionary<Player, TreeIter>();
-			Dictionary<Player, TreeIter> visitorDict = new Dictionary<Player, TreeIter>();
-			
-			localTeam = new TreeStore(typeof(object));
-			visitorTeam = new TreeStore(typeof(object));
-
-			foreach(var player in LocalTeamTemplate) {
-				/* Add a root in the tree with the option name */
-				var iter = localTeam.AppendValues(player);
-				localDict.Add(player, iter);
-			}
-			
-			foreach(var player in VisitorTeamTemplate) {
-				/* Add a root in the tree with the option name */
-				var iter = visitorTeam.AppendValues(player);
-				visitorDict.Add(player, iter);
-			}
-			
-			foreach (var play in timeline) {
-				foreach (var player in play.Players.AllUniqueElements) {
-					if (localDict.ContainsKey(player.Value))
-						localTeam.AppendValues(localDict[player.Value], new object[1] {play});
-					else
-						visitorTeam.AppendValues(visitorDict[player.Value], new object[1] {play});
-				}
-			}
-		}
-
-		#region Private Methods
-		#endregion
 	}
 }
diff --git a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
index dc8d73b..ad49829 100644
--- a/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/CategoriesTemplate.cs
@@ -19,8 +19,9 @@
 //
 using System;
 using System.Collections.Generic;
+using System.Drawing;
 using System.Linq;
-using Gdk;
+
 using Mono.Unix;
 using LongoMatch.Common;
 using LongoMatch.Interfaces;
@@ -73,7 +74,7 @@ namespace LongoMatch.Store.Templates
 			PlayerSubCategory localplayers, visitorplayers;
 			TagSubCategory period;
 			TeamSubCategory team;
-			Color c = new Color((Byte)255, (Byte)0, (Byte)0);
+			Color c = Color.FromArgb(255, 0, 0);
 			HotKey h = new HotKey();
 			
 			team = new TeamSubCategory {
diff --git a/LongoMatch.Core/Store/Templates/TeamTemplate.cs b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
index 160bfb7..2b3a8e2 100644
--- a/LongoMatch.Core/Store/Templates/TeamTemplate.cs
+++ b/LongoMatch.Core/Store/Templates/TeamTemplate.cs
@@ -20,7 +20,6 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using Mono.Unix;
-using Gdk;
 
 using LongoMatch.Common;
 using LongoMatch.Interfaces;
@@ -49,14 +48,13 @@ namespace LongoMatch.Store.Templates
 			set;
 		}
 		
-		public Pixbuf Shield {
+		public Image Shield {
 			get {
 				if(thumbnailBuf != null)
-					return new Pixbuf(thumbnailBuf);
+					return Image.Deserialize(thumbnailBuf);
 				else return null;
 			} set {
-				var pix = ImageUtils.Scale(value, MAX_WIDTH, MAX_HEIGHT);
-				thumbnailBuf = ImageUtils.Serialize(pix);
+				thumbnailBuf = value.Serialize();
 			}
 		}
 		
diff --git a/LongoMatch.Core/Common/Cairo.cs b/LongoMatch.GUI/Gui/Cairo.cs
similarity index 99%
rename from LongoMatch.Core/Common/Cairo.cs
rename to LongoMatch.GUI/Gui/Cairo.cs
index e396b2f..3df74a9 100644
--- a/LongoMatch.Core/Common/Cairo.cs
+++ b/LongoMatch.GUI/Gui/Cairo.cs
@@ -18,6 +18,7 @@
 using System;
 using Cairo;
 
+
 namespace LongoMatch.Common
 {
 	public class CairoUtils
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
new file mode 100644
index 0000000..3845287
--- /dev/null
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -0,0 +1,307 @@
+// 
+//  Copyright (C) 2011 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 Gtk;
+using Gdk;
+using Mono.Unix;
+
+using Image = LongoMatch.Common.Image;
+using LongoMatch.Common;
+using LongoMatch.Interfaces;
+using LongoMatch.Interfaces.GUI;
+using LongoMatch.Gui.Component;
+using LongoMatch.Gui.Dialog;
+using LongoMatch.Gui.Popup;
+using LongoMatch.Store;
+using LongoMatch.Store.Templates;
+using LongoMatch.Video.Utils;
+
+namespace LongoMatch.Gui
+{
+	public class GUIToolkit: IGUIToolkit
+	{
+		IMainWindow mainWindow;
+		
+		public GUIToolkit ()
+		{
+			mainWindow = new MainWindow();
+			(mainWindow as MainWindow).Show();
+		}
+		
+		public IMainWindow MainWindow{
+			get {
+				return mainWindow;
+			}
+		}
+		
+		public void InfoMessage(string message) {
+			MessagePopup.PopupMessage(mainWindow as Gtk.Widget, Gtk.MessageType.Info, message);
+		}
+		
+		public void ErrorMessage(string message) {
+			MessagePopup.PopupMessage(mainWindow as Gtk.Widget, Gtk.MessageType.Error, message);
+		}
+		
+		public void WarningMessage(string message) {
+			MessagePopup.PopupMessage(mainWindow as Gtk.Widget, Gtk.MessageType.Warning, message);
+		}
+		
+		public bool QuestionMessage(string question, string title) {
+			MessageDialog md = new MessageDialog(mainWindow as Gtk.Window, DialogFlags.Modal,
+				MessageType.Question, Gtk.ButtonsType.YesNo, question);
+			md.Icon = Gtk.IconTheme.Default.LoadIcon("longomatch", 48, 0);
+			var res = md.Run();
+			md.Destroy();
+			return (res == (int)ResponseType.Yes);
+		}
+		
+		public string SaveFile(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter)
+		{
+			return FileChooser(title, defaultName, defaultFolder, filterName,
+				extensionFilter, FileChooserAction.Save);
+		}
+		
+		public string SelectFolder(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter)
+		{
+			return FileChooser(title, defaultName, defaultFolder, filterName,
+				extensionFilter, FileChooserAction.SelectFolder);
+		}
+		
+		public string OpenFile(string title, string defaultName, string defaultFolder,
+			string filterName, string extensionFilter)
+		{
+			return FileChooser(title, defaultName, defaultFolder, filterName,
+				extensionFilter, FileChooserAction.Open);
+		}
+		
+		public Job ConfigureRenderingJob (IPlayList playlist)
+		{
+			VideoEditionProperties vep;
+			Job job = null;
+			int response;
+
+			vep = new VideoEditionProperties();
+			vep.TransientFor = mainWindow as Gtk.Window;
+			response = vep.Run();
+			while(response == (int)ResponseType.Ok && vep.EncodingSettings.OutputFile == "") {
+				WarningMessage(Catalog.GetString("Please, select a video file."));
+				response=vep.Run();
+			}
+			if(response ==(int)ResponseType.Ok)
+				job = new Job(playlist, vep.EncodingSettings, vep.EnableAudio, vep.TitleOverlay);
+			vep.Destroy();
+			return job;
+		}
+		
+		public void ExportFrameSeries(Project openedProject, Play play, string snapshotsDir) {
+			SnapshotsDialog sd;
+			uint interval;
+			string seriesName;
+			string outDir;
+
+
+			sd= new SnapshotsDialog();
+			sd.TransientFor= mainWindow as Gtk.Window;
+			sd.Play = play.Name;
+
+			if(sd.Run() == (int)ResponseType.Ok) {
+				sd.Destroy();
+				interval = sd.Interval;
+				seriesName = sd.SeriesName;
+				outDir = System.IO.Path.Combine(snapshotsDir, seriesName);
+				var fsc = new FramesSeriesCapturer(openedProject.Description.File.FilePath,
+				                               play.Start.MSeconds, play.Stop.MSeconds,
+				                               interval, outDir);
+				var fcpd = new FramesCaptureProgressDialog(fsc);
+				fcpd.TransientFor = mainWindow as Gtk.Window;
+				fcpd.Run();
+				fcpd.Destroy();
+			}
+			else
+				sd.Destroy();
+		}
+		
+		public void TagPlay (Play play, TeamTemplate local, TeamTemplate visitor) {
+			TaggerDialog tg = new TaggerDialog(play.Category, play.Tags, play.Players, play.Teams,
+			                                   local, visitor);
+			tg.TransientFor = mainWindow as Gtk.Window;
+			tg.Run();
+			tg.Destroy();
+		}
+
+		public void DrawingTool (Image image, Play play, int stopTime) {
+			DrawingTool dialog = new DrawingTool();
+
+			dialog.Image = image.Value;
+			if (play != null)
+				dialog.SetPlay(play, stopTime);
+			dialog.TransientFor = mainWindow as Gtk.Window;
+			image.Dispose();
+			dialog.Run();
+			dialog.Destroy();	
+		}
+		
+		public ProjectDescription SelectProject(List<ProjectDescription> projects) {
+			ProjectDescription project = null;
+			OpenProjectDialog opd = new OpenProjectDialog();
+			
+			opd.Fill(projects);	
+			opd.TransientFor = mainWindow as Gtk.Window;
+			if(opd.Run() == (int)ResponseType.Ok)
+				project = opd.SelectedProject;
+			opd.Destroy();
+			return project;
+		}
+		
+		public void OpenCategoriesTemplatesManager(ICategoriesTemplatesProvider tp)
+		{
+			var tManager = new TemplatesManager<Categories, Category> (tp, new CategoriesTemplateEditorWidget (tp));
+			tManager.TransientFor = mainWindow as Gtk.Window;
+			tManager.Show();
+		}
+
+		public void OpenTeamsTemplatesManager(ITeamTemplatesProvider tp)
+		{
+			var tManager = new TemplatesManager<TeamTemplate, Player>(tp, new TeamTemplateEditorWidget (tp));
+			tManager.TransientFor = mainWindow as Gtk.Window;
+			tManager.Show();
+		}
+		
+		public void OpenProjectsManager(Project openedProject, IDatabase db, ITemplatesService ts)
+		{
+			Gui.Dialog.ProjectsManager pm = new Gui.Dialog.ProjectsManager(openedProject, db, ts);
+			pm.TransientFor = mainWindow as Gtk.Window;
+			pm.Show();
+		}
+		
+		public void ManageJobs(IRenderingJobsManager manager) {
+			RenderingJobsDialog dialog = new RenderingJobsDialog(manager);
+			dialog.TransientFor = mainWindow as Gtk.Window;
+			dialog.Run();
+			dialog.Destroy();
+		}
+		
+		public ProjectType SelectNewProjectType () {
+			ProjectSelectionDialog psd;
+			int response;
+
+			psd = new ProjectSelectionDialog();
+			psd.TransientFor = mainWindow as Gtk.Window;;
+			response = psd.Run();
+			psd.Destroy();
+			if(response != (int)ResponseType.Ok)
+				return ProjectType.None;
+			return psd.ProjectType;
+		}
+		
+		public Project NewCaptureProject(IDatabase db, ITemplatesService ts,
+			List<LongoMatch.Common.Device> devices, out CaptureSettings captureSettings)
+		{
+			return NewProject(db, null, ProjectType.CaptureProject, ts, devices, out captureSettings);
+		}
+		
+		public Project NewFakeProject(IDatabase db, ITemplatesService ts) {
+			CaptureSettings captureSettings = new CaptureSettings();
+			return NewProject(db, null, ProjectType.FakeCaptureProject, ts, null, out captureSettings);
+		}
+		
+		public Project NewFileProject(IDatabase db, ITemplatesService ts) {
+			CaptureSettings captureSettings = new CaptureSettings();
+			return NewProject(db, null, ProjectType.FileProject, ts, null, out captureSettings);
+		}
+		
+		public Project EditFakeProject(IDatabase db, Project project, ITemplatesService ts) {
+			CaptureSettings captureSettings = new CaptureSettings();
+			return NewProject(db, null, ProjectType.FakeCaptureProject, ts, null, out captureSettings);
+		}
+		
+		public IBusyDialog BusyDialog(string message) {
+			BusyDialog dialog;
+
+			dialog = new BusyDialog();
+			dialog.TransientFor = mainWindow as Gtk.Window;
+			dialog.Message = message; 
+			return dialog;
+		}
+		
+		Project NewProject(IDatabase db, Project project, ProjectType type,
+			ITemplatesService tps, List<LongoMatch.Common.Device> devices, out CaptureSettings captureSettings)
+		{
+			NewProjectDialog npd = new NewProjectDialog();
+			
+			npd.TransientFor = mainWindow as Gtk.Window;
+			npd.Use = type;
+			npd.Project = project;
+			if(type == ProjectType.CaptureProject)
+				npd.Devices = devices;
+			npd.TemplatesService = tps;
+			int response = npd.Run();
+			while(true) {
+				if(response != (int)ResponseType.Ok) {
+					break;
+				} else if(npd.Project == null) {
+					InfoMessage(Catalog.GetString("Please, select a video file."));
+					response=npd.Run();
+				} else {
+					project = npd.Project;
+					break;
+				}
+			}	
+			if (type == ProjectType.CaptureProject)
+				captureSettings = npd.CaptureSettings;
+			npd.Destroy();
+			return project;
+		}
+		
+		string  FileChooser(string title, string defaultName,
+			string defaultFolder, string filterName, string extensionFilter,
+			FileChooserAction action)
+		{
+			FileChooserDialog fChooser;
+			FileFilter filter;
+			string button, path;
+			
+			if (action == FileChooserAction.Save)
+				button = "gtk-save";
+			else
+				button = "gtk-open";
+			
+			fChooser = new FileChooserDialog(title, mainWindow as Gtk.Window, action,
+			                                 "gtk-cancel",ResponseType.Cancel,
+			                                 button,ResponseType.Accept);
+			fChooser.SetCurrentFolder(defaultFolder);
+			fChooser.SetFilename(defaultName);
+			filter = new FileFilter();
+			filter.Name = filterName;
+			filter.AddPattern(extensionFilter);
+			fChooser.AddFilter(filter);	
+			
+			if (fChooser.Run() != (int)ResponseType.Accept) 
+				path = null;
+			else
+				path = fChooser.Filename;
+			
+			fChooser.Destroy();
+			return path;
+		}
+	}
+}
+
diff --git a/LongoMatch.Core/Common/Images.cs b/LongoMatch.GUI/Gui/Helpers.cs
similarity index 88%
rename from LongoMatch.Core/Common/Images.cs
rename to LongoMatch.GUI/Gui/Helpers.cs
index 68408de..2cd68f6 100644
--- a/LongoMatch.Core/Common/Images.cs
+++ b/LongoMatch.GUI/Gui/Helpers.cs
@@ -21,38 +21,10 @@ using Gtk;
 using Gdk;
 using Mono.Unix;
 
-namespace LongoMatch.Common
+namespace LongoMatch.Gui
 {
-	public class ImageUtils
+	public class Helpers
 	{
-		public static Pixbuf Scale(Pixbuf pixbuf, int max_width, int max_height) {
-			int ow,oh,h,w;
-
-			h = ow = pixbuf.Height;
-			w = oh = pixbuf.Width;
-			ow = max_width;
-			oh = max_height;
-
-			if(w>max_width || h>max_height) {
-				Pixbuf scalledPixbuf;
-				double rate = (double)w/(double)h;
-				
-				if(h>w)
-					ow = (int)(oh * rate);
-				else
-					oh = (int)(ow / rate);
-				scalledPixbuf = pixbuf.ScaleSimple(ow,oh,Gdk.InterpType.Bilinear);
-				pixbuf.Dispose();
-				return scalledPixbuf;
-			} else {
-				return pixbuf;
-			}
-		}
-		
-		public static byte[] Serialize(Pixbuf pixbuf) {
-			return pixbuf.SaveToBuffer("png");
-		}
-		
 		public static FileFilter GetFileFilter() {
 			FileFilter filter = new FileFilter();
 			filter.Name = "Images";
@@ -83,6 +55,38 @@ namespace LongoMatch.Common
 			fChooser.Destroy();
 			return pimage;
 		}
+		
+		public static Pixbuf Scale(Pixbuf pixbuf, int max_width, int max_height) {
+			int ow,oh,h,w;
+
+			h = ow = pixbuf.Height;
+			w = oh = pixbuf.Width;
+			ow = max_width;
+			oh = max_height;
+
+			if(w>max_width || h>max_height) {
+				Pixbuf scalledPixbuf;
+				double rate = (double)w/(double)h;
+				
+				if(h>w)
+					ow = (int)(oh * rate);
+				else
+					oh = (int)(ow / rate);
+				scalledPixbuf = pixbuf.ScaleSimple(ow,oh,Gdk.InterpType.Bilinear);
+				pixbuf.Dispose();
+				return scalledPixbuf;
+			} else {
+				return pixbuf;
+			}
+		}
+		
+		public static Color ToGdkColor(System.Drawing.Color color) {
+			return new Color((byte)color.R, (byte)color.G, (byte)color.B);
+		}
+		
+		public static System.Drawing.Color ToDrawingColor(Color color) {
+			return System.Drawing.Color.FromArgb((int)color.Red, (int)color.Green, (int)color.Blue);
+		}
 	}
 }
 



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