Exemplo n.º 1
0
 /// <summary>
 /// Sends a notification about the composing state.
 /// </summary>
 public void SendComposingNotification(bool isComposing)
 {
     //send the event 'as-is' without checking the success
     try
     {
         myImModality.BeginSetComposing(isComposing, null, null);
     }
     catch (LyncClientException e)
     {
         var eventHandler = MessageError;
         if (eventHandler != null)
         {
             eventHandler(e);
         }
     }
     catch (SystemException e)
     {
         if (LyncModelExceptionHelper.IsLyncException(e))
         {
             // Handle the exception thrown by the Lync Model API.
             var eventHandler = MessageError;
             if (eventHandler != null)
             {
                 eventHandler(e);
             }
         }
         else
         {
             // Rethrow the SystemException which did not come from the Lync Model API.
             throw;
         }
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Translates the message assyncronously.
        /// </summary>
        /// <param name="message"></param>
        private void SendLocalMessageForTranslation(string message)
        {
            //assembles a MessageContext object
            messageContext = new MessageContext();
            messageContext.OriginalMessage = message;
            //reads the self participant's name
            try
            {
                messageContext.ParticipantName =
                    conversation.SelfParticipant.Contact.GetContactInformation(ContactInformationType.DisplayName) as string;
            }
            catch (LyncClientException e)
            {
                ShowError(e);
                return;
            }
            catch (SystemException e)
            {
                if (LyncModelExceptionHelper.IsLyncException(e))
                {
                    // Log the exception thrown by the Lync Model API.
                    ShowError(e);
                    return;
                }
                else
                {
                    // Rethrow the SystemException which did not come from the Lync Model API.
                    throw;
                }
            }
            messageContext.SourceLanguage = viewModel.SourceLanguage.Code;
            messageContext.TargetLanguage = viewModel.TargetLanguage.Code;
            messageContext.Direction      = MessageDirection.Outgoing;
            messageContext.MessageTime    = DateTime.Now;

            //sends the message for translation
            translationService.Translate(messageContext);
        }