Пример #1
0
        void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e)
        {
            // if this is the remote participant then lets connect the ContentSharing modality.
            if (e.Participant.IsSelf != true)
            {
                _contentModality = (ContentSharingModality)((Conversation)sender).Modalities[ModalityTypes.ContentSharing];

                if (_contentModality.CanInvoke(ModalityAction.Connect))
                {
                    try
                    {
                        _contentModality.BeginConnect(HandleCallBacks, "Connect");
                    }
                    catch (Exception ec)
                    {
                        dispatcher.BeginInvoke(new Action <string>(Log), ec.ToString());
                    }
                }
            }
        }
Пример #2
0
        void Conversation_ParticipantAdded(object sender, ParticipantCollectionChangedEventArgs e)
        {
            // if this is the remote participant then lets connect the ContentSharing modality.
            if (e.Participant.IsSelf != true)
            {
                _contentModality = (ContentSharingModality)((Conversation)sender).Modalities[ModalityTypes.ContentSharing];
                // Following events will help maintain the Content Bin
                _contentModality.ContentAdded += new EventHandler <ContentCollectionChangedEventArgs>(_contentModality_ContentAdded);

                if (_contentModality.CanInvoke(ModalityAction.Connect))
                {
                    try
                    {
                        // This will send a notification to remote party.
                        _contentModality.BeginConnect(HandleCallBacks, "Connect");
                    }
                    catch (Exception ec)
                    {
                        dispatcher.BeginInvoke(new Action <string>(Log), ec.ToString());
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 共享电子白板
        /// </summary>
        public static void ShareWhiteboard(ConversationWindow conversationWindow, string selfName, Action callBack)
        {
            try
            {
                if (conversationWindow != null)
                {
                    DispatcherTimer timer1 = null;
                    TimerJob.StartRun(new Action(() =>
                    {
                        if (conversationWindow.Conversation == null)
                        {
                            timer1.Stop();
                            return;
                        }

                        //获取电子白板启动模型实例
                        ContentSharingModality contentShareingModality = (ContentSharingModality)conversationWindow.Conversation.Modalities[ModalityTypes.ContentSharing];
                        DispatcherTimer timer2 = null;

                        //查看是否可以共享白板
                        var canShareWhiteboard = contentShareingModality.CanInvoke(ModalityAction.CreateShareableWhiteboardContent);
                        if (canShareWhiteboard)
                        {
                            if (contentShareingModality.CanInvoke(ModalityAction.Connect))
                            {
                                contentShareingModality.BeginConnect(null, null);
                            }
                            //获取共享白板的名称
                            string whiteShareName = GetWhiteShareName(selfName, whiteBoardShareName);

                            if (contentShareingModality.CanInvoke(ModalityAction.CreateShareableWhiteboardContent))
                            {
                                //创建一个默认的电子白板
                                IAsyncResult result = contentShareingModality.BeginCreateContent(ShareableContentType.Whiteboard, whiteShareName, null, null);
                                //结束提交
                                ShareableContent whiteBoardContent = contentShareingModality.EndCreateContent(result);

                                TimerJob.StartRun(new Action(() =>
                                {
                                    int reason; //【在此可监控异常】
                                    if (whiteBoardContent.CanInvoke(ShareableContentAction.Upload, out reason))
                                    {
                                        //电子白板上传
                                        whiteBoardContent.Upload();
                                    }
                                    if (whiteBoardContent.State == ShareableContentState.Online)
                                    {
                                        timer2.Stop();

                                        //当前呈现(电子白板)
                                        whiteBoardContent.Present();
                                        if (callBack != null)
                                        {
                                            callBack();
                                        }
                                    }
                                }), 10, out timer2);
                                timer1.Stop();
                            }
                        }
                    }), 400, out timer1);
                }
                else
                {
                    MessageBox.Show("使用电子白板共享之前先选择一个会话", "操作提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
        }