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); } }
void SetupUI() { win = new Window("Board Control"); win.Resize(600, 550); VBox box = new VBox(); HBox guide = new HBox(); guide.Add(new Label("Event")); guide.Add(new Label("Type")); guide.Add(new Label("Key")); guide.Add(new Label("")); box.PackStart(guide, false, false, 0); AddBox(box); Button addButton = new Button("+ New Control"); addButton.Pressed += (o, args) => { AddBox(box); box.QueueDraw(); win.ShowAll(); }; VBox framebox = new VBox(); framebox.Add(statuslabel = new Label(status) { Margin = 10 }); HBox buttonbox = new HBox() { Margin = 4 }; Button connect = new Button("Connect"); Button disconnect = new Button("Disconnect"); connect.Pressed += (o, args) => { Connect(); }; disconnect.Pressed += (o, args) => { Disconnect(); }; buttonbox.Add(connect); buttonbox.Add(disconnect); framebox.Add(buttonbox); Frame frame = new Frame() { Margin = 4, BorderWidth = 6 }; frame.Add(framebox); box.PackEnd(frame, false, false, 0); box.PackEnd(addButton, false, false, 0); win.Add(box); win.ShowAll(); }