예제 #1
0
 void pptContent_StateChanged(object sender, ShareableContentStateChangedEventArgs e)
 {
     if ((e.OldState == ShareableContentState.Connecting) && (e.NewState == ShareableContentState.Online))
     {
         // Lets make the content visible.
         pptContent.Present();
     }
 }
예제 #2
0
        private void buttonPresent_Click(object sender, RoutedEventArgs e)
        {
            ShareableContent selectedContent = (ShareableContent)listBoxContentBin.SelectedItem;

            if (selectedContent != null)
            {
                int reason; // if can invoke returns false, you can get the reason from here.
                if (selectedContent.CanInvoke(ShareableContentAction.Present, out reason))
                {
                    selectedContent.Present();
                }
            }
            else
            {
                Log("Select a content from Content Bin first");
            }
        }
예제 #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);
            }
        }