Exemple #1
0
 public void AddAlias(AliasItem alias)
 {
     listAliases.Add(alias);
 }
Exemple #2
0
        private void SaveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //save all the settings
            try
            {
                textAliases.Text = ReplaceCharsXml(textAliases.Text);

                //parse out all the aliases

                aliasList.listAliases.Clear();

                string[] aliases = textAliases.Text.Trim().Split(new String[] { Environment.NewLine }, StringSplitOptions.None);

                bool      isMultiLine    = false;
                AliasItem multiLineAlias = null;
                string    aliasCommands  = "";

                foreach (string alias in aliases)
                {
                    if (alias.Length > 0)
                    {
                        //check if it is a multilined alias
                        if (alias.EndsWith("{") && !isMultiLine)
                        {
                            //start of a multilined alias
                            isMultiLine    = true;
                            multiLineAlias = new AliasItem
                            {
                                AliasName = alias.Substring(0, alias.IndexOf(' '))
                            };
                            aliasCommands = "";
                        }
                        else if (alias == "}")
                        {
                            //end of multiline alias
                            isMultiLine            = false;
                            multiLineAlias.Command = aliasCommands.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            aliasList.AddAlias(multiLineAlias);
                            multiLineAlias = null;
                        }
                        else if (!isMultiLine)
                        {
                            //just a normal alias
                            AliasItem a = new AliasItem
                            {
                                AliasName = alias.Substring(0, alias.IndexOf(' ')),
                                Command   = new String[] { alias.Substring(alias.IndexOf(' ') + 1) }
                            };
                            aliasList.AddAlias(a);
                            a = null;
                        }
                        else
                        {
                            //add a line to the multiline alias
                            aliasCommands += alias + Environment.NewLine;
                        }
                    }
                }

                FormMain.Instance.IceChatAliases = aliasList;

                //save the current popup menu
                UpdateCurrentPopupMenus();

                //save any plugin addons for the Script Editor
                foreach (Plugin p in  FormMain.Instance.LoadedPlugins)
                {
                    IceChatPlugin ipc = p as IceChatPlugin;
                    if (ipc != null)
                    {
                        if (ipc.plugin.Enabled == true)
                        {
                            ipc.plugin.SaveEditorForm();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                FormMain.Instance.WindowMessage(FormMain.Instance.InputPanel.CurrentConnection, "Console", "\x000304SaveEditor Error:" + ex.Message + ":" + ex.Source, "", true);
            }
            finally
            {
                this.Close();
            }
        }
Exemple #3
0
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //save all the settings
            try
            {
                //parse out all the aliases
                textAliases.Text = textAliases.Text.Replace(((char)3).ToString(), "").Replace(((char)2).ToString(), "");

                aliasList.listAliases.Clear();

                string[] aliases = textAliases.Text.Trim().Split(new String[] { Environment.NewLine }, StringSplitOptions.None);
                bool isMultiLine = false;
                AliasItem multiLineAlias = null;
                string aliasCommands = "";

                foreach (string alias in aliases)
                {
                    if (alias.Length > 0)
                    {
                        //check if it is a multilined alias
                        if (alias.EndsWith("{") && !isMultiLine)
                        {
                            //start of a multilined alias
                            isMultiLine = true;
                            multiLineAlias = new AliasItem();
                            multiLineAlias.AliasName = alias.Substring(0, alias.IndexOf(' '));
                            aliasCommands = "";
                        }
                        else if (alias == "}")
                        {
                            //end of multiline alias
                            isMultiLine = false;
                            multiLineAlias.Command = aliasCommands.Split(new String[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            aliasList.AddAlias(multiLineAlias);
                            multiLineAlias = null;
                        }
                        else if (!isMultiLine)
                        {
                            //just a normal alias
                            AliasItem a = new AliasItem();
                            a.AliasName = alias.Substring(0, alias.IndexOf(' '));
                            a.Command = new String[] { alias.Substring(alias.IndexOf(' ') + 1) };
                            aliasList.AddAlias(a);
                            a = null;
                        }
                        else
                        {
                            //add a line to the multiline alias
                            aliasCommands += alias + Environment.NewLine;
                        }
                    }
                }

                FormMain.Instance.IceChatAliases = aliasList;

                //save the current popup menu
                UpdateCurrentPopupMenus();

                //save any plugin addons for the Script Editor
                foreach (IPluginIceChat ipc in FormMain.Instance.IceChatPlugins)
                {
                    if (ipc.Enabled)
                        ipc.SaveEditorForm();
                }
            }
            catch (Exception ex)
            {
                FormMain.Instance.WindowMessage(FormMain.Instance.InputPanel.CurrentConnection, "Console", "SaveEditor Error:" + ex.Message + ":" + ex.Source, 4, true);
            }
            finally
            {
                this.Close();
            }
        }
Exemple #4
0
 public void AddAlias(AliasItem alias)
 {
     listAliases.Add(alias);
 }
Exemple #5
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();
        }