示例#1
0
        public FormServers(ServerSetting s)
        {
            InitializeComponent();
            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;

            LoadDefaultServerSettings();

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

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

            ApplyLanguage();
        }
示例#2
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.textDisplayName.KeyDown += new System.Windows.Forms.KeyEventHandler(this.text_KeyDown);
            this.textQuitMessage.KeyDown += new System.Windows.Forms.KeyEventHandler(this.text_KeyDown);
            this.textFullName.KeyDown    += new System.Windows.Forms.KeyEventHandler(this.text_KeyDown);
            this.textAutoPerform.KeyDown += new System.Windows.Forms.KeyEventHandler(this.text_KeyDown);

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

            //if (s.conn
            foreach (IRCConnection c in FormMain.Instance.ServerTree.ServerConnections.Values)
            {
                //see if the server is connected
                if (c.ServerSetting == s)
                {
                    if (c.IsConnected)
                    {
                        this.checkUseIPv6.Enabled            = false;
                        this.checkUseSSL.Enabled             = false;
                        this.checkInvalidCertificate.Enabled = false;
                        this.checkUseProxy.Enabled           = false;
                        this.checkUseBNC.Enabled             = false;
                        this.checkDisableLogging.Enabled     = false;
                    }
                }
            }

            ApplyLanguage();
        }
示例#3
0
        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();
        }
示例#4
0
        public IRCConnection(ServerSetting ss)
        {
            commandQueue = new ArrayList();
            sendBuffer = new Queue<string>();
            serverSetting = ss;

            reconnectTimer = new System.Timers.Timer(30000);
            reconnectTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnReconnectTimerElapsed);

            buddyListTimer = new System.Timers.Timer(60000);
            buddyListTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnBuddyListTimerElapsed);

            pongTimer = new System.Timers.Timer(60000 * serverSetting.PongTimerMinutes);    //15 minutes
            pongTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnPongTimerElapsed);

            ircTimers = new List<IrcTimer>();
        }
示例#5
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();
        }
示例#6
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();
            }
        }
示例#7
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;").Replace(((char)2).ToString(), "&#x2;");

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

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

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

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

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

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

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

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

            BuddyListItem[] oldList = serverSetting.BuddyList;

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

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

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

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

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

                serverSetting.BuddyList[i] = b;
            }

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

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

            int result;

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

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


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

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

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

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

            serverSetting.ServerNotes = textNotes.Text;

            serverSetting.AdvancedSettings = checkAdvancedSettings.Checked;

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

            return(true);
        }
示例#8
0
 private void OnSaveServer(ServerSetting s, bool removeServer)
 {
     //check if the server needs to be removed
     if (removeServer)
     {
         serversCollection.RemoveServer(s);
     }
     SaveServerSettings();
     f = null;
 }
示例#9
0
        /// <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.toolStripMenuItemBlank,
                            this.editToolStripMenuItem,
                            this.removeServerToolStripMenuItem,
                            this.toolStripMenuItem1,
                            this.autoJoinToolStripMenuItem,
                            this.autoPerformToolStripMenuItem,
                            this.openLogFolderToolStripMenuItem});

                        //add the menu's created by plugins
                        foreach (IPluginIceChat ipc in FormMain.Instance.IceChatPlugins)
                        {
                            //ipc.ServerTreeCurrentConnection = ((ServerSetting)findNode).
                            if (ipc.Enabled == true)
                            {
                                ToolStripItem[] popServer = ipc.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.clearWindowToolStripMenuItem,
                            this.closeChannelToolStripMenuItem,
                            this.reJoinChannelToolStripMenuItem,
                            this.addToAutoJoinToolStripMenuItem,
                            this.channelInformationToolStripMenuItem,
                            this.channelFontToolStripMenuItem,
                            this.noColorModeToolStripMenuItem});

                            this.noColorModeToolStripMenuItem.Checked = ((IceTabPage)findNode).TextWindow.NoColorMode;

                            //add the menu's created by plugins
                            foreach (IPluginIceChat ipc in FormMain.Instance.IceChatPlugins)
                            {
                                if (ipc.Enabled == true)
                                {
                                    ipc.ServerTreeCurrentConnection = ((IceTabPage)findNode).Connection;
                                    ipc.ServerTreeCurrentTab = ((IceTabPage)findNode).TabCaption;

                                    ToolStripItem[] popChan = ipc.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.clearWindowToolStripMenuItem1,
                            this.closeWindowToolStripMenuItem,
                            this.userInformationToolStripMenuItem,
                            this.silenceUserToolStripMenuItem});

                            //add the menu's created by plugins
                            foreach (IPluginIceChat ipc in FormMain.Instance.IceChatPlugins)
                            {
                                if (ipc.Enabled == true)
                                {
                                    ipc.ServerTreeCurrentConnection = ((IceTabPage)findNode).Connection;
                                    ipc.ServerTreeCurrentTab = ((IceTabPage)findNode).TabCaption;

                                    ToolStripItem[] popQuery = ipc.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)
                        {
                            //
                        }
                    }
                }
            }
        }
