Пример #1
0
        /// <summary>
        /// Calls async web api to get the text translation
        /// </summary>
        /// <param name="fromString">From text</param>
        /// <param name="fromLang">From language</param>
        /// <param name="toLang">To langauge</param>
        /// <returns>True if a web call was made, false if the translator already had this phrase cached away</returns>
        protected bool CallWebApi(
            string fromString,
            string fromLang,
            string toLang
            )
        {
            bool callMade = false;

            if (
                (String.Compare(fromString, _lastPhraseString, StringComparison.CurrentCultureIgnoreCase) != 0)
                ||
                (fromLang != _lastFromLanguage) || (toLang != _lastToLanguage)
                ||
                (App.Model.TestingParameterForceAllWebCalls == true)
                )
            {
                _lastPhraseString = fromString;
                _lastFromLanguage = fromLang;
                _lastToLanguage = toLang;
                callMade = true;

                //
                // If there was already a translate request out on the wire, don't bother listening to it any more
                //
                if (_currentRequest != null)
                {
                    _currentRequest.Cancelled = true;
                }

                _currentRequest = InitiateRequest(GetUriRequest(fromString, fromLang, toLang), fromString, fromLang, toLang);
            }

            return callMade;
        }
Пример #2
0
        /// <summary>
        /// Gets the text to speech wave asynch from the cloud
        /// </summary>
        /// <param name="fromString">Text in "from" langauge.</param>
        /// <param name="toString">Text in "to" langauge</param>
        /// <param name="fromLang">From Langauge</param>
        /// <param name="toLang">To langauge</param>
        public void GetTextToSpeech(string fromString, string toString, string fromLang, string toLang)
        {
            // The reason for the fromString getting passed onto InitiateRequest is that the
            // Historylist needs to know the source phrase so that it can put the wave file in the
            // correct place

            //
            // If there was already a translate request out on the wire, don't bother listening to it any more
            //
            if (_currentRequest != null)
            {
                _currentRequest.Cancelled = true;
            }

            _currentRequest = InitiateRequest(GetUriRequest(toString, fromLang, toLang), fromString, fromLang, toString, toLang);
        }