コード例 #1
0
 internal void RemoveBuddy(IRCConnection connection, BuddyListItem buddy)
 {
     if (this.InvokeRequired)
     {
         ClearBuddyDelegate cbl = new ClearBuddyDelegate(RemoveBuddy);
         this.Invoke(cbl, new object[] { connection, buddy });
     }
     else
     {
         //remove buddy from list with this connection
         //check CONNECTED
         for (int i = treeBuddies.Nodes[1].Nodes.Count; i > 0; i--)
         {
             if (treeBuddies.Nodes[1].Nodes[i - 1].Tag == connection)
             {
                 //nick could start with a ;
                 if (buddy.Nick.StartsWith(";"))
                 {
                     if (treeBuddies.Nodes[1].Nodes[i - 1].Text == buddy.Nick.Substring(1))
                     {
                         treeBuddies.Nodes[1].Nodes[i - 1].Remove();
                     }
                 }
                 else
                 {
                     if (treeBuddies.Nodes[1].Nodes[i - 1].Text == buddy.Nick)
                     {
                         treeBuddies.Nodes[1].Nodes[i - 1].Remove();
                     }
                 }
             }
         }
         //check DISCONNECTED
         for (int i = treeBuddies.Nodes[0].Nodes.Count; i > 0; i--)
         {
             if (treeBuddies.Nodes[0].Nodes[i - 1].Tag == connection)
             {
                 //nick could start with a ;
                 if (buddy.Nick.StartsWith(";"))
                 {
                     if (treeBuddies.Nodes[0].Nodes[i - 1].Text == buddy.Nick.Substring(1))
                     {
                         treeBuddies.Nodes[0].Nodes[i - 1].Remove();
                     }
                 }
                 else
                 {
                     if (treeBuddies.Nodes[0].Nodes[i - 1].Text == buddy.Nick)
                     {
                         treeBuddies.Nodes[0].Nodes[i - 1].Remove();
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
ファイル: BuddyList.cs プロジェクト: icechat/IceChat
        internal void UpdateBuddy(IRCConnection connection, BuddyListItem buddy)
        {
            if (this.InvokeRequired)
            {
                UpdateBuddyListDelegate ubl = new UpdateBuddyListDelegate(UpdateBuddy);
                this.Invoke(ubl, new object[] { connection, buddy });
            }
            else
            {
                try
                {
                    //check if buddy is already in list
                    RemoveBuddy(connection, buddy);

                    TreeNode t = new TreeNode
                    {
                        Text = buddy.Nick,
                        Tag  = connection
                    };

                    if (buddy.Connected)
                    {
                        t.ToolTipText = buddy.Nick + " on " + connection.ServerSetting.RealServerName;
                        this.treeBuddies.Nodes[1].Nodes.Add(t);
                        if (buddy.PreviousState == false)
                        {
                            _parent.PlaySoundFile("buddy");

                            if (_parent.IceChatOptions.SystemTrayBuddyOnline == true && _parent.IceChatOptions.SystemTrayServerMessage)
                            {
                                _parent.ShowTrayNotification("Your buddy " + buddy.Nick + " has come online on " + connection.ServerSetting.RealServerName);
                            }
                        }
                        buddy.PreviousState = true;
                    }
                    else if (!buddy.Nick.StartsWith(";"))
                    {
                        t.ToolTipText = buddy.Nick + " not on " + connection.ServerSetting.RealServerName;
                        this.treeBuddies.Nodes[0].Nodes.Add(t);
                        buddy.PreviousState = false;
                    }


                    this.treeBuddies.ExpandAll();
                }
                catch (Exception)
                {
                    //
                }
            }
        }
コード例 #3
0
ファイル: FormServerEditor.cs プロジェクト: W0LFOX/IceChat
        /// <summary>
        /// Update the Server Settings
        /// </summary>
        private bool SaveSettings()
        {
            if (serverSetting == null)
            {
                serverSetting = new ServerSetting();
            }

            if (textServername.Text.Length == 0)
            {
                MessageBox.Show("You do not have a server name");
                return(false);
            }
            if (textNickName.Text.Length == 0)
            {
                MessageBox.Show("You do not have a nick name");
                return(false);
            }

            serverSetting.NickName = textNickName.Text;
            if (textAltNickName.Text.Length > 0)
            {
                serverSetting.AltNickName = textAltNickName.Text;
            }
            else
            {
                serverSetting.AltNickName = textNickName.Text + "_";
            }

            serverSetting.AwayNickName = textAwayNick.Text;

            serverSetting.ServerName  = textServername.Text;
            serverSetting.DisplayName = textDisplayName.Text.Replace(((char)3).ToString(), "&#x3;").Replace(((char)2).ToString(), "&#x2;");

            if (textFullName.Text.Length == 0)
            {
                textFullName.Text = textDefaultFullName.Text;
            }
            serverSetting.FullName = textFullName.Text.Replace(((char)3).ToString(), "&#x3;").Replace(((char)2).ToString(), "&#x2;");

            if (textQuitMessage.Text.Length == 0)
            {
                textQuitMessage.Text = textDefaultQuitMessage.Text;
            }
            serverSetting.QuitMessage = textQuitMessage.Text.Replace(((char)3).ToString(), "&#x3;").Replace(((char)2).ToString(), "&#x2;");

            serverSetting.Password         = textServerPassword.Text;
            serverSetting.NickservPassword = textNickservPassword.Text;

            if (textServerPort.Text.Length == 0)
            {
                textServerPort.Text = "6667";
            }
            serverSetting.ServerPort = textServerPort.Text;

            if (textIdentName.Text.Length == 0)
            {
                textIdentName.Text = textDefaultIdent.Text;
            }
            serverSetting.IdentName = textIdentName.Text;

            serverSetting.AutoJoinEnable       = checkAutoJoin.Checked;
            serverSetting.AutoJoinDelay        = checkAutoJoinDelay.Checked;
            serverSetting.AutoJoinDelayBetween = checkAutoJoinDelayBetween.Checked;
            serverSetting.AutoPerformEnable    = checkAutoPerform.Checked;
            serverSetting.IgnoreListEnable     = checkIgnore.Checked;
            serverSetting.BuddyListEnable      = checkBuddyList.Checked;
            serverSetting.DisableLogging       = checkDisableLogging.Checked;
            serverSetting.DisableQueries       = checkDisableQueries.Checked;

            serverSetting.AutoJoinChannels = new string[listChannel.Items.Count];
            for (int i = 0; i < listChannel.Items.Count; i++)
            {
                if (listChannel.Items[i].Checked == false)
                {
                    if (listChannel.Items[i].SubItems.Count > 1)
                    {
                        serverSetting.AutoJoinChannels[i] = ";" + listChannel.Items[i].Text + " " + listChannel.Items[i].SubItems[1].Text;
                    }
                    else
                    {
                        serverSetting.AutoJoinChannels[i] = ";" + listChannel.Items[i].Text;
                    }
                }
                else
                {
                    if (listChannel.Items[i].SubItems.Count > 1)
                    {
                        serverSetting.AutoJoinChannels[i] = listChannel.Items[i].Text + " " + listChannel.Items[i].SubItems[1].Text;
                    }
                    else
                    {
                        serverSetting.AutoJoinChannels[i] = listChannel.Items[i].Text;
                    }
                }
            }

            serverSetting.IgnoreList = new string[listIgnore.Items.Count];
            for (int i = 0; i < listIgnore.Items.Count; i++)
            {
                if (listIgnore.Items[i].Checked == false)
                {
                    serverSetting.IgnoreList[i] = ";" + listIgnore.Items[i].Text;
                }
                else
                {
                    serverSetting.IgnoreList[i] = listIgnore.Items[i].Text;
                }
            }

            BuddyListItem[] oldList = serverSetting.BuddyList;

            serverSetting.BuddyList = new BuddyListItem[listBuddyList.Items.Count];
            for (int i = 0; i < listBuddyList.Items.Count; i++)
            {
                BuddyListItem b = new BuddyListItem();

                if (listBuddyList.Items[i].Checked == false)
                {
                    b.Nick = ";" + listBuddyList.Items[i].Text;
                }
                else
                {
                    b.Nick = listBuddyList.Items[i].Text;
                }

                //check if was sent on old list
                foreach (BuddyListItem bo in oldList)
                {
                    if (bo != null)
                    {
                        if (bo.IsOnSent)    //was sent, so was used
                        {
                            //now check for match
                            if (bo.Nick == b.Nick)
                            {
                                b.IsOnSent     = true;
                                b.IsOnReceived = bo.IsOnReceived;
                                b.Connected    = bo.Connected;

                                System.Diagnostics.Debug.WriteLine("matched:" + bo.Nick);
                            }
                            else if (b.Nick.StartsWith(";") && bo.Nick == b.Nick.Substring(1))
                            {
                                //nick is now disabled
                                b.Connected    = bo.Connected;
                                b.IsOnReceived = bo.IsOnReceived;
                                b.IsOnSent     = false;

                                System.Diagnostics.Debug.WriteLine("matched DIS:" + bo.Nick);
                            }
                        }
                    }
                }

                serverSetting.BuddyList[i] = b;
            }

            serverSetting.AutoPerform = textAutoPerform.Text.Replace(((char)3).ToString(), "&#x3;").Replace(((char)2).ToString(), "&#x2;").Trim().Split(new String[] { Environment.NewLine }, StringSplitOptions.None);

            serverSetting.SetModeI            = checkModeI.Checked;
            serverSetting.ShowMOTD            = checkMOTD.Checked;
            serverSetting.ShowPingPong        = checkPingPong.Checked;
            serverSetting.RejoinChannels      = checkRejoinChannel.Checked;
            serverSetting.DisableCTCP         = checkDisableCTCP.Checked;
            serverSetting.DisableAwayMessages = checkDisableAwayMessages.Checked;
            serverSetting.AutoStart           = checkAutoStart.Checked;
            serverSetting.UseIPv6             = checkUseIPv6.Checked;
            serverSetting.UseSSL = checkUseSSL.Checked;
            serverSetting.SSLAcceptInvalidCertificate = checkInvalidCertificate.Checked;
            serverSetting.Encoding = comboEncoding.Text;

            int result;

            if (Int32.TryParse(textPingTimer.Text, out result))
            {
                serverSetting.PingTimerMinutes = Convert.ToInt32(textPingTimer.Text);
            }
            else
            {
                serverSetting.PingTimerMinutes = 5;
            }

            if (Int32.TryParse(textReconnectTime.Text, out result))
            {
                serverSetting.ReconnectTime = Convert.ToInt32(textReconnectTime.Text);
            }
            else
            {
                serverSetting.ReconnectTime = 60;
            }


            serverSetting.UseSASL       = checkUseSASL.Checked;
            serverSetting.SASLUser      = textSASLUser.Text;
            serverSetting.SASLPass      = textSASLPass.Text;
            serverSetting.ExtendedJoin  = checkExtendedJoin.Checked;
            serverSetting.AccountNotify = checkAccountNotify.Checked;
            serverSetting.AwayNotify    = checkAwayNotify.Checked;
            serverSetting.ChangeHost    = checkChgHost.Checked;
            serverSetting.EchoMessage   = checkEchoMessage.Checked;

            serverSetting.UseProxy  = checkUseProxy.Checked;
            serverSetting.ProxyIP   = textProxyIP.Text;
            serverSetting.ProxyPort = textProxyPort.Text;
            serverSetting.ProxyUser = textProxyUser.Text;
            serverSetting.ProxyPass = textProxyPass.Text;

            if (radioSocksHTTP.Checked)
            {
                serverSetting.ProxyType = 1;
            }
            else if (radioSocks4.Checked)
            {
                serverSetting.ProxyType = 2;
            }
            else if (radioSocks5.Checked)
            {
                serverSetting.ProxyType = 3;
            }

            serverSetting.UseBNC  = checkUseBNC.Checked;
            serverSetting.BNCIP   = textBNCIP.Text;
            serverSetting.BNCPort = textBNCPort.Text;
            serverSetting.BNCUser = textBNCUser.Text;
            serverSetting.BNCPass = textBNCPass.Text;

            serverSetting.ServerNotes = textNotes.Text;

            serverSetting.AdvancedSettings = checkAdvancedSettings.Checked;

            if (newServer == true)
            {
                //add in the server to the server collection
                if (NewServer != null)
                {
                    NewServer(serverSetting);
                }
            }
            else
            if (SaveServer != null)
            {
                SaveServer(serverSetting, false);
            }

            return(true);
        }
コード例 #4
0
ファイル: FormServerEditor.cs プロジェクト: origins/ICEChat
        /// <summary>
        /// Update the Server Settings
        /// </summary>
        private void SaveSettings()
        {
            if (serverSetting == null)
                serverSetting = new ServerSetting();

            if (textServername.Text.Length == 0)
                return;

            if (textNickName.Text.Length == 0)
                return;

            serverSetting.NickName = textNickName.Text;
            if (textAltNickName.Text.Length > 0)
                serverSetting.AltNickName = textAltNickName.Text;
            else
                serverSetting.AltNickName = textNickName.Text + "_";

            if (textAwayNick.Text.Length > 0)
                serverSetting.AwayNickName = textAwayNick.Text;
            else
                serverSetting.AwayNickName = textNickName.Text + "[A]";

            serverSetting.ServerName = textServername.Text;
            serverSetting.DisplayName = textDisplayName.Text;
            serverSetting.Password = textServerPassword.Text;
            serverSetting.NickservPassword = textNickservPassword.Text;

            if (textServerPort.Text.Length == 0)
                textServerPort.Text = "6667";
            serverSetting.ServerPort = textServerPort.Text;

            if (textIdentName.Text.Length == 0)
                textIdentName.Text = textDefaultIdent.Text;
            serverSetting.IdentName = textIdentName.Text;

            if (textFullName.Text.Length == 0)
                textFullName.Text = textDefaultFullName.Text;
            serverSetting.FullName = textFullName.Text;

            if (textQuitMessage.Text.Length == 0)
                textQuitMessage.Text = textDefaultQuitMessage.Text;

            serverSetting.QuitMessage = textQuitMessage.Text;

            serverSetting.AutoJoinEnable = checkAutoJoin.Checked;
            serverSetting.AutoJoinDelay = checkAutoJoinDelay.Checked;
            serverSetting.AutoPerformEnable = checkAutoPerform.Checked;
            serverSetting.IgnoreListEnable = checkIgnore.Checked;
            serverSetting.BuddyListEnable = checkBuddyList.Checked;

            serverSetting.AutoJoinChannels = new string[listChannel.Items.Count];
            for (int i = 0; i < listChannel.Items.Count; i++)
            {
                if (listChannel.Items[i].Checked == false)
                {
                    if (listChannel.Items[i].SubItems.Count > 1)
                        serverSetting.AutoJoinChannels[i] = ";" + listChannel.Items[i].Text + " " + listChannel.Items[i].SubItems[1].Text;
                    else
                        serverSetting.AutoJoinChannels[i] = ";" + listChannel.Items[i].Text;
                }
                else
                {
                    if (listChannel.Items[i].SubItems.Count > 1)
                        serverSetting.AutoJoinChannels[i] = listChannel.Items[i].Text + " " + listChannel.Items[i].SubItems[1].Text;
                    else
                        serverSetting.AutoJoinChannels[i] = listChannel.Items[i].Text;
                }
            }

            serverSetting.IgnoreList = new string[listIgnore.Items.Count];
            for (int i = 0; i < listIgnore.Items.Count; i++)
            {
                if (listIgnore.Items[i].Checked == false)
                    serverSetting.IgnoreList[i] = ";" + listIgnore.Items[i].Text;
                else
                    serverSetting.IgnoreList[i] = listIgnore.Items[i].Text;
            }

            serverSetting.BuddyList = new BuddyListItem[listBuddyList.Items.Count];
            for (int i = 0; i < listBuddyList.Items.Count; i++)
            {
                BuddyListItem b = new BuddyListItem();

                if (listBuddyList.Items[i].Checked == false)
                {
                    b.Nick = ";" + listBuddyList.Items[i].Text;
                }
                else
                {
                    b.Nick = listBuddyList.Items[i].Text;
                }
                //b.Note = serverSetting.ServerName;
                serverSetting.BuddyList[i] = b;
            }

            serverSetting.AutoPerform = textAutoPerform.Text.Trim().Split(new String[] { Environment.NewLine }, StringSplitOptions.None);

            serverSetting.SetModeI = checkModeI.Checked;
            serverSetting.ShowMOTD = checkMOTD.Checked;
            serverSetting.ShowPingPong = checkPingPong.Checked;
            serverSetting.RejoinChannels = checkRejoinChannel.Checked;
            serverSetting.DisableCTCP = checkDisableCTCP.Checked;
            serverSetting.AutoStart = checkAutoStart.Checked;
            serverSetting.UseIPv6 = checkUseIPv6.Checked;
            serverSetting.UseSSL = checkUseSSL.Checked;
            serverSetting.SSLAcceptInvalidCertificate = checkInvalidCertificate.Checked;
            serverSetting.Encoding = comboEncoding.Text;

            serverSetting.UseProxy = checkUseProxy.Checked;
            serverSetting.ProxyIP = textProxyIP.Text;
            serverSetting.ProxyPort = textProxyPort.Text;
            serverSetting.ProxyUser = textProxyUser.Text;
            serverSetting.ProxyPass = textProxyPass.Text;

            if (radioSocksHTTP.Checked)
                serverSetting.ProxyType = 1;
            else if (radioSocks4.Checked)
                serverSetting.ProxyType = 2;
            else if (radioSocks5.Checked)
                serverSetting.ProxyType = 3;

            serverSetting.UseBNC = checkUseBNC.Checked;
            serverSetting.BNCIP = textBNCIP.Text;
            serverSetting.BNCPort = textBNCPort.Text;
            serverSetting.BNCUser = textBNCUser.Text;
            serverSetting.BNCPass = textBNCPass.Text;

            serverSetting.ServerNotes = textNotes.Text;

            serverSetting.AdvancedSettings = checkAdvancedSettings.Checked;

            if (newServer == true)
            {
                //add in the server to the server collection
                if (NewServer != null)
                    NewServer(serverSetting);
            }
            else
                if (SaveServer != null)
                    SaveServer(serverSetting, false);
        }
コード例 #5
0
ファイル: FormMain.cs プロジェクト: origins/ICEChat
        /// <summary>
        /// Parse out command written in Input Box or sent from Plugin
        /// </summary>
        /// <param name="connection">Which Connection it is for</param>
        /// <param name="data">The Message to Parse</param>
        public void ParseOutGoingCommand(IRCConnection connection, string data)
        {
            try
            {
                data = data.Replace("&#x3;", ((char)3).ToString());

                PluginArgs args = new PluginArgs(connection);
                args.Command = data;

                foreach (IPluginIceChat ipc in loadedPlugins)
                {
                    if (ipc.Enabled == true)
                        args = ipc.InputText(args);
                }

                data = args.Command;

                if (data.Length == 0)
                    return;

                if (data.StartsWith("//"))
                {
                    //parse out identifiers
                    ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data));
                    return;
                }

                if (data.StartsWith("/"))
                {
                    int indexOfSpace = data.IndexOf(" ");
                    string command = "";
                    string temp = "";

                    if (indexOfSpace > 0)
                    {
                        command = data.Substring(0, indexOfSpace);
                        data = data.Substring(command.Length + 1);
                    }
                    else
                    {
                        command = data;
                        data = "";
                    }

                    //check for aliases
                    foreach (AliasItem a in iceChatAliases.listAliases)
                    {
                        if (a.AliasName == command)
                        {
                            if (a.Command.Length == 1)
                            {
                                data = ParseIdentifierValue(a.Command[0], data);
                                ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data));
                            }
                            else
                            {
                                //it is a multulined alias, run multiple commands
                                foreach (string c in a.Command)
                                {
                                    data = ParseIdentifierValue(c, data);
                                    ParseOutGoingCommand(connection, ParseIdentifiers(connection, data, data));
                                }
                            }
                            return;
                        }
                    }

                    switch (command.ToLower())
                    {
                        case "/makeexception":
                            throw new Exception("IceChat 9 Test Exception Error");

                        case "/addlines":
                            for (int i = 0; i < 250; i++)
                            {
                                string msg = i.ToString() + ". The quick brown fox jumps over the lazy dog and gets away with it";
                                CurrentWindowMessage(connection, msg, 4, true);
                            }
                            break;

                        case "/background":
                        case "/bg": //change background image for a window(s)
                            if (data.Length > 0)
                            {
                                //bg windowtype imagefile
                                //bg windowtype windowname imagefile
                                //if imagefile is blank, erase background image
                                string window = data.Split(' ')[0];
                                string file = "";
                                if (data.IndexOf(' ') > -1)
                                    file = data.Substring(window.Length + 1);

                                switch (window.ToLower())
                                {
                                    case "nicklist":

                                        break;
                                    case "serverlist":

                                        break;
                                    case "console":
                                        //check if the file is a URL
                                        if (file.StartsWith("http://"))
                                        {
                                            System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file);
                                            myRequest.Method = "GET";
                                            System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse();
                                            mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImageURL = myResponse.GetResponseStream();
                                        }
                                        else
                                        {
                                            if (file.Length > 0 && File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                                mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file);
                                            else
                                                mainTabControl.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = "";
                                        }
                                        break;
                                    case "channel":
                                        //get the channel name
                                        if (file.IndexOf(' ') > -1)
                                        {
                                            string channel = file.Split(' ')[0];
                                            //if channel == "all" do it for all

                                            file = file.Substring(channel.Length + 1);
                                            if (channel.ToLower() == "all")
                                            {
                                                foreach (IceTabPage t in mainTabControl.TabPages)
                                                {
                                                    if (t.WindowStyle == IceTabPage.WindowType.Channel)
                                                    {
                                                        if (file.StartsWith("http://"))
                                                        {
                                                            System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file);
                                                            myRequest.Method = "GET";
                                                            System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse();
                                                            t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream();
                                                        }
                                                        else
                                                        {
                                                            if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                                                t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file);
                                                            else
                                                                t.TextWindow.BackGroundImage = "";

                                                        }
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
                                                if (t != null)
                                                {
                                                    if (file.StartsWith("http://"))
                                                    {
                                                        System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file);
                                                        myRequest.Method = "GET";
                                                        System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse();
                                                        t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream();
                                                    }
                                                    else
                                                    {
                                                        if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                                            t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file);
                                                        else
                                                            t.TextWindow.BackGroundImage = "";
                                                    }
                                                }
                                            }
                                        }
                                        else
                                        {
                                            //only a channel name specified, no file, erase the image
                                            //if file == "all" clear em all
                                            if (file.ToLower() == "all")
                                            {
                                                foreach (IceTabPage t in mainTabControl.TabPages)
                                                {
                                                    if (t.WindowStyle == IceTabPage.WindowType.Channel)
                                                        t.TextWindow.BackGroundImage = "";
                                                }
                                            }
                                            else
                                            {
                                                IceTabPage t = GetWindow(connection, file, IceTabPage.WindowType.Channel);
                                                if (t != null)
                                                    t.TextWindow.BackGroundImage = "";
                                            }
                                        }
                                        break;
                                    case "query":

                                        break;
                                    case "window":
                                        if (file.IndexOf(' ') > -1)
                                        {
                                            string windowName = file.Split(' ')[0];

                                            file = file.Substring(windowName.Length + 1);
                                            IceTabPage t = GetWindow(connection, windowName, IceTabPage.WindowType.Window);
                                            if (t != null)
                                            {
                                                if (file.StartsWith("http://"))
                                                {
                                                    System.Net.HttpWebRequest myRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(file);
                                                    myRequest.Method = "GET";
                                                    System.Net.HttpWebResponse myResponse = (System.Net.HttpWebResponse)myRequest.GetResponse();
                                                    t.TextWindow.BackGroundImageURL = myResponse.GetResponseStream();
                                                }
                                                else
                                                {
                                                    if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                                        t.TextWindow.BackGroundImage = (picturesFolder + System.IO.Path.DirectorySeparatorChar + file);
                                                    else
                                                        t.TextWindow.BackGroundImage = "";
                                                }
                                            }

                                        }
                                        else
                                        {
                                            IceTabPage t = GetWindow(connection, file, IceTabPage.WindowType.Window);
                                            if (t != null)
                                                t.TextWindow.BackGroundImage = "";

                                        }
                                        break;
                                }
                            }
                            break;

                        case "/unloadplugin":
                            if (data.Length > 0)
                            {
                                //get the plugin name, and look for it in the menu items
                                ToolStripMenuItem menuItem = null;
                                foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems)
                                    if (t.ToolTipText.ToLower() == data.ToLower())
                                        menuItem = t;

                                if (menuItem != null)
                                {
                                    //match
                                    IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag;

                                    plugin.OnCommand -= new OutGoingCommandHandler(Plugin_OnCommand);
                                    loadedPlugins.Remove(plugin);
                                    menuItem.Click -= new EventHandler(OnPluginMenuItemClick);
                                    pluginsToolStripMenuItem.DropDownItems.Remove(menuItem);

                                    //AppDomain.Unload(plugin.domain);
                                    //plugin.domain = null;

                                    plugin.Dispose();

                                    WindowMessage(null, "Console", "Unloaded Plugin - " + plugin.Name, 4, true);

                                }
                            }
                            break;
                        case "/statusplugin":
                            if (data.Length > 0 && data.IndexOf(' ') > 0)
                            {
                                string[] values = data.Split(new char[] { ' ' }, 2);

                                ToolStripMenuItem menuItem = null;
                                foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems)
                                    if (t.ToolTipText.ToLower() == values[1].ToLower())
                                        menuItem = t;

                                if (menuItem != null)
                                {
                                    //match
                                    IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag;
                                    plugin.Enabled = Convert.ToBoolean(values[0]);

                                    if (plugin.Enabled == true)
                                    {
                                        WindowMessage(null, "Console", "Enabled Plugin - " + plugin.Name + " v" + plugin.Version, 4, true);
                                        //remove the icon
                                        menuItem.Image = null;
                                    }
                                    else
                                    {
                                        WindowMessage(null, "Console", "Disabled Plugin - " + plugin.Name + " v" + plugin.Version, 4, true);
                                        menuItem.Image = StaticMethods.LoadResourceImage("CloseButton.png");
                                    }
                                }
                            }
                            break;
                        case "/loadplugin":
                            if (data.Length > 0)
                            {
                                loadPlugin(pluginsFolder + System.IO.Path.DirectorySeparatorChar + data);
                            }
                            break;
                        case "/reload":
                            if (data.Length > 0)
                            {
                                switch (data)
                                {
                                    case "alias":
                                    case "aliases":
                                        CurrentWindowMessage(connection, "Aliases file reloaded", 4, true);
                                        LoadAliases();
                                        break;
                                    case "popup":
                                    case "popups":
                                        CurrentWindowMessage(connection, "Popups file reloaded", 4, true);
                                        LoadPopups();
                                        break;
                                    case "emoticon":
                                    case "emoticons":
                                        CurrentWindowMessage(connection, "Emoticons file reloaded", 4, true);
                                        LoadEmoticons();
                                        break;
                                    case "sound":
                                    case "sounds":
                                        CurrentWindowMessage(connection, "Sounds file reloaded", 4, true);
                                        LoadSounds();
                                        break;
                                    case "color":
                                    case "colors":
                                        CurrentWindowMessage(connection, "Colors file reloaded", 4, true);
                                        LoadColors();
                                        toolStripMain.BackColor = IrcColor.colors[iceChatColors.ToolbarBackColor];
                                        menuMainStrip.BackColor = IrcColor.colors[iceChatColors.MenubarBackColor];
                                        statusStripMain.BackColor = IrcColor.colors[iceChatColors.StatusbarBackColor];
                                        toolStripStatus.ForeColor = IrcColor.colors[iceChatColors.StatusbarForeColor];
                                        inputPanel.SetInputBoxColors();
                                        channelList.SetListColors();
                                        buddyList.SetListColors();
                                        break;
                                    case "font":
                                    case "fonts":
                                        CurrentWindowMessage(connection, "Fonts file reloaded", 4, true);
                                        LoadFonts();
                                        nickList.Font = new Font(iceChatFonts.FontSettings[3].FontName, iceChatFonts.FontSettings[3].FontSize);
                                        serverTree.Font = new Font(iceChatFonts.FontSettings[4].FontName, iceChatFonts.FontSettings[4].FontSize);
                                        menuMainStrip.Font = new Font(iceChatFonts.FontSettings[7].FontName, iceChatFonts.FontSettings[7].FontSize);
                                        break;
                                }
                            }
                            break;
                        /*
                        case "/reloadplugin":
                            if (data.Length > 0)
                            {
                                //get the plugin name, and look for it in the menu items
                                ToolStripMenuItem menuItem = null;
                                foreach (ToolStripMenuItem t in pluginsToolStripMenuItem.DropDownItems)
                                    if (t.ToolTipText.ToLower() == data.ToLower())
                                        menuItem = t;

                                if (menuItem != null)
                                {
                                    //match

                                    IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag;

                                    plugin.OnCommand -= new OutGoingCommandHandler(Plugin_OnCommand);
                                    loadedPlugins.Remove(plugin);
                                    plugin.Dispose();

                                    Type ObjType = null;
                                    Assembly ass = null;

                                    try
                                    {
                                        //reload the plugin
                                        ass = Assembly.LoadFile(pluginsFolder + System.IO.Path.DirectorySeparatorChar + menuItem.ToolTipText);

                                        //System.Diagnostics.Debug.WriteLine(ass.ToString());
                                        if (ass != null)
                                        {
                                            ObjType = ass.GetType("IceChatPlugin.Plugin");
                                        }
                                        else
                                        {
                                            System.Diagnostics.Debug.WriteLine("assembly is null");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        WriteErrorFile(connection, "ReLoadPlugins Cast:", ex);
                                    }
                                    try
                                    {
                                        // OK Lets create the object as we have the Report Type
                                        if (ObjType != null)
                                        {
                                            //System.Diagnostics.Debug.WriteLine("create instance of " + args);

                                            IPluginIceChat ipi = (IPluginIceChat)Activator.CreateInstance(ObjType);

                                            ipi.MainForm = this;
                                            ipi.MainMenuStrip = this.MainMenuStrip;
                                            ipi.CurrentFolder = currentFolder;

                                            WindowMessage(null, "Console", "Re-Loaded Plugin - " + ipi.Name + " v" + ipi.Version + " by " + ipi.Author, 4, true);

                                            menuItem.Tag = ipi;

                                            ipi.OnCommand += new OutGoingCommandHandler(Plugin_OnCommand);
                                            ipi.Initialize();
                                            loadedPlugins.Add(ipi);
                                        }
                                        else
                                        {
                                            System.Diagnostics.Debug.WriteLine("obj type is null:" + menuItem.ToolTipText);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        WriteErrorFile(connection, "ReLoadPlugins", ex);
                                    }
                                }
                            }
                            break;
                         */
                         case "/addtext":
                            if (data.Length > 0)
                            {
                                inputPanel.AppendText(data);
                                FocusInputBox();
                            }
                            break;
                        case "/ame":    //me command for all channels
                            if (connection != null && data.Length > 0)
                            {
                                foreach (IceTabPage t in FormMain.Instance.TabMain.TabPages)
                                {
                                    if (t.WindowStyle == IceTabPage.WindowType.Channel)
                                    {
                                        if (t.Connection == connection)
                                        {
                                            SendData(connection, "PRIVMSG " + t.TabCaption + " :ACTION " + data + "");
                                            string msg = GetMessageFormat("Self Channel Action");
                                            msg = msg.Replace("$nick", t.Connection.ServerSetting.NickName).Replace("$channel", t.TabCaption);
                                            msg = msg.Replace("$message", data);

                                            t.TextWindow.AppendText(msg, 1);
                                            t.TextWindow.ScrollToBottom();
                                            t.LastMessageType = ServerMessageType.Action;
                                        }
                                    }
                                }
                            }
                            break;
                        case "/amsg":   //send a message to all channels
                            if (connection != null && data.Length > 0)
                            {
                                foreach (IceTabPage t in FormMain.Instance.TabMain.TabPages)
                                {
                                    if (t.WindowStyle == IceTabPage.WindowType.Channel)
                                    {
                                        if (t.Connection == connection)
                                        {
                                            SendData(connection, "PRIVMSG " + t.TabCaption + " :" + data);
                                            string msg = GetMessageFormat("Self Channel Message");
                                            msg = msg.Replace("$nick", t.Connection.ServerSetting.NickName).Replace("$channel", t.TabCaption);

                                            //assign $color to the nickname
                                            if (msg.Contains("$color"))
                                            {
                                                User u = CurrentWindow.GetNick(t.Connection.ServerSetting.NickName);
                                                for (int i = 0; i < u.Level.Length; i++)
                                                {
                                                    if (u.Level[i])
                                                    {
                                                        if (connection.ServerSetting.StatusModes[0][i] == 'v')
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00"));
                                                        else if (connection.ServerSetting.StatusModes[0][i] == 'h')
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00"));
                                                        else if (connection.ServerSetting.StatusModes[0][i] == 'o')
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00"));
                                                        else if (connection.ServerSetting.StatusModes[0][i] == 'a')
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00"));
                                                        else if (connection.ServerSetting.StatusModes[0][i] == 'q')
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));
                                                        else
                                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));

                                                        break;
                                                    }
                                                }
                                                if (msg.Contains("$color"))
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00"));

                                            }

                                            msg = msg.Replace("$status", CurrentWindow.GetNick(t.Connection.ServerSetting.NickName).ToString().Replace(t.Connection.ServerSetting.NickName, ""));
                                            msg = msg.Replace("$message", data);

                                            t.TextWindow.AppendText(msg, 1);
                                            t.TextWindow.ScrollToBottom();
                                            t.LastMessageType = ServerMessageType.Message;

                                        }
                                    }
                                }
                            }
                            break;
                        case "/anick":
                            if (data.Length > 0)
                            {
                                foreach (IRCConnection c in serverTree.ServerConnections.Values)
                                    if (c.IsConnected)
                                        SendData(c, "NICK " + data);
                            }
                            break;
                        case "/autojoin":
                            if (connection != null)
                            {
                                if (data.Length == 0)
                                {
                                    if (connection.ServerSetting.AutoJoinChannels != null)
                                    {
                                        foreach (string chan in connection.ServerSetting.AutoJoinChannels)
                                        {
                                            if (!chan.StartsWith(";"))
                                                SendData(connection, "JOIN " + chan);
                                        }
                                    }
                                }
                                else
                                {
                                    if (connection.ServerSetting.AutoJoinChannels == null)
                                    {
                                        //we have no autojoin channels, so just add it
                                        connection.ServerSetting.AutoJoinChannels = new string[1];
                                        connection.ServerSetting.AutoJoinChannels[0] = data;
                                        CurrentWindowMessage(connection, data + " is added to the Autojoin List", 7, true);
                                        serverTree.SaveServers(serverTree.ServersCollection);
                                    }
                                    else
                                    {
                                        //check if it is in the list first
                                        bool Exists = false;
                                        bool Disabled = false;

                                        string[] oldAutoJoin = new string[connection.ServerSetting.AutoJoinChannels.Length];
                                        int i = 0;
                                        foreach (string chan in connection.ServerSetting.AutoJoinChannels)
                                        {
                                            if (chan.ToLower() == data.ToLower())
                                            {
                                                //already in the list
                                                Exists = true;
                                                oldAutoJoin[i] = chan;
                                                CurrentWindowMessage(connection, data + " is already in the Autojoin List", 7, true);
                                            }
                                            else if (chan.ToLower() == (";" + data.ToLower()))
                                            {
                                                //already in the list, but disabled
                                                //so lets enable it
                                                Disabled = true;
                                                oldAutoJoin[i] = chan.Substring(1);
                                                CurrentWindowMessage(connection, data + " is enabled in the Autojoin List", 7, true);
                                            }
                                            else
                                                oldAutoJoin[i] = chan;

                                            i++;
                                        }

                                        if (!Exists)
                                        {
                                            //add a new item
                                            connection.ServerSetting.AutoJoinChannels = new string[connection.ServerSetting.AutoJoinChannels.Length + 1];
                                            i = 0;
                                            foreach (string chan in oldAutoJoin)
                                            {
                                                connection.ServerSetting.AutoJoinChannels[i] = chan;
                                                i++;
                                            }
                                            connection.ServerSetting.AutoJoinChannels[i] = data;
                                            CurrentWindowMessage(connection, data + " is added to the Autojoin List", 7, true);
                                            serverTree.SaveServers(serverTree.ServersCollection);
                                        }
                                        else if (Disabled)
                                        {
                                            connection.ServerSetting.AutoJoinChannels = new string[connection.ServerSetting.AutoJoinChannels.Length];
                                            i = 0;
                                            foreach (string chan in oldAutoJoin)
                                            {
                                                connection.ServerSetting.AutoJoinChannels[i] = chan;
                                            }
                                            serverTree.SaveServers(serverTree.ServersCollection);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/autoperform":
                            if (connection != null)
                            {
                                if (connection.ServerSetting.AutoPerform != null)
                                {
                                    foreach (string ap in connection.ServerSetting.AutoPerform)
                                    {
                                        string autoCommand = ap.Replace("\r", String.Empty);
                                        if (!autoCommand.StartsWith(";"))
                                            ParseOutGoingCommand(connection, autoCommand);
                                    }
                                }
                            }
                            break;
                        case "/aaway":
                            foreach (IRCConnection c in serverTree.ServerConnections.Values)
                            {
                                if (c.IsConnected)
                                {
                                    ParseOutGoingCommand(c, "/away " + data);
                                }
                            }
                            break;
                        case "/away":
                            if (connection != null)
                            {
                                if (connection.ServerSetting.Away)
                                {
                                    connection.ServerSetting.Away = false;
                                    ParseOutGoingCommand(connection, "/nick " + connection.ServerSetting.DefaultNick);
                                    TimeSpan t = DateTime.Now.Subtract(connection.ServerSetting.AwayStart);

                                    string s = t.Seconds.ToString() + " secs";
                                    if (t.Minutes > 0)
                                        s = t.Minutes.ToString() + " mins " + s;
                                    if (t.Hours > 0)
                                        s = t.Hours.ToString() + " hrs " + s;
                                    if (t.Days > 0)
                                        s = t.Days.ToString() + " days " + s;

                                    ParseOutGoingCommand(connection, "/ame is no longer away : Gone for " + s);
                                }
                                else
                                {
                                    connection.ServerSetting.Away = true;
                                    connection.ServerSetting.DefaultNick = connection.ServerSetting.NickName;
                                    connection.ServerSetting.AwayStart = System.DateTime.Now;
                                    ParseOutGoingCommand(connection, "/nick " + connection.ServerSetting.AwayNickName);
                                    if (data.Length == 0)
                                        ParseOutGoingCommand(connection, "/ame is set as away");
                                    else
                                        ParseOutGoingCommand(connection, "/ame is set as away : Reason(" + data + ")");
                                }
                            }
                            break;
                        case "/ban":  // /ban #channel nick|address   /mode #channel +b host
                            if (connection != null && data.IndexOf(' ') > 0)
                            {
                                string channel = data.Split(' ')[0];
                                string host = data.Split(' ')[1];
                                ParseOutGoingCommand(connection, "/mode " + channel + " +b " + host);
                            }
                            break;
                        case "/browser":
                            if (data.Length > 0)
                            {
                                if (data.StartsWith("http"))
                                    System.Diagnostics.Process.Start(data);
                                else
                                    System.Diagnostics.Process.Start("http://" + data);
                            }
                            break;
                        case "/buddylist":
                        case "/notify":
                            //add a nickname to the buddy list
                            if (connection != null && data.Length > 0 && data.IndexOf(" ") == -1)
                            {
                                //check if the nickname is already in the buddy list
                                if (connection.ServerSetting.BuddyList != null)
                                {
                                    foreach (BuddyListItem buddy in connection.ServerSetting.BuddyList)
                                    {
                                        if (!buddy.Nick.StartsWith(";"))
                                            if (buddy.Nick.ToLower() == data.ToLower())
                                                return;
                                        else
                                            if (buddy.Nick.Substring(1).ToLower() == data.ToLower())
                                                return;
                                    }
                                }
                                //add in the new buddy list item
                                BuddyListItem b = new BuddyListItem();
                                b.Nick = data;

                                BuddyListItem[] buddies = connection.ServerSetting.BuddyList;
                                Array.Resize(ref buddies, buddies.Length + 1);
                                buddies[buddies.Length - 1] = b;

                                connection.ServerSetting.BuddyList = buddies;

                                serverTree.SaveServers(serverTree.ServersCollection);

                                connection.BuddyListCheck();
                            }
                            break;
                        case "/chaninfo":
                            if (connection != null)
                            {
                                if (data.Length > 0)
                                {
                                    IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                    if (t != null)
                                    {
                                        FormChannelInfo fci = new FormChannelInfo(t);
                                        SendData(connection, "MODE " + t.TabCaption + " +b");
                                        //check if mode (e) exists for Exception List
                                        if (connection.ServerSetting.ChannelModeParam.Contains("e"))
                                            SendData(connection, "MODE " + t.TabCaption + " +e");
                                        SendData(connection, "TOPIC :" + t.TabCaption);
                                        fci.ShowDialog(this);
                                    }
                                }
                                else
                                {
                                    //check if current window is channel
                                    if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                    {
                                        FormChannelInfo fci = new FormChannelInfo(CurrentWindow);
                                        SendData(connection, "MODE " + CurrentWindow.TabCaption + " +b");
                                        //check if mode (e) exists for Exception List
                                        if (connection.ServerSetting.ChannelModeParam.Contains("e"))
                                            SendData(connection, "MODE " + CurrentWindow.TabCaption + " +e");
                                        SendData(connection, "TOPIC :" + CurrentWindow.TabCaption);
                                        fci.ShowDialog(this);
                                    }
                                }
                            }
                            break;
                        case "/clear":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowType != IceTabPage.WindowType.Console)
                                    CurrentWindow.TextWindow.ClearTextWindow();
                                else
                                {
                                    //find the current console tab window
                                    mainTabControl.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow();
                                }
                            }
                            else
                            {
                                //find a match
                                if (data == "Console")
                                {
                                    mainTabControl.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow();
                                    return;
                                }
                                else if (data.ToLower() == "all console")
                                {
                                    //clear all the console windows and channel/queries
                                    foreach (ConsoleTab c in mainTabControl.GetTabPage("Console").ConsoleTab.TabPages)
                                        ((TextWindow)c.Controls[0]).ClearTextWindow();

                                }
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                    t.TextWindow.ClearTextWindow();
                                else
                                {
                                    IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query);
                                    if (q != null)
                                    {
                                        q.TextWindow.ClearTextWindow();
                                        return;
                                    }
                                    IceTabPage dcc = GetWindow(connection, data, IceTabPage.WindowType.DCCChat);
                                    if (dcc != null)
                                        dcc.TextWindow.ClearTextWindow();

                                }
                            }
                            break;
                        case "/clearall":
                            //clear all the text windows
                            for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--)
                            {
                                if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel || mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                {
                                    mainTabControl.TabPages[i].TextWindow.ClearTextWindow();
                                }
                                else if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Console)
                                {
                                    //clear all console windows
                                    foreach (ConsoleTab c in mainTabControl.GetTabPage("Console").ConsoleTab.TabPages)
                                    {
                                        ((TextWindow)c.Controls[0]).ClearTextWindow();
                                    }
                                }
                            }
                            break;
                        case "/close":
                            if (connection != null && data.Length > 0)
                            {
                                //check if it is a channel list window
                                if (data == "Channels")
                                {
                                    IceTabPage c = GetWindow(connection, "", IceTabPage.WindowType.ChannelList);
                                    if (c != null)
                                        RemoveWindow(connection, "", IceTabPage.WindowType.ChannelList);
                                    return;
                                }
                                //check if it is a query window
                                IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query);
                                if (q != null)
                                {
                                    RemoveWindow(connection, q.TabCaption, IceTabPage.WindowType.Query);
                                    return;
                                }

                                //check if it is a dcc chat window
                                IceTabPage dcc = GetWindow(connection, data, IceTabPage.WindowType.DCCChat);
                                if (dcc != null)
                                    RemoveWindow(connection, dcc.TabCaption, IceTabPage.WindowType.DCCChat);
                            }
                            else if (connection != null)
                            {
                                //check if current window is channel/query/dcc chat
                                if (CurrentWindowType == IceTabPage.WindowType.Query)
                                    RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                else if (CurrentWindowType == IceTabPage.WindowType.DCCChat)
                                    RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                else if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                {
                                    SendData(connection, "PART " + CurrentWindow.TabCaption);
                                    RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                }
                            }
                            else
                            {
                                //check if the current window is the debug window
                                if (CurrentWindowType == IceTabPage.WindowType.Debug)
                                {
                                    RemoveWindow(null, "Debug", IceTabPage.WindowType.Debug);
                                }
                            }
                            break;
                        case "/closequery":
                            if (connection != null)
                            {
                                for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                    {
                                        if (mainTabControl.TabPages[i].Connection == connection)
                                        {
                                            RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Query);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/closeallquery":
                            if (connection != null)
                            {
                                for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                    {
                                        RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Query);
                                    }
                                }
                            }
                            break;
                        case "/ctcp":
                            if (connection != null && data.IndexOf(' ') > 0)
                            {
                                //ctcp nick ctcptype
                                string nick = data.Substring(0, data.IndexOf(' '));
                                //get the message
                                string ctcp = data.Substring(data.IndexOf(' ') + 1);

                                string msg = GetMessageFormat("Ctcp Send");
                                msg = msg.Replace("$nick", nick); ;
                                msg = msg.Replace("$ctcp", ctcp.ToUpper());
                                CurrentWindowMessage(connection, msg, 7, true);
                                if (ctcp.ToUpper() == "PING")
                                    SendData(connection, "PRIVMSG " + nick + " :" + ctcp.ToUpper() + " " + System.Environment.TickCount.ToString() + "");
                                else
                                    SendData(connection, "PRIVMSG " + nick + " " + ctcp.ToUpper() + "");
                            }
                            break;
                        case "/dcc":
                            if (connection != null && data.IndexOf(' ') > 0)
                            {
                                //get the type of dcc
                                string dccType = data.Substring(0, data.IndexOf(' ')).ToUpper();
                                //get who it is being sent to
                                string nick = data.Substring(data.IndexOf(' ') + 1);

                                switch (dccType)
                                {
                                    case "CHAT":
                                        //start a dcc chat
                                        if (nick.IndexOf(' ') == -1)    //make sure no space in the nick name
                                        {
                                            //check if we already have a dcc chat open with this person
                                            if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.DCCChat))
                                            {
                                                //create a new window
                                                AddWindow(connection, nick, IceTabPage.WindowType.DCCChat);
                                                IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat);
                                                if (t != null)
                                                {
                                                    t.RequestDCCChat();
                                                    string msg = GetMessageFormat("DCC Chat Outgoing");
                                                    msg = msg.Replace("$nick", nick);
                                                    t.TextWindow.AppendText(msg, 1);
                                                    t.TextWindow.ScrollToBottom();
                                                }
                                            }
                                            else
                                            {
                                                mainTabControl.SelectTab(GetWindow(connection, nick, IceTabPage.WindowType.DCCChat));
                                                serverTree.SelectTab(mainTabControl.CurrentTab, false);

                                                //see if it is connected or not
                                                IceTabPage dcc = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat);
                                                if (dcc != null)
                                                {
                                                    if (!dcc.IsConnected)
                                                    {
                                                        dcc.RequestDCCChat();
                                                        string msg = GetMessageFormat("DCC Chat Outgoing");
                                                        msg = msg.Replace("$nick", nick);
                                                        dcc.TextWindow.AppendText(msg, 1);
                                                        dcc.TextWindow.ScrollToBottom();
                                                    }
                                                }
                                            }
                                        }
                                        break;
                                    case "SEND":
                                        //was a filename specified, if not try and select one
                                        string file;
                                        if (nick.IndexOf(' ') > 0)
                                        {
                                            file = nick.Substring(nick.IndexOf(' ') + 1);
                                            nick = nick.Substring(0,nick.IndexOf(' '));

                                            //see if the file exists
                                            if (!File.Exists(file))
                                            {
                                                //file does not exists, just quit
                                                //try from the dccsend folder
                                                if (File.Exists(iceChatOptions.DCCSendFolder + Path.DirectorySeparatorChar + file))
                                                    file=iceChatOptions.DCCSendFolder + Path.DirectorySeparatorChar + file;
                                                else
                                                    return;
                                            }
                                        }
                                        else
                                        {
                                            //ask for a file name
                                            OpenFileDialog dialog = new OpenFileDialog();
                                            dialog.InitialDirectory = iceChatOptions.DCCSendFolder;
                                            dialog.CheckFileExists = true;
                                            dialog.CheckPathExists = true;
                                            if (dialog.ShowDialog() == DialogResult.OK)
                                            {
                                                //returns the full path
                                                System.Diagnostics.Debug.WriteLine(dialog.FileName);
                                                file = dialog.FileName;
                                            }
                                            else
                                                return;

                                        }

                                        //more to it, maybe a file to send
                                        if (!mainTabControl.WindowExists(null, "DCC Files", IceTabPage.WindowType.DCCFile))
                                            AddWindow(null, "DCC Files", IceTabPage.WindowType.DCCFile);

                                        IceTabPage tt = GetWindow(null, "DCC Files", IceTabPage.WindowType.DCCFile);
                                        if (tt != null)
                                            ((IceTabPageDCCFile)tt).RequestDCCFile(connection, nick, file);

                                        break;
                                }
                            }
                            break;
                        case "/describe":   //me command for a specific channel
                            if (connection != null && data.IndexOf(' ') > 0)
                            {
                                //get the channel name
                                string channel = data.Substring(0, data.IndexOf(' '));
                                //get the message
                                string message = data.Substring(data.IndexOf(' ') + 1);
                                //check for the channel
                                IceTabPage t = GetWindow(connection, channel, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    SendData(connection, "PRIVMSG " + t.TabCaption + " :ACTION " + message + "");
                                    string msg = GetMessageFormat("Self Channel Action");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$channel", t.TabCaption);
                                    msg = msg.Replace("$message", message);
                                    t.TextWindow.AppendText(msg, 1);
                                    t.TextWindow.ScrollToBottom();
                                    t.LastMessageType = ServerMessageType.Action;
                                }
                            }
                            break;
                        case "/dns":
                            if (data.Length > 0)
                            {
                                if (data.IndexOf(".") > 0)
                                {
                                    //dns a host
                                    try
                                    {
                                        System.Net.IPAddress[] addresslist = System.Net.Dns.GetHostAddresses(data);
                                        ParseOutGoingCommand(connection, "/echo " + data + " resolved to " + addresslist.Length + " address(es)");
                                        foreach (System.Net.IPAddress address in addresslist)
                                            ParseOutGoingCommand(connection, "/echo -> " + address.ToString());
                                    }
                                    catch (Exception)
                                    {
                                        ParseOutGoingCommand(connection, "/echo " + data + " does not resolve (unknown address)");
                                    }
                                }
                                else
                                {
                                    //dns a nickname (send a userhost)
                                    SendData(connection, "USERHOST " + data);
                                }
                            }
                            break;
                        case "/echo":
                            //currently just echo to the current window
                            if (data.Length > 0)
                            {
                                if (CurrentWindowType == IceTabPage.WindowType.Channel || CurrentWindowType == IceTabPage.WindowType.Query)
                                {
                                    string msg = GetMessageFormat("User Echo");
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.Console)
                                {
                                    string msg = GetMessageFormat("User Echo");
                                    msg = msg.Replace("$message", data);

                                    mainTabControl.GetTabPage("Console").CurrentConsoleWindow().AppendText(msg, 1);
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.DCCChat)
                                {
                                    string msg = GetMessageFormat("User Echo");
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                }
                            }
                            break;
                        case "/flash":
                            //used to flash a specific channel or query
                            if (connection != null && data.Length > 0)
                            {
                                string window = data;
                                bool flashWindow = true;
                                if (data.IndexOf(" ") > 0)
                                {
                                    window = data.Substring(0, data.IndexOf(' '));
                                    string t = data.Substring(data.IndexOf(' ') + 1);
                                    if (t.ToLower() == "off")
                                        flashWindow = false;
                                }

                                //check if it is a channel window
                                IceTabPage c = GetWindow(connection, window, IceTabPage.WindowType.Channel);
                                if (c != null)
                                {
                                    c.FlashTab = flashWindow;
                                    mainTabControl.Invalidate();
                                    serverTree.Invalidate();
                                }
                                else
                                {
                                    //check if it is a query
                                    IceTabPage q = GetWindow(connection, window, IceTabPage.WindowType.Query);
                                    if (q != null)
                                    {
                                        q.FlashTab = flashWindow;
                                        mainTabControl.Invalidate();
                                        serverTree.Invalidate();
                                    }
                                }

                            }
                            break;
                        case "/flashtray":
                            //check if we are minimized
                            if (this.WindowState == FormWindowState.Minimized)
                            {
                                this.flashTaskBarIconTimer.Enabled = true;
                                this.flashTaskBarIconTimer.Start();
                            }

                            if (this.notifyIcon.Visible == true)
                            {
                                this.flashTrayIconTimer.Enabled = true;
                                this.flashTrayIconTimer.Start();
                                //show a message in a balloon
                                if (data.Length > 0)
                                {
                                    this.notifyIcon.BalloonTipTitle = "IceChat 9";
                                    this.notifyIcon.BalloonTipText = data;
                                    this.notifyIcon.ShowBalloonTip(1000);
                                }
                            }
                            break;
                        case "/font":
                            //change the font of the current window
                            //check if data is a channel
                            if (connection != null && data.Length > 0)
                            {
                                if (data.IndexOf(' ') == -1)
                                {
                                    IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                    if (t != null)
                                    {
                                        //bring up a font dialog
                                        FontDialog fd = new FontDialog();
                                        //load the current font
                                        fd.Font = t.TextWindow.Font;
                                        if (fd.ShowDialog() != DialogResult.Cancel && fd.Font.Style == FontStyle.Regular)
                                        {
                                            t.TextWindow.Font = fd.Font;
                                        }
                                    }
                                }
                            }
                            break;
                        case "/forcequit":
                            if (connection != null)
                            {
                                connection.AttemptReconnect = false;
                                connection.ForceDisconnect();
                            }
                            break;
                        case "/google":
                            if (data.Length > 0)
                                System.Diagnostics.Process.Start("http://www.google.com/search?q=" + data);
                            else
                                System.Diagnostics.Process.Start("http://www.google.com");
                            break;
                        case "/hop":
                            if (connection != null && data.Length == 0)
                            {
                                if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                {
                                    temp = CurrentWindow.TabCaption;
                                    SendData(connection, "PART " + temp);
                                    ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + temp);
                                }
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    SendData(connection, "PART " + t.TabCaption);
                                    ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + t.TabCaption);
                                }
                            }
                            break;
                        case "/icechat":
                            if (connection != null)
                                ParseOutGoingCommand(connection, "/me is using " + ProgramID + " " + VersionID);
                            else
                                ParseOutGoingCommand(connection, "/echo using " + ProgramID + " " + VersionID);
                            break;
                        case "/icepath":
                            //To get current Folder and paste it into /me
                            if (connection != null)
                                ParseOutGoingCommand(connection, "/me Build Path = " + Directory.GetCurrentDirectory());
                            else
                                ParseOutGoingCommand(connection, "/echo Build Path = " + Directory.GetCurrentDirectory());
                            break;
                        case "/ignore":
                            if (connection != null)
                            {
                                if (data.Length > 0)
                                {
                                    //check if just a nick/host , no extra params
                                    if (data.IndexOf(" ") == -1)
                                    {
                                        //check if already in ignore list or not
                                        for (int i = 0; i < connection.ServerSetting.IgnoreList.Length;i++ )
                                        {
                                            string checkNick = connection.ServerSetting.IgnoreList[i];
                                            if (connection.ServerSetting.IgnoreList[i].StartsWith(";"))
                                                checkNick = checkNick.Substring(1);

                                            if (checkNick.ToLower() == data.ToLower())
                                            {
                                                if (connection.ServerSetting.IgnoreList[i].StartsWith(";"))
                                                    connection.ServerSetting.IgnoreList[i] = checkNick;
                                                else
                                                    connection.ServerSetting.IgnoreList[i] = ";" + checkNick;

                                                serverTree.SaveServers(serverTree.ServersCollection);
                                                return;
                                            }
                                        }

                                        //no match found, add the new item to the IgnoreList
                                        string[] ignores = connection.ServerSetting.IgnoreList;
                                        Array.Resize(ref ignores, ignores.Length + 1);
                                        ignores[ignores.Length - 1] = data;

                                        connection.ServerSetting.IgnoreList = ignores;

                                        serverTree.SaveServers(serverTree.ServersCollection);
                                    }
                                }
                            }
                            break;
                        case "/join":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "JOIN " + data);
                            break;
                        case "/kick":
                            if (connection != null && data.Length > 0)
                            {
                                //kick #channel nick reason
                                if (data.IndexOf(' ') > 0)
                                {
                                    //get the channel
                                    temp = data.Substring(0, data.IndexOf(' '));
                                    //check if temp is a channel or not
                                    if (Array.IndexOf(connection.ServerSetting.ChannelTypes, temp[0]) == -1)
                                    {
                                        //temp is not a channel, substitute with current channel
                                        //make sure we are in a channel
                                        if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Channel)
                                        {
                                            temp = CurrentWindow.TabCaption;
                                            if (data.IndexOf(' ') > 0)
                                            {
                                                //there is a kick reason
                                                string msg = data.Substring(data.IndexOf(' ') + 1);
                                                data = data.Substring(0, data.IndexOf(' '));
                                                SendData(connection, "KICK " + temp + " " + data + " :" + msg);
                                            }
                                            else
                                            {
                                                SendData(connection, "KICK " + temp + " " + data);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        data = data.Substring(temp.Length + 1);
                                        if (data.IndexOf(' ') > 0)
                                        {
                                            //there is a kick reason
                                            string msg = data.Substring(data.IndexOf(' ') + 1);
                                            data = data.Substring(0, data.IndexOf(' '));
                                            SendData(connection, "KICK " + temp + " " + data + " :" + msg);
                                        }
                                        else
                                        {
                                            SendData(connection, "KICK " + temp + " " + data);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/me":
                            //check if in channel, query, etc
                            if (connection != null && data.Length > 0)
                            {
                                if (CurrentWindowType == IceTabPage.WindowType.Channel || CurrentWindowType == IceTabPage.WindowType.Query)
                                {
                                    SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :ACTION " + data + "");
                                    string msg = GetMessageFormat("Self Channel Action");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$channel", CurrentWindow.TabCaption);
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                    CurrentWindow.TextWindow.ScrollToBottom();
                                    CurrentWindow.LastMessageType = ServerMessageType.Action;
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.DCCChat)
                                {

                                    IceTabPage c = GetWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.DCCChat);
                                    if (c != null)
                                    {
                                        c.SendDCCData("ACTION " + data + "");

                                        string msg = GetMessageFormat("DCC Chat Action");
                                        msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName);
                                        msg = msg.Replace("$message", data);

                                        CurrentWindow.TextWindow.AppendText(msg, 1);
                                        CurrentWindow.TextWindow.ScrollToBottom();
                                        CurrentWindow.LastMessageType = ServerMessageType.Action;

                                    }
                                }
                            }
                            break;
                        case "/mode":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "MODE " + data);
                            break;
                        case "/modex":
                            if (connection != null)
                                SendData(connection, "MODE " + connection.ServerSetting.NickName + " +x");
                            break;
                        case "/motd":
                            if (connection != null)
                            {
                                connection.ServerSetting.ForceMOTD = true;
                                SendData(connection, "MOTD");
                            }
                            break;
                        case "/msg":
                            if (connection != null && data.IndexOf(' ') > -1)
                            {
                                string nick = data.Substring(0, data.IndexOf(' '));
                                string msg2 = data.Substring(data.IndexOf(' ') + 1);
                                if (nick.StartsWith("="))
                                {
                                    //send to a dcc chat window
                                    nick = nick.Substring(1);

                                    IceTabPage c = GetWindow(connection, nick, IceTabPage.WindowType.DCCChat);
                                    if (c != null)
                                    {
                                        c.SendDCCData(data);
                                        string msg = GetMessageFormat("Self DCC Chat Message");
                                        msg = msg.Replace("$nick", c.Connection.ServerSetting.NickName).Replace("$message", data);

                                        c.TextWindow.AppendText(msg, 1);

                                    }
                                }
                                else
                                {
                                    SendData(connection, "PRIVMSG " + nick + " :" + msg2);

                                    //get the color for the private message
                                    string msg = GetMessageFormat("Self Channel Message");
                                    msg = msg.Replace("$nick", connection.ServerSetting.NickName).Replace("$channel", nick);

                                    if (msg.StartsWith("&#x3;"))
                                    {
                                        //get the color
                                        string color = msg.Substring(0, 6);
                                        int result;
                                        if (Int32.TryParse(msg.Substring(6, 1), out result))
                                            color += msg.Substring(6, 1);

                                        msg = color + "*" + nick + "* " + data.Substring(data.IndexOf(' ') + 1); ;
                                    }

                                    //check if the nick has a query window open
                                    IceTabPage q = GetWindow(connection, nick, IceTabPage.WindowType.Query);
                                    if (q != null)
                                    {
                                        string nmsg = GetMessageFormat("Self Private Message");
                                        nmsg = nmsg.Replace("$nick", connection.ServerSetting.NickName).Replace("$message", msg2);

                                        q.TextWindow.AppendText(nmsg, 1);
                                        q.LastMessageType = ServerMessageType.Message;

                                        if (q != CurrentWindow)
                                            CurrentWindowMessage(connection, msg, 1, true);

                                    }
                                    else
                                        CurrentWindowMessage(connection, msg, 1, true);
                                }
                            }
                            break;
                        case "/nick":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "NICK " + data);
                            break;
                        case "/notice":
                            if (connection != null && data.IndexOf(' ') > -1)
                            {
                                string nick = data.Substring(0, data.IndexOf(' '));
                                string msg = data.Substring(data.IndexOf(' ') + 1);
                                SendData(connection, "NOTICE " + nick + " :" + msg);

                                string nmsg = GetMessageFormat("Self Notice");
                                nmsg = nmsg.Replace("$nick", nick).Replace("$message", msg);

                                CurrentWindowMessage(connection, nmsg, 1, true);
                            }
                            break;
                        case "/part":
                            if (connection != null && data.Length > 0)
                            {
                                //check if it is a query window
                                IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query);
                                if (q != null)
                                {
                                    RemoveWindow(connection, q.TabCaption, IceTabPage.WindowType.Query);
                                    return;
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.Query)
                                {
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query);
                                    return;
                                }

                                //is there a part message
                                if (data.IndexOf(' ') > -1)
                                {
                                    //check if channel is a valid channel
                                    if (Array.IndexOf(connection.ServerSetting.ChannelTypes, data[0]) != -1)
                                    {
                                        SendData(connection, "PART " + data.Substring(0, data.IndexOf(' ')) + " :" + data.Substring(data.IndexOf(' ') + 1));
                                        RemoveWindow(connection, data.Substring(0, data.IndexOf(' ')), IceTabPage.WindowType.Channel);
                                    }
                                    else
                                    {
                                        //not a valid channel, use the current window
                                        if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                        {
                                            SendData(connection, "PART " + CurrentWindow.TabCaption + " :" + data);
                                            RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel);
                                        }
                                    }
                                }
                                else
                                {
                                    //see if data is a valid channel;
                                    if (Array.IndexOf(connection.ServerSetting.ChannelTypes, data[0]) != -1)
                                    {
                                        SendData(connection, "PART " + data);
                                        RemoveWindow(connection, data, IceTabPage.WindowType.Channel);
                                    }
                                    else
                                    {
                                        if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                        {
                                            SendData(connection, "PART " + CurrentWindow.TabCaption + " :" + data);
                                            RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel);
                                        }
                                    }
                                }
                            }
                            else if (connection != null)
                            {
                                //check if current window is channel
                                if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                {
                                    SendData(connection, "PART " + CurrentWindow.TabCaption);
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel);
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.Query)
                                {
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query);
                                }
                            }
                            break;
                        case "/partall":
                            if (connection != null)
                            {
                                for (int i = mainTabControl.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainTabControl.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel)
                                    {
                                        if (mainTabControl.TabPages[i].Connection == connection)
                                        {
                                            SendData(connection, "PART " + mainTabControl.TabPages[i].TabCaption);
                                            RemoveWindow(connection, mainTabControl.TabPages[i].TabCaption, IceTabPage.WindowType.Channel);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/ping":
                            if (connection != null && data.Length > 0 && data.IndexOf(' ') == -1)
                            {
                                //ctcp nick ping
                                string msg = GetMessageFormat("Ctcp Send");
                                msg = msg.Replace("$nick", data); ;
                                msg = msg.Replace("$ctcp", "PING");
                                CurrentWindowMessage(connection, msg, 7, true);
                                SendData(connection, "PRIVMSG " + data + " :PING " + System.Environment.TickCount.ToString() + "");
                            }
                            break;
                        case "/play":   //play a WAV sound
                            if (data.Length > 4 && data.ToLower().EndsWith(".wav"))
                            {
                                //check if the WAV file exists in the Sounds Folder
                                if (File.Exists(soundsFolder + System.IO.Path.DirectorySeparatorChar + data))
                                {
                                    try
                                    {
                                        player.SoundLocation = soundsFolder + System.IO.Path.DirectorySeparatorChar + data;
                                        player.Play();
                                    }
                                    catch { }
                                }
                                //check if the entire path was passed for the sound file
                                else if (File.Exists(data))
                                {
                                    try
                                    {
                                        player.SoundLocation = @data;
                                        player.Play();
                                    }
                                    catch { }
                                }
                            }
                            break;
                        case "/query":
                            if (connection != null && data.Length > 0)
                            {
                                string nick = "";
                                string msg = "";

                                if (data.IndexOf(" ") > 0)
                                {
                                    //check if there is a message added
                                    nick = data.Substring(0, data.IndexOf(' '));
                                    msg = data.Substring(data.IndexOf(' ') + 1);
                                }
                                else
                                    nick = data;

                                if (!mainTabControl.WindowExists(connection, nick, IceTabPage.WindowType.Query))
                                    AddWindow(connection, nick, IceTabPage.WindowType.Query);

                                mainTabControl.SelectTab(GetWindow(connection, nick, IceTabPage.WindowType.Query));
                                serverTree.SelectTab(mainTabControl.CurrentTab, false);

                                if (msg.Length > 0)
                                {
                                    SendData(connection, "PRIVMSG " + nick + " :" + msg);

                                    string nmsg = GetMessageFormat("Self Private Message");
                                    nmsg = nmsg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", msg);

                                    CurrentWindow.TextWindow.AppendText(nmsg, 1);
                                    CurrentWindow.LastMessageType = ServerMessageType.Message;
                                }
                            }
                            break;
                        case "/quit":
                            if (connection != null)
                            {
                                connection.AttemptReconnect = false;

                                if (data.Length > 0)
                                    SendData(connection, "QUIT :" + data);
                                else
                                    SendData(connection, "QUIT :" + ParseIdentifiers(connection, connection.ServerSetting.QuitMessage, ""));
                            }
                            break;
                        case "/aquit":
                        case "/quitall":
                            foreach (IRCConnection c in serverTree.ServerConnections.Values)
                            {
                                if (c.IsConnected)
                                {
                                    c.AttemptReconnect = false;

                                    if (data.Length > 0)
                                        SendData(c, "QUIT :" + data);
                                    else
                                        SendData(c, "QUIT :" + ParseIdentifiers(connection, c.ServerSetting.QuitMessage, ""));
                                }
                            }
                            break;
                        case "/redrawtree":
                            System.Diagnostics.Debug.WriteLine(mainTabControl.CurrentTab.TabCaption);
                            this.serverTree.Invalidate();
                            break;
                        case "/run":
                            if (data.Length > 0)
                            {
                                if (data.IndexOf("'") == -1)
                                    System.Diagnostics.Process.Start(data);
                                else
                                {
                                    string cmd = data.Substring(0, data.IndexOf("'"));
                                    string arg = data.Substring(data.IndexOf("'") + 1);
                                    System.Diagnostics.Process p = System.Diagnostics.Process.Start(cmd, arg);
                                }
                            }
                            break;
                        case "/say":
                            if (connection != null && data.Length > 0)
                            {
                                if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                {
                                    SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);

                                    string msg = GetMessageFormat("Self Channel Message");
                                    string nick = inputPanel.CurrentConnection.ServerSetting.NickName;

                                    msg = msg.Replace("$nick", nick).Replace("$channel", CurrentWindow.TabCaption);

                                    //assign $color to the nickname
                                    if (msg.Contains("$color"))
                                    {
                                        User u = CurrentWindow.GetNick(nick);
                                        for (int i = 0; i < u.Level.Length; i++)
                                        {
                                            if (u.Level[i])
                                            {
                                                if (connection.ServerSetting.StatusModes[0][i] == 'v')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'h')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'o')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'a')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'q')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));
                                                else
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));

                                                break;
                                            }
                                        }
                                        if (msg.Contains("$color"))
                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00"));

                                    }

                                    msg = msg.Replace("$status", CurrentWindow.GetNick(nick).ToString().Replace(nick, ""));
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                    CurrentWindow.LastMessageType = ServerMessageType.Message;
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.Query)
                                {
                                    SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);

                                    string msg = GetMessageFormat("Self Private Message");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                    CurrentWindow.LastMessageType = ServerMessageType.Message;
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.DCCChat)
                                {
                                    CurrentWindow.SendDCCData(data);

                                    string msg = GetMessageFormat("Self DCC Chat Message");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data);
                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                }
                                else if (CurrentWindowType == IceTabPage.WindowType.Console)
                                {
                                    WindowMessage(connection, "Console", data, 4, true);
                                }
                            }
                            break;
                        case "/joinserv":       //joinserv irc.server.name #channel
                            if (data.Length > 0 && data.IndexOf(' ') > 0)
                            {
                                //check if default nick name has been set
                                if (iceChatOptions.DefaultNick == null || iceChatOptions.DefaultNick.Length == 0)
                                {
                                    CurrentWindowMessage(connection, "No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.",4 , false);
                                }
                                else
                                {
                                    ServerSetting s = new ServerSetting();
                                    //get the server name
                                    //if there is a port name. extract it
                                    string server = data.Substring(0,data.IndexOf(' '));
                                    string channel = data.Substring(data.IndexOf(' ')+1);
                                    if (server.Contains(":"))
                                    {
                                        s.ServerName = server.Substring(0, server.IndexOf(':'));
                                        s.ServerPort = server.Substring(server.IndexOf(':') + 1);
                                        if (s.ServerPort.IndexOf(' ') > 0)
                                        {
                                            s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' '));
                                        }
                                        //check for + in front of port, SSL Connection
                                        if (s.ServerPort.StartsWith("+"))
                                        {
                                            s.ServerPort = s.ServerPort.Substring(1);
                                            s.UseSSL = true;
                                        }
                                    }
                                    else
                                    {
                                        s.ServerName = server;
                                        s.ServerPort = "6667";
                                    }

                                    s.NickName = iceChatOptions.DefaultNick;
                                    s.AltNickName = iceChatOptions.DefaultNick + "_";
                                    s.AwayNickName = iceChatOptions.DefaultNick + "[A]";
                                    s.FullName = iceChatOptions.DefaultFullName;
                                    s.QuitMessage = iceChatOptions.DefaultQuitMessage;
                                    s.IdentName = iceChatOptions.DefaultIdent;
                                    s.IAL = new Hashtable();
                                    s.AutoJoinChannels = new string[] { channel };
                                    s.AutoJoinEnable = true;
                                    Random r = new Random();
                                    s.ID = r.Next(50000, 99999);
                                    NewServerConnection(s);
                                }
                            }
                            break;
                        case "/server":
                            if (data.Length > 0)
                            {
                                //check if default nick name has been set
                                if (iceChatOptions.DefaultNick == null || iceChatOptions.DefaultNick.Length == 0)
                                {
                                    CurrentWindowMessage(connection, "No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.", 4, false);
                                }
                                else if (data.StartsWith("id="))
                                {
                                    string serverID = data.Substring(3);
                                    foreach (ServerSetting s in serverTree.ServersCollection.listServers)
                                    {
                                        if (s.ID.ToString() == serverID)
                                        {
                                            NewServerConnection(s);
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    ServerSetting s = new ServerSetting();
                                    //get the server name
                                    //if there is a port name. extract it
                                    if (data.Contains(" "))
                                    {
                                        s.ServerName = data.Substring(0, data.IndexOf(' '));
                                        s.ServerPort = data.Substring(data.IndexOf(' ') + 1);
                                        if (s.ServerPort.IndexOf(' ') > 0)
                                        {
                                            s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' '));
                                        }
                                        //check for + in front of port, SSL Connection
                                        if (s.ServerPort.StartsWith("+"))
                                        {
                                            s.ServerPort = s.ServerPort.Substring(1);
                                            s.UseSSL = true;
                                            s.SSLAcceptInvalidCertificate = true;
                                        }
                                    }
                                    else if (data.Contains(":"))
                                    {
                                        s.ServerName = data.Substring(0, data.IndexOf(':'));
                                        s.ServerPort = data.Substring(data.IndexOf(':') + 1);
                                        if (s.ServerPort.IndexOf(' ') > 0)
                                        {
                                            s.ServerPort = s.ServerPort.Substring(0, s.ServerPort.IndexOf(' '));
                                        }
                                        //check for + in front of port, SSL Connection
                                        if (s.ServerPort.StartsWith("+"))
                                        {
                                            s.ServerPort = s.ServerPort.Substring(1);
                                            s.UseSSL = true;
                                            s.SSLAcceptInvalidCertificate = true;
                                        }
                                    }
                                    else
                                    {
                                        s.ServerName = data;
                                        s.ServerPort = "6667";
                                    }

                                    s.NickName = iceChatOptions.DefaultNick;
                                    s.AltNickName = iceChatOptions.DefaultNick + "_";
                                    s.AwayNickName = iceChatOptions.DefaultNick + "[A]";
                                    s.FullName = iceChatOptions.DefaultFullName;
                                    s.QuitMessage = iceChatOptions.DefaultQuitMessage;
                                    s.IdentName = iceChatOptions.DefaultIdent;
                                    s.IAL = new Hashtable();

                                    Random r = new Random();
                                    s.ID = r.Next(50000, 99999);
                                    NewServerConnection(s);
                                }
                            }
                            break;
                        case "/timers":
                            if (connection != null)
                            {
                                if (connection.IRCTimers.Count == 0)
                                    OnServerMessage(connection, "No Timers");
                                else
                                {
                                    foreach (IrcTimer timer in connection.IRCTimers)
                                        OnServerMessage(connection, "[ID=" + timer.TimerID + "] [Interval=" + timer.TimerInterval + "] [Reps=" + timer.TimerRepetitions + "] [Count=" + timer.TimerCounter + "] [Command=" + timer.TimerCommand + "]");
                                }
                            }
                            break;
                        case "/timer":
                            if (connection != null)
                            {
                                if (data.Length != 0)
                                {
                                    string[] param = data.Split(' ');
                                    if (param.Length == 2)
                                    {
                                        //check for /timer ID off
                                        if (param[1].ToLower() == "off")
                                        {
                                            connection.DestroyTimer(param[0]);
                                            break;
                                        }
                                    }
                                    else if (param.Length > 3)
                                    {
                                        // param[0] = TimerID
                                        // param[1] = Repetitions
                                        // param[2] = Interval
                                        // param[3+] = Command

                                        string timerCommand = String.Join(" ", param, 3, param.GetUpperBound(0) - 2);
                                        connection.CreateTimer(param[0], Convert.ToDouble(param[1]), Convert.ToInt32(param[2]), timerCommand);
                                    }
                                    else
                                    {
                                        string msg = GetMessageFormat("User Error");
                                        msg = msg.Replace("$message", "/timer [ID] [INTERVAL] [REPS] [COMMAND]");
                                        CurrentWindowMessage(connection, msg, 4, true);
                                    }
                                }
                                else
                                {
                                    string msg = GetMessageFormat("User Error");
                                    msg = msg.Replace("$message", "/timer [ID] [INTERVAL] [REPS] [COMMAND]");
                                    CurrentWindowMessage(connection, msg, 4, true);
                                }
                            }
                            break;

                        case "/topic":
                            if (connection != null)
                            {
                                if (data.Length == 0)
                                {
                                    if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                        SendData(connection, "TOPIC :" + CurrentWindow.TabCaption);
                                }
                                else
                                {
                                    //check if a channel name was passed
                                    string word = "";

                                    if (data.IndexOf(' ') > -1)
                                        word = data.Substring(0, data.IndexOf(' '));
                                    else
                                        word = data;

                                    if (Array.IndexOf(connection.ServerSetting.ChannelTypes, word[0]) != -1)
                                    {
                                        IceTabPage t = GetWindow(connection, word, IceTabPage.WindowType.Channel);
                                        if (t != null)
                                        {
                                            if (data.IndexOf(' ') > -1)
                                                SendData(connection, "TOPIC " + t.TabCaption + " :" + data.Substring(data.IndexOf(' ') + 1));
                                            else
                                                SendData(connection, "TOPIC :" + t.TabCaption);
                                        }
                                    }
                                    else
                                    {
                                        if (CurrentWindowType == IceTabPage.WindowType.Channel)
                                            SendData(connection, "TOPIC " + CurrentWindow.TabCaption + " :" + data);
                                    }
                                }
                            }
                            break;
                        case "/update":
                            checkForUpdate();
                            break;
                        case "/userinfo":
                            if (connection != null && data.Length > 0)
                            {
                                FormUserInfo fui = new FormUserInfo(connection);
                                //find the user
                                fui.NickName(data);
                                fui.ShowDialog(this);
                            }
                            break;
                        case "/version":
                            if (connection != null && data.Length > 0)
                            {
                                string msg = GetMessageFormat("Ctcp Send");
                                msg = msg.Replace("$nick", data); ;
                                msg = msg.Replace("$ctcp", "VERSION");
                                CurrentWindowMessage(connection, msg, 7, true);
                                SendData(connection, "PRIVMSG " + data + " VERSION");
                            }
                            else
                                SendData(connection, "VERSION");
                            break;
                        case "/who":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "WHO " + data);
                            break;
                        case "/whois":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "WHOIS " + data);
                            break;
                        case "/aline":  //for adding lines to @windows
                            if (data.Length > 0 && data.IndexOf(" ") > -1)
                            {
                                string window = data.Substring(0, data.IndexOf(' '));
                                string msg = data.Substring(data.IndexOf(' ') + 1);
                                if (GetWindow(null, window, IceTabPage.WindowType.Window) == null)
                                    AddWindow(null, window, IceTabPage.WindowType.Window);

                                IceTabPage t = GetWindow(null, window, IceTabPage.WindowType.Window);
                                if (t != null)
                                    t.TextWindow.AppendText(msg, 1);
                            }
                            break;
                        case "/window":
                            if (data.Length > 0)
                            {
                                if (data.StartsWith("@") && data.IndexOf(" ") == -1)
                                {
                                    if (GetWindow(null, data, IceTabPage.WindowType.Window) == null)
                                        AddWindow(null, data, IceTabPage.WindowType.Window);
                                }
                            }
                            break;
                        case "/quote":
                        case "/raw":
                            if (connection != null && connection.IsConnected)
                                connection.SendData(data);
                            break;
                        default:
                            //parse the outgoing data
                            if (connection != null)
                                SendData(connection, command.Substring(1) + " " + data);
                            break;
                    }
                }
                else
                {
                    //sends a message to the channel
                    if (inputPanel.CurrentConnection != null)
                    {
                        if (inputPanel.CurrentConnection.IsConnected)
                        {
                            //check if the current window is a Channel/Query, etc
                            if (CurrentWindowType == IceTabPage.WindowType.Channel)
                            {
                                SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);
                                //check if we got kicked out of the channel or not, and the window is still open
                                if (CurrentWindow.IsFullyJoined)
                                {
                                    string msg = GetMessageFormat("Self Channel Message");
                                    string nick = inputPanel.CurrentConnection.ServerSetting.NickName;
                                    msg = msg.Replace("$nick", nick).Replace("$channel", CurrentWindow.TabCaption);

                                    //assign $color to the nickname
                                    if (msg.Contains("$color"))
                                    {
                                        User u = CurrentWindow.GetNick(nick);
                                        for (int i = 0; i < u.Level.Length; i++)
                                        {
                                            if (u.Level[i])
                                            {
                                                if (connection.ServerSetting.StatusModes[0][i] == 'v')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelVoiceColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'h')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelHalfOpColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'o')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOpColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'a')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelAdminColor.ToString("00"));
                                                else if (connection.ServerSetting.StatusModes[0][i] == 'q')
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));
                                                else
                                                    msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelOwnerColor.ToString("00"));

                                                break;
                                            }
                                        }

                                        if (msg.Contains("$color"))
                                            msg = msg.Replace("$color", ((char)3).ToString() + iceChatColors.ChannelRegularColor.ToString("00"));
                                    }

                                    msg = msg.Replace("$status", CurrentWindow.GetNick(nick).ToString().Replace(nick, ""));
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, 1);
                                    CurrentWindow.LastMessageType = ServerMessageType.Message;
                                }
                            }
                            else if (CurrentWindowType == IceTabPage.WindowType.Query)
                            {
                                SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);

                                string msg = GetMessageFormat("Self Private Message");
                                msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data);

                                CurrentWindow.TextWindow.AppendText(msg, 1);
                                CurrentWindow.LastMessageType = ServerMessageType.Message;
                            }
                            else if (CurrentWindowType == IceTabPage.WindowType.DCCChat)
                            {
                                CurrentWindow.SendDCCData(data);

                                string msg = GetMessageFormat("Self DCC Chat Message");
                                msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.NickName).Replace("$message", data);

                                CurrentWindow.TextWindow.AppendText(msg, 1);
                            }
                            else if (CurrentWindowType == IceTabPage.WindowType.Console)
                            {
                                WindowMessage(connection, "Console", data, 4, true);
                            }
                        }
                        else
                        {
                            WindowMessage(connection, "Console", "Error: Not Connected", 4, true);
                            WindowMessage(connection, "Console", data, 4, true);
                        }
                    }
                    else
                    {
                        if (CurrentWindowType == IceTabPage.WindowType.Window)
                            CurrentWindow.TextWindow.AppendText(data, 1);
                        else
                            WindowMessage(null, "Console", data, 4, true);
                    }
                }
            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "ParseOutGoingCommand", e);
            }
        }
コード例 #6
0
ファイル: BuddyList.cs プロジェクト: origins/ICEChat
        internal void UpdateBuddy(IRCConnection connection,  BuddyListItem buddy)
        {
            if (this.InvokeRequired)
            {
                UpdateBuddyListDelegate ubl = new UpdateBuddyListDelegate(UpdateBuddy);
                this.Invoke(ubl, new object[] { connection, buddy });
            }
            else
            {
                TreeNode t = new TreeNode();
                t.Text = buddy.Nick;
                t.Tag = connection;
                t.ToolTipText = connection.ServerSetting.ServerName;

                if (buddy.Connected)
                {
                    this.treeBuddies.Nodes[1].Nodes.Add(t);
                    if (buddy.PreviousState == false)
                        FormMain.Instance.PlaySoundFile("buddy");
                    buddy.PreviousState = true;
                }
                else if (!buddy.Nick.StartsWith(";"))
                {
                    this.treeBuddies.Nodes[0].Nodes.Add(t);
                    buddy.PreviousState = false;
                }
                this.treeBuddies.ExpandAll();
            }
        }