示例#10
0
        private void OnQuickConnectServer(ServerSetting s)
        {
            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);
        }
示例#11
0
        /// <summary>
        /// Create a new Server Connection
        /// </summary>
        /// <param name="serverSetting">Which ServerSetting to use</param>
        private void NewServerConnection(ServerSetting serverSetting)
        {
            //System.Threading.ParameterizedThreadStart threadStart = new System.Threading.ParameterizedThreadStart(NewConnection);
            //System.Threading.Thread thread = new System.Threading.Thread(threadStart);
            //thread.IsBackground = true;
            //thread.Start(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.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.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.RawServerIncomingData += new RawServerIncomingDataDelegate(OnRawServerData);
            c.RawServerOutgoingData += new RawServerOutgoingDataDelegate(OnRawServerOutgoingData);

            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 IceChat.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.ChannelInfoWindowExists += new ChannelInfoWindowExistsDelegate(OnChannelInfoWindowExists);
            c.ChannelInfoAddBan += new ChannelInfoAddBanDelegate(OnChannelInfoAddBan);
            c.ChannelInfoAddException += new ChannelInfoAddExceptionDelegate(OnChannelInfoAddException);
            c.ChannelInfoTopicSet += new ChannelInfoTopicSetDelegate(OnChannelInfoTopicSet);

            c.WriteErrorFile += new WriteErrorFileDelegate(OnWriteErrorFile);

            OnAddConsoleTab(c);

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

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

            c.ConnectSocket();
        }
示例#12
0
 public void RemoveServer(ServerSetting server)
 {
     listServers.Remove(server);
 }
示例#13
0
 public void AddServer(ServerSetting server)
 {
     listServers.Add(server);
 }
示例#14
0
 public void RemoveServer(ServerSetting server)
 {
     listServers.Remove(server);
 }
示例#15
0
 public void AddServer(ServerSetting server)
 {
     listServers.Add(server);
 }
