コード例 #1
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
        private void OnSaveServer(ServerSetting s, bool removeServer)
        {
            //check if the server needs to be removed
            if (removeServer)
            {
                serversCollection.RemoveServer(s);
            }

            IRCConnection c = (IRCConnection)serverConnections[selectedServerID];
            if (c != null)
            {
                if (c.IsConnected)
                {
                    if (s.NickName != c.ServerSetting.CurrentNickName && s.TriedAltNick == false)
                        _parent.ParseOutGoingCommand(c, "/nick " + s.NickName);

                    //check for monitor list
                    if (c.ServerSetting.MonitorSupport)
                    {
                        if (c.ServerSetting.BuddyListEnable)
                            c.MonitorListCheck();
                    }
                }
            }

            SaveServerSettings();
            f = null;
        }
コード例 #2
0
ファイル: QuickConnect.cs プロジェクト: nicholatian/monody
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            if (textServer.Text.Trim().Length == 0)
            {
                MessageBox.Show(FormMain.Instance.IceChatLanguage.quickConnectErrorNoServer, FormMain.Instance.IceChatLanguage.quickConnectTitle);
                return;
            }
            if (textNick.Text.Trim().Length == 0)
            {
                MessageBox.Show(FormMain.Instance.IceChatLanguage.quickConnectErrorNoNick, FormMain.Instance.IceChatLanguage.quickConnectTitle);
                return;
            }

            if (QuickConnectServer != null)
            {
                ServerSetting s = new ServerSetting();
                //check if a server:port was entered
                if (textServer.Text.IndexOf(':') != -1)
                {
                    s.ServerName = textServer.Text.Substring(0, textServer.Text.IndexOf(':'));
                    s.ServerPort = textServer.Text.Substring(textServer.Text.IndexOf(':') + 1);
                }
                else if (textServer.Text.IndexOf(' ') != -1)
                {
                    s.ServerName = textServer.Text.Substring(0, textServer.Text.IndexOf(' '));
                    s.ServerPort = textServer.Text.Substring(textServer.Text.IndexOf(' ') + 1);
                }
                else
                {
                    s.ServerName = textServer.Text;
                    s.ServerPort = "6667";
                }

                s.NickName = textNick.Text;

                if (textChannel.Text.Trim().Length > 0)
                {
                    s.AutoJoinEnable = true;
                    s.AutoJoinChannels = new string[] { textChannel.Text };
                }

                QuickConnectServer(s);
            }

            this.Close();
        }
コード例 #3
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
        /// <summary>
        /// Return focus back to the InputText Box
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnMouseUp(object sender, MouseEventArgs e)
        {
            //see what menu to popup according to the nodetype
            if (selectedDragID != null)
            {
                //save the server list
                SaveServerSettings();
                selectedDragID = null;
            }

            if (e.Button == MouseButtons.Right)
            {
                //see what kind of a node we right clicked
                object findNode = FindNodeValue(selectedNodeIndex);
                if (findNode != null)
                {
                    if (findNode.GetType() == typeof(ServerSetting))
                    {
                        //make the default menu
                        this.contextMenuServer.Items.Clear();

                        this.contextMenuServer.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                            this.connectToolStripMenuItem,
                            this.disconnectToolStripMenuItem,
                            this.forceDisconnectToolStripMenuItem,
                            this.autoStartToolStripMenuItem,
                            this.toolStripMenuItemBlank,
                            this.editToolStripMenuItem,
                            this.removeServerToolStripMenuItem,
                            this.toolStripMenuItem1,
                            this.autoJoinToolStripMenuItem,
                            this.autoPerformToolStripMenuItem,
                            this.openLogFolderToolStripMenuItem});

                        this.autoStartToolStripMenuItem.Checked = ((ServerSetting)findNode).AutoStart;

                        //add the menu's created by plugins
                        foreach (Plugin p in _parent.LoadedPlugins)
                        {
                            IceChatPlugin ipc = p as IceChatPlugin;
                            if (ipc != null)
                            {
                                if (ipc.plugin.Enabled == true)
                                {
                                    ToolStripItem[] popServer = ipc.plugin.AddServerPopups();
                                    if (popServer != null && popServer.Length > 0)
                                    {
                                        this.contextMenuServer.Items.AddRange(popServer);
                                    }
                                }
                            }
                        }

                        //add in the popup menu
                        AddPopupMenu("Console", contextMenuServer);

                        this.contextMenuServer.Show(this, new Point(e.X, e.Y));
                    }
                    else if (findNode.GetType() == typeof(IceTabPage))
                    {
                        //check if it is a channel or query window
                        if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Channel)
                        {
                            contextMenuChannel.Items.Clear();

                            this.contextMenuChannel.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                            this.clearChannelToolStripMenuItem,
                            this.closeChannelToolStripMenuItem,
                            this.reJoinChannelToolStripMenuItem,
                            this.addToAutoJoinToolStripMenuItem,
                            this.channelInformationToolStripMenuItem,
                            this.channelFontToolStripMenuItem,
                            this.noColorModeToolStripMenuItem,
                            this.loggingToolStripMenuItem,
                            this.eventsToolStripMenuItem});

                            //System.Diagnostics.Debug.WriteLine("popup:" + ((IceTabPage)findNode).DisableSounds + ":" + ((IceTabPage)findNode).TabCaption);

                            this.noColorModeToolStripMenuItem.Checked = ((IceTabPage)findNode).TextWindow.NoColorMode;
                            this.disableEventsToolStripMenuItem.Checked = ((IceTabPage)findNode).EventOverLoad;
                            this.disableSoundsToolStripMenuItem.Checked = ((IceTabPage)findNode).DisableSounds;
                            this.disableLoggingToolStripMenuItem.Checked = ((IceTabPage)findNode).LoggingDisable;

                            if (((IceTabPage)findNode).JoinEventLocationOverload)
                            {
                                switch (((IceTabPage)findNode).JoinEventLocation)
                                {
                                    case 0:
                                        this.inChannelToolStripMenuItem.Checked = true;
                                        this.inConsoleToolStripMenuItem.Checked = false;
                                        this.hideToolStripMenuItem.Checked = false;
                                        break;
                                    case 1:
                                        this.inConsoleToolStripMenuItem.Checked = true;
                                        this.inChannelToolStripMenuItem.Checked = false;
                                        this.hideToolStripMenuItem.Checked = false;
                                        break;
                                    case 2:
                                        this.hideToolStripMenuItem.Checked = true;
                                        this.inChannelToolStripMenuItem.Checked = false;
                                        this.inConsoleToolStripMenuItem.Checked = false;
                                        break;
                                }
                            }
                            else
                            {
                                this.inChannelToolStripMenuItem.Checked = false;
                                this.inConsoleToolStripMenuItem.Checked = false;
                                this.hideToolStripMenuItem.Checked = false;
                            }

                            if (((IceTabPage)findNode).PartEventLocationOverload)
                            {
                                switch (((IceTabPage)findNode).PartEventLocation)
                                {
                                    case 0:
                                        this.inChannelToolStripMenuItem1.Checked = true;
                                        this.inConsoleToolStripMenuItem1.Checked = false;
                                        this.hideToolStripMenuItem1.Checked = false;
                                        break;
                                    case 1:
                                        this.inConsoleToolStripMenuItem1.Checked = true;
                                        this.inChannelToolStripMenuItem1.Checked = false;
                                        this.hideToolStripMenuItem1.Checked = false;
                                        break;
                                    case 2:
                                        this.hideToolStripMenuItem1.Checked = true;
                                        this.inChannelToolStripMenuItem1.Checked = false;
                                        this.inConsoleToolStripMenuItem1.Checked = false;
                                        break;
                                }
                            }
                            else
                            {
                                this.inChannelToolStripMenuItem1.Checked = false;
                                this.inConsoleToolStripMenuItem1.Checked = false;
                                this.hideToolStripMenuItem1.Checked = false;
                            }

                            if (((IceTabPage)findNode).QuitEventLocationOverload)
                            {
                                switch (((IceTabPage)findNode).QuitEventLocation)
                                {
                                    case 0:
                                        this.inChannelToolStripMenuItem2.Checked = true;
                                        this.inConsoleToolStripMenuItem2.Checked = false;
                                        this.hideToolStripMenuItem2.Checked = false;
                                        break;
                                    case 1:
                                        this.inConsoleToolStripMenuItem2.Checked = true;
                                        this.inChannelToolStripMenuItem2.Checked = false;
                                        this.hideToolStripMenuItem2.Checked = false;
                                        break;
                                    case 2:
                                        this.hideToolStripMenuItem2.Checked = true;
                                        this.inChannelToolStripMenuItem2.Checked = false;
                                        this.inConsoleToolStripMenuItem2.Checked = false;
                                        break;
                                }
                            }
                            else
                            {
                                this.inChannelToolStripMenuItem2.Checked = false;
                                this.inConsoleToolStripMenuItem2.Checked = false;
                                this.hideToolStripMenuItem2.Checked = false;
                            }

                            //add the menu's created by plugins
                            foreach (Plugin p in _parent.LoadedPlugins)
                            {
                                IceChatPlugin ipc = p as IceChatPlugin;
                                if (ipc != null)
                                {
                                    if (ipc.plugin.Enabled == true)
                                    {
                                        ipc.plugin.ServerTreeCurrentConnection = ((IceTabPage)findNode).Connection;
                                        ipc.plugin.ServerTreeCurrentTab = ((IceTabPage)findNode).TabCaption;

                                        ToolStripItem[] popChan = ipc.plugin.AddChannelPopups();
                                        if (popChan != null && popChan.Length > 0)
                                        {
                                            this.contextMenuChannel.Items.AddRange(popChan);
                                        }
                                    }
                                }
                            }

                            //add in the popup menu
                            AddPopupMenu("Channel", contextMenuChannel);

                            this.contextMenuChannel.Show(this, new Point(e.X, e.Y));
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Query)
                        {
                            contextMenuQuery.Items.Clear();

                            this.contextMenuQuery.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                            this.clearQueryToolStripMenuItem,
                            this.closeQueryToolStripMenuItem,
                            this.userInformationToolStripMenuItem,
                            this.silenceUserToolStripMenuItem,
                            this.eventsQueryMenuItem});

                            this.disableSoundsQueryMenuItem.Checked = ((IceTabPage)findNode).DisableSounds;

                            //add the menu's created by plugins
                            foreach (Plugin p in _parent.LoadedPlugins)
                            {
                                IceChatPlugin ipc = p as IceChatPlugin;
                                if (ipc != null)
                                {
                                    if (ipc.plugin.Enabled == true)
                                    {
                                        ipc.plugin.ServerTreeCurrentConnection = ((IceTabPage)findNode).Connection;
                                        ipc.plugin.ServerTreeCurrentTab = ((IceTabPage)findNode).TabCaption;

                                        ToolStripItem[] popQuery = ipc.plugin.AddQueryPopups();
                                        if (popQuery != null && popQuery.Length > 0)
                                        {
                                            this.contextMenuQuery.Items.AddRange(popQuery);
                                        }
                                    }
                                }
                            }

                            //add in the popup menu
                            AddPopupMenu("Query", contextMenuQuery);

                            this.contextMenuQuery.Show(this, new Point(e.X, e.Y));
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.DCCChat)
                        {
                            this.contextMenuDCCChat.Show(this, new Point(e.X, e.Y));
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.ChannelList)
                        {
                            this.contextMenuChannelList.Show(this, new Point(e.X, e.Y));
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.DCCFile)
                        {
                            //
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Window)
                        {
                            this.contextMenuWindow.Show(this, new Point(e.X, e.Y));
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Debug)
                        {
                            contextMenuDebug.Items.Clear();
                            this.contextMenuDebug.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                                this.toolStripMenuClearDebug,
                                this.toolStripMenuCloseDebug
                            });

                            contextMenuDebug.Items.Add(new ToolStripSeparator());
                            //add the servers to the list
                            foreach (IRCConnection c in _parent.ServerTree.ServerConnections.Values)
                            {
                                if (c.IsConnected)
                                {
                                    ToolStripMenuItem t = new ToolStripMenuItem();
                                    t.Click += new EventHandler(DebugMenuItemClick);
                                    if (c.ServerSetting.RealServerName.Length > 0)
                                        t.Text = c.ServerSetting.RealServerName;
                                    else
                                        t.Text = c.ServerSetting.ServerName;

                                    if (c.ShowDebug)
                                    {
                                        t.Tag = "/debug disable " + +c.ServerSetting.ID;
                                        t.Checked = true;
                                        this.contextMenuDebug.Items.Add(t);

                                    }
                                    else
                                    {
                                        t.Tag = "/debug enable " + +c.ServerSetting.ID;
                                        this.contextMenuDebug.Items.Add(t);
                                    }
                                }
                            }

                            this.contextMenuDebug.Show(this, new Point(e.X, e.Y));
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
        private void OnNewServer(ServerSetting s)
        {
            s.ID = serversCollection.GetNextID();
            s.IAL = new Hashtable();

            serversCollection.AddServer(s);
            SaveServerSettings();
            f = null;
        }
