Пример #1
0
        public void addLine(Pso2LogEventArgs msg)
        {
            // Callback
            if (this.txtLog.InvokeRequired)
            {
                addLineCallback d = new addLineCallback(addLine);
                this.Invoke(d, new object[] { msg });
            }
            else
            {
                // Let's pick a color to print
                Color msgColor;
                switch (msg.SendTo)
                {
                case "PARTY": msgColor = Properties.Settings.Default.ColorParty; break;

                case "GUILD": msgColor = Properties.Settings.Default.ColorGuild; break;

                case "REPLY": msgColor = Properties.Settings.Default.ColorReply; break;

                case "GROUP": msgColor = Properties.Settings.Default.ColorGroup; break;

                default: msgColor = Properties.Settings.Default.ColorDefault; break;
                }

                TranslatorService tr = AvailableTranslationServices.Active;

                // Which language is it?
                string msgLang = tr.DetectLanguage(msg.Message);

                // If not EN, translate
                string transText = "";
                if (msgLang != "en")
                {
                    transText = tr.Translate(msg.Message, ref msgLang);
                }

                // Let's add whatever
                txtLog.AppendText(msg.From + "\r\n", msgColor, 0, true);
                string[] a_Message = msg.Message.Split('\n');
                foreach (string line in a_Message)
                {
                    txtLog.AppendText(line + "\r\n", msgColor, 15);                                 // Adding one line at a time solves multi-laguage/multi-line formatting issue
                }
                if ((msgLang != "en") && (msg.Message != transText.Trim()))                         // Sometimes gibberish gets translated because it's detected as some other language
                {
                    txtLog.AppendText(transText + "\r\n", msgColor, 15, false, true, 0.7F);
                }
            }
        }
Пример #2
0
 public static void Add(TranslatorService service)
 {
     _list.Add(service);
     if (Active == null) Active = service;
 }