Ejemplo n.º 1
0
 public void AddAlias(AliasItem alias)
 {
     listAliases.Add(alias);
 }
Ejemplo n.º 2
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(), "").Replace(((char)219).ToString(), "").Replace(((char)206).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 (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();
            }
        }