示例#16
0
        private void MakeDefaultFiles()
        {
            //make the server file
            string serversFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatServer.xml";

            IceChatServers servers = new IceChatServers();

            int ID = 1;

            _nickName = _nickName.Replace(" ", "");
            _nickName = _nickName.Replace("#", "");
            _nickName = _nickName.Replace(",", "");
            _nickName = _nickName.Replace("`", "");

            FormMain.Instance.IceChatOptions.DefaultNick = _nickName;

            if (comboData.Text.Length > 0)
            {
                ServerSetting s = new ServerSetting();
                s.ID = ID;
                s.ServerName = comboData.Text;
                s.NickName = _nickName;
                s.AltNickName = _nickName + "_";
                s.ServerPort = "6667";
                s.FullName = FormMain.Instance.IceChatOptions.DefaultFullName;
                s.IdentName = FormMain.Instance.IceChatOptions.DefaultIdent;
                s.QuitMessage = FormMain.Instance.IceChatOptions.DefaultQuitMessage;
                s.SetModeI = true;

                if (comboData.Text.ToLower() == "irc.quakenet.org")
                {
                    s.AutoJoinChannels = new string[] { "#icechat" };
                    s.AutoJoinEnable = true;
                }

                ID++;

                servers.AddServer(s);
            }

            foreach (string server in comboData.Items)
            {
                if (server != comboData.Text && server.Length > 0)
                {
                    ServerSetting ss = new ServerSetting();
                    ss.ID = ID;
                    ss.ServerName = server;
                    ss.NickName = _nickName;
                    ss.AltNickName = _nickName + "_";
                    ss.ServerPort = "6667";
                    ss.SetModeI = true;
                    ss.FullName = FormMain.Instance.IceChatOptions.DefaultFullName;
                    ss.IdentName = FormMain.Instance.IceChatOptions.DefaultIdent;
                    ss.QuitMessage = FormMain.Instance.IceChatOptions.DefaultQuitMessage;

                    if (server.ToLower() == "irc.quakenet.org")
                    {
                        ss.AutoJoinChannels = new string[] { "#icechat" };
                        ss.AutoJoinEnable = true;
                    }

                    ID++;

                    servers.AddServer(ss);
                }
            }

            XmlSerializer serializer = new XmlSerializer(typeof(IceChatServers));
            TextWriter textWriter = new StreamWriter(FormMain.Instance.ServersFile);
            serializer.Serialize(textWriter, servers);
            textWriter.Close();
            textWriter.Dispose();

            //make the default aliases file
            string aliasesFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatAliases.xml";
            IceChatAliases aliasList = new IceChatAliases();

            foreach (string alias in Default_Aliases)
            {
                AliasItem a = new AliasItem();
                string name = alias.Substring(0,alias.IndexOf(" ")).Trim();
                string command = alias.Substring(alias.IndexOf(" ") + 1);
                a.AliasName = name;
                a.Command = new String[] { command };

                aliasList.AddAlias(a);
            }

            XmlSerializer serializerA = new XmlSerializer(typeof(IceChatAliases));
            TextWriter textWriterA = new StreamWriter(aliasesFile);
            serializerA.Serialize(textWriterA, aliasList);
            textWriterA.Close();
            textWriterA.Dispose();

            //make the default popups file
            string popupsFile = _currentFolder + System.IO.Path.DirectorySeparatorChar + "IceChatPopups.xml";
            IceChatPopupMenus popupList = new IceChatPopupMenus();

            popupList.AddPopup(newPopupMenu("NickList", Nicklist_Popup));
            popupList.AddPopup(newPopupMenu("Console", Console_Popup));
            popupList.AddPopup(newPopupMenu("Channel", Channel_Popup));
            popupList.AddPopup(newPopupMenu("Query", Query_Popup));

            XmlSerializer serializerP = new XmlSerializer(typeof(IceChatPopupMenus));
            TextWriter textWriterP = new StreamWriter(popupsFile);
            serializerP.Serialize(textWriterP, popupList);
            textWriterP.Close();
            textWriterP.Dispose();
        }
示例#17
0
        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)
                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();

            SelectNodeByIndex(nodeNumber, true);

            //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;

                        return;
                    }
                }
            }

            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)
                        {
                            //part the channel/close the query window
                            FormMain.Instance.ParseOutGoingCommand(((IceTabPage)findNode).Connection, "/part " + ((IceTabPage)findNode).TabCaption);
                        }
                    }
                    else if (findNode.GetType() == typeof(IceTabPageDCCFile))
                    {
                        //close dcc file/send window

                    }
                }
            }
        }
