Esempio n. 1
0
 public void setAvatar(Status status)
 {
     Avatar.Clear();
     if (status == Status.idle)
     {
         for (int i = 0; i < Idle.Count; i++)
         {
             Avatar.Add(new Bitmap(Idle[i]));
         }
     }
     else if (status == Status.run)
     {
         for (int i = 0; i < Run.Count; i++)
         {
             Avatar.Add(new Bitmap(Run[i]));
         }
     }
     else if (status == Status.jump)
     {
         for (int i = 0; i < Jump.Count; i++)
         {
             Avatar.Add(new Bitmap(Jump[i]));
         }
     }
 }
Esempio n. 2
0
        private void AppendToList(Connection conn)
        {
            if (conn == null || conn.Roster == null)
            {
                return;
            }

            foreach (Contact contact in conn.Roster.GetAllContacts())
            {
                if (contact == null || contact.Avatar == null)
                {
                    continue;
                }

                MenuTile tile = new MenuTile();
                tile.SizeAllocated += delegate(object o, SizeAllocatedArgs args) {
                    int main_width, main_height = 0;
                    main_box.GetSizeRequest(out main_width, out main_height);

                    tile.WidthRequest = main_width;
                };

                tile.PrimaryText   = contact.Name;
                tile.SecondaryText = String.IsNullOrEmpty(contact.StatusMessage) ? contact.Status.ToString() : contact.StatusMessage;

                Avatar avatar = contact.Avatar;
                if (avatar.State == AvatarState.Loaded)
                {
                    tile.Pixbuf = new Gdk.Pixbuf(avatar.Image);
                    avatar.Clear(false);
                }
                else
                {
                    tile_map.Add(contact, tile);

                    avatar.Loaded += delegate(object sender, AvatarStateEventArgs e) {
                        Avatar a = sender as Avatar;
                        if (a != null && tile_map.ContainsKey(a.Contact))
                        {
                            if (e.State == AvatarState.Loaded)
                            {
                                tile_map[a.Contact].Pixbuf = new Gdk.Pixbuf(a.Image);
                                a.Clear(false);

                                main_box.QueueDraw();
                            }

                            tile_map.Remove(a.Contact);
                        }
                    };

                    avatar.Load();
                }

                contacts_view.AddWidget(tile);
            }
        }