ConversationWindow的闭幕活动 [英] close event of ConversationWindow
问题描述
我创建的程序使用Automation类和ConversationWindow类启动了一个lync对话窗口。我可以发送和接收聊天消息,代码如下
__________
自动化 _Automation =
LyncClient .GetAutomation();
          
string firstIMText =
" Testing Please Ignore" ;
字典 < AutomationModalitySettings ,
对象跨度>> _ModalitySettings =
new Dictionary < AutomationModalitySettings ,
object >();
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
AutomationModalities _ChosenMode =
AutomationModalities .InstantMessage;
_ ModalitySettings.Add( AutomationModalitySettings .FirstInstantMessage,firstIMText);
_ModalitySettings.Add( AutomationModalitySettings .SendFirstInstantMessageImmediately,
true );
_ModalitySettings.Add( AutomationModalitySettings .Subject,
"" );
//开始对话。
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;
IAsyncResult ar = _Automation.BeginStartConversation(
_ChosenMode
; ,inviteeList
; ,_ModalitySettings
,
null
,
null );
cwindow = _Automation.EndStartConversation(ar);
cwindow.Conversation.ParticipantAdded + =
new EventHandler < ParticipantCollectionChangedEventArgs >(Conversation_ParticipantAdded);
cwindow.Conversation.ParticipantRemoved + =
new EventHandler < ParticipantCollectionChangedEventArgs >(Conversation_ParticipantRemoved);
//捕获收到的消息
foreach (< span style ="color:blue"> var 参与者
cwindow.Conversation.Participants)
{
if (!participant.IsSelf)
{
< span style ="color:#2B91AF"> InstantMessageModality participantModality = participant.Modalities [ ModalityTypes .InstantMessage]
as InstantMessageModality ;
participantModality.InstantMessageReceived + =
new EventHandler < MessageSentEventArgs >(modality_InstantMessageReceived);
}
}
// capture sent msg
InstantMessageModality conversationModality = cwindow.Conversation.Modalities [ ModalityTypes .InstantMessage]
as InstantMessageModality ;
conversationModality.InstantMessageReceived + =
new EventHandler < MessageSentEventArgs >(modality_InstantMessageReceived);
___________
现在我想处理对话窗口的关闭事件,我不知道找到了对话的默认关闭事件处理程序。如果有人分享技术来实现这一点会很有帮助。谢谢
您需要订阅
Conversation.StateChanged 事件。
这会告诉您会话何时从"已建立"更改为"终止"或"终止到终止"。
希望这会有所帮助。
-tom
Hi,
I created program to initiate a lync conversation window using Automation class and ConversationWindow class. I could send and receive chat messages, code as follows
__________
Automation _Automation = LyncClient.GetAutomation();
string firstIMText = "Testing Please Ignore";
Dictionary<AutomationModalitySettings, object> _ModalitySettings = new Dictionary<AutomationModalitySettings, object>();
AutomationModalities _ChosenMode = AutomationModalities.InstantMessage;
_ModalitySettings.Add(AutomationModalitySettings.FirstInstantMessage, firstIMText);
_ModalitySettings.Add(AutomationModalitySettings.SendFirstInstantMessageImmediately, true);
_ModalitySettings.Add(AutomationModalitySettings.Subject, "");
// Start the conversation.
IAsyncResult ar = _Automation.BeginStartConversation(
_ChosenMode
, inviteeList
, _ModalitySettings
, null
, null);
cwindow = _Automation.EndStartConversation(ar);
cwindow.Conversation.ParticipantAdded += new EventHandler<ParticipantCollectionChangedEventArgs>(Conversation_ParticipantAdded);
cwindow.Conversation.ParticipantRemoved += new EventHandler<ParticipantCollectionChangedEventArgs>(Conversation_ParticipantRemoved);
// capture received msg
foreach (var participant in cwindow.Conversation.Participants)
{
if (!participant.IsSelf)
{
InstantMessageModality participantModality = participant.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality;
participantModality.InstantMessageReceived += new EventHandler<MessageSentEventArgs>(modality_InstantMessageReceived);
}
}
// capture sent msg
InstantMessageModality conversationModality = cwindow.Conversation.Modalities[ModalityTypes.InstantMessage] as InstantMessageModality;
conversationModality.InstantMessageReceived += new EventHandler<MessageSentEventArgs>(modality_InstantMessageReceived);
___________
Now I want to handle the close event of conversation window, I don't found the default close event handler for conversation. It would helpful if anybody share the technique to achieve this.Thanks
You need to subscribe to the Conversation.StateChanged event.
This will tell you when the conversation changes state from Established to Terminating, or Terminating to Terminated.
Hope this helps.
-tom
这篇关于ConversationWindow的闭幕活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!