Esempio n. 1
0
        public static NameEntry Parse( string entry )
        {
            Match match = NameRegex.Match( entry );

            if ( !match.Success )
                return null;

            string name = match.Groups[ "name" ].Value.Trim();
            int time = int.Parse( match.Groups[ "time" ].Value.Trim() );

            NameEntry nameEntry = new NameEntry
            {
                Name = name,
                Time = time
            };

            return nameEntry;
        }
Esempio n. 2
0
        private void btnEnable_Click(object sender, EventArgs e)
        {
            if (changingNames)
            {
                txtNameChanger.Enabled = true;

                nameEntries.Clear();

                if (nameTimer != null)
                {
                    nameTimer.Change(Timeout.Infinite, Timeout.Infinite);

                    nameTimer.Dispose();
                    nameTimer = null;
                }

                btnEnable.Text = "Enable";

                changingNames = false;
            }
            else
            {
                string[] lines = txtNameChanger.Text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

                if (lines.Length == 0)
                {
                    return;
                }

                nameEntries.Clear();

                foreach (string lineEntry in lines)
                {
                    NameEntry entry = NameEntry.Parse(lineEntry);

                    if (entry == null)
                    {
                        continue;
                    }

                    nameEntries.Add(entry);
                }

                if (nameEntries.Count == 0)
                {
                    return;
                }

                txtNameChanger.Enabled = false;

                currentIndex = 0;

                changingNames = true;

                nameTimer = new System.Threading.Timer(NameChangeTick, null, 0, 0);

                btnEnable.Text = "Disable";
            }

            string[] nameLines = txtNameChanger.Text.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

            sets.NameChanger.Clear();
            sets.NameChanger.AddRange(nameLines);

            sets.NoEscape       = chkNoEscape.Checked;
            sets.NoEscapeString = awayMessageBox.Text;

            sets.Save("settings.xml");
        }