コード例 #1
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is XmppGroupChatView))
                    {
                        // only invite to group chats
                        continue;
                    }
                    if (chatView == ChatViewManager.ActiveChat)
                    {
                        // don't need to add current chat to invite list
                        continue;
                    }
                    if (chatView.ProtocolManager != ProtocolManager)
                    {
                        // only add chats from current server
                        continue;
                    }
                    var groupChatView = (XmppGroupChatView)chatView;
                    if (groupChatView.IsContactList)
                    {
                        // ignore our abused groupchatview
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    var chatid = chatView.ID;
                    item.Activated += delegate {
                        var inviteFromChatModel = ChatViewManager.ActiveChat.ChatModel;
                        ThreadPool.QueueUserWorkItem(delegate {
                            try {
                                for (int i = 0; i < Invitees.Count; i++)
                                {
                                    ProtocolManager.CommandInvite(
                                        new CommandModel(
                                            Frontend.FrontendManager,
                                            inviteFromChatModel,
                                            chatid + " " + Invitees[i].ID
                                            )
                                        );
                                }
                            } catch (Exception ex) {
                                Frontend.ShowException(ex);
                            }
                        });
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }
コード例 #2
0
        void OnItemActivated(ChatView chat)
        {
            Trace.Call(chat);

            foreach (var invitee in Invitees)
            {
                var inviteeId = invitee.ID;
                ThreadPool.QueueUserWorkItem(delegate {
                    try {
                        ProtocolManager.CommandInvite(
                            new CommandModel(
                                Frontend.FrontendManager,
                                ChatViewManager.ActiveChat.ChatModel,
                                String.Format("{0} {1}", inviteeId, chat.ID)
                                )
                            );
                    } catch (Exception ex) {
                        Frontend.ShowException(ex);
                    }
                });
            }
        }
コード例 #3
0
        protected override void OnShown()
        {
            Trace.Call();

            if (!IsPopulated)
            {
                IsPopulated = true;
                foreach (var chatView in ChatViewManager.Chats)
                {
                    if (!(chatView is GroupChatView))
                    {
                        continue;
                    }

                    var item = new Gtk.ImageMenuItem(chatView.Name);
                    item.Image = new Gtk.Image(GroupChatView.IconPixbuf);
                    // HACK: anonymous methods inside foreach loops needs this
                    var chat = chatView;
                    item.Activated += delegate {
                        foreach (var invitee in Invitees)
                        {
                            ProtocolManager.CommandInvite(
                                new CommandModel(
                                    Frontend.FrontendManager,
                                    ChatViewManager.ActiveChat.ChatModel,
                                    String.Format("{0} {1}",
                                                  invitee.ID,
                                                  chat.ID)
                                    )
                                );
                        }
                    };
                    item.Show();
                    Append(item);
                }
            }

            base.OnShown();
        }