Exemplo n.º 1
0
        private void addNewNameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sel = lastSelection;

            if (!string.IsNullOrWhiteSpace(sel))
            {
                ParseResult pr          = lastSelectedParseResult;
                EdictMatch  oldName     = Edict.instance.findName(sel);
                string      oldSense    = "";
                string      oldNameType = null;
                if (oldName != null)
                {
                    EdictEntry oldNameEntry = oldName.findAnyName();
                    if (oldNameEntry != null)
                    {
                        if (oldNameEntry.sense.Count > 0 && oldNameEntry.sense[0].glossary.Count > 0)
                        {
                            oldSense = oldNameEntry.sense[0].glossary[0];
                        }
                        oldNameType = oldNameEntry.nameType;
                    }
                }
                if (oldSense == "" && sel.All((c) => TextUtils.isKana(c)))
                {
                    if (Settings.app.okuriganaType == OkuriganaType.RUSSIAN)
                    {
                        oldSense = TextUtils.kanaToCyrillic(sel);
                    }
                    else
                    {
                        oldSense = TextUtils.kanaToRomaji(sel);
                    }
                    oldSense = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(oldSense);
                }
                UserNameForm userNameForm = new UserNameForm();
                this.hideHint();
                this.SuspendTopMost(() => {
                    moveBackgroundForm();
                    if (userNameForm.Open(sel, oldSense, oldNameType))
                    {
                        string key      = userNameForm.getKey();
                        string sense    = userNameForm.getSense();
                        string nameType = userNameForm.getNameType();
                        if (sense != "")
                        {
                            Settings.session.addUserName(key, sense, nameType);
                        }
                        else
                        {
                            Settings.session.removeUserName(key);
                        }
                        if (pr != null)
                        {
                            TranslationService.instance.updateId(pr.id, pr.asText(), null);
                        }
                    }
                });
                moveBackgroundForm();
            }
        }
Exemplo n.º 2
0
 private void addNewNameToolStripMenuItem_Click(object sender, EventArgs e)
 {
     string sel = lastSelection;
     if (!string.IsNullOrWhiteSpace(sel)) {
         ParseResult pr = lastSelectedParseResult;
         EdictMatch oldName = Edict.instance.findName(sel);
         string oldSense = "";
         string oldNameType = null;
         if (oldName != null) {
             EdictEntry oldNameEntry = oldName.findAnyName();
             if (oldNameEntry != null) {
                 if (oldNameEntry.sense.Count > 0 && oldNameEntry.sense[0].glossary.Count > 0) {
                     oldSense = oldNameEntry.sense[0].glossary[0];
                 }
                 oldNameType = oldNameEntry.nameType;
             }
         }
         if (oldSense == "" && sel.All((c) => TextUtils.isKana(c))) {
             if (Settings.app.okuriganaType == OkuriganaType.RUSSIAN) {
                 oldSense = TextUtils.kanaToCyrillic(sel);
             } else {
                 oldSense = TextUtils.kanaToRomaji(sel);
             }
             oldSense = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(oldSense);
         }
         UserNameForm userNameForm = new UserNameForm();
         this.hideHint();
         this.SuspendTopMost(() => {
             moveBackgroundForm();
             if (userNameForm.Open(sel, oldSense, oldNameType)) {
                 string key = userNameForm.getKey();
                 string sense = userNameForm.getSense();
                 string nameType = userNameForm.getNameType();
                 if (sense != "") {
                     Settings.session.addUserName(key, sense, nameType);
                 } else {
                     Settings.session.removeUserName(key);
                 }
                 if (pr != null) {
                     TranslationService.instance.updateId(pr.id, pr.asText(), null);
                 }
             }
         });
         moveBackgroundForm();
     }
 }