Example #1
0
 void MyContext_onSentence(TextHookContext sender, string text)
 {
     log.Enqueue(text);
     if (log.Count > MAX_LOG) {
         string unused;
         log.TryDequeue(out unused);
     }
 }
Example #2
0
 void MyContext_onSentence(TextHookContext sender, string text)
 {
     log.Enqueue(text);
     if (log.Count > MAX_LOG)
     {
         string unused;
         log.TryDequeue(out unused);
     }
 }
Example #3
0
        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);
        }
Example #4
0
 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()));
         }
     }
 }
Example #5
0
        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);
        }
Example #6
0
 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;
 }
Example #7
0
 internal void translate(string text)
 {
     TranslationService.instance.update(TextHookContext.cleanText(text), false);
 }