[gbrainy] gbrainy' WebForms experimental client
- From: Jordi Mas <jmas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gbrainy] gbrainy' WebForms experimental client
- Date: Wed, 18 Aug 2010 11:27:18 +0000 (UTC)
commit d762d292bd3f3e19dd35fc53b08d7fb6e7b0ae59
Author: Jordi Mas <jmas softcatala org>
Date: Wed Aug 18 13:28:21 2010 +0200
gbrainy' WebForms experimental client
src/Clients/WebForms/Default.aspx | 60 ++++++
src/Clients/WebForms/Default.aspx.cs | 48 +++++
src/Clients/WebForms/Default.aspx.designer.cs | 30 +++
src/Clients/WebForms/Finish.aspx | 9 +
src/Clients/WebForms/Finish.aspx.cs | 38 ++++
src/Clients/WebForms/Finish.aspx.designer.cs | 26 +++
src/Clients/WebForms/Game.aspx | 37 ++++
src/Clients/WebForms/Game.aspx.cs | 206 ++++++++++++++++++++
src/Clients/WebForms/Game.aspx.designer.cs | 36 ++++
src/Clients/WebForms/Global.asax | 1 +
src/Clients/WebForms/Global.asax.cs | 100 ++++++++++
src/Clients/WebForms/LanguageSupport.cs | 77 ++++++++
src/Clients/WebForms/Logger.cs | 174 +++++++++++++++++
src/Clients/WebForms/MasterPage.master | 28 +++
src/Clients/WebForms/MasterPage.master.cs | 73 +++++++
src/Clients/WebForms/MasterPage.master.designer.cs | 20 ++
src/Clients/WebForms/README | 15 ++
src/Clients/WebForms/Status.aspx | 53 +++++
src/Clients/WebForms/Status.aspx.cs | 133 +++++++++++++
src/Clients/WebForms/Status.aspx.designer.cs | 30 +++
src/Clients/WebForms/TODO | 5 +
src/Clients/WebForms/WebForms.csproj | 149 ++++++++++++++
src/Clients/WebForms/WebForms.sln | 20 ++
src/Clients/WebForms/WebSession.cs | 21 ++
src/Clients/WebForms/images/allgames-32.png | Bin 0 -> 445 bytes
src/Clients/WebForms/images/endgame-32.png | Bin 0 -> 474 bytes
src/Clients/WebForms/images/logic-games-32.png | Bin 0 -> 1811 bytes
src/Clients/WebForms/images/math-games-32.png | Bin 0 -> 1191 bytes
src/Clients/WebForms/images/memory-games-32.png | Bin 0 -> 1146 bytes
src/Clients/WebForms/images/pause-32.png | Bin 0 -> 457 bytes
src/Clients/WebForms/images/resume-32.png | Bin 0 -> 559 bytes
src/Clients/WebForms/images/verbal-games-32.png | Bin 0 -> 1762 bytes
src/Clients/WebForms/styles.css | 43 ++++
src/Clients/WebForms/web.config | 33 +++
src/Core/Main/GameSession.cs | 3 +-
35 files changed, 1467 insertions(+), 1 deletions(-)
---
diff --git a/src/Clients/WebForms/Default.aspx b/src/Clients/WebForms/Default.aspx
new file mode 100644
index 0000000..6867ceb
--- /dev/null
+++ b/src/Clients/WebForms/Default.aspx
@@ -0,0 +1,60 @@
+<%@ Page Language="C#" MasterPageFile = "MasterPage.master" Inherits="WebForms.Default" %>
+<%@ Import Namespace="System.Data" %>
+
+<asp:content id="main_content" ContentPlaceHolderID ="main_placeholder" runat="server">
+
+ <b>Welcome to gbrainy.com</b>
+ <br/>
+
+ <br/>
+ <asp:Label id="intro_label" runat="server"/>
+ <br/>
+ <br/>
+
+ <!-- Logic -->
+ <span class="WelcomeLeft">
+ <img src = "images/logic-games-32.png"/>
+ </span>
+
+ <span class="WelcomeRight">
+ <asp:Label id="logic_label" runat="server"/>
+ </span>
+ <br/>
+ <br/>
+
+ <!-- Calculation -->
+ <span class="WelcomeLeft">
+ <img src = "images/math-games-32.png"/>
+ </span>
+
+ <span class="WelcomeRight">
+ <asp:Label id="calculation_label" runat="server"/>
+ </span>
+ <br/>
+ <br/>
+
+ <!-- Memory -->
+ <span class="WelcomeLeft">
+ <img src = "images/memory-games-32.png"/>
+ </span>
+
+ <span class="WelcomeRight">
+ <asp:Label id="memory_label" runat="server"/>
+ </span>
+ <br/>
+ <br/>
+
+ <!-- Verbal -->
+ <span class="WelcomeLeft">
+ <img src = "images/verbal-games-32.png"/>
+ </span>
+
+ <span class="WelcomeRight">
+ <asp:Label id="verbal_label" runat="server"/>
+ </span>
+
+ <br/>
+ <br/>
+ <asp:Button id="start_button" Text="Start game!" OnClick="OnStartGame" runat="server"/>
+
+</asp:content>
diff --git a/src/Clients/WebForms/Default.aspx.cs b/src/Clients/WebForms/Default.aspx.cs
new file mode 100644
index 0000000..99c3e84
--- /dev/null
+++ b/src/Clients/WebForms/Default.aspx.cs
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace WebForms
+{
+ public partial class Default : System.Web.UI.Page
+ {
+ WebSession web_session;
+
+ void Page_Load (object o, EventArgs e)
+ {
+ web_session = Global.Sessions [Session.SessionID];
+
+ intro_label.Text = LanguageSupport.GetString (web_session, "gbrainy is a brain teaser game and trainer to have fun and to keep your brain trained. It includes:");
+ logic_label.Text = LanguageSupport.GetString (web_session, "Logic puzzles. Challenge your reasoning and thinking skills.");
+ calculation_label.Text = LanguageSupport.GetString (web_session,"Mental calculation. Arithmetical operations that test your mental calculation abilities.");
+ memory_label.Text = LanguageSupport.GetString (web_session, "Memory trainers. To prove your short term memory.");
+ verbal_label.Text = LanguageSupport.GetString (web_session, "Verbal analogies. Challenge your verbal aptitude.");
+ }
+
+ protected void OnStartGame (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Default.OnStartGame. Start game button click");
+ Response.Redirect ("Game.aspx");
+ }
+ }
+}
+
diff --git a/src/Clients/WebForms/Default.aspx.designer.cs b/src/Clients/WebForms/Default.aspx.designer.cs
new file mode 100644
index 0000000..8375722
--- /dev/null
+++ b/src/Clients/WebForms/Default.aspx.designer.cs
@@ -0,0 +1,30 @@
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace WebForms {
+
+
+ public partial class Default {
+
+ protected System.Web.UI.WebControls.Content main_content;
+
+ protected System.Web.UI.WebControls.Label intro_label;
+
+ protected System.Web.UI.WebControls.Label logic_label;
+
+ protected System.Web.UI.WebControls.Label calculation_label;
+
+ protected System.Web.UI.WebControls.Label memory_label;
+
+ protected System.Web.UI.WebControls.Label verbal_label;
+
+ protected System.Web.UI.WebControls.Button start_button;
+ }
+}
diff --git a/src/Clients/WebForms/Finish.aspx b/src/Clients/WebForms/Finish.aspx
new file mode 100644
index 0000000..add1c8e
--- /dev/null
+++ b/src/Clients/WebForms/Finish.aspx
@@ -0,0 +1,9 @@
+<%@ Page Language="C#" Inherits="WebForms.Finish" MasterPageFile="~/MasterPage.master" %>
+<%@ MasterType VirtualPath="~/MasterPage.master" %>
+<asp:Content ContentPlaceHolderID="main_placeholder" ID="main_placeholderContent" runat="server">
+
+ <asp:Image id="image" runat="server" />
+
+</asp:Content>
+
+
diff --git a/src/Clients/WebForms/Finish.aspx.cs b/src/Clients/WebForms/Finish.aspx.cs
new file mode 100644
index 0000000..d9e45f6
--- /dev/null
+++ b/src/Clients/WebForms/Finish.aspx.cs
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+
+namespace WebForms
+{
+ public partial class Finish : System.Web.UI.Page
+ {
+ void Page_Load (object o, EventArgs e)
+ {
+ WebSession web_session;
+ gbrainy.Core.Main.GameSession session;
+
+ web_session = Global.Sessions [Session.SessionID];
+ image.ImageUrl = Game.CreateImage (web_session);
+ }
+ }
+}
+
diff --git a/src/Clients/WebForms/Finish.aspx.designer.cs b/src/Clients/WebForms/Finish.aspx.designer.cs
new file mode 100644
index 0000000..b6fdd15
--- /dev/null
+++ b/src/Clients/WebForms/Finish.aspx.designer.cs
@@ -0,0 +1,26 @@
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace WebForms {
+
+
+ public partial class Finish {
+
+ protected System.Web.UI.WebControls.Content main_placeholderContent;
+
+ protected System.Web.UI.WebControls.Image image;
+
+ public new WebForms.MasterPage Master {
+ get {
+ return ((WebForms.MasterPage)(base.Master));
+ }
+ }
+ }
+}
diff --git a/src/Clients/WebForms/Game.aspx b/src/Clients/WebForms/Game.aspx
new file mode 100644
index 0000000..ec0fd2d
--- /dev/null
+++ b/src/Clients/WebForms/Game.aspx
@@ -0,0 +1,37 @@
+<%@ Page Language="C#" MasterPageFile = "MasterPage.master" Inherits="WebForms.Game" %>
+
+<asp:content id="main_content" ContentPlaceHolderID ="main_placeholder" runat="server">
+ <table border="1px" width = "500px" >
+ <tr>
+ <td colspan="2"><strong>Puzzle</strong></td>
+ </tr>
+ <tr>
+ <td>
+ <asp:Label id="question" runat="server"></asp:Label>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <asp:Image id="image" runat="server" />
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <asp:TextBox id = "answer_textbox" AutoCompleteType="None" EnableViewState="true" runat="server"></asp:TextBox>
+ <asp:Button id = "answer_button" Text = "Answer" OnClick ="OnClickAnswer" runat="server"></asp:Button>
+ <asp:Label id="result_label" runat="server"></asp:Label>
+ <asp:Label id="rationale_label" runat="server"></asp:Label>
+
+ <asp:LinkButton id="nextgame_link" OnClick ="OnClickNextGame" runat="server" />
+ <asp:LinkButton id="endgame_link" OnClick ="OnClickEndGame" runat="server" />
+ </td>
+ </tr>
+
+ <tr>
+ <td>
+ <asp:Label id="status" runat="server"></asp:Label>
+ </td>
+ </tr>
+ </table>
+ <br/>
+</asp:content>
diff --git a/src/Clients/WebForms/Game.aspx.cs b/src/Clients/WebForms/Game.aspx.cs
new file mode 100644
index 0000000..f8f70dd
--- /dev/null
+++ b/src/Clients/WebForms/Game.aspx.cs
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.IO;
+using System.Web;
+using System.Web.UI;
+using gbrainy.Core.Main;
+
+namespace WebForms
+{
+ public partial class Game : System.Web.UI.Page
+ {
+ gbrainy.Core.Main.Game _game;
+ gbrainy.Core.Main.GameSession session;
+ WebSession web_session;
+ static GameManager manager;
+
+ static public GameManager CreateManager ()
+ {
+ manager = new GameManager ();
+ manager.LoadAssemblyGames ("bin/gbrainy.Games.dll");
+
+ manager.LoadVerbalAnalogies (System.IO.Path.Combine ("data/", "verbal_analogies.xml"));
+ //manager.LoadGamesFromXml (System.IO.Path.Combine (Defines.DATA_DIR, "games.xml"));
+ //manager.LoadPlugins ();
+
+ manager.Difficulty = gbrainy.Core.Main.GameDifficulty.Medium;
+ manager.GameType = gbrainy.Core.Main.GameSession.Types.LogicPuzzles |
+ gbrainy.Core.Main.GameSession.Types.CalculationTrainers |
+ gbrainy.Core.Main.GameSession.Types.VerbalAnalogies;
+ return manager;
+ }
+
+ private void Page_Load (Object sender, EventArgs e)
+ {
+ web_session = Global.Sessions [Session.SessionID];
+
+ Logger.Debug ("Game.Page_Load. Page load starts. Session ID {0}, IsPostBack {1}", Session.SessionID,
+ IsPostBack);
+
+ if (web_session.GameState == null ||
+ web_session.GameState.Status == GameSession.SessionStatus.Finished)
+ {
+ Logger.Debug ("Game.Page_Load creating new session");
+ session = new gbrainy.Core.Main.GameSession ();
+ session.GameManager = CreateManager ();
+ session.New ();
+ web_session.GameState = session;
+
+ // If the first time that loads this does not have a session
+ // send the user to the home page
+ //Logger.Debug ("New Session, redirecting to Default.aspx");
+ //Response.Redirect ("Default.aspx");
+ } else
+ session = web_session.GameState;
+
+ if (IsPostBack == true) {
+ Logger.Debug ("Game.Page_Load. Ignoring postback");
+ return;
+ }
+
+ string answer = answer_textbox.Text;
+
+ Logger.Debug ("Game.Page_Load. Got answer: {0}", answer);
+
+ _game = GetNextGame ();
+
+ UpdateGame ();
+
+ nextgame_link.Text = "Next Game";
+ endgame_link.Text = "End Game";
+ Logger.Debug ("Game.Page_Load. Page load completed");
+ }
+
+ void UpdateGame ()
+ {
+ if (_game == null)
+ return;
+
+ status.Text = session.StatusText;
+ question.Text = LanguageSupport.GetString (web_session, _game.Question);
+ image.ImageUrl = CreateImage (web_session);
+ }
+
+ public gbrainy.Core.Main.Game GetNextGame ()
+ {
+ gbrainy.Core.Main.Game g = null;
+
+ if (session.Status != gbrainy.Core.Main.GameSession.SessionStatus.Finished)
+ {
+ session.NextGame ();
+ g = session.CurrentGame;
+ }
+ return g;
+ }
+
+ //
+ static public string GetImageFileName (string sessionid)
+ {
+ string file;
+
+ file = "tmp/" + sessionid + ".png";
+ return file;
+ }
+
+ static public string CreateImage (WebSession _session)
+ {
+ Cairo.ImageSurface cairo_image = null;
+ gbrainy.Core.Main.CairoContextEx cr = null;
+ string file = string.Empty;
+
+ try
+ {
+ cairo_image = new Cairo.ImageSurface (Cairo.Format.ARGB32, 400, 400);
+ cr = new gbrainy.Core.Main.CairoContextEx (cairo_image, "sans 12", 96);
+ file = GetImageFileName (_session.Session.SessionID);
+
+ // Draw Image
+ _session.GameState.Draw (cr, 400, 400, false);
+ cairo_image.WriteToPng (file);
+
+ if (File.Exists (file) == false)
+ Logger.Error ("Game.CreateImage. Error writting {0}", file);
+ else
+ Logger.Debug ("Game.CreateImage. Wrote image {0}", file);
+ }
+
+ finally
+ {
+ if (cr != null)
+ ((IDisposable) cr).Dispose ();
+
+ if (cairo_image != null)
+ ((IDisposable) cairo_image).Dispose ();
+ }
+
+ return file;
+ }
+
+ public virtual void OnClickNextGame (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Game.OnClickNextGame");
+ /*
+ Console.WriteLine ("--> OnClick Next Game");
+ Cache.Remove ("game");
+
+ _game = GetNextGame ();
+ UpdateGame ();
+ */
+
+ // TODO: This should be done at GameSession.Level
+ session.ScoreGame (String.Empty);
+ // TODO: Use Ajax for dynamic loading
+ Response.Redirect ("Game.aspx");
+ }
+
+ public virtual void OnClickAnswer (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Game.OnClickAnswer");
+
+ string answer = answer_textbox.Text;
+
+ if (String.IsNullOrEmpty (answer) == false)
+ {
+ if (session.ScoreGame (answer) == true) {
+ result_label.Text = LanguageSupport.GetString (web_session, "Congratulations.");
+ result_label.CssClass = "CorrectAnswer";
+ }
+ else {
+ result_label.Text = LanguageSupport.GetString (web_session, "Incorrect. ");
+ result_label.CssClass = null;
+ }
+
+ rationale_label.Text = LanguageSupport.GetString (web_session, session.CurrentGame.Answer);
+ } else
+
+ answer_button.Enabled = false;
+ }
+
+ public virtual void OnClickEndGame (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Game.OnClickEndGame");
+ session.End ();
+
+ Response.Redirect ("Finish.aspx");
+ }
+
+ }
+}
diff --git a/src/Clients/WebForms/Game.aspx.designer.cs b/src/Clients/WebForms/Game.aspx.designer.cs
new file mode 100644
index 0000000..6e5509b
--- /dev/null
+++ b/src/Clients/WebForms/Game.aspx.designer.cs
@@ -0,0 +1,36 @@
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace WebForms {
+
+
+ public partial class Game {
+
+ protected System.Web.UI.WebControls.Content main_content;
+
+ protected System.Web.UI.WebControls.Label question;
+
+ protected System.Web.UI.WebControls.Image image;
+
+ protected System.Web.UI.WebControls.TextBox answer_textbox;
+
+ protected System.Web.UI.WebControls.Button answer_button;
+
+ protected System.Web.UI.WebControls.Label result_label;
+
+ protected System.Web.UI.WebControls.Label rationale_label;
+
+ protected System.Web.UI.WebControls.LinkButton nextgame_link;
+
+ protected System.Web.UI.WebControls.LinkButton endgame_link;
+
+ protected System.Web.UI.WebControls.Label status;
+ }
+}
diff --git a/src/Clients/WebForms/Global.asax b/src/Clients/WebForms/Global.asax
new file mode 100644
index 0000000..a18034e
--- /dev/null
+++ b/src/Clients/WebForms/Global.asax
@@ -0,0 +1 @@
+<%@ Application Inherits="WebForms.Global" %>
diff --git a/src/Clients/WebForms/Global.asax.cs b/src/Clients/WebForms/Global.asax.cs
new file mode 100644
index 0000000..a6837df
--- /dev/null
+++ b/src/Clients/WebForms/Global.asax.cs
@@ -0,0 +1,100 @@
+
+using System;
+using System.IO;
+using System.Collections;
+using System.ComponentModel;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.SessionState;
+
+namespace WebForms
+{
+ public class Global : System.Web.HttpApplication
+ {
+ static public Dictionary <string, WebSession> Sessions = new Dictionary <string, WebSession> ();
+
+ protected virtual void Application_Start (Object sender, EventArgs e)
+ {
+ // Init log system
+ if (String.Compare (Environment.GetEnvironmentVariable ("GBRAINY_DEBUG"), "false", false) != 0)
+ {
+ Logger.LogLevel = Level.DEBUG;
+ Logger.LogDevice = new FileLogger ();
+ } else
+ {
+ Logger.LogLevel = Level.INFO;
+ Logger.LogDevice = new ConsoleLogger ();
+ }
+
+ Logger.Info ("Global.Application_Start.gbrainy web starting");
+ }
+
+ protected virtual void Session_Start (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Global.Session_Start. Session {0}", Session.SessionID);
+
+ WebSession details = new WebSession (HttpContext.Current.Session);
+
+ if (Sessions.ContainsKey (Session.SessionID))
+ {
+ Sessions [Session.SessionID] = details;
+ }
+ else
+ {
+ Sessions.Add (Session.SessionID, details);
+ }
+ }
+
+ protected virtual void Application_BeginRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_EndRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_AuthenticateRequest (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Application_Error (Object sender, EventArgs e)
+ {
+ }
+
+ protected virtual void Session_End (Object sender, EventArgs e)
+ {
+ const string CachePrefix = "@@@InProc@";
+ string sessionid;
+
+ // Needed due to a bug in Mono < 2.7.
+ // See: http://bugzilla.novell.com/show_bug.cgi?id=629990
+ if (Session.SessionID.StartsWith (CachePrefix, StringComparison.OrdinalIgnoreCase))
+ sessionid = Session.SessionID.Substring (CachePrefix.Length);
+ else
+ sessionid = Session.SessionID;
+
+ Logger.Debug ("Global.Session_End. Session {0}", sessionid);
+
+ if (Sessions.ContainsKey (sessionid)) {
+ Sessions.Remove (sessionid);
+
+ try
+ {
+ File.Delete (Game.GetImageFileName (Session.SessionID));
+ }
+ catch (Exception ex)
+ {
+ Logger.Error ("Global.Session_End. Could not delete {0}, exception: {1}",
+ Game.GetImageFileName (Session.SessionID), ex);
+ }
+ }
+ else
+ Logger.Error ("Global.Session_End. Could not find session " + Session.SessionID);
+ }
+
+ protected virtual void Application_End (Object sender, EventArgs e)
+ {
+ Logger.Debug ("Global.Application_End.");
+ }
+ }
+}
diff --git a/src/Clients/WebForms/LanguageSupport.cs b/src/Clients/WebForms/LanguageSupport.cs
new file mode 100644
index 0000000..5e48c60
--- /dev/null
+++ b/src/Clients/WebForms/LanguageSupport.cs
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using Mono.Unix;
+
+namespace WebForms
+{
+ static public class LanguageSupport
+ {
+ public class Language
+ {
+ public string Name { get; set; }
+ public string LangCode { get; set; }
+
+ public Language (string name, string code)
+ {
+ Name = name;
+ LangCode = code;
+ }
+ };
+
+ static Language [] languages =
+ {
+ new Language ("English", "en_US.utf8"),
+ new Language ("Catalan", "ca_ES.utf8"),
+ new Language ("Spanish", "es_ES.utf8"),
+ new Language ("German", "de_DE.utf8")
+ };
+
+ static public Language [] Languages
+ {
+ get { return languages;}
+
+ }
+
+ static public Language GetFromIndex (int i)
+ {
+ return languages [i];
+ }
+
+ static public String GetString (WebSession session, string str)
+ {
+ // GetText
+ string s = null;
+
+ Environment.SetEnvironmentVariable ("LANGUAGE",
+ LanguageSupport.GetFromIndex (session.LanguageIndex).LangCode);
+
+ Catalog.Init ("gbrainy", "locale/");
+ s = Catalog.GetString (str);
+
+ if (String.IsNullOrEmpty (s) == true)
+ return str;
+
+ return s;
+ }
+
+ }
+}
+
diff --git a/src/Clients/WebForms/Logger.cs b/src/Clients/WebForms/Logger.cs
new file mode 100644
index 0000000..eb311a7
--- /dev/null
+++ b/src/Clients/WebForms/Logger.cs
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.IO;
+
+namespace WebForms
+{
+ public enum Level { DEBUG, INFO, WARN, ERROR, FATAL };
+
+ public interface ILogger
+ {
+ void Log (Level lvl, string msg, params object[] args);
+ }
+
+ class NullLogger : ILogger
+ {
+ public void Log (Level lvl, string msg, params object[] args)
+ {
+ }
+ }
+
+ class ConsoleLogger : ILogger
+ {
+ public void Log (Level lvl, string msg, params object[] args)
+ {
+ msg = string.Format ("{0} [{1}]: {2}",
+ DateTime.Now.ToString(),
+ Enum.GetName (typeof (Level), lvl),
+ msg);
+
+ Console.WriteLine (msg, args);
+ }
+ }
+
+ class FileLogger : ILogger
+ {
+ StreamWriter log;
+ ConsoleLogger console;
+
+ public FileLogger ()
+ {
+ try {
+ string home = Environment.GetEnvironmentVariable ("HOME");
+ log = File.CreateText (Path.Combine (home != null ? home: string.Empty,
+ "gbrainy_web.log"));
+ log.Flush ();
+ } catch (IOException) {
+ // FIXME: Use temp file
+ }
+
+ console = new ConsoleLogger ();
+ }
+
+ ~FileLogger ()
+ {
+ if (log != null)
+ try {
+ log.Flush ();
+ } catch { }
+ }
+
+ public void Log (Level lvl, string msg, params object[] args)
+ {
+ console.Log (lvl, msg, args);
+
+ if (log != null) {
+ msg = string.Format ("{0} [{1}]: {2}",
+ DateTime.Now.ToString(),
+ Enum.GetName (typeof (Level), lvl),
+ msg);
+ log.WriteLine (msg, args);
+ log.Flush();
+ }
+ }
+ }
+
+ // This class provides a generic logging facility. By default all
+ // information is written to standard out and a log file, but other
+ // loggers are pluggable.
+ public static class Logger
+ {
+ private static Level log_level = Level.INFO;
+
+ static ILogger log_dev = new ConsoleLogger ();
+
+ static bool muted = false;
+
+ public static Level LogLevel
+ {
+ get {
+ return log_level;
+ }
+ set {
+ log_level = value;
+ }
+ }
+
+ public static ILogger LogDevice
+ {
+ get {
+ return log_dev;
+ }
+ set {
+ log_dev = value;
+ }
+ }
+
+ public static void Debug (string msg, params object[] args)
+ {
+ Log (Level.DEBUG, msg, args);
+ }
+
+ public static void Info (string msg, params object[] args)
+ {
+ Log (Level.INFO, msg, args);
+ }
+
+ public static void Warn (string msg, params object[] args)
+ {
+ Log (Level.WARN, msg, args);
+ }
+
+ public static void Error (string msg, params object[] args)
+ {
+ Log (Level.ERROR, msg, args);
+ }
+
+ public static void Fatal (string msg, params object[] args)
+ {
+ Log (Level.FATAL, msg, args);
+ }
+
+ public static void Log (Level lvl, string msg, params object[] args)
+ {
+ if (!muted && lvl >= log_level)
+ log_dev.Log (lvl, msg, args);
+ }
+
+ // This is here to support the original logging, but it should be
+ // considered deprecated and old code that uses it should be upgraded to
+ // call one of the level specific log methods.
+ public static void Log (string msg, params object[] args)
+ {
+ Log (Level.DEBUG, msg, args);
+ }
+
+ public static void Mute ()
+ {
+ muted = true;
+ }
+
+ public static void Unmute ()
+ {
+ muted = false;
+ }
+ }
+}
diff --git a/src/Clients/WebForms/MasterPage.master b/src/Clients/WebForms/MasterPage.master
new file mode 100644
index 0000000..99557c9
--- /dev/null
+++ b/src/Clients/WebForms/MasterPage.master
@@ -0,0 +1,28 @@
+<%@ Master Language="C#" Inherits="WebForms.MasterPage" AutoEventWireup="true" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+ <title>Welcome to gbrainy.com main page</title>
+ <link href="styles.css" rel="stylesheet" type="text/css"/>
+</head>
+<body>
+<form runat="server">
+<div class="Header">
+ <asp:HyperLink class="HeaderText" text ="Home" NavigateUrl ="Default.aspx" runat="server"/>
+ <span class="HeaderText">Play</span>
+ <span class="HeaderText">Download</span>
+ <span class="HeaderText">Help</span>
+ <span class="HeaderText">About</span>
+ <span class="HeaderText">
+ <asp:DropDownList id = "languages_drop" AutoPostBack="True" ViewStateMode="Enabled"
+ onselectedindexchanged="OnSelectedIndexChanged" runat="server">
+ </asp:DropDownList>
+ </span>
+</div>
+
+<div class="MainContent">
+ <asp:contentplaceholder id="main_placeholder" runat="server" />
+</div>
+</form>
+</body>
+</html>
diff --git a/src/Clients/WebForms/MasterPage.master.cs b/src/Clients/WebForms/MasterPage.master.cs
new file mode 100644
index 0000000..1f5d91f
--- /dev/null
+++ b/src/Clients/WebForms/MasterPage.master.cs
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace WebForms
+{
+ public partial class MasterPage : System.Web.UI.MasterPage
+ {
+ const string CookieName = "Lang";
+
+ // Instead of Page_Load we do Page_Init (Executed before)
+ // To make sure that this code is executed before Page_Load the first page load
+ public void Page_Init (object o, EventArgs e)
+ {
+ Logger.Debug ("MasterPage.Page_Load. IsPostBack {0}", IsPostBack);
+
+ if (IsPostBack == true)
+ return;
+
+ for (int i = 0; i <LanguageSupport.Languages.Length; i++)
+ {
+ languages_drop.Items.Add (new ListItem (LanguageSupport.Languages[i].Name,
+ i.ToString ()));
+ }
+
+ if (Request.Cookies [CookieName] != null)
+ languages_drop.SelectedValue = Request.Cookies[CookieName].Value;
+ else // Default language value
+ languages_drop.SelectedValue = "0";
+
+ Global.Sessions [Session.SessionID].LanguageIndex =
+ Int32.Parse (languages_drop.SelectedValue);
+ }
+
+ protected void OnSelectedIndexChanged (object sender, EventArgs e)
+ {
+ if (Response.Cookies[CookieName].Value == languages_drop.SelectedValue)
+ return;
+
+ Response.Cookies[CookieName].Value = languages_drop.SelectedValue;
+ Response.Cookies[CookieName].Expires = DateTime.Now.AddYears (1);
+
+ Logger.Debug ("MasterPage.OnSelectedIndexChanged. Set lang cookie to: {0}",
+ languages_drop.SelectedValue);
+
+ Global.Sessions [Session.SessionID].LanguageIndex =
+ Int32.Parse (languages_drop.SelectedValue);
+
+ Response.Redirect ("Default.aspx");
+
+ }
+ }
+}
diff --git a/src/Clients/WebForms/MasterPage.master.designer.cs b/src/Clients/WebForms/MasterPage.master.designer.cs
new file mode 100644
index 0000000..daaee5e
--- /dev/null
+++ b/src/Clients/WebForms/MasterPage.master.designer.cs
@@ -0,0 +1,20 @@
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace WebForms {
+
+
+ public partial class MasterPage {
+
+ protected System.Web.UI.WebControls.DropDownList languages_drop;
+
+ protected System.Web.UI.WebControls.ContentPlaceHolder main_placeholder;
+ }
+}
diff --git a/src/Clients/WebForms/README b/src/Clients/WebForms/README
new file mode 100644
index 0000000..66145c4
--- /dev/null
+++ b/src/Clients/WebForms/README
@@ -0,0 +1,15 @@
+This is an experimental gbrainy web client using Mono's ASP.NET 3.5
+
+* User preferences
+
+To avoid deal with database access:
+
+- We use the user session InProc session handler. The status.Aspx will not work with other session types.
+- We store the user language using a cookie (named lang)
+
+* Localization
+
+Based on GNU GetText to reuse current translations
+
+
+
diff --git a/src/Clients/WebForms/Status.aspx b/src/Clients/WebForms/Status.aspx
new file mode 100644
index 0000000..712f74f
--- /dev/null
+++ b/src/Clients/WebForms/Status.aspx
@@ -0,0 +1,53 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Status.aspx.cs" Inherits="WebForms.Status" %>
+
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+ <title></title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ <b>gbrainy's status page</b>
+ <br/>
+ <asp:Label runat ="server" ID="updated_label"/>
+ <br/><br/>
+ <b>Current active list of gbrainy user's sessions</b>
+ <br/><br/>
+ <asp:Table id="sessions_table" GridLines="Both" CellPadding="5" CellSpacing="5" Runat="server">
+ <asp:TableHeaderRow Runat="server">
+ <asp:TableHeaderCell Runat="server">Session ID</asp:TableHeaderCell>
+ <asp:TableHeaderCell Runat="server">Time Started</asp:TableHeaderCell>
+ </asp:TableHeaderRow>
+ </asp:Table>
+ <br/>
+ <asp:Label runat ="server" ID="total_label"/>
+ <br/><br/>
+ <b>Games</b>
+ <br/>
+ <asp:Label runat ="server" ID="games_label"/>
+ <br/><br/>
+ <b>gbrainy assemblies versions</b>
+ <asp:Table id="assemblies_table" GridLines="Both" CellPadding="5" CellSpacing="5" Runat="server">
+ <asp:TableHeaderRow Runat="server">
+ <asp:TableHeaderCell Runat="server">Assembly</asp:TableHeaderCell>
+ <asp:TableHeaderCell Runat="server">Version</asp:TableHeaderCell>
+ </asp:TableHeaderRow>
+ </asp:Table>
+ <br/><br/>
+
+ <b>Performance Counters</b>
+ <br/>
+ <asp:Table id="counters_table" GridLines="Both" CellPadding="5" CellSpacing="5" Runat="server">
+ <asp:TableHeaderRow Runat="server">
+ <asp:TableHeaderCell Runat="server">Category</asp:TableHeaderCell>
+ <asp:TableHeaderCell Runat="server">Counter</asp:TableHeaderCell>
+ <asp:TableHeaderCell Runat="server">Value</asp:TableHeaderCell>
+ </asp:TableHeaderRow>
+ </asp:Table>
+
+
+ </form>
+</body>
+</html>
diff --git a/src/Clients/WebForms/Status.aspx.cs b/src/Clients/WebForms/Status.aspx.cs
new file mode 100644
index 0000000..c06e421
--- /dev/null
+++ b/src/Clients/WebForms/Status.aspx.cs
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2010 Jordi Mas i Hernà ndez <jmas softcatala org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Reflection;
+using System.Diagnostics;
+
+namespace WebForms
+{
+ public partial class Status : System.Web.UI.Page
+ {
+ //protected System.Web.UI.WebControls.ListView ListView1;
+
+ public class PerfCounter
+ {
+ public string Category { get; set; }
+ public string Counter { get; set; }
+
+ public PerfCounter (string category, string counter)
+ {
+ Category = category;
+ Counter = counter;
+ }
+ }
+
+ static PerfCounter [] PerfCounters =
+ {
+ new PerfCounter ("Mono Memory", "Allocated Objects"),
+ new PerfCounter ("ASP.NET", "Requests Total"),
+
+ };
+
+
+ public void Page_Load (object sender, EventArgs e)
+ {
+ updated_label.Text = "Updated: " + DateTime.Now;
+
+ // Sessions
+ foreach (WebSession session in Global.Sessions.Values)
+ {
+ TableRow r = new TableRow ();
+
+ // Session ID
+ TableCell c = new TableCell ();
+ c.Controls.Add (new LiteralControl (session.Session.SessionID.ToString ()));
+ r.Cells.Add (c);
+
+ // Date
+ c = new TableCell ();
+ c.Controls.Add (new LiteralControl (session.Started.ToString ()));
+ r.Cells.Add (c);
+
+ sessions_table.Rows.Add (r);
+ }
+
+ total_label.Text = "Total sessions: " + Global.Sessions.Count;
+
+ // Games
+ string text = Game.CreateManager ().GetGamesSummary ();
+ text = text.Replace (Environment.NewLine, "<br/>");
+ games_label.Text = text;
+
+ // Assemblies
+ foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
+ {
+ TableRow r = new TableRow ();
+ AssemblyName name = asm.GetName ();
+
+ // Name
+ TableCell c = new TableCell ();
+ c.Controls.Add (new LiteralControl (name.Name));
+ r.Cells.Add (c);
+
+ // Version
+ c = new TableCell ();
+ c.Controls.Add (new LiteralControl (name.Version.ToString ()));
+ r.Cells.Add (c);
+
+ assemblies_table.Rows.Add (r);
+ }
+
+ // Performace counters
+ foreach (PerfCounter perf in PerfCounters)
+ {
+ TableRow r = new TableRow ();
+
+ // Category
+ TableCell c = new TableCell ();
+ c.Controls.Add (new LiteralControl (perf.Category));
+ r.Cells.Add (c);
+
+ // Name
+ c = new TableCell ();
+ c.Controls.Add (new LiteralControl (perf.Counter));
+ r.Cells.Add (c);
+
+ // Value
+ c = new TableCell ();
+ c.Controls.Add (new LiteralControl (ReadCounter (perf.Category, perf.Counter)));
+ r.Cells.Add (c);
+
+ counters_table.Rows.Add (r);
+ }
+ }
+
+ string ReadCounter (string category, string counter)
+ {
+ PerformanceCounter pc = new PerformanceCounter (category, counter);
+ pc.NextValue ();
+ return pc.NextValue ().ToString ();
+ }
+ }
+}
diff --git a/src/Clients/WebForms/Status.aspx.designer.cs b/src/Clients/WebForms/Status.aspx.designer.cs
new file mode 100644
index 0000000..478c421
--- /dev/null
+++ b/src/Clients/WebForms/Status.aspx.designer.cs
@@ -0,0 +1,30 @@
+// ------------------------------------------------------------------------------
+// <autogenerated>
+// This code was generated by a tool.
+// Mono Runtime Version: 2.0.50727.1433
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+// </autogenerated>
+// ------------------------------------------------------------------------------
+
+namespace WebForms {
+
+
+ public partial class Status {
+
+ protected System.Web.UI.HtmlControls.HtmlForm form1;
+
+ protected System.Web.UI.WebControls.Label updated_label;
+
+ protected System.Web.UI.WebControls.Table sessions_table;
+
+ protected System.Web.UI.WebControls.Label total_label;
+
+ protected System.Web.UI.WebControls.Label games_label;
+
+ protected System.Web.UI.WebControls.Table assemblies_table;
+
+ protected System.Web.UI.WebControls.Table counters_table;
+ }
+}
diff --git a/src/Clients/WebForms/TODO b/src/Clients/WebForms/TODO
new file mode 100644
index 0000000..d8e1db7
--- /dev/null
+++ b/src/Clients/WebForms/TODO
@@ -0,0 +1,5 @@
+Features
+
+- There are no user preferences (we should probably use Profiles)
+- There are no user statistics
+
diff --git a/src/Clients/WebForms/WebForms.csproj b/src/Clients/WebForms/WebForms.csproj
new file mode 100644
index 0000000..cfd3689
--- /dev/null
+++ b/src/Clients/WebForms/WebForms.csproj
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.21022</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{6F788C5C-17C2-47BC-82C8-2D318D91CB76}</ProjectGuid>
+ <ProjectTypeGuids>{349C5851-65DF-11DA-9384-00065B846F21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <OutputType>Library</OutputType>
+ <RootNamespace>WebForms</RootNamespace>
+ <AssemblyName>gbrainyWeb</AssemblyName>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin</OutputPath>
+ <DefineConstants>DEBUG</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin</OutputPath>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="gbrainy.Core, Version=1.51.0.0, Culture=neutral, PublicKeyToken=null">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\gbrainy.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="gbrainy.Games, Version=1.51.0.0, Culture=neutral, PublicKeyToken=null">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\..\gbrainy.Games.dll</HintPath>
+ </Reference>
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Extensions" />
+ <Reference Include="Mono.Cairo" />
+ <Reference Include="Mono.Posix" />
+ </ItemGroup>
+ <ItemGroup>
+ <Content Include="web.config" />
+ <Content Include="Default.aspx" />
+ <Content Include="images\allgames-32.png" />
+ <Content Include="images\endgame-32.png" />
+ <Content Include="images\logic-games-32.png" />
+ <Content Include="images\math-games-32.png" />
+ <Content Include="images\memory-games-32.png" />
+ <Content Include="images\pause-32.png" />
+ <Content Include="images\resume-32.png" />
+ <Content Include="images\verbal-games-32.png" />
+ <Content Include="MasterPage.master" />
+ <Content Include="styles.css" />
+ <Content Include="Status.aspx" />
+ <Content Include="Global.asax" />
+ <Content Include="Finish.aspx" />
+ <Content Include="Game.aspx" />
+ <Content Include="..\..\..\po\ca.gmo">
+ <Link>locale\ca.gmo</Link>
+ <DeployService-Deploy>true</DeployService-Deploy>
+ <DeployService-RelativeDeployPath>../locale/ca/LC_MESSAGES/gbrainy.mo</DeployService-RelativeDeployPath>
+ <DeployService-TargetDirectoryId>ProgramFiles</DeployService-TargetDirectoryId>
+ </Content>
+ <Content Include="..\..\..\po\de.gmo">
+ <Link>locale\de.gmo</Link>
+ <DeployService-Deploy>true</DeployService-Deploy>
+ <DeployService-RelativeDeployPath>../locale/de/LC_MESSAGES/gbrainy.mo</DeployService-RelativeDeployPath>
+ <DeployService-TargetDirectoryId>ProgramFiles</DeployService-TargetDirectoryId>
+ </Content>
+ <Content Include="..\..\..\po\es.gmo">
+ <Link>locale\es.gmo</Link>
+ <DeployService-Deploy>true</DeployService-Deploy>
+ <DeployService-RelativeDeployPath>../locale/es/LC_MESSAGES/gbrainy.mo</DeployService-RelativeDeployPath>
+ <DeployService-TargetDirectoryId>ProgramFiles</DeployService-TargetDirectoryId>
+ </Content>
+ <Content Include="..\..\..\data\verbal_analogies.xml">
+ <Link>data\verbal_analogies.xml</Link>
+ </Content>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Default.aspx.cs">
+ <DependentUpon>Default.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Default.aspx.designer.cs">
+ <DependentUpon>Default.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Game.aspx.cs">
+ <DependentUpon>Game.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Game.aspx.designer.cs">
+ <DependentUpon>Game.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="MasterPage.master.cs">
+ <DependentUpon>MasterPage.master</DependentUpon>
+ </Compile>
+ <Compile Include="MasterPage.master.designer.cs">
+ <DependentUpon>MasterPage.master</DependentUpon>
+ </Compile>
+ <Compile Include="LanguageSupport.cs" />
+ <Compile Include="Logger.cs" />
+ <Compile Include="Status.aspx.cs">
+ <DependentUpon>Status.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Status.aspx.designer.cs">
+ <DependentUpon>Status.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Global.asax.cs">
+ <DependentUpon>Global.asax</DependentUpon>
+ </Compile>
+ <Compile Include="WebSession.cs" />
+ <Compile Include="Finish.aspx.cs">
+ <DependentUpon>Finish.aspx</DependentUpon>
+ </Compile>
+ <Compile Include="Finish.aspx.designer.cs">
+ <DependentUpon>Finish.aspx</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v9.0\WebApplications\Microsoft.WebApplication.targets" />
+ <ProjectExtensions>
+ <MonoDevelop>
+ <Properties VerifyCodeBehindFields="true" VerifyCodeBehindEvents="true">
+ <XspParameters Port="8080" Address="127.0.0.1" SslMode="None" SslProtocol="Default" KeyType="None" CertFile="" KeyFile="" PasswordOptions="None" Password="" Verbose="true" />
+ <WebDeployTargets>
+ <Target Name="">
+ <FileCopier Handler="MonoDevelop.Deployment.LocalFileCopyHandler" TargetDirectory="/home/jordi/dev/gbrainy_web/src/Clients/WebForms/web" ctype="LocalFileCopyConfiguration" />
+ </Target>
+ </WebDeployTargets>
+ </Properties>
+ </MonoDevelop>
+ </ProjectExtensions>
+ <ItemGroup>
+ <Folder Include="images\" />
+ <Folder Include="locale\" />
+ <Folder Include="data\" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="TODO" />
+ <None Include="README" />
+ <None Include="..\..\..\data\games.xml">
+ <Link>data\games.xml</Link>
+ </None>
+ </ItemGroup>
+</Project>
diff --git a/src/Clients/WebForms/WebForms.sln b/src/Clients/WebForms/WebForms.sln
new file mode 100644
index 0000000..e52cb09
--- /dev/null
+++ b/src/Clients/WebForms/WebForms.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebForms", "WebForms.csproj", "{6F788C5C-17C2-47BC-82C8-2D318D91CB76}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {6F788C5C-17C2-47BC-82C8-2D318D91CB76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6F788C5C-17C2-47BC-82C8-2D318D91CB76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6F788C5C-17C2-47BC-82C8-2D318D91CB76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6F788C5C-17C2-47BC-82C8-2D318D91CB76}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(MonoDevelopProperties) = preSolution
+ StartupItem = WebForms.csproj
+ EndGlobalSection
+EndGlobal
diff --git a/src/Clients/WebForms/WebSession.cs b/src/Clients/WebForms/WebSession.cs
new file mode 100644
index 0000000..a85cdeb
--- /dev/null
+++ b/src/Clients/WebForms/WebSession.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Web.SessionState;
+using gbrainy.Core;
+
+namespace WebForms
+{
+ public class WebSession
+ {
+ public HttpSessionState Session { get; set; }
+ public DateTime Started { get; set; }
+ public gbrainy.Core.Main.GameSession GameState { get; set; }
+ public int LanguageIndex { get; set; }
+
+ public WebSession (HttpSessionState session)
+ {
+ Session = session;
+ Started = DateTime.Now;
+ }
+ }
+}
+
diff --git a/src/Clients/WebForms/images/allgames-32.png b/src/Clients/WebForms/images/allgames-32.png
new file mode 100644
index 0000000..0c87b4e
Binary files /dev/null and b/src/Clients/WebForms/images/allgames-32.png differ
diff --git a/src/Clients/WebForms/images/endgame-32.png b/src/Clients/WebForms/images/endgame-32.png
new file mode 100644
index 0000000..0a32116
Binary files /dev/null and b/src/Clients/WebForms/images/endgame-32.png differ
diff --git a/src/Clients/WebForms/images/logic-games-32.png b/src/Clients/WebForms/images/logic-games-32.png
new file mode 100644
index 0000000..1475418
Binary files /dev/null and b/src/Clients/WebForms/images/logic-games-32.png differ
diff --git a/src/Clients/WebForms/images/math-games-32.png b/src/Clients/WebForms/images/math-games-32.png
new file mode 100644
index 0000000..7c91653
Binary files /dev/null and b/src/Clients/WebForms/images/math-games-32.png differ
diff --git a/src/Clients/WebForms/images/memory-games-32.png b/src/Clients/WebForms/images/memory-games-32.png
new file mode 100644
index 0000000..a60dd23
Binary files /dev/null and b/src/Clients/WebForms/images/memory-games-32.png differ
diff --git a/src/Clients/WebForms/images/pause-32.png b/src/Clients/WebForms/images/pause-32.png
new file mode 100644
index 0000000..0e55e59
Binary files /dev/null and b/src/Clients/WebForms/images/pause-32.png differ
diff --git a/src/Clients/WebForms/images/resume-32.png b/src/Clients/WebForms/images/resume-32.png
new file mode 100644
index 0000000..105d4e6
Binary files /dev/null and b/src/Clients/WebForms/images/resume-32.png differ
diff --git a/src/Clients/WebForms/images/verbal-games-32.png b/src/Clients/WebForms/images/verbal-games-32.png
new file mode 100644
index 0000000..ab7e352
Binary files /dev/null and b/src/Clients/WebForms/images/verbal-games-32.png differ
diff --git a/src/Clients/WebForms/styles.css b/src/Clients/WebForms/styles.css
new file mode 100644
index 0000000..b103dc9
--- /dev/null
+++ b/src/Clients/WebForms/styles.css
@@ -0,0 +1,43 @@
+.Header
+{
+ width: 80%;
+ background-color: rgb(90%, 90%, 90%);
+ font-size: 24px;
+ margin-bottom: 30px;
+ margin-left: 30px;
+}
+
+body
+{
+ font: Arial,Helvetica,sans-serif;
+ font-size: 14px;
+}
+
+
+.CorrectAnswer
+{
+ color: green;
+}
+
+
+.HeaderText
+{
+ margin-right: 20px;
+}
+
+.WelcomeLeft
+{
+ width = 30%;
+}
+
+.WelcomeRight
+{
+ width = 70%;
+}
+
+.MainContent
+{
+
+ margin-left: 30px;
+ width: 80%;
+}
diff --git a/src/Clients/WebForms/web.config b/src/Clients/WebForms/web.config
new file mode 100644
index 0000000..c2a3f2f
--- /dev/null
+++ b/src/Clients/WebForms/web.config
@@ -0,0 +1,33 @@
+<?xml version="1.0"?>
+<!--
+Web.config file for WebForms.
+
+The settings that can be used in this file are documented at
+http://www.mono-project.com/Config_system.web and
+http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
+-->
+<configuration>
+ <system.web>
+ <compilation defaultLanguage="C#" debug="true">
+ <assemblies>
+ <add assembly="Mono.Posix, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+ <add assembly="Mono.Cairo, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" />
+ <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
+ </assemblies>
+ </compilation>
+ <customErrors mode="RemoteOnly">
+ </customErrors>
+ <authentication mode="None">
+ </authentication>
+ <authorization>
+ <allow users="*" />
+ </authorization>
+ <httpHandlers>
+ </httpHandlers>
+ <trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
+ <sessionState mode="InProc" cookieless="false" timeout="20" />
+ <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
+ <pages>
+ </pages>
+ </system.web>
+</configuration>
\ No newline at end of file
diff --git a/src/Core/Main/GameSession.cs b/src/Core/Main/GameSession.cs
index 741525d..3086dc5 100644
--- a/src/Core/Main/GameSession.cs
+++ b/src/Core/Main/GameSession.cs
@@ -148,7 +148,8 @@ namespace gbrainy.Core.Main
}
public GameManager GameManager {
- get {return game_manager;}
+ get { return game_manager;}
+ set { game_manager = value;}
}
public string TimePlayed {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]