~do-plugins/do-plugins/trunk

« back to all changes in this revision

Viewing changes to Emesene/src/EmeseneChangeAvatarAction.cs

  • Committer: Luis Montiel
  • Date: 2009-01-18 22:37:05 UTC
  • mto: (680.1.3 emesene-plugin)
  • mto: This revision was merged to the branch mainline in revision 533.
  • Revision ID: luis@luis-laptop-20090118223705-xtncxzad06f1miyf
updating with latest trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// EmeseneChangeAvatarAction.cs created with MonoDevelop
 
2
// User: luis at 07:56 p 20/11/2008
 
3
//
 
4
// To change standard headers go to Edit->Preferences->Coding->Standard Headers
 
5
//
 
6
 
 
7
using System;
 
8
using Do.Universe;
 
9
using System.Collections.Generic;
 
10
using System.IO;
 
11
        
 
12
namespace Emesene
 
13
{
 
14
        
 
15
        
 
16
        public class EmeseneChangeAvatarAction : Act
 
17
        {
 
18
                public static Dictionary<string, string> imageMimeTypeMap = new Dictionary<string,string>
 
19
                        {
 
20
                                {".jpg", "image/jpeg"},
 
21
                                {".jpeg", "image/jpeg"},
 
22
                                {".png", "image/png"}, 
 
23
                                {".gif", "image/gif"}, 
 
24
                                {".bmp", "image/bmp"}, 
 
25
                                {".tif", "image/tiff"}, 
 
26
                                {".tiff", "image/tiff"}
 
27
                        };
 
28
                
 
29
                public EmeseneChangeAvatarAction()
 
30
                {
 
31
                }
 
32
                
 
33
                private bool IsImageFile (IFileItem file)
 
34
                {
 
35
                        return imageMimeTypeMap.ContainsKey (Path.GetExtension (file.Path));
 
36
                }
 
37
                
 
38
                public override string Name
 
39
                {
 
40
                        get { return "Change emesene display picture"; }
 
41
                }
 
42
                
 
43
                public override string Description
 
44
                {
 
45
                        get { return "Change your emesene display picture"; }
 
46
                }
 
47
                
 
48
                public override string Icon 
 
49
                {
 
50
                        get { return "emesene"; }
 
51
                }
 
52
                
 
53
                public override IEnumerable<Type> SupportedItemTypes {
 
54
                        get { yield return      typeof (IFileItem); }
 
55
                }
 
56
                        
 
57
                public override bool SupportsItem (Item item)
 
58
                {       
 
59
                        if (item is IFileItem) {        
 
60
                                    return IsImageFile((item as IFileItem));
 
61
                                }
 
62
                        return false;
 
63
                }       
 
64
                
 
65
                public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
 
66
                {
 
67
                        foreach(Item avatar in items){
 
68
                                string path = (avatar as IFileItem).Path;
 
69
                                Emesene.set_avatar(path);
 
70
                        }
 
71
                        return null;
 
72
                }
 
73
        }
 
74
}