예제 #1
0
        public override void RemoveChat(ChatModel chat)
        {
            ChatView chatView = f_Notebook.GetChat(chat);

            f_Notebook.TabPages.Remove(chatView);
            f_Chats.Remove(chatView);
        }
예제 #2
0
        private void _CommandWindow(CommandModel cd)
        {
            FrontendManager fm = cd.FrontendManager;

            if (cd.DataArray.Length >= 2)
            {
                ChatModel currentChatModel = _Notebook.CurrentChatView.ChatModel;
                string    name;
                if (cd.DataArray[1].ToLower() == "close")
                {
                    name = currentChatModel.Name;
                    // BUG: handle this in GNOME-IRC

                    /*
                     * if (currentChatModel.ChatType != ChatType.Network) {
                     *  if (currentChatModel.ProtocolManager is IrcProtocolManager) {
                     *      IrcProtocolManager ircm = (IrcProtocolManager) currentChatModel.ProtocolManager;
                     *      if (currentChatModel.ChatType == ChatType.Group) {
                     *          // channel
                     *          ircm.CommandPart(new CommandModel(fm, currentChatModel, name));
                     *      } else {
                     *          // query
                     *          Frontend.Session.RemoveChat(currentChatModel);
                     *      }
                     *  }
                     * }
                     */
                }
                else
                {
                    bool is_number = false;
                    int  pagecount = _Notebook.TabCount;
                    try {
                        int number = Int32.Parse(cd.DataArray[1]);
                        is_number = true;
                        if (number <= pagecount)
                        {
                            _Notebook.SelectedIndex = number - 1;
                        }
                    } catch (FormatException) {
                    }

                    if (!is_number)
                    {
                        // seems to be query- or channelname
                        // let's see if we find something
                        ArrayList candidates = new ArrayList();
                        for (int i = 0; i < pagecount; i++)
                        {
                            ChatView  chatView  = _Notebook.GetChat(i);
                            ChatModel chatModel = chatView.ChatModel;

                            if (chatModel.Name.ToLower() == cd.DataArray[1].ToLower())
                            {
                                // name matches
                                // first let's see if there is an exact match, if so, take it
                                if ((chatModel.ChatType == currentChatModel.ChatType) &&
                                    (chatModel.ProtocolManager == currentChatModel.ProtocolManager))
                                {
                                    _Notebook.SelectedIndex = i;
                                    break;
                                }
                                else
                                {
                                    // there was no exact match
                                    candidates.Add(i);
                                }
                            }
                        }

                        if (candidates.Count > 0)
                        {
                            _Notebook.SelectedIndex = (int)candidates[0];
                        }
                    }
                }
            }
        }