* Shop + Plugin is now functionnal, sample Plugin provided to connect to the default...
[circ.git] / Circ.Frontend.GtkSharp / EmoticonsFactory.cs
blobe20a5fe27134bf0627f7d692543daae171dd4f1f
1 #region License
2 /* Circ.Frontend.GtkSharp : GTK# frontend for Circ
3 * Copyright (C) 2007 LAVAL Jérémie
5 * This file is licensed under the terms of the LGPL.
7 * For the complete licence see the file COPYING.
8 */
9 #endregion
10 using System;
11 using System.Collections.Generic;
12 using Gtk;
13 using Gdk;
15 namespace Circ.Frontend.GtkSharp
17 public static class EmoticonsFactory
19 delegate Pixbuf Worker();
20 // Thinking about memoization
21 public static Pixbuf GetEmoticonFromSmiley(string smiley)
23 Dictionary<string, Pixbuf> smileys = new Dictionary<string, Pixbuf>();
25 Worker worker = delegate {
26 Pixbuf temp;
27 if (smileys.TryGetValue(smiley, out temp))
28 return temp;
30 switch (smiley) {
31 case ":)":
32 temp = Pixbuf.LoadFromResource("smile.png");
33 smileys.Add(":)", temp);
34 break;
35 case ":D":
36 temp = Pixbuf.LoadFromResource("wink.png");
37 smileys.Add(":D", temp);
38 break;
41 return temp;
44 return worker();