Exemple #1
0
 void watcher_Changed(object sender, FileSystemEventArgs e)
 {
     if (System.Threading.Monitor.TryEnter(changeSync))
     {
         while (sr.BaseStream.Position != sr.BaseStream.Length)
         {
             string line = sr.ReadLine();
             if (MinecraftFormatUtils.IsLineChat(line))
             {
                 string  stripped   = MinecraftFormatUtils.RemoveColorCodes(MinecraftFormatUtils.GetChatContent(line));
                 string  playerName = MinecraftFormatUtils.GetPlayerName(stripped);
                 SpVoice speech;
                 if (!playerVoices.TryGetValue(playerName, out speech))
                 {
                     speech                   = new SpVoiceClass();
                     speech.Voice             = voices[(new Random()).Next(voices.Count)];
                     playerVoices[playerName] = speech;
                 }
                 appendTextLineAndScrollToEnd(stripped);
                 try
                 {
                     string trimmed = MinecraftFormatUtils.TrimPlayerName(stripped);
                     if (trimmed.StartsWith("<"))
                     {
                         trimmed = string.Format("less than sign {0}", trimmed.Substring(1));
                     }
                     speech.Speak(trimmed, SpeechVoiceSpeakFlags.SVSFlagsAsync);
                 }
                 catch {}
             }
         }
         System.Threading.Monitor.Exit(changeSync);
     }
 }
Exemple #2
0
        void TestButtonClick(object sender, EventArgs e)
        {
            string  line       = speakTestTextBox.Text;
            string  stripped   = MinecraftFormatUtils.RemoveColorCodes(line);
            string  playerName = MinecraftFormatUtils.GetPlayerName(stripped);
            SpVoice speech;

            if (!playerVoices.TryGetValue(playerName, out speech))
            {
                speech                   = new SpVoiceClass();
                speech.Voice             = voices[(new Random()).Next(voices.Count)];
                playerVoices[playerName] = speech;
            }
            appendTextLineAndScrollToEnd(stripped);
            try
            {
                string trimmed = MinecraftFormatUtils.TrimPlayerName(stripped);
                if (trimmed.StartsWith("<"))
                {
                    trimmed = string.Format("less than sign {0}", trimmed.Substring(1));
                }
                speech.Speak(trimmed, SpeechVoiceSpeakFlags.SVSFlagsAsync);
            }
            catch {}
        }