示例#18
0
        /// <summary>
        /// Parse out command written in Input Box or sent from Plugin
        /// </summary>
        /// <param name="connection">Which Connection it is for</param>
        /// <param name="data">The Message to Parse</param>
        public void ParseOutGoingCommand(IRCConnection connection, string data)
        {
            try
            {
                data = data.Replace("&#x3;", ((char)3).ToString());

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

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

                data = args.Command;

                if (data.Length == 0)
                    return;

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

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

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

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

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

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

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

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

                                        break;
                                    case "serverlist":

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

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

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

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

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

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

                                        }
                                        break;
                                }
                            }
                            break;

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

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

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

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

                                    plugin.Dispose();

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

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

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

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

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

                                if (menuItem != null)
                                {
                                    //match

                                    IPluginIceChat plugin = (IPluginIceChat)menuItem.Tag;

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

                                    Type ObjType = null;
                                    Assembly ass = null;

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

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

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

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

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

                                            menuItem.Tag = ipi;

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

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

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

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

                                            }

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

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

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

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

                                            i++;
                                        }

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

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

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

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

                                connection.ServerSetting.BuddyList = buddies;

                                serverTree.SaveServers(serverTree.ServersCollection);

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

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

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

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

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

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

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

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

                                        }

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

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

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

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

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

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

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

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

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

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

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

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

                                        connection.ServerSetting.IgnoreList = ignores;

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

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

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

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

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

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

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

                                        c.TextWindow.AppendText(msg, 1);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                                                break;
                                            }
                                        }

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

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

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

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

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

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

                                CurrentWindow.TextWindow.AppendText(msg, 1);
                            }
                            else if (CurrentWindowType == IceTabPage.WindowType.Console)
                            {
                                WindowMessage(connection, "Console", data, 4, true);
                            }
                        }
                        else
                        {
                            WindowMessage(connection, "Console", "Error: Not Connected", 4, true);
                            WindowMessage(connection, "Console", data, 4, true);
                        }
                    }
                    else
                    {
                        if (CurrentWindowType == IceTabPage.WindowType.Window)
                            CurrentWindow.TextWindow.AppendText(data, 1);
                        else
                            WindowMessage(null, "Console", data, 4, true);
                    }
                }
            }
            catch (Exception e)
            {
                WriteErrorFile(connection, "ParseOutGoingCommand", e);
            }
        }
示例#19
0
 private void OnNewServer(ServerSetting s)
 {
     s.ID = serversCollection.GetNextID();
     s.IAL = new Hashtable();
     serversCollection.AddServer(s);
     SaveServerSettings();
     f = null;
 }
示例#20
0
        /// <summary>
        /// Update the Server Settings
        /// </summary>
        private void SaveSettings()
        {
            if (serverSetting == null)
                serverSetting = new ServerSetting();

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

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

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

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

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

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

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

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

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

            serverSetting.QuitMessage = textQuitMessage.Text;

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

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

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

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

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

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

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

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

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

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

            serverSetting.ServerNotes = textNotes.Text;

            serverSetting.AdvancedSettings = checkAdvancedSettings.Checked;

            if (newServer == true)
            {
                //add in the server to the server collection
                if (NewServer != null)
                    NewServer(serverSetting);
            }
            else
                if (SaveServer != null)
                    SaveServer(serverSetting, false);
        }
示例#21
0
 private string IsServerConnected(ServerSetting s)
 {
     foreach (IRCConnection c in serverConnections.Values)
     {
         //see if the server is connected
         if (c.ServerSetting == s)
             if (c.IsFullyConnected)
                 return "1";
             else if (c.IsConnected)
                 return "2";
     }
     return "0";
 }
示例#22
0
        private void buttonConnect_Click(object sender, EventArgs e)
        {
            if (textServer.Text.Length == 0)
            {
                MessageBox.Show(FormMain.Instance.IceChatLanguage.quickConnectErrorNoServer, FormMain.Instance.IceChatLanguage.quickConnectTitle);
                return;
            }
            if (textNick.Text.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.NickName = textNick.Text;
                if (textChannel.Text.Length > 0)
                {
                    s.AutoJoinEnable = true;
                    s.AutoJoinChannels = new string[] { textChannel.Text };
                }

                QuickConnectServer(s);
            }

            this.Close();
        }