void MyContext_onSentence(TextHookContext sender, string text) { log.Enqueue(text); if (log.Count > MAX_LOG) { string unused; log.TryDequeue(out unused); } }
private void ctx_onSentence(TextHookContext sender, string text) { var ctx = (MyContext)sender; if (ctx.enabled) { TranslationService.instance.update(text); } webBrowser1.callScript("newSentence", sender.id, text); }
void clipboardMonitor1_ClipboardChanged(object sender, EventArgs e) { if (Clipboard.ContainsText()) { string text = Clipboard.GetText(); if (!Settings.app.clipboardJapanese || TextUtils.containsJapanese(text)) { TranslationService.instance.update(TextHookContext.cleanText(Clipboard.GetText())); } } }
internal List <int> disableContextsIfNeeded(TextHookContext ctx) { List <int> disabledContexts = null; switch (newContextsBehavior) { case NewContextsBehavior.SWITCH_TO_NEW: disabledContexts = new List <int>(); foreach (var ctx2 in textHook.getContexts()) { if (ctx2.internalId < ctx.internalId) { if ((ctx2 as MyContext).enabled) { (ctx2 as MyContext).enabled = false; disabledContexts.Add(ctx2.id); } } } break; case NewContextsBehavior.SMART: if (isContextSpecial(ctx.name)) { disabledContexts = new List <int>(); foreach (var ctx2 in textHook.getContexts()) { if (ctx2.internalId < ctx.internalId && !isContextSpecial(ctx2.name)) { if ((ctx2 as MyContext).enabled) { (ctx2 as MyContext).enabled = false; disabledContexts.Add(ctx2.id); } } } } break; } return(disabledContexts); }
internal List<int> disableContextsIfNeeded(TextHookContext ctx) { List<int> disabledContexts = null; switch (newContextsBehavior) { case NewContextsBehavior.SWITCH_TO_NEW: disabledContexts = new List<int>(); foreach (var ctx2 in textHook.getContexts()) { if (ctx2.internalId < ctx.internalId) { if ((ctx2 as MyContext).enabled) { (ctx2 as MyContext).enabled = false; disabledContexts.Add(ctx2.id); } } } break; case NewContextsBehavior.SMART: if (isContextSpecial(ctx.name)) { disabledContexts = new List<int>(); foreach (var ctx2 in textHook.getContexts()) { if (ctx2.internalId < ctx.internalId && !isContextSpecial(ctx2.name)) { if ((ctx2 as MyContext).enabled) { (ctx2 as MyContext).enabled = false; disabledContexts.Add(ctx2.id); } } } } break; } return disabledContexts; }
internal void translate(string text) { TranslationService.instance.update(TextHookContext.cleanText(text), false); }