コード例 #5
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
 private string IsServerConnected(ServerSetting s)
 {
     foreach (IRCConnection c in serverConnections.Values)
     {
         //see if the server is connected
         if (c.ServerSetting == s)
         {
             if (c.ServerSetting.AutoStart)
             {
                 if (c.IsFullyConnected)
                     return "1a";
                 else if (c.IsConnected)
                     return "2a";
             }
             else
             {
                 if (c.IsFullyConnected)
                     return "1";
                 else if (c.IsConnected)
                     return "2";
             }
         }
     }
     if (s.AutoStart)
         return "0a";
     else
         return "0";
 }
コード例 #6
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
        private void OnMouseDown(object sender, MouseEventArgs e)
        {
            if (this.Parent.Parent.GetType() != typeof(FormFloat))
            {
                if (e.Y <= headerHeight)
                {
                    //which side are we docked on
                    if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Right && e.X < 22)
                    {
                        ((IceDockPanel)this.Parent.Parent.Parent.Parent).DockControl();
                        return;
                    }
                    else if (((IceDockPanel)this.Parent.Parent.Parent.Parent).Dock == DockStyle.Left && e.X > (this.Width - 22))
                    {
                        ((IceDockPanel)this.Parent.Parent.Parent.Parent).DockControl();
                        return;
                    }
                }
            }

            if (e.Y <= headerHeight)
            {
                //de-select any previous items
                selectedNodeIndex = 0;
                Invalidate();
                return;
            }

            Graphics g = this.CreateGraphics();

            int _lineSize = Convert.ToInt32(this.Font.GetHeight(g));
            //find the server number, add 1 to it to make it a non-zero value
            int nodeNumber = Convert.ToInt32((e.Location.Y - headerHeight) / _lineSize) + 1 + topIndex;

            g.Dispose();

            //check if we have clicked the + or - to collapse or not collapse the tree
            if (e.Button == MouseButtons.Left && serverNodes.Count > 0 && e.X < 16)
            {
                object findNode = FindNodeValue(nodeNumber);
                if (findNode != null)
                {
                    if (findNode.GetType() == typeof(ServerSetting))
                    {
                        int t = ((ServerSetting)findNode).TreeCollapse;
                        if (t == 0)
                            return;
                        else if (t == 1)
                            ((ServerSetting)findNode).TreeCollapse = 2;
                        else
                            ((ServerSetting)findNode).TreeCollapse = 1;

                        this.Invalidate();
                        return;
                    }
                }
            }

            SelectNodeByIndex(nodeNumber, true);

            if (e.Button == MouseButtons.Left && serverNodes.Count > 1)
            {
                object findNode = FindNodeValue(nodeNumber);
                if (findNode != null)
                {
                    if (findNode.GetType() == typeof(ServerSetting))
                    {
                        selectedDragID = (ServerSetting)findNode;
                    }
                }
            }

            if (e.Button == MouseButtons.Middle)
            {
                object findNode = FindNodeValue(nodeNumber);
                if (findNode != null)
                {
                    if (findNode.GetType() == typeof(IceTabPage))
                    {
                        if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Channel || ((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Query || ((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.DCCChat)
                        {
                            //part the channel/close the query window
                            _parent.ParseOutGoingCommand(((IceTabPage)findNode).Connection, "/part " + ((IceTabPage)findNode).TabCaption);
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Window)
                        {
                            //just close the window
                            _parent.ParseOutGoingCommand(null, "/close " + ((IceTabPage)findNode).TabCaption);
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.Debug)
                        {
                            _parent.ParseOutGoingCommand(null, "/close debug");
                        }
                        else if (((IceTabPage)findNode).WindowStyle == IceTabPage.WindowType.ChannelList)
                        {
                            System.Diagnostics.Debug.WriteLine("found channel list");
                            _parent.ParseOutGoingCommand(((IceTabPage)findNode).Connection, "/close Channels");
                        }
                    }
                    else if (findNode.GetType() == typeof(IceTabPageDCCFile))
                    {
                        //close dcc file/send window

                    }
                }
            }
        }
コード例 #7
0
        public FormServers(ServerSetting s)
        {
            InitializeComponent();

            this.Load += new EventHandler(FormServers_Load);
            serverSetting = s;

            foreach (EncodingInfo ei in System.Text.Encoding.GetEncodings())
            {
                try
                {
                    comboEncoding.Items.Add(ei.Name);
                }
                catch { }
            }

            newServer = false;
            LoadSettings();

            this.Text = "Server Editor: " + s.ServerName + " - " + s.ID;

            LoadDefaultServerSettings();

            if (!s.AdvancedSettings)
                RemoveAdvancedTabs();
            else
                checkAdvancedSettings.Checked = true;

            this.checkAdvancedSettings.CheckedChanged += new System.EventHandler(this.checkAdvancedSettings_CheckedChanged);

            ApplyLanguage();
        }
コード例 #8
0
ファイル: ServerTree.cs プロジェクト: nicholatian/monody
        private int GetLastMessageColor(ServerSetting s)
        {
            int color = _parent.IceChatColors.TabBarDefault;

            foreach (ConsoleTab t in _parent.ChannelBar.GetTabPage("Console").ConsoleTab.TabPages)
            {
                if (t.Connection != null && t.Connection.ServerSetting == s)
                {
                    if (t.LastMessageType == FormMain.ServerMessageType.Default)
                            color = _parent.IceChatColors.TabBarDefault;
                        else if (t.LastMessageType == FormMain.ServerMessageType.JoinChannel)
                            color = _parent.IceChatColors.TabBarChannelJoin;
                        else if (t.LastMessageType == FormMain.ServerMessageType.PartChannel)
                            color = _parent.IceChatColors.TabBarChannelPart;
                        else if (t.LastMessageType == FormMain.ServerMessageType.Message)
                            color = _parent.IceChatColors.TabBarNewMessage;
                        else if (t.LastMessageType == FormMain.ServerMessageType.Action)
                            color = _parent.IceChatColors.TabBarNewAction;
                        else if (t.LastMessageType == FormMain.ServerMessageType.ServerMessage)
                            color = _parent.IceChatColors.TabBarServerMessage;
                        else if (t.LastMessageType == FormMain.ServerMessageType.ServerNotice)
                            color = _parent.IceChatColors.TabBarServerNotice;
                        else if (t.LastMessageType == FormMain.ServerMessageType.BuddyNotice)
                            color = _parent.IceChatColors.TabBarBuddyNotice;
                        else if (t.LastMessageType == FormMain.ServerMessageType.QuitServer)
                            color = _parent.IceChatColors.TabBarServerQuit;
                    else if (t.LastMessageType == FormMain.ServerMessageType.Other)
                        color = _parent.IceChatColors.TabBarOtherMessage;
                    else
                        color = _parent.IceChatColors.TabBarDefault;

                    return color;
                }
            }
            return color;
        }
コード例 #9
0
        private void buttonDuplicateServer_Click(object sender, EventArgs e)
        {
            //duplicate the server

            if (MessageBox.Show("Are you sure you want to Duplicate this Server?", "Duplicate Server", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
            {

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

                //make a copy of the server settings
                ServerSetting dupe = new ServerSetting();

                dupe.AccountNotify = serverSetting.AccountNotify;
                dupe.AdvancedSettings = serverSetting.AdvancedSettings;
                dupe.AltNickName = serverSetting.AltNickName;
                dupe.AutoJoinChannels = serverSetting.AutoJoinChannels;
                dupe.AutoJoinDelay = serverSetting.AutoJoinDelay;
                dupe.AutoJoinDelayBetween = serverSetting.AutoJoinDelayBetween;
                dupe.AutoJoinEnable = serverSetting.AutoJoinEnable;
                dupe.AutoPerform = serverSetting.AutoPerform;
                dupe.AutoPerformEnable = serverSetting.AutoPerformEnable;
                dupe.AutoStart = serverSetting.AutoStart;
                dupe.Away = serverSetting.Away;
                dupe.AwayNickName = serverSetting.AwayNickName;
                dupe.AwayNotify = serverSetting.AwayNotify;
                dupe.AwayStart = serverSetting.AwayStart;
                dupe.BNCIP = serverSetting.BNCIP;
                dupe.BNCPass = serverSetting.BNCPass;
                dupe.BNCPort = serverSetting.BNCPort;
                dupe.BNCUser = serverSetting.BNCUser;
                dupe.BuddyList = serverSetting.BuddyList;
                dupe.BuddyListEnable = serverSetting.BuddyListEnable;
                dupe.DisableAwayMessages = serverSetting.DisableAwayMessages;
                dupe.DisableCTCP = serverSetting.DisableCTCP;
                dupe.DisableSounds = serverSetting.DisableSounds;
                dupe.DisplayName = serverSetting.DisplayName;
                dupe.Encoding = serverSetting.Encoding;
                dupe.ExtendedJoin = serverSetting.ExtendedJoin;
                dupe.FullName = serverSetting.FullName;
                dupe.IdentName = serverSetting.IdentName;
                dupe.IgnoreList = serverSetting.IgnoreList;
                dupe.IgnoreListEnable = serverSetting.IgnoreListEnable;
                dupe.IRCV3 = serverSetting.IRCV3;
                dupe.NickName = serverSetting.NickName;
                dupe.NickservPassword = serverSetting.NickservPassword;
                dupe.Password = serverSetting.Password;
                dupe.PingTimerMinutes = serverSetting.PingTimerMinutes;
                dupe.ProxyIP = serverSetting.ProxyIP;
                dupe.ProxyPass = serverSetting.ProxyPass;
                dupe.ProxyPort = serverSetting.ProxyPort;
                dupe.ProxyType = serverSetting.ProxyType;
                dupe.ProxyUser = serverSetting.ProxyUser;
                dupe.QuitMessage = serverSetting.QuitMessage;
                dupe.RejoinChannels = serverSetting.RejoinChannels;
                dupe.SASLPass = serverSetting.SASLPass;
                dupe.SASLUser = serverSetting.SASLUser;
                dupe.ServerName = serverSetting.ServerName;
                dupe.ServerNotes = serverSetting.ServerNotes;
                dupe.ServerPort = serverSetting.ServerPort;
                dupe.SetModeI = serverSetting.SetModeI;
                dupe.ShowMOTD = serverSetting.ShowMOTD;
                dupe.ShowPingPong = serverSetting.ShowPingPong;
                dupe.SSLAcceptInvalidCertificate = serverSetting.SSLAcceptInvalidCertificate;
                dupe.UseBNC = serverSetting.UseBNC;
                dupe.UseIPv6 = serverSetting.UseIPv6;
                dupe.UseProxy = serverSetting.UseProxy;
                dupe.UseSASL = serverSetting.UseSASL;
                dupe.UseSSL = serverSetting.UseSSL;

                if (NewServer != null)
                    NewServer(dupe);

                this.Close();

            }
        }
コード例 #10
0
        /// <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;");

            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.AutoJoinDelayBetween = checkAutoJoinDelayBetween.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;
            }

            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.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.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.UseTLS = checkUseTLS.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;
        }
コード例 #11
0
ファイル: FormMain.cs プロジェクト: nicholatian/monody
        private void OnQuickConnectServer(ServerSetting s)
        {
            s.AltNickName =  s.NickName + "_";
            s.AwayNickName = s.NickName + "[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);
        }
コード例 #12
0
ファイル: FormMain.cs プロジェクト: nicholatian/monody
        /// <summary>
        /// Create a new Server Connection
        /// </summary>
        /// <param name="serverSetting">Which ServerSetting to use</param>
        private void NewServerConnection(ServerSetting serverSetting)
        {
            IRCConnection c = new IRCConnection(serverSetting);

            c.ChannelMessage += new ChannelMessageDelegate(OnChannelMessage);
            c.ChannelAction += new ChannelActionDelegate(OnChannelAction);
            c.QueryMessage += new QueryMessageDelegate(OnQueryMessage);
            c.QueryAction += new QueryActionDelegate(OnQueryAction);
            c.ChannelNotice += new ChannelNoticeDelegate(OnChannelNotice);

            c.ChangeNick += new ChangeNickDelegate(OnChangeNick);
            c.ChannelKick += new ChannelKickDelegate(OnChannelKick);

            c.OutGoingCommand += new OutGoingCommandDelegate(OutGoingCommand);
            c.JoinChannel += new JoinChannelDelegate(OnChannelJoin);
            c.PartChannel += new PartChannelDelegate(OnChannelPart);
            c.QuitServer += new QuitServerDelegate(OnServerQuit);

            c.JoinChannelMyself += new JoinChannelMyselfDelegate(OnChannelJoinSelf);
            c.PartChannelMyself += new PartChannelMyselfDelegate(OnChannelPartSelf);
            c.ChannelKickSelf += new ChannelKickSelfDelegate(OnChannelKickSelf);

            c.ChannelTopic += new ChannelTopicDelegate(OnChannelTopic);
            c.ChannelMode += new ChannelModeChangeDelegate(OnChannelMode);
            c.UserMode += new UserModeChangeDelegate(OnUserMode);
            c.ChannelInvite += new ChannelInviteDelegate(OnChannelInvite);

            c.ServerMessage += new ServerMessageDelegate(OnServerMessage);
            c.ServerError += new ServerErrorDelegate(OnServerError);
            c.ServerMOTD += new ServerMOTDDelegate(OnServerMOTD);
            c.WhoisData += new WhoisDataDelegate(OnWhoisData);
            c.UserNotice += new UserNoticeDelegate(OnUserNotice);
            c.CtcpMessage += new CtcpMessageDelegate(OnCtcpMessage);
            c.CtcpReply += new CtcpReplyDelegate(OnCtcpReply);
            c.GenericChannelMessage += new GenericChannelMessageDelegate(OnGenericChannelMessage);
            c.ServerNotice += new ServerNoticeDelegate(OnServerNotice);
            c.ChannelListStart += new ChannelListStartDelegate(OnChannelListStart);
            c.ChannelList += new ChannelListDelegate(OnChannelList);
            c.ChannelListEnd += new ChannelListEndDelegate(OnChannelListEnd);
            c.DCCChat += new DCCChatDelegate(OnDCCChat);
            c.DCCFile += new DCCFileDelegate(OnDCCFile);
            c.DCCPassive += new DCCPassiveDelegate(OnDCCPassive);
            c.UserHostReply += new UserHostReplyDelegate(OnUserHostReply);
            c.IALUserData += new IALUserDataDelegate(OnIALUserData);
            c.IALUserDataAwayOnly += new IALUserDataAwayOnlyDelegate(OnIALUserDataAwayOnly);
            c.IALUserChange += new IALUserChangeDelegate(OnIALUserChange);
            c.IALUserPart += new IALUserPartDelegate(OnIALUserPart);
            c.IALUserQuit += new IALUserQuitDelegate(OnIALUserQuit);

            c.BuddyListData += new BuddyListDelegate(OnBuddyList);
            c.BuddyListClear += new BuddyListClearDelegate(OnBuddyListClear);
            c.BuddyRemove +=new BuddyRemoveDelegate(OnBuddyRemove);
            c.MonitorListData += new MonitorListDelegate(OnMonitorListData);
            c.RawServerIncomingData += new RawServerIncomingDataDelegate(OnRawServerData);
            c.RawServerOutgoingData += new RawServerOutgoingDataDelegate(OnRawServerOutgoingData);
            c.RawServerIncomingDataOverRide += new RawServerIncomingDataOverRideDelegate(OnRawServerIncomingDataOverRide);

            c.AutoJoin += new AutoJoinDelegate(OnAutoJoin);
            c.AutoRejoin += new AutoRejoinDelegate(OnAutoRejoin);
            c.AutoPerform += new AutoPerformDelegate(OnAutoPerform);

            c.EndofNames += new EndofNamesDelegate(OnEndofNames);
            c.EndofWhoReply += new EndofWhoReplyDelegate(OnEndofWhoReply);
            c.WhoReply += new WhoReplyDelegate(OnWhoReply);
            c.ChannelUserList += new ChannelUserListDelegate(OnChannelUserList);

            c.StatusText += new StatusTextDelegate(OnStatusText);
            c.RefreshServerTree += new RefreshServerTreeDelegate(OnRefreshServerTree);
            c.ServerReconnect += new ServerReconnectDelegate(OnServerReconnect);
            c.ServerDisconnect += new ServerReconnectDelegate(OnServerDisconnect);
            c.ServerConnect += new ServerConnectDelegate(OnServerConnect);
            c.ServerForceDisconnect += new ServerForceDisconnectDelegate(OnServerForceDisconnect);
            c.ServerPreConnect += new ServerPreConnectDelegate(OnServerPreConnect);
            c.UserInfoWindowExists += new UserInfoWindowExistsDelegate(OnUserInfoWindowExists);
            c.UserInfoHostFullName += new UserInfoHostFullnameDelegate(OnUserInfoHostFullName);
            c.UserInfoIdleLogon += new UserInfoIdleLogonDelegate(OnUserInfoIdleLogon);
            c.UserInfoAddChannels += new UserInfoAddChannelsDelegate(OnUserInfoAddChannels);
            c.UserInfoAwayStatus += new UserInfoAwayStatusDelegate(OnUserInfoAwayStatus);
            c.UserInfoLoggedIn+=new UserInfoLoggedInDelegate(OnUserInfoLoggedIn);
            c.UserInfoServer += new UserInfoServerDelegate(OnUserInfoServer);

            c.ChannelInfoWindowExists += new ChannelInfoWindowExistsDelegate(OnChannelInfoWindowExists);
            c.ChannelInfoAddBan += new ChannelInfoAddBanDelegate(OnChannelInfoAddBan);
            c.ChannelInfoAddException += new ChannelInfoAddExceptionDelegate(OnChannelInfoAddException);
            c.ChannelInfoTopicSet += new ChannelInfoTopicSetDelegate(OnChannelInfoTopicSet);

            c.AutoAwayTrigger += new AutoAwayDelegate(OnAutoAwayTrigger);
            c.ServerFullyConnected += new ServerForceDisconnectDelegate(OnServerFullyConnected);

            c.WriteErrorFile += new WriteErrorFileDelegate(OnWriteErrorFile);
            c.ParseIdentifier += new IRCConnection.ParseIdentifierDelegate(OnParseIdentifier);

            OnAddConsoleTab(c);

            serverSetting.CurrentNickName = serverSetting.NickName;

            mainChannelBar.SelectTab(mainChannelBar.GetTabPage("Console"));

            inputPanel.CurrentConnection = c;
            serverTree.AddConnection(c);

            c.ConnectSocket();
        }
コード例 #13
0
ファイル: FormMain.cs プロジェクト: nicholatian/monody
        /// <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)
        {
            int error = 0;

            try
            {
                data = data.Replace("&#x3;", "\x0003");
                data = data.Replace("&#x2;", "\x0002");
                data = data.Replace("&#x1F;", "\x001F");
                data = data.Replace("&#x1D;", "\x001D");
                data = data.Replace("&#x16;", "\x0016");
                data = data.Replace("&#x0F;", "\x000F");

                data = data.Replace(@"\%C", "\x0003");
                data = data.Replace(@"\%B", "\x0002");
                data = data.Replace(@"\%U", "\x001F");
                data = data.Replace(@"\%I", "\x001D");
                data = data.Replace(@"\%R", "\x0016");
                data = data.Replace(@"\%O", "\x000F");

                PluginArgs args = new PluginArgs(connection);
                args.Command = data;
                //pass the channel or query/chat if either is active window
                if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Channel)
                {
                    args.Channel = CurrentWindow.TabCaption;
                    args.Extra = IceTabPage.WindowType.Channel.ToString();
                }
                else if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Query)
                {
                    args.Nick = CurrentWindow.TabCaption;
                    args.Extra = IceTabPage.WindowType.Query.ToString();
                }
                else if (CurrentWindow.WindowStyle == IceTabPage.WindowType.DCCChat)
                {
                    args.Nick = CurrentWindow.TabCaption;
                    args.Extra = IceTabPage.WindowType.DCCChat.ToString();
                }
                else if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Console)
                {
                    args.Nick = "Console";
                    args.Extra = "Console";
                }

                foreach (Plugin p in loadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (((IceChatPlugin)ipc).plugin.Enabled == true)
                            args = ((IceChatPlugin)ipc).plugin.InputText(args);
                    }
                }

                data = args.Command;

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

                if (data.Length == 0)
                    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 multilined alias, run multiple commands
                                string oldData = data;
                                foreach (string c in a.Command)
                                {
                                    //System.Diagnostics.Debug.WriteLine("a1:" + c + ":" + data + "::" + oldData);
                                    //data = ParseIdentifierValue(c, data);
                                    string data2 = ParseIdentifierValue(c, oldData);
                                    //System.Diagnostics.Debug.WriteLine("a2:" + data2);
                                    ParseOutGoingCommand(connection, ParseIdentifiers(connection, data2, oldData));
                                }
                            }
                            return;
                        }
                    }

                    switch (command.ToLower())
                    {
                        case "/makeexception":
                            throw new Exception("Monody 9 Test Exception Error");
                        case "/setupdde":
                            SetupIRCDDE();
                            break;
                        case "/updater":
                            RunUpdater();
                            break;
                        case "/updateversion":
                            UpdateInstallVersion();
                            break;
                        case "/searchchannel":
                        case "/searchchannels":
                            if (data.Length > 0)
                            {
                                //searchChannels(data);
                            }
                            break;
                        case "/searchnetwork":
                        case "/searchnetworks":
                            if (data.Length > 0)
                            {
                                //searchNetworks(data);
                            }
                            break;
                        case "/connectionstatus":
                            if (connection != null)
                            {
                                System.Diagnostics.Debug.WriteLine(connection.IsConnected);
                            }
                            break;
                        case "/debug":
                            if (data.Length == 0)
                                debugWindowToolStripMenuItem.PerformClick();
                            else
                            {
                                string[] dt = data.Split(' ');
                                if (dt[0].Equals("disable", StringComparison.OrdinalIgnoreCase))
                                {
                                    //disable this server from debug window/popup
                                    foreach (IRCConnection c in serverTree.ServerConnections.Values)
                                    {
                                        if (c.ServerSetting.ID.ToString() ==  dt[1])
                                        {
                                            c.ShowDebug = false;
                                        }
                                    }

                                }
                                else if (dt[0].Equals("enable", StringComparison.OrdinalIgnoreCase))
                                {
                                    //disable this server from debug window/popup
                                    foreach (IRCConnection c in serverTree.ServerConnections.Values)
                                    {
                                        if (c.ServerSetting.ID.ToString() == dt[1])
                                        {
                                            c.ShowDebug = true;
                                        }
                                    }
                                }

                            }
                            break;
                        case "/addlines":
                            if (data.Length == 0)
                            {
                                for (int i = 0; i < 250; i++)
                                {
                                    //pick a random color
                                    int randColor = new Random().Next(0, 71);

                                    string msg = "\x000304 " + i.ToString() + ":The quick brown \x0003" + randColor.ToString("00") + ",4fox jumps over the\x0003 www.icechat.net lazy dog and gets away with it at http://icechat.codeplex.com";
                                    CurrentWindowMessage(connection, msg, "", true);
                                }
                            }
                            else
                            {
                                int c = Convert.ToInt32(data);
                                for (int i = 0; i < c; i++)
                                {
                                    //pick a random color
                                    int randColor = new Random().Next(0, 71);

                                    string msg = "\x000304 " + i.ToString() + ":The quick brown \x0003" + randColor.ToString("00") + ",4fox jumps over the\x0003 www.icechat.net lazy dog and gets away with it at http://icechat.codeplex.com";
                                    CurrentWindowMessage(connection, msg, "", true);
                                }
                            }
                            break;

                        case "/ipsum":
                            string[] words = new[]{"lorem", "ipsum", "dolor", "sit", "amet", "consectetuer",  "adipiscing", "elit", "sed", "diam", "nonummy", "nibh", "euismod",
            "tincidunt", "ut", "laoreet", "dolore", "magna", "aliquam", "erat"};
                            Random rn = new Random();
                            string rs = string.Empty;
                            int maxWords = 25;
                            for (int w = 0; w < maxWords; w++)
                            {
                                if (w > 0) { rs += " "; }
                                rs += words[rn.Next(words.Length)];
                            }

                            CurrentWindowMessage(connection, rs, "", true);
                            break;

                        case "/colormode":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                    CurrentWindow.TextWindow.NoColorMode = !CurrentWindow.TextWindow.NoColorMode;
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                    t.TextWindow.NoColorMode = !t.TextWindow.NoColorMode;
                            }
                            break;
                        case "/sounds":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                    CurrentWindow.DisableSounds = !CurrentWindow.DisableSounds;
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                    t.DisableSounds = !t.DisableSounds;
                            }
                            break;

                        case "/flashing":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                    CurrentWindow.EventOverLoad = !CurrentWindow.EventOverLoad;
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                    t.EventOverLoad = !t.EventOverLoad;
                            }
                            break;

                        case "/logging":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    CurrentWindow.LoggingDisable = !CurrentWindow.LoggingDisable;
                                    CurrentWindow.TextWindow.DisableLogFile();
                                }
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    t.LoggingDisable = !t.LoggingDisable;
                                    t.TextWindow.DisableLogFile();
                                }
                            }
                            break;

                        case "/dump":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    CurrentWindow.TextWindow.SaveDumpFile();
                                }
                            }
                            break;
                        case "/loaddump":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    CurrentWindow.TextWindow.LoadDumpFile(CurrentWindow);
                                    CurrentWindow.TextWindow.Invalidate();
                                }
                            }
                            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 'none', 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":
                                        if (file.Length == 0)
                                        {
                                            //ask for a file/picture
                                            file = GetBackgroundImage();
                                            if (file.Length > 0)
                                            {
                                                this.nickList.BackGroundImage = file;
                                                //save the image file
                                                if (System.IO.Path.GetDirectoryName(file).ToLower().CompareTo(picturesFolder.ToLower()) == 0)
                                                    iceChatOptions.NickListImage = System.IO.Path.GetFileName(file);
                                                else
                                                    iceChatOptions.NickListImage = file;

                                            }
                                            return;
                                        }
                                        else if (file.ToLower() == "none" || file.ToLower() == "remove")
                                        {
                                            this.nickList.BackGroundImage = "";
                                            iceChatOptions.NickListImage = "";
                                        }
                                        else
                                        {
                                            //check if it is a full path or just a pic in the pictures folder
                                            if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                            {
                                                this.nickList.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + file;
                                                iceChatOptions.NickListImage = file;
                                            }
                                            else if (File.Exists(file))
                                            {
                                                this.nickList.BackGroundImage = file;
                                                iceChatOptions.NickListImage = file;
                                            }
                                        }

                                        break;
                                    case "serverlist":
                                    case "servertree":
                                        if (file.Length == 0)
                                        {
                                            //ask for a file/picture
                                            file = GetBackgroundImage();
                                            if (file.Length > 0)
                                            {
                                                this.serverTree.BackGroundImage = file;
                                                //save the image file
                                                if (System.IO.Path.GetDirectoryName(file).ToLower().CompareTo(picturesFolder.ToLower()) == 0)
                                                    iceChatOptions.ServerTreeImage = System.IO.Path.GetFileName(file);
                                                else
                                                    iceChatOptions.ServerTreeImage = file;

                                            }
                                            return;
                                        }
                                        else if (file.ToLower() == "none" || file.ToLower() == "remove")
                                        {
                                            this.serverTree.BackGroundImage = "";
                                            iceChatOptions.ServerTreeImage = "";
                                        }
                                        else
                                        {
                                            //check if it is a full path or just a pic in the pictures folder
                                            if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                            {
                                                this.serverTree.BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + file;
                                                iceChatOptions.ServerTreeImage = file;
                                            }
                                            else if (File.Exists(file))
                                            {
                                                this.serverTree.BackGroundImage = file;
                                                iceChatOptions.ServerTreeImage = file;
                                            }
                                        }
                                        break;
                                    case "console":
                                        //check if the file is a URL
                                        if (file.Length > 0)
                                        {
                                            if (File.Exists(picturesFolder + System.IO.Path.DirectorySeparatorChar + file))
                                                mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = picturesFolder + System.IO.Path.DirectorySeparatorChar + file;
                                            else
                                            {
                                                //check if this is a full path to the file
                                                if (File.Exists(file))
                                                    mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().BackGroundImage = file;
                                                else
                                                    mainChannelBar.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 mainChannelBar.TabPages)
                                                {
                                                    if (t.WindowStyle == IceTabPage.WindowType.Channel)
                                                    {
                                                        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.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 mainChannelBar.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.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 "/bgcolor":
                            //change the background color for the current or selected window
                            if (data.Length > 0)
                            {
                                int result;
                                if (Int32.TryParse(data, out result))
                                    if (result >= 0 && result < 72)
                                        if (CurrentWindowStyle == IceTabPage.WindowType.Console)
                                            mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().IRCBackColor = result;
                                        else if (CurrentWindowStyle == IceTabPage.WindowType.Channel || CurrentWindowStyle == IceTabPage.WindowType.Query || CurrentWindowStyle == IceTabPage.WindowType.Window)
                                            CurrentWindow.TextWindow.IRCBackColor = result;
                            }
                            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)
                                {
                                    IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag;

                                    plugin.Enabled = false;
                                    plugin.Unloaded = true;

                                    //remove any panels added to the main form
                                    Panel[] addedPanels = plugin.AddMainPanel();
                                    if (addedPanels != null && addedPanels.Length > 0)
                                    {
                                        bool foundOther = false;
                                        foreach (Panel p in addedPanels)
                                        {
                                            //fix the bottom panel / splitter
                                            if (p != null)
                                            {
                                                if (p.Dock == DockStyle.Bottom)
                                                {
                                                    //are there any other
                                                    foreach (Control cp in this.Controls)
                                                    {
                                                        if (cp != p)
                                                        {
                                                            if (cp.GetType() == typeof(Panel))
                                                                if (cp.Dock == DockStyle.Bottom)
                                                                    foundOther = true;
                                                        }
                                                    }
                                                }
                                            }
                                            this.Controls.Remove(p);
                                        }

                                        if (!foundOther)
                                        {
                                            this.Invoke((MethodInvoker)delegate()
                                            {
                                                this.splitterBottom.Visible = false;
                                            });
                                        }
                                    }

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

                                    for (int i = 0; i < iceChatPlugins.listPlugins.Count; i++)
                                    {
                                        if (((PluginItem)iceChatPlugins.listPlugins[i]).PluginFile.Equals(menuItem.ToolTipText))
                                        {
                                            ((PluginItem)iceChatPlugins.listPlugins[i]).Enabled = false;
                                            ((PluginItem)iceChatPlugins.listPlugins[i]).Unloaded = true;
                                            SavePluginFiles();
                                        }
                                    }

                                    WindowMessage(null, "Console", "\x000304Unloaded Plugin - " + plugin.Name, "", 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", "\x000304Enabled Plugin - " + plugin.Name + " v" + plugin.Version, "", true);

                                        //init the plugin
                                        System.Threading.Thread initPlugin = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(InitializePlugin));
                                        initPlugin.Start(plugin);

                                        //remove the icon
                                        menuItem.Image = null;
                                    }
                                    else
                                    {
                                        WindowMessage(null, "Console", "\x000304Disabled Plugin - " + plugin.Name + " v" + plugin.Version, "", true);
                                        menuItem.Image = StaticMethods.LoadResourceImage("CloseButton.png");

                                    }
                                }
                            }
                            break;
                        case "/loadplugin":
                            if (data.Length > 0)
                            {
                                IPluginIceChat ipc = loadPlugin(pluginsFolder + System.IO.Path.DirectorySeparatorChar + data);
                                if (ipc != null)
                                {
                                    System.Threading.Thread initPlugin = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(InitializePlugin));
                                    initPlugin.Start(ipc);
                                }
                            }
                            break;
                        case "/reload":
                            if (data.Length > 0)
                            {
                                switch (data)
                                {
                                    case "alias":
                                    case "aliases":
                                        CurrentWindowMessage(connection, "\x000304 Aliases file reloaded", "", true);
                                        LoadAliases();
                                        break;
                                    case "popup":
                                    case "popups":
                                        CurrentWindowMessage(connection, "\x000304 Popups file reloaded", "", true);
                                        LoadPopups();
                                        break;
                                    case "emoticon":
                                    case "emoticons":
                                        CurrentWindowMessage(connection, "\x000304 Emoticons file reloaded", "", true);
                                        LoadEmoticons();
                                        break;
                                    case "sound":
                                    case "sounds":
                                        CurrentWindowMessage(connection, "\x000304 Sounds file reloaded", "", true);
                                        LoadSounds();
                                        break;
                                    case "color":
                                    case "colors":
                                        CurrentWindowMessage(connection, "\x00034 Colors file reloaded", "", 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();
                                        serverTree.SetListColors();
                                        nickList.SetListColors();
                                        break;
                                    case "font":
                                    case "fonts":
                                        CurrentWindowMessage(connection, "\x00034 Fonts file reloaded", "", 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 "/addtext":
                            if (data.Length > 0)
                                AddInputPanelText(data);
                            break;
                        case "/beep":
                            System.Media.SystemSounds.Beep.Play();
                            break;
                        case "/size":
                            CurrentWindowMessage(connection, "\x00034Window Size is: " + this.Width + ":" + this.Height, "", true);
                            break;
                        case "/ame":    //me command for all channels
                            if (connection != null && data.Length > 0)
                            {
                                foreach (IceTabPage t in mainChannelBar.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.CurrentNickName).Replace("$channel", t.TabCaption);
                                            msg = msg.Replace("$message", data);

                                            t.TextWindow.AppendText(msg, "");
                                            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 mainChannelBar.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.CurrentNickName).Replace("$channel", t.TabCaption);

                                            //assign $color to the nickname
                                            if (msg.Contains("$color"))
                                            {
                                                User u = CurrentWindow.GetNick(t.Connection.ServerSetting.CurrentNickName);
                                                //get the nick color
                                                if (u.nickColor == -1)
                                                {
                                                    if (IceChatColors.RandomizeNickColors == true)
                                                    {
                                                        int randColor = new Random().Next(0, 71);
                                                        if (randColor == IceChatColors.NickListBackColor)
                                                            randColor = new Random().Next(0, 71);
                                                        u.nickColor = randColor;
                                                    }
                                                    else
                                                    {
                                                        //get the correct nickname color for channel status
                                                        for (int y = 0; y < u.Level.Length; y++)
                                                        {
                                                            if (u.Level[y])
                                                            {
                                                                switch (connection.ServerSetting.StatusModes[0][y])
                                                                {
                                                                    case 'q':
                                                                        u.nickColor = IceChatColors.ChannelOwnerColor;
                                                                        break;
                                                                    case 'a':
                                                                        u.nickColor = IceChatColors.ChannelAdminColor;
                                                                        break;
                                                                    case 'o':
                                                                        u.nickColor = IceChatColors.ChannelOpColor;
                                                                        break;
                                                                    case 'h':
                                                                        u.nickColor = IceChatColors.ChannelHalfOpColor;
                                                                        break;
                                                                    case 'v':
                                                                        u.nickColor = IceChatColors.ChannelVoiceColor;
                                                                        break;
                                                                    default:
                                                                        u.nickColor = IceChatColors.ChannelRegularColor;
                                                                        break;
                                                                }
                                                                break;
                                                            }
                                                        }

                                                    }
                                                    if (u.nickColor == -1)
                                                        u.nickColor = IceChatColors.ChannelRegularColor;

                                                }

                                                msg = msg.Replace("$color", "\x0003" + u.nickColor.ToString("00"));
                                            }

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

                                            t.TextWindow.AppendText(msg, "");
                                            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 != null)
                                            {
                                                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, "\x000307" + data + " is added to the Autojoin List", "", 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 != null)
                                            {
                                                if (chan.ToLower() == data.ToLower())
                                                {
                                                    //already in the list
                                                    Exists = true;
                                                    Disabled = true;
                                                    oldAutoJoin[i] = ";" + chan;
                                                    CurrentWindowMessage(connection, "\x000307" + data + " is now disabled in the Autojoin List", "", true);
                                                }
                                                else if (chan.ToLower() == (";" + data.ToLower()))
                                                {
                                                    //already in the list, but disabled
                                                    //so lets enable it
                                                    Disabled = true;
                                                    oldAutoJoin[i] = chan.Substring(1);
                                                    Exists = true;
                                                    CurrentWindowMessage(connection, "\x000307" + data + " is enabled in the Autojoin List", "", 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, "\x000307" + data + " is added to the Autojoin List", "", 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;
                                                i++;
                                            }
                                            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 "/autostart":
                            if (connection != null)
                            {
                                connection.ServerSetting.AutoStart = !connection.ServerSetting.AutoStart;
                                serverTree.SaveServers(serverTree.ServersCollection);
                            }
                            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;

                                    if (connection.ServerSetting.AwayNickName.Length > 0)
                                        SendData(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;

                                    string msg = iceChatOptions.ReturnCommand;
                                    msg = msg.Replace("$awaytime", s);
                                    if (iceChatOptions.SendAwayCommands == true && !connection.ServerSetting.DisableAwayMessages)
                                        ParseOutGoingCommand(connection, msg);

                                }
                                else
                                {
                                    connection.ServerSetting.Away = true;
                                    connection.ServerSetting.DefaultNick = connection.ServerSetting.CurrentNickName;
                                    connection.ServerSetting.AwayStart = System.DateTime.Now;

                                    if (connection.ServerSetting.AwayNickName.Length > 0)
                                        SendData(connection, "NICK " + connection.ServerSetting.AwayNickName);

                                    string msg = iceChatOptions.AwayCommand;
                                    msg = msg.Replace("$awayreason", data);

                                    if (iceChatOptions.SendAwayCommands == true && !connection.ServerSetting.DisableAwayMessages)
                                        ParseOutGoingCommand(connection, msg);
                                }
                            }
                            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.Show(this);
                                    }
                                }
                                else
                                {
                                    //check if current window is channel
                                    if (CurrentWindowStyle == 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.Show(this);
                                    }
                                }
                            }
                            break;
                        case "/pin":
                            if (data.Length > 0)
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    t.PinnedTab = true;
                                }
                                else
                                {
                                    IceTabPage c = GetWindow(null, data, IceTabPage.WindowType.Console);
                                    if (c != null)
                                        c.PinnedTab = true;
                                    else
                                    {
                                        //debug window?
                                        IceTabPage d = GetWindow(null, data, IceTabPage.WindowType.Debug);
                                        if (d != null)
                                            d.PinnedTab = true;
                                        else
                                        {
                                            IceTabPage w = GetWindow(null, data, IceTabPage.WindowType.Window);
                                            if (w != null)
                                                w.PinnedTab = true;
                                            else
                                            {
                                                IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query);
                                                if (q != null)
                                                    q.PinnedTab = true;
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "/unpin":
                            if (data.Length > 0)
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    t.PinnedTab = false;
                                }
                                else
                                {
                                    IceTabPage c = GetWindow(null, data, IceTabPage.WindowType.Console);
                                    if (c != null)
                                        c.PinnedTab = false;
                                    else
                                    {
                                        //debug window?
                                        IceTabPage d = GetWindow(null, data, IceTabPage.WindowType.Debug);
                                        if (d != null)
                                            d.PinnedTab = false;
                                        else
                                        {
                                            IceTabPage w = GetWindow(null, data, IceTabPage.WindowType.Window);
                                            if (w != null)
                                                w.PinnedTab = false;
                                            else
                                            {
                                                IceTabPage q = GetWindow(connection, data, IceTabPage.WindowType.Query);
                                                if (q != null)
                                                    q.PinnedTab = false;

                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "/attach":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel || CurrentWindowStyle == IceTabPage.WindowType.Query || CurrentWindowStyle == IceTabPage.WindowType.Window)
                                {
                                    //are we in windowed mode or not?
                                    if (!mainTabControl.windowedMode)
                                    {
                                        //need to get the FormWindow
                                        FormWindow child =(FormWindow)CurrentWindow.Parent;
                                        child.MainMenu.Hide();
                                        child.DisableActivate();

                                        IceTabPage tab = child.DockedControl;
                                        tab.DockedForm = false;
                                        tab.Detached = false;

                                        mainTabControl.AddTabPage(tab);
                                        mainChannelBar.SelectTab(tab);

                                        //close the window
                                        child.Close();
                                    }
                                    else
                                    {
                                        //we are already in windowed mode.. back to the parent
                                        FormWindow child = (FormWindow)CurrentWindow.Parent;
                                        child.MdiParent = this;
                                        child.MainMenu.Hide();
                                        CurrentWindow.Detached = false;
                                    }
                                }
                            }
                            break;
                        case "/detach":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel || CurrentWindowStyle == IceTabPage.WindowType.Query || CurrentWindowStyle == IceTabPage.WindowType.Window)
                                {
                                    //are we in windowed mode or not?
                                    if (!mainTabControl.windowedMode)
                                    {
                                        IceTabPage tab = CurrentWindow;
                                        tab.Detached = true;
                                        tab.DockedForm = true;

                                        FormWindow fw = new FormWindow(tab);

                                        fw.Text = tab.TabCaption;
                                        if (tab.WindowStyle == IceTabPage.WindowType.Channel || tab.WindowStyle == IceTabPage.WindowType.Query)
                                            fw.Text += " {" + tab.Connection.ServerSetting.NetworkName + "}";

                                        Point location = tab.WindowLocation;

                                        fw.Show();

                                        if (location != null)
                                        {
                                            //set new window location
                                            fw.Location = location;
                                        }

                                        if (tab.WindowSize != null && tab.WindowSize.Height != 0)
                                        {
                                            fw.Size = tab.WindowSize;
                                        }
                                    }
                                    else
                                    {
                                        //we are already in windowed mode.. remove the parent
                                        FormWindow child = (FormWindow)CurrentWindow.Parent;
                                        child.MdiParent = null;
                                        CurrentWindow.Detached = true;

                                    }
                                }
                            }
                            else
                            {
                                //detach a specific window

                            }
                            break;
                        case "/loadorder":
                            mainChannelBar.SortPageTabs();
                            mainChannelBar.Invalidate();
                            break;

                        case "/saveorder":
                            int curWindow = 1;  //window #
                            for (int i = 0; i < mainChannelBar.TabPages.Count; i++)
                            {
                                if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    curWindow++;
                                    mainChannelBar.TabPages[i].WindowIndex = curWindow;
                                }
                            }
                            //save the channel settings
                            SaveChannelSettings();
                            break;

                        case "/switch":
                            //switch to a specific channel / query on a server
                            //  /switch #channel serverID
                            if (data.IndexOf(' ') > -1)
                            {
                                string channel = data.Split(' ')[0];
                                string server = data.Split(' ')[1];
                                int serverID;
                                if (Int32.TryParse(server, out serverID))
                                {
                                    //switch to this window
                                    for (int i = 0; i < mainChannelBar.TabPages.Count; i++)
                                    {
                                        if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel || mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                        {
                                            if (mainChannelBar.TabPages[i].Connection.ServerSetting.ID == serverID)
                                            {
                                                if (mainChannelBar.TabPages[i].TabCaption.ToLower() == channel.ToLower())
                                                    mainChannelBar.SelectTab(mainChannelBar.TabPages[i]);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        case "/clear":
                            if (data.Length == 0)
                            {
                                if (CurrentWindowStyle != IceTabPage.WindowType.Console)
                                {
                                    CurrentWindow.TextWindow.ClearTextWindow();
                                }
                                else
                                {
                                    //find the current console tab window
                                    mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow();
                                }
                            }
                            else
                            {
                                //find a match
                                if (data == "Console")
                                {
                                    mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().ClearTextWindow();
                                    return;
                                }
                                else if (data == "Debug")
                                {
                                    IceTabPage db = GetWindow(null, "Debug", IceTabPage.WindowType.Debug);
                                    if (db != null)
                                    {
                                        db.TextWindow.ClearTextWindow();
                                    }
                                }
                                else if (data.ToLower() == "all console")
                                {
                                    //clear all the console windows and channel/queries
                                    foreach (ConsoleTab c in mainChannelBar.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();
                                        return;
                                    }
                                    IceTabPage win = GetWindow(null, data, IceTabPage.WindowType.Window);
                                    if (win != null)
                                    {
                                        win.TextWindow.ClearTextWindow();
                                        return;
                                    }
                                }
                            }
                            break;
                        case "/clearall":
                            //clear all the text windows
                            for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                            {
                                if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel || mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                {
                                    mainChannelBar.TabPages[i].TextWindow.ClearTextWindow();
                                }
                                else if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Console)
                                {
                                    //clear all console windows
                                    foreach (ConsoleTab c in mainChannelBar.GetTabPage("Console").ConsoleTab.TabPages)
                                    {
                                        ((TextWindow)c.Controls[0]).ClearTextWindow();
                                    }
                                }
                            }
                            break;
                        case "/closeall":
                            for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                            {
                                if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Window)
                                {
                                    RemoveWindow(connection, mainChannelBar.TabPages[i].TabCaption, IceTabPage.WindowType.Window);
                                }
                            }
                            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);
                                    return;
                                }
                            }
                            else if (connection != null)
                            {
                                //check if current window is channel/query/dcc chat
                                if (CurrentWindowStyle == IceTabPage.WindowType.Query)
                                    RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                else if (CurrentWindowStyle == IceTabPage.WindowType.DCCChat)
                                    RemoveWindow(connection, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                else if (CurrentWindowStyle == 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 (data.Length == 0)
                                {
                                    if (CurrentWindowStyle == IceTabPage.WindowType.Window)
                                        RemoveWindow(null, CurrentWindow.TabCaption, CurrentWindow.WindowStyle);
                                    else if (CurrentWindowStyle == IceTabPage.WindowType.Debug)
                                        RemoveWindow(null, "Debug", IceTabPage.WindowType.Debug);
                                }
                                else if (data.ToLower() == "debug")
                                {
                                    RemoveWindow(null, "Debug", IceTabPage.WindowType.Debug);
                                }
                                else
                                {
                                    if (data.StartsWith("@"))
                                        RemoveWindow(null, data, IceTabPage.WindowType.Window);
                                }
                            }
                            break;
                        case "/closequery":
                            if (connection != null)
                            {
                                for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                    {
                                        if (mainChannelBar.TabPages[i].Connection == connection)
                                        {
                                            RemoveWindow(connection, mainChannelBar.TabPages[i].TabCaption, IceTabPage.WindowType.Query);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/closeallquery":
                            if (connection != null)
                            {
                                for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Query)
                                    {
                                        RemoveWindow(connection, mainChannelBar.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, "", 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 (!mainChannelBar.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, "");
                                                    t.TextWindow.ScrollToBottom();
                                                }
                                            }
                                            else
                                            {
                                                mainChannelBar.SelectTab(GetWindow(connection, nick, IceTabPage.WindowType.DCCChat));
                                                serverTree.SelectTab(mainChannelBar.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, "");
                                                        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 (!mainChannelBar.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.CurrentNickName).Replace("$channel", t.TabCaption);
                                    msg = msg.Replace("$message", message);
                                    t.TextWindow.AppendText(msg, "");
                                    t.TextWindow.ScrollToBottom();
                                    t.LastMessageType = ServerMessageType.Action;
                                }
                            }
                            break;
                        case "/dns":
                            if (data.Length > 0)
                            {
                                if (data.IndexOf(".") > 0)
                                {
                                    //dns a host
                                    try
                                    {
                                        args.Extra = data;
                                        foreach (Plugin p in loadedPlugins)
                                        {
                                            IceChatPlugin ipc = p as IceChatPlugin;
                                            if (ipc != null)
                                            {
                                                if (ipc.plugin.Enabled == true)
                                                    args = ipc.plugin.DNSResolve(args);
                                            }
                                        }

                                        if (args.Extra.Length > 0)
                                        {

                                            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":
                            if (data.Length > 0)
                            {
                                //check if we are on the current server or not, otherwise , echo to console
                                if (CurrentWindow.Connection != connection)
                                {
                                    //echo to the console
                                    string msg = GetMessageFormat("User Echo");
                                    msg = msg.Replace("$message", "\x000F" + data);
                                    WindowMessage(connection, "Console", msg, "", true);
                                }
                                else
                                {
                                    if (CurrentWindowStyle == IceTabPage.WindowType.Channel || CurrentWindowStyle == IceTabPage.WindowType.Query)
                                    {
                                        string msg = GetMessageFormat("User Echo");
                                        msg = msg.Replace("$message", "\x000F" + data);

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

                                        mainChannelBar.GetTabPage("Console").CurrentConsoleWindow().AppendText(msg, "");
                                    }
                                    else if (CurrentWindowStyle == IceTabPage.WindowType.DCCChat)
                                    {
                                        string msg = GetMessageFormat("User Echo");
                                        msg = msg.Replace("$message", "\x000F" + data);

                                        CurrentWindow.TextWindow.AppendText(msg, "");
                                    }
                                    else if (CurrentWindowStyle == IceTabPage.WindowType.Window)
                                    {
                                        string msg = GetMessageFormat("User Echo");
                                        msg = msg.Replace("$message", "\x000F" + data);

                                        CurrentWindow.TextWindow.AppendText(msg, "");
                                    }
                                }
                            }
                            break;
                        case "/export":
                            if (connection != null)
                            {
                                //export the channel list to a file
                                if (CurrentWindowStyle == IceTabPage.WindowType.ChannelList)
                                {
                                    System.Diagnostics.Debug.WriteLine("Total:"+ CurrentWindow.ChannelList.Items.Count);
                                    if (CurrentWindow.ChannelList.Items.Count > 0)
                                    {
                                        //ask for a file name
                                        SaveFileDialog sfd = new SaveFileDialog();

                                        sfd.Filter = "TXT Files (*.txt)|*.txt";
                                        sfd.FilterIndex = 2;
                                        sfd.RestoreDirectory = true;
                                        if (sfd.ShowDialog() == DialogResult.OK)
                                        {
                                            //this is the full filename
                                            StreamWriter writer = new StreamWriter(sfd.OpenFile());

                                            for (int i = 1; i < CurrentWindow.ChannelList.Items.Count; i++)
                                            {
                                                writer.WriteLine(CurrentWindow.ChannelList.Items[i].Text + " : " + CurrentWindow.ChannelList.Items[i].SubItems[1].Text + " : " + CurrentWindow.ChannelList.Items[i].SubItems[2].Text);
                                            }
                                            writer.Flush();
                                            writer.Close();
                                            writer.Dispose();

                                            MessageBox.Show("Channel List Exported");
                                        }
                                    }
                                }

                            }
                            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;
                                    mainChannelBar.Invalidate();
                                    serverTree.Invalidate();
                                }
                                else
                                {
                                    //check if it is a query
                                    IceTabPage q = GetWindow(connection, window, IceTabPage.WindowType.Query);
                                    if (q != null)
                                    {
                                        q.FlashTab = flashWindow;
                                        mainChannelBar.Invalidate();
                                        serverTree.Invalidate();
                                    }
                                }

                            }
                            break;
                        case "/flashtask":
                        case "/flashtaskbar":
                            FlashTaskBar();
                            break;

                        case "/flashtray":
                            //check if we are minimized
                            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 = "Monody 9";
                                    this.notifyIcon.BalloonTipText = data;
                                    this.notifyIcon.ShowBalloonTip(1000);
                                }
                            }
                            break;

                        case "/sound":
                            //change the sound 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)
                                    {
                                        t.DisableSounds = !t.DisableSounds;
                                    }
                                }
                            }
                            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;

                                        fd.ShowEffects = false;
                                        fd.ShowColor = false;
                                        fd.FontMustExist = true;
                                        fd.AllowVectorFonts = false;
                                        fd.AllowVerticalFonts = false;
                                        try
                                        {
                                            if (fd.ShowDialog() != DialogResult.Cancel && fd.Font.Style == FontStyle.Regular)
                                            {
                                                t.TextWindow.Font = fd.Font;
                                            }
                                            else
                                            {
                                                if (fd.Font.Style != FontStyle.Regular)
                                                {
                                                    MessageBox.Show("Monody only supports 'Regular' font styles", "Font Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                                }
                                            }
                                        }
                                        catch (Exception)
                                        {
                                            MessageBox.Show("Monody only supports TrueType fonts", "Font Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }
                                }
                            }
                            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":
                        case "/cycle":
                            if (connection != null && data.Length == 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    CurrentWindow.ChannelHop = true;
                                    string key = CurrentWindow.ChannelKey;

                                    temp = CurrentWindow.TabCaption;
                                    SendData(connection, "PART " + temp);
                                    if (key.Length > 0 && key != "*")
                                        ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + temp + " " + key);
                                    else
                                        ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + temp);

                                }
                            }
                            else
                            {
                                IceTabPage t = GetWindow(connection, data, IceTabPage.WindowType.Channel);
                                if (t != null)
                                {
                                    t.ChannelHop = true;
                                    string key = CurrentWindow.ChannelKey;

                                    SendData(connection, "PART " + t.TabCaption);
                                    if (key.Length > 0 && key != "*")
                                        ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + t.TabCaption + " " + key);
                                    else
                                        ParseOutGoingCommand(connection, "/timer joinhop 1 1 /join " + t.TabCaption);

                                }
                            }
                            break;
                        case "/icechat":
                            if (connection != null)
                                ParseOutGoingCommand(connection, "/me is using " + ProgramID + " " + VersionID + " - Build " + BuildNumber);
                            else
                                ParseOutGoingCommand(connection, "/echo you are using " + ProgramID + " " + VersionID + " - Build " + BuildNumber);
                            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)
                                    {
                                        if (data.ToLower() == "enable")
                                        {
                                            connection.ServerSetting.IgnoreListEnable = true;
                                            ParseOutGoingCommand(connection, "/echo ignore list enabled");
                                        }
                                        else if (data.ToLower() == "disable")
                                        {
                                            connection.ServerSetting.IgnoreListEnable = false;
                                            ParseOutGoingCommand(connection, "/echo ignore list disabled");
                                        }
                                        else
                                        {
                                            //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;
                                                        ParseOutGoingCommand(connection, "/echo " + checkNick + " added to ignore list");
                                                    }
                                                    else
                                                    {
                                                        connection.ServerSetting.IgnoreList[i] = ";" + checkNick;
                                                        ParseOutGoingCommand(connection, "/echo " + checkNick + " remove from ignore list");
                                                    }

                                                    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;
                                            connection.ServerSetting.IgnoreListEnable = true;

                                            ParseOutGoingCommand(connection, "/echo " + data + " added to ignore list");

                                            serverTree.SaveServers(serverTree.ServersCollection);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/join":
                            if (connection != null && data.Length > 0)
                            {
                                if (connection.ServerSetting.ChannelTypes != null && Array.IndexOf(connection.ServerSetting.ChannelTypes, data[0]) == -1)
                                {
                                    data = connection.ServerSetting.ChannelTypes[0] + data;
                                }
                                if (data.IndexOf(' ') > -1)
                                {
                                    string[] c = data.Split(new char[] { ' ' }, 2);
                                    if (connection.ServerSetting.ChannelJoins.ContainsKey(c[0]))
                                        connection.ServerSetting.ChannelJoins[c[0]] = c[1];
                                    else
                                        connection.ServerSetting.ChannelJoins.Add(c[0], c[1]);
                                }
                                else
                                {
                                    if (!connection.ServerSetting.ChannelJoins.ContainsKey(data))
                                        connection.ServerSetting.ChannelJoins.Add(data, "");
                                    else
                                        connection.ServerSetting.ChannelJoins[data] = "";
                                }

                                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 (CurrentWindowStyle == IceTabPage.WindowType.Channel || CurrentWindowStyle == IceTabPage.WindowType.Query)
                                {
                                    SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :ACTION " + data + "");
                                    string msg = GetMessageFormat("Self Channel Action");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.CurrentNickName).Replace("$channel", CurrentWindow.TabCaption);
                                    msg = msg.Replace("$message", data);

                                    CurrentWindow.TextWindow.AppendText(msg, "");
                                    CurrentWindow.TextWindow.ScrollToBottom();
                                    CurrentWindow.LastMessageType = ServerMessageType.Action;
                                }
                                else if (CurrentWindowStyle == 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.CurrentNickName);
                                        msg = msg.Replace("$message", data);

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

                                    }
                                }
                            }
                            break;
                        case "/umode":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "MODE " + connection.ServerSetting.CurrentNickName + " " + data);
                            break;
                        case "/mode":
                            if (connection != null && data.Length > 0)
                                SendData(connection, "MODE " + data);
                            break;
                        case "/modex":
                            if (connection != null)
                                SendData(connection, "MODE " + connection.ServerSetting.CurrentNickName + " +x");
                            break;
                        case "/motd":
                            if (connection != null)
                            {
                                connection.ServerSetting.ForceMOTD = true;
                                SendData(connection, "MOTD");
                            }
                            break;
                        case "/msg":
                        case "/msgsec":
                            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");
                                        if (command.ToLower() == "/msgsec")
                                            msg = msg.Replace("$nick", c.Connection.ServerSetting.CurrentNickName).Replace("$message", "*");
                                        else
                                            msg = msg.Replace("$nick", c.Connection.ServerSetting.CurrentNickName).Replace("$message", data);

                                        c.TextWindow.AppendText(msg, "");

                                    }
                                }
                                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.CurrentNickName).Replace("$channel", nick);

                                    //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");
                                        if (command.ToLower() == "/msgsec")
                                            nmsg = nmsg.Replace("$nick", connection.ServerSetting.CurrentNickName).Replace("$message", "*");
                                        else
                                            nmsg = nmsg.Replace("$nick", connection.ServerSetting.CurrentNickName).Replace("$message", msg2);

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

                                    }
                                    else
                                    {
                                        IceTabPage t = GetWindow(connection, nick, IceTabPage.WindowType.Channel);
                                        if (t != null)
                                        {
                                            if (msg.Contains("$color"))
                                            {
                                                User u = t.GetNick(connection.ServerSetting.CurrentNickName);

                                                //get the nick color
                                                if (u.nickColor == -1)
                                                {
                                                    if (IceChatColors.RandomizeNickColors == true)
                                                    {
                                                        int randColor = new Random().Next(0, 71);
                                                        if (randColor == IceChatColors.NickListBackColor)
                                                            randColor = new Random().Next(0, 71);
                                                        u.nickColor = randColor;
                                                    }
                                                    else
                                                    {
                                                        //get the correct nickname color for channel status
                                                        for (int y = 0; y < u.Level.Length; y++)
                                                        {
                                                            if (u.Level[y])
                                                            {
                                                                switch (connection.ServerSetting.StatusModes[0][y])
                                                                {
                                                                    case 'q':
                                                                        u.nickColor = IceChatColors.ChannelOwnerColor;
                                                                        break;
                                                                    case 'a':
                                                                        u.nickColor = IceChatColors.ChannelAdminColor;
                                                                        break;
                                                                    case 'o':
                                                                        u.nickColor = IceChatColors.ChannelOpColor;
                                                                        break;
                                                                    case 'h':
                                                                        u.nickColor = IceChatColors.ChannelHalfOpColor;
                                                                        break;
                                                                    case 'v':
                                                                        u.nickColor = IceChatColors.ChannelVoiceColor;
                                                                        break;
                                                                    default:
                                                                        u.nickColor = IceChatColors.ChannelRegularColor;
                                                                        break;
                                                                }
                                                                break;
                                                            }
                                                        }

                                                    }
                                                    if (u.nickColor == -1)
                                                        u.nickColor = IceChatColors.ChannelRegularColor;
                                                }

                                                msg = msg.Replace("$color", "\x0003" + u.nickColor.ToString("00"));
                                            }

                                            if (t.GetNick(connection.ServerSetting.CurrentNickName) != null)
                                                msg = msg.Replace("$status", t.GetNick(connection.ServerSetting.CurrentNickName).ToString().Replace(connection.ServerSetting.CurrentNickName, ""));

                                            if (command.ToLower() == "/msgsec")
                                                msg = msg.Replace("$message", "*");
                                            else
                                                msg = msg.Replace("$message", msg2);

                                            t.TextWindow.AppendText(msg, "");
                                            t.LastMessageType = ServerMessageType.Message;
                                        }
                                        else
                                        {
                                            //send to the current window
                                            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);
                                                if (command.ToLower() == "/msgsec")
                                                    msg = color + "*" + nick + "* *";
                                                else
                                                    msg = color + "*" + nick + "* " + data.Substring(data.IndexOf(' ') + 1);
                                            }
                                            CurrentWindowMessage(connection, msg, "", true);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/names":
                            if (connection != null && data.Length > 0)
                            {
                                SendData(connection, "NAMES " + data);
                            }
                            break;
                        case "/nick":
                            if (connection != null && data.Length > 0)
                            {
                                connection.SendData("NICK " + data);
                                if (data.IndexOf(' ') == -1)
                                {
                                    if (connection.ServerSetting.NickName.CompareTo(data) != 0)
                                        connection.ServerSetting.NickName = data;
                                }
                                else
                                {
                                    //has a space
                                    string nick = data.Substring(0, data.IndexOf(' '));
                                    if (connection.ServerSetting.NickName.CompareTo(nick) != 0)
                                        connection.ServerSetting.NickName = nick;
                                }
                            }
                            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, "", true);
                            }
                            break;
                        case "/onotice":
                            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, "", true);
                            }
                            break;
                        case "/parse":
                            //if (data.Length == 0)
                            {
                                /*
                                string pattern2 = @"\[style.*\](.+?)\[/style\]";
                                Regex regex = new Regex(pattern2, RegexOptions.IgnoreCase);
                                //[br][Style ff:Tahoma;bgco:blue;co:blue;b;]___.[/style][Style ff:Tahoma;bgco:blue;co:yellow;b;]The Script-Testing Room[/style][Style ff:Tahoma;bgco:blue;co:blue;b;].___[/style][br][Style co:gold;b;]C[Style co:red;b;]RI[Style-co:blue;b;]m[Style co:green;b;]-[Style co:blue;b;]m[Style co:red;b;]IR[Style co:gold;b;]C [Style co:black;]http://crim-mirc.com[br][Style ff:Tahoma;bgco:red;co:red;b;]___.[/style][Style ff:Tahoma;bgco:red;co:white;b;]The Script Testing-Room[/style]

                                MatchCollection m = regex.Matches(@data);
                                System.Diagnostics.Debug.WriteLine(m.Count);
                                string s = Regex.Replace(data, @"\[[^]]+\]", "");

                                string p = regex.Replace(data, "$1");

                                System.Diagnostics.Debug.WriteLine(p);
                                System.Diagnostics.Debug.WriteLine(s);
                                */

                                //string message = @"&#x3;0<04@Snerf&#x3;> heya \test how are ya";
                                string message = "123 \test nick|name 123";
                                string nick = "\test";
                                nick = "nick|name";

                                // \t = tab
                                // \d = digit
                                // \b = boundary

                                if (Regex.IsMatch(message, Regex.Escape(nick), RegexOptions.IgnoreCase))
                                {
                                    System.Diagnostics.Debug.WriteLine("match");
                                }
                                else
                                    System.Diagnostics.Debug.WriteLine("no match");

                            }
                            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 (CurrentWindowStyle == IceTabPage.WindowType.Query)
                                {
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query);
                                    return;
                                }
                                else if (CurrentWindowStyle == IceTabPage.WindowType.DCCChat)
                                {
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.DCCChat);
                                    return;
                                }
                                else if (CurrentWindowStyle == IceTabPage.WindowType.Window)
                                {
                                    RemoveWindow(null, CurrentWindow.TabCaption, IceTabPage.WindowType.Window);
                                    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 (CurrentWindowStyle == 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 (CurrentWindowStyle == 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 (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    SendData(connection, "PART " + CurrentWindow.TabCaption);
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Channel);
                                }
                                else if (CurrentWindowStyle == IceTabPage.WindowType.Query)
                                {
                                    RemoveWindow(connection, CurrentWindow.TabCaption, IceTabPage.WindowType.Query);
                                }
                                else if (CurrentWindowStyle == IceTabPage.WindowType.Window)
                                {
                                    RemoveWindow(null, CurrentWindow.TabCaption, IceTabPage.WindowType.Window);
                                }
                            }
                            break;
                        case "/partall":
                            if (connection != null)
                            {
                                for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                                {
                                    if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel)
                                    {
                                        if (mainChannelBar.TabPages[i].Connection == connection)
                                        {
                                            if (connection.IsConnected)
                                                SendData(connection, "PART " + mainChannelBar.TabPages[i].TabCaption);

                                            RemoveWindow(connection, mainChannelBar.TabPages[i].TabCaption, IceTabPage.WindowType.Channel);
                                        }
                                    }
                                }
                            }
                            break;
                        case "/spartall":
                            for (int i = mainChannelBar.TabPages.Count - 1; i >= 0; i--)
                            {
                                if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    if (mainChannelBar.TabPages[i].Connection.IsConnected)
                                        SendData(mainChannelBar.TabPages[i].Connection, "PART " + mainChannelBar.TabPages[i].TabCaption);

                                    RemoveWindow(mainChannelBar.TabPages[i].Connection, mainChannelBar.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, "", true);
                                SendData(connection, "PRIVMSG " + data + " :PING " + System.Environment.TickCount.ToString() + "");
                            }
                            break;
                        case "/cplay":  //play a file in a specific channel /cplay #channel test.wav
                            if (connection != null && data.Length > 4 && data.IndexOf(' ') > 0)
                            {
                                string chan = data.Substring(0, data.IndexOf(' '));
                                string soundFile = data.Substring(data.IndexOf(' ') + 1);
                                //check if the channel is muted or not
                                ChannelSetting cs = ChannelSettings.FindChannel(chan, connection.ServerSetting.NetworkName);
                                if (cs != null)
                                {
                                    if (cs.SoundsDisable)
                                        return;
                                }

                                ParseOutGoingCommand(connection, "/play " + soundFile);

                            }
                            break;

                        case "/play":   //play a WAV sound or MP3
                            if (data.Length > 4 && (data.ToLower().EndsWith(".wav") || data.ToLower().EndsWith(".mp3")))
                            {
                                //check if the WAV file exists in the Sounds Folder
                                //check if the entire path was passed for the sound file
                                if (File.Exists(data))
                                {
                                    try
                                    {
                                        if (StaticMethods.IsRunningOnMono())
                                        {
                                            player.SoundLocation = @data;
                                            player.Play();
                                        }
                                        else
                                        {
                                            mp3Player.Open(data);
                                            mp3Player.Play();
                                        }
                                    }
                                    catch { }
                                }
                                else if (File.Exists(soundsFolder + System.IO.Path.DirectorySeparatorChar + data))
                                {
                                    try
                                    {
                                        if (StaticMethods.IsRunningOnMono())
                                        {
                                            player.SoundLocation = soundsFolder + System.IO.Path.DirectorySeparatorChar + data;
                                            player.Play();
                                        }
                                        else
                                        {
                                            mp3Player.Open(soundsFolder + System.IO.Path.DirectorySeparatorChar + data);
                                            mp3Player.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 (!mainChannelBar.WindowExists(connection, nick, IceTabPage.WindowType.Query))
                                    AddWindow(connection, nick, IceTabPage.WindowType.Query);

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

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

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

                                    CurrentWindow.TextWindow.AppendText(nmsg, "");
                                    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(mainChannelBar.CurrentTab.TabCaption);
                            this.serverTree.Invalidate();
                            break;
                        case "/run":
                            if (data.Length > 0)
                            {
                                try
                                {
                                    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);
                                    }
                                }
                                catch { }
                            }
                            break;
                        case "/say":
                            if (connection != null && data.Length > 0)
                            {
                                if (CurrentWindowStyle == IceTabPage.WindowType.Channel)
                                {
                                    SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);

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

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

                                    //assign $color to the nickname
                                    if (msg.Contains("$color"))
                                    {
                                        User u = CurrentWindow.GetNick(nick);

                                                //get the nick color
                                        if (u.nickColor == -1)
                                        {
                                            if (IceChatColors.RandomizeNickColors == true)
                                            {
                                                int randColor = new Random().Next(0, 71);
                                                if (randColor == IceChatColors.NickListBackColor)
                                                    randColor = new Random().Next(0, 71);
                                                u.nickColor = randColor;
                                            }
                                            else
                                            {
                                                //get the correct nickname color for channel status
                                                for (int y = 0; y < u.Level.Length; y++)
                                                {
                                                    if (u.Level[y])
                                                    {
                                                        switch (connection.ServerSetting.StatusModes[0][y])
                                                        {
                                                            case 'q':
                                                                u.nickColor = IceChatColors.ChannelOwnerColor;
                                                                break;
                                                            case 'a':
                                                                u.nickColor = IceChatColors.ChannelAdminColor;
                                                                break;
                                                            case 'o':
                                                                u.nickColor = IceChatColors.ChannelOpColor;
                                                                break;
                                                            case 'h':
                                                                u.nickColor = IceChatColors.ChannelHalfOpColor;
                                                                break;
                                                            case 'v':
                                                                u.nickColor = IceChatColors.ChannelVoiceColor;
                                                                break;
                                                            default:
                                                                u.nickColor = IceChatColors.ChannelRegularColor;
                                                                break;
                                                        }
                                                        break;
                                                    }
                                                }

                                            }
                                            if (u.nickColor == -1)
                                                u.nickColor = IceChatColors.ChannelRegularColor;

                                        }
                                        msg = msg.Replace("$color", "\x0003" + u.nickColor.ToString("00"));
                                    }

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

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

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

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

                                    string msg = GetMessageFormat("Self DCC Chat Message");
                                    msg = msg.Replace("$nick", inputPanel.CurrentConnection.ServerSetting.CurrentNickName).Replace("$message", data);
                                    CurrentWindow.TextWindow.AppendText(msg, "");
                                }
                                else if (CurrentWindowStyle == IceTabPage.WindowType.Console)
                                {
                                    WindowMessage(connection, "Console", data, "", 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, "\x000304No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.", "", 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 "/scid": //scid <ServerNumber/NetworkName> /command [parameters]
                            if (data.Length > 0 && data.IndexOf(' ') > -1)
                            {
                                string[] param = data.Split(new char[] {' '}, 2);
                                int result;
                                if (Int32.TryParse(param[0], out result))
                                {
                                    //result is the server id
                                    foreach (IRCConnection c in serverTree.ServerConnections.Values)
                                    {
                                        if (c.ServerSetting.ID == result)
                                        {
                                            ParseOutGoingCommand(c, param[1]);
                                        }
                                    }
                                }
                                else
                                {
                                    //check for a network name match
                                    foreach (IRCConnection c in serverTree.ServerConnections.Values)
                                    {
                                        if (c.ServerSetting.NetworkName.Equals(param[0], StringComparison.OrdinalIgnoreCase))
                                        {
                                            ParseOutGoingCommand(c, param[1]);
                                        }
                                    }
                                }
                            }
                            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, "\x000304No Default Nick Name Assigned. Go to Server Settings and set one under the Default Server Settings section.", "", 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();
                                    s.NickName = "";
                                    // get the server name
                                    // if there is a port name. extract it

                                    // server [-6e] <server:port> [port] [password] [-i nick anick email name] [-j #channel pass]

                                    if (data.Contains(" "))
                                    {
                                        if (data.StartsWith("-"))
                                        {
                                            //parameters
                                            // [-46epoc] - poc not used
                                            string switches = data.Substring(0, data.IndexOf(' '));
                                            data = data.Substring(switches.Length + 1);
                                            if (switches.IndexOf('e') > -1)
                                            {
                                                //enable ssl
                                                s.UseSSL = true;
                                                s.SSLAcceptInvalidCertificate = true;
                                            }
                                            //6 is ipv6
                                            if (switches.IndexOf('6') > -1)
                                            {
                                                //enable ssl
                                                s.UseIPv6 = true;
                                            }
                                        }
                                    }
                                    //data is now w/o the starting switches
                                    if (data.Contains(" "))
                                    {
                                        s.ServerName = data.Substring(0, data.IndexOf(' '));
                                        string sp = data.Substring(data.IndexOf(' ') + 1);
                                        //server address [port] [password]
                                        if (sp.IndexOf(' ') > 0)
                                        {
                                            if (sp.StartsWith("-"))
                                            {
                                                // -j or -i or both
                                                string[] sections = sp.Split(new char[]{'-'},StringSplitOptions.RemoveEmptyEntries);
                                                foreach(string section in sections)
                                                {
                                                    string switches = section.Substring(0, section.IndexOf(' '));
                                                    sp = section.Substring(switches.Length + 1);

                                                    if (switches.IndexOf('j') > -1)
                                                    {
                                                        //auto join this channel
                                                        //could have a channel pass
                                                        s.AutoJoinChannels = new string[1];
                                                        s.AutoJoinChannels[0] = sp;
                                                        s.AutoJoinEnable = true;
                                                    }

                                                    if (switches.IndexOf('i') > -1)
                                                    {
                                                        //use this nick
                                                        s.NickName = sp;
                                                        s.AltNickName = sp + "_";
                                                        s.AwayNickName = sp + "[A]";
                                                    }

                                                }
                                            }
                                            else
                                            {
                                                s.ServerPort = sp.Substring(0, sp.IndexOf(' '));
                                                if (s.ServerPort.StartsWith("+"))
                                                {
                                                    s.ServerPort = s.ServerPort.Substring(1);
                                                    s.UseSSL = true;
                                                    s.SSLAcceptInvalidCertificate = true;
                                                }
                                                s.Password = sp.Substring(sp.IndexOf(' ') + 1);
                                            }
                                        }
                                        else
                                        {
                                            //no space, check if value is a number or not
                                            int result;
                                            if (int.TryParse(sp, out result))
                                            {
                                                s.ServerPort = sp;
                                            }
                                            else
                                            {
                                                //check for + in front of port, SSL Connection
                                                if (sp.StartsWith("+"))
                                                {
                                                    s.ServerPort = sp.Substring(1);
                                                    s.UseSSL = true;
                                                    s.SSLAcceptInvalidCertificate = true;
                                                }
                                                else
                                                {
                                                    s.ServerPort = "6667";
                                                    s.Password = sp;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        s.ServerName = data;
                                        s.ServerPort = "6667";
                                    }

                                    //check if server name has : or :+ port
                                    if (s.ServerName.IndexOf(":") > -1)
                                    {
                                        string server = s.ServerName.Substring(0, s.ServerName.IndexOf(':'));
                                        s.ServerPort = s.ServerName.Substring(s.ServerName.IndexOf(':') + 1);
                                        s.ServerName = server;

                                        if (s.ServerPort.StartsWith("+"))
                                        {
                                            s.ServerPort = s.ServerPort.Substring(1);
                                            s.UseSSL = true;
                                            s.SSLAcceptInvalidCertificate = true;
                                        }
                                    }

                                    //nick could be set above
                                    if (s.NickName.Length == 0)
                                    {
                                        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 "/set":
                            // set an internal variable
                            // set -uNg <%var> [value]
                            // -u - unset in N amount of seconds
                            // -g for global

                            if (data.IndexOf(' ') > -1)
                            {
                                bool global = false;
                                string name = "";

                                if (data.StartsWith("-"))
                                {
                                    string switches = data.Substring(0, data.IndexOf(' '));
                                    data = data.Substring(switches.Length + 1);
                                    if (switches.Contains("g"))
                                        global = true;
                                    if (switches.Contains("u"))
                                    {
                                        // set a timed variable
                                        //need to get the numeric value
                                        string delay = switches.Substring(switches.IndexOf('u')+1);
                                        if (delay.Length > 0)
                                        {
                                            int result = 0;
                                            int z = 1;
                                            bool number = false;
                                            //get the numeric value out of it
                                            while (z < delay.Length)
                                            {
                                                if (Int32.TryParse(delay.Substring(z, 1), out result))
                                                {
                                                    z++;
                                                    number = true;
                                                }
                                                else
                                                    break;
                                            }

                                            System.Diagnostics.Debug.WriteLine(switches + ":" + delay + ":" + delay.Substring(0, z) + ":" + z + ":" + number);

                                            if (connection != null && global == false)
                                            {
                                                name = data.Substring(0, data.IndexOf(' '));
                                                //add the /timer command globally
                                                connection.CreateTimer("unset", 1, 1, "/unset " + name);
                                            }
                                        }

                                    }
                                }
                                //needs to have a space  <%var value>
                                if (data.IndexOf(' ') > -1)
                                {
                                    name = data.Substring(0, data.IndexOf(' '));
                                    object val = data.Substring(data.IndexOf(' ') + 1);

                                    if (connection != null && global == false)
                                        connection.ServerSetting.Variables.AddVariable(name, val);
                                    else
                                    {
                                        //add it as a global variable
                                        _variables.AddVariable(name, val);
                                    }
                                }
                            }
                            break;
                        case "/unset":
                            //unset <%var>
                            if (data.Length > 0)
                            {
                                if (connection != null)
                                    connection.ServerSetting.Variables.RemoveVariable(data);
                                else
                                {
                                    //remove it as a global variable
                                    _variables.RemoveVariable(data);
                                }
                            }
                            break;

                        case "/tab":
                            if (data.Length > 0)
                            {
                                //activate a specific tab
                                if (data.ToLower().Equals("buddylist"))
                                    ((TabControl)buddyListTab.Parent).SelectedTab = buddyListTab;
                                else if (data.ToLower().Equals("serverlist") || data.ToLower().Equals("servertree"))
                                    ((TabControl)serverListTab.Parent).SelectedTab = serverListTab;
                                else if (data.ToLower().Equals("nicklist"))
                                    ((TabControl)nickListTab.Parent).SelectedTab = nickListTab;
                                else if (data.ToLower().Equals("channellist"))
                                    ((TabControl)channelListTab.Parent).SelectedTab = channelListTab;

                                FocusInputBox();
                            }
                            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 + "]", "");
                                }
                            }
                            else
                            {
                                if (this._globalTimers.Count == 0)
                                    ParseOutGoingCommand(null, "/echo No Global Timers");
                                else
                                {
                                    foreach (IrcTimer timer in this._globalTimers)
                                        ParseOutGoingCommand(null, "/echo [Global 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(new char[] { ' ' }, 4);
                                    if (param.Length == 2)
                                    {
                                        //check for /timer ID off
                                        if (param[1].ToLower() == "off")
                                        {
                                            connection.DestroyTimer(param[0]);
                                            break;
                                        }
                                    }
                                    else if (param.Length == 4)
                                    {
                                        // param[0] = TimerID
                                        // param[1] = Repetitions
                                        // param[2] = Interval
                                        // param[3+] = Command
                                        if (param[0].StartsWith("-g"))
                                            this.CreateTimer(param[0], Convert.ToInt32(param[1]), Convert.ToDouble(param[2]), param[3]);
                                        else
                                            connection.CreateTimer(param[0], Convert.ToInt32(param[1]), Convert.ToDouble(param[2]), param[3]);
                                    }
                                    else
                                    {
                                        string msg = GetMessageFormat("User Error");
                                        msg = msg.Replace("$message", "/timer [ID] [REPS] [INTERVAL] [COMMAND]");
                                        CurrentWindowMessage(connection, msg, "", true);
                                    }
                                }
                                else
                                {
                                    string msg = GetMessageFormat("User Error");
                                    msg = msg.Replace("$message", "/timer [ID] [REPS] [INTERVAL] [COMMAND]");
                                    CurrentWindowMessage(connection, msg, "", true);
                                }
                            }
                            else
                            {
                                //add it to a global timer
                                if (data.Length != 0)
                                {
                                    string[] param = data.Split(new char[] { ' ' }, 4);
                                    if (param.Length == 2)
                                    {
                                        //check for /timer ID off
                                        if (param[1].ToLower() == "off")
                                        {
                                            this.DestroyTimer(param[0]);
                                            break;
                                        }
                                    }
                                    else if (param.Length == 4)
                                    {
                                        this.CreateTimer(param[0], Convert.ToInt32(param[1]), Convert.ToDouble(param[2]), param[3]);
                                    }
                                    else
                                    {
                                        string msg = GetMessageFormat("User Error");
                                        msg = msg.Replace("$message", "/timer [ID] [REPS] [INTERVAL] [COMMAND]");
                                        CurrentWindowMessage(null, msg, "", true);
                                    }
                                }
                                else
                                {
                                    string msg = GetMessageFormat("User Error");
                                    msg = msg.Replace("$message", "/timer [ID] [REPS] [INTERVAL] [COMMAND]");
                                    CurrentWindowMessage(null, msg, "", true);
                                }
                            }
                            break;
                        case "/topicbar":
                            if (connection != null)
                            {
                                if (data.Length > 0)
                                {
                                    if (data.IndexOf(' ') == -1)
                                    {
                                        if (CurrentWindow.WindowStyle == IceTabPage.WindowType.Channel)
                                        {
                                            //topicbar show //topicbar hide for current channel
                                            if (data.ToLower() == "show" || data.ToLower() == "on")
                                                CurrentWindow.ShowTopicBar = true;
                                            if (data.ToLower() == "hide" || data.ToLower() == "off")
                                                CurrentWindow.ShowTopicBar = false;

                                            ChannelSetting cs = ChannelSettings.FindChannel(CurrentWindow.TabCaption, connection.ServerSetting.NetworkName);
                                            if (cs != null)
                                            {
                                                cs.HideTopicBar = !CurrentWindow.ShowTopicBar;
                                            }
                                            else
                                            {
                                                ChannelSetting cs1 = new ChannelSetting();
                                                cs1.HideTopicBar = !CurrentWindow.ShowTopicBar;
                                                cs1.ChannelName = CurrentWindow.TabCaption;
                                                cs1.NetworkName = connection.ServerSetting.NetworkName;
                                                ChannelSettings.AddChannel(cs1);
                                            }

                                            SaveChannelSettings();

                                        }
                                    }
                                    else
                                    {
                                        //topicbar #channel show
                                        //string[] words = data.Split(' ');

                                    }
                                }
                            }
                            break;
                        case "/topic":
                            if (connection != null)
                            {
                                if (data.Length == 0)
                                {
                                    if (CurrentWindowStyle == 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 (CurrentWindowStyle == 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.Show(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, "", 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, "");
                                    t.LastMessageType = ServerMessageType.Message;
                                }
                            }
                            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);
                                    else
                                    {
                                        //switch to this window
                                        for (int i = 0; i < mainChannelBar.TabPages.Count; i++)
                                        {
                                            if (mainChannelBar.TabPages[i].WindowStyle == IceTabPage.WindowType.Window)
                                            {
                                                if (mainChannelBar.TabPages[i].TabCaption == data)
                                                {
                                                    mainChannelBar.SelectTab(mainChannelBar.TabPages[i]);
                                                    return;
                                                }
                                            }
                                        }

                                    }
                                }
                            }
                            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
                    error = 1;
                    if (inputPanel.CurrentConnection != null && connection != null)
                    {
                        if(connection.IsConnected)
                        {
                            error = 2;
                            //check if the current window is a Channel/Query, etc
                            if (CurrentWindowStyle == 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)
                                {
                                    error = 3;
                                    string msg = GetMessageFormat("Self Channel Message");
                                    string nick = connection.ServerSetting.CurrentNickName;
                                    msg = msg.Replace("$nick", nick).Replace("$channel", CurrentWindow.TabCaption);
                                    error = 4;
                                    //assign $color to the nickname
                                    if (msg.Contains("$color"))
                                    {
                                        error = 5;
                                        User u = CurrentWindow.GetNick(nick);

                                        //get the nick color
                                        if (u != null && u.nickColor == -1)
                                        {
                                            error = 6;
                                            if (IceChatColors.RandomizeNickColors == true)
                                            {
                                                int randColor = new Random().Next(0, 71);
                                                if (randColor == IceChatColors.NickListBackColor)
                                                    randColor = new Random().Next(0, 71);
                                                u.nickColor = randColor;
                                                error = 7;
                                            }
                                            else
                                            {
                                                //get the correct nickname color for channel status
                                                error = 8;
                                                for (int y = 0; y < u.Level.Length; y++)
                                                {
                                                    if (u.Level[y])
                                                    {
                                                        switch (connection.ServerSetting.StatusModes[0][y])
                                                        {
                                                            case 'q':
                                                                u.nickColor = IceChatColors.ChannelOwnerColor;
                                                                break;
                                                            case 'a':
                                                                u.nickColor = IceChatColors.ChannelAdminColor;
                                                                break;
                                                            case 'o':
                                                                u.nickColor = IceChatColors.ChannelOpColor;
                                                                break;
                                                            case 'h':
                                                                u.nickColor = IceChatColors.ChannelHalfOpColor;
                                                                break;
                                                            case 'v':
                                                                u.nickColor = IceChatColors.ChannelVoiceColor;
                                                                break;
                                                            default:
                                                                u.nickColor = IceChatColors.ChannelRegularColor;
                                                                break;
                                                        }
                                                        break;
                                                    }
                                                }
                                                error = 9;
                                            }
                                            if (u.nickColor == -1)
                                                u.nickColor = IceChatColors.ChannelRegularColor;
                                            error = 10;

                                            msg = msg.Replace("$color", "\x0003" + u.nickColor.ToString("00"));
                                        }
                                        else
                                            msg = msg.Replace("$color", "");

                                        error = 11;
                                    }

                                    error = 12; //this errors, losing a nickname for some reason!!

                                    if (CurrentWindow.GetNick(nick) != null)
                                        msg = msg.Replace("$status", CurrentWindow.GetNick(nick).ToString().Replace(nick, ""));
                                    else
                                        msg = msg.Replace("$status", "");

                                    error = 13;
                                    msg = msg.Replace("$message", data);
                                    error = 14;
                                    CurrentWindow.TextWindow.AppendText(msg, "");
                                    CurrentWindow.LastMessageType = ServerMessageType.Message;
                                    error = 15;
                                }
                            }
                            else if (CurrentWindowStyle == IceTabPage.WindowType.Query)
                            {
                                SendData(connection, "PRIVMSG " + CurrentWindow.TabCaption + " :" + data);

                                string msg = GetMessageFormat("Self Private Message");
                                msg = msg.Replace("$nick", connection.ServerSetting.CurrentNickName).Replace("$message", data);

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

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

                                CurrentWindow.TextWindow.AppendText(msg, "");
                            }
                            else if (CurrentWindowStyle == IceTabPage.WindowType.Console)
                            {
                                WindowMessage(connection, "Console", "\x000304" + data, "", true);
                            }
                        }
                        else
                        {
                            WindowMessage(connection, "Console", "\x000304Error: Not Connected", "", true);
                            WindowMessage(connection, "Console", "\x000304" + data, "", true);
                        }
                    }
                    else
                    {
                        if (CurrentWindowStyle == IceTabPage.WindowType.Window)
                            CurrentWindow.TextWindow.AppendText("\x000301" + data, "");
                        else
                            WindowMessage(null, "Console","\x000304" + data, "", true);
                    }
                }
            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "ParseOutGoingCommand:" + CurrentWindowStyle.ToString() + ":" + error + ":" + data, e);
            }
        }
コード例 #14
0
ファイル: ServerSetting.cs プロジェクト: nicholatian/monody
 public void RemoveServer(ServerSetting server)
 {
     listServers.Remove(server);
 }
コード例 #15
0
ファイル: ServerSetting.cs プロジェクト: nicholatian/monody
 public void AddServer(ServerSetting server)
 {
     listServers.Add(server);
 }