Example #1
0
 /// <summary>
 /// lync签出
 /// </summary>
 public static void LyncSignOut(Action callBack)
 {
     try
     {
         if (ConversationCodeEnterEntity.lyncClient != null)
         {
             callBack();
             //签出
             LyncHelper.LyncSignOut();
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(typeof(LyncHelper), ex);
     }
     finally
     {
     }
 }
Example #2
0
        /// <summary>
        /// 启动视频
        /// </summary>
        /// <param name="conversationWindow"></param>
        public static void StartVideo(ConversationWindow conversationWindow)
        {
            try
            {
                ThreadPool.QueueUserWorkItem((o) =>
                {
                    AVModality avModality = (AVModality)conversationWindow.Conversation.SelfParticipant.Modalities[ModalityTypes.AudioVideo];
                    if (avModality != null)
                    {
                        VideoChannel videoChannel = avModality.VideoChannel;

                        //object obV = videoChannel.InnerObject;
                        if (videoChannel != null)
                        {
                            if (videoChannel != null && videoChannel.CanInvoke(ChannelAction.Start))
                            {
                                videoChannel.BeginStart(null, null);
                            }

                            TimerJob.StartRun(new Action(() =>
                            {
                                if (videoChannel.State != ChannelState.Connecting)
                                {
                                    if (videoChannel != null && videoChannel.CanInvoke(ChannelAction.Start))
                                    {
                                        videoChannel.BeginStart(null, null);
                                    }
                                }
                            }), 1500);
                            LyncHelper.ExitFullScreen();
                            LyncHelper.FullScreen();
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }
Example #3
0
        /// <summary>
        /// 附加到新窗体
        /// </summary>
        /// <param name="handle"></param>
        public static void DockToNewParentWindow(IntPtr handle, Action <bool> callBack)
        {
            try
            {
                if (ConversationCodeEnterEntity.lyncClient != null && ConversationCodeEnterEntity.lyncClient.State == ClientState.SignedIn && LyncHelper.MainConversation != null && !LyncHelper.MainConversation.IsDocked)
                {
                    if (LyncHelper.MainConversation != null)
                    {
                        if (LyncHelper.MainConversation.IsFullScreen)
                        {
                            //先退出全屏
                            LyncHelper.ExitFullScreen();
                        }

                        TimerJob.StartRun(new Action(() =>
                        {
                            if (!LyncHelper.MainConversation.IsDocked && LyncHelper.MainConversation.State == ConversationWindowState.Initialized)
                            {
                                Thread.Sleep(500);
                                if (LyncHelper.DockNewWindowCallBack != null)
                                {
                                    LyncHelper.DockNewWindowCallBack();
                                }
                                LyncHelper.MainConversation.Dock(handle);
                                LyncHelper.FullScreen();
                                callBack(true);
                            }
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }
Example #4
0
        /// <summary>
        /// lync程序环境设置(事件、状态、原生态界面抑制、注册表、标示)
        /// </summary>
        public static void SetLyncAplicationEnviroment(Action containCompleateCallBack)
        {
            try
            {
                //获取lync进程
                Process[] processes = Process.GetProcessesByName("Lync");
                if (processes.Count() > 0)
                {
                    IntPtr handle = ProcessManage.GetMainWindowHandle(processes[0]);
                    if (handle.ToInt32() > 0)
                    {
                        //设置lync常用对象
                        SettingLyncObject();

                        if (ConversationCodeEnterEntity.lyncClient != null)
                        {
                            #region 注册Lync事件

                            //lync状态更改事件
                            ConversationCodeEnterEntity.lyncClient.StateChanged -= lyncClient_StateChanged;
                            //lync状态更改事件
                            ConversationCodeEnterEntity.lyncClient.StateChanged += lyncClient_StateChanged;

                            #endregion

                            #region lync初始化

                            //首先将捕获到的lync实例进行一次初始化加载
                            if (ConversationCodeEnterEntity.lyncClient.State == ClientState.Uninitialized)
                            {
                                //lync客户端初始化
                                ConversationCodeEnterEntity.lyncClient.BeginInitialize(null, null);
                            }

                            //签入
                            if (ConversationCodeEnterEntity.lyncClient.State == ClientState.SigningIn || ConversationCodeEnterEntity.lyncClient.State == ClientState.SignedIn)
                            {
                                //先签出(lync控制)
                                ConversationCodeEnterEntity.lyncClient.BeginSignOut(null, null);
                            }
                            if (ConversationCodeEnterEntity.lyncClient.State == ClientState.SignedOut)
                            {
                                //是否可以签入回调事件
                                if (CanSiginedCallBack != null)
                                {
                                    CanSiginedCallBack();
                                }
                            }

                            #endregion

                            #region  序相关设置

                            WindowHide.SetTrayIconVisible("Lync", false);

                            ////将lync的原生态的主窗体封装起来
                            APPContainManage.APP_Conatain(handle);

                            containCompleateCallBack();

                            #endregion
                        }
                    }
                    else
                    {
                        LyncHelper.SetLyncAplicationEnviroment(containCompleateCallBack);
                    }
                }
                else
                {
                    LyncHelper.SetLyncAplicationEnviroment(containCompleateCallBack);
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }