/// <summary> /// Externally called as handler /// </summary> /// <param name="h"></param> public void Accept(HotKey h) { var b1 = waitingForUserDecision; var b2 = (!waitingForUserDecision && !requireUserDecision); if (b1 || b2) { Add(); // cant be, then will create pascal //if (h.Tag != null) //{ // h.Tag = null; //} waitingForUserDecision = false; ThisApp.SetStatus(TypeOfMessage.Success, txtEnglishTranslate.Text + " accepted"); ClearTextBoxes(true, true); } else { #if DEBUG string postfix = string.Empty; if (!waitingForUserDecision) { postfix = ", wasn't waited for user desision. Press button"; } ThisApp.SetStatus(TypeOfMessage.Information, "wasn't accepted" + postfix); #endif } }
/// <summary> /// Recognize language and set to txt /// Translate if is needed and put into *.xlf /// </summary> /// <param name="requireUserDecision"></param> /// <param name="text"></param> /// <param name="key2"></param> public void Add(bool requireUserDecision, string text, string key2 = null) { #region Recognize language and set to txt // If A2 is path, A1 is text if (FS.ExistsFile(text)) { return; } this.requireUserDecision = requireUserDecision; acceptHotkey.Tag = key2; if (TextLang.IsCzech(text)) { l = Langs.cs; //rbCs.IsChecked = true; } else { // not to lb but directly to l. manybe in UC will raise event handler to set l, but in XlfEngine not. l = Langs.en; //rbEn.IsChecked = true; } ClearTextBoxes(false, true); txtText.Text = text; #endregion #region Process text if (l == Langs.en) { // Insert as content of <target> // Will use only english so czech don't translate now Add(); } else { string englishTranslate = null; englishTranslate = TranslateHelper.Instance.Translate(text, "en", "cs"); if (char.IsUpper(text[0])) { englishTranslate = SH.FirstCharUpper(englishTranslate); } txtEnglishTranslate.Text = englishTranslate; ThisApp.SetStatus(TypeOfMessage.Error, "Press enter to add or delete to exit"); if (requireUserDecision) { waitingForUserDecision = true; } else { Accept(acceptHotkey); } } #endregion }
/// <summary> /// Return whether A1 is in XlfKeys /// if A2, save A1 to clipboard /// Externally called from InsertIntoXlfAndConstantCsUC.ClipboardMonitor_OnClipboardContentChanged /// </summary> /// <param name="pascal"></param> /// <param name="insertToClipboard"></param> public bool IsAlreadyContainedInXlfKeys(string pascal, bool insertToClipboard) { int first = -1; var keys = GetConsts(out first); if (keys.Contains(pascal)) { if (insertToClipboard) { ClipboardHelper.SetText(pascal); } ThisApp.SetStatus(TypeOfMessage.Information, "Already " + pascal + " contained"); return true; } return false; }