Пример #1
0
        /// <summary>
        /// 附加到新窗体
        /// </summary>
        /// <param name="handle"></param>
        public static void DockToNewParentWindow(IntPtr handle, Action <bool> callBack)
        {
            try
            {
                if (Constant.lyncClient != null && Constant.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);
                                LyncHelper.MainConversation.Dock(handle);
                                LyncHelper.FullScreen();
                                callBack(true);
                            }
                        }));
                    }
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(typeof(LyncHelper), ex);
            }
            finally
            {
            }
        }
Пример #2
0
 /// <summary>
 /// 退出lync辅助
 /// </summary>
 public static void LyncCloseHelper(Action callBack)
 {
     try
     {
         if (Constant.lyncClient != null)
         {
             callBack();
             //签出
             LyncHelper.LyncSignOut();
         }
     }
     catch (Exception ex)
     {
         LogManage.WriteLog(typeof(LyncHelper), ex);
     }
     finally
     {
     }
 }
Пример #3
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客户端
                        Constant.lyncClient = LyncClient.GetClient();
                        if (Constant.lyncClient != null)
                        {
                            #region 注册Lync事件

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

                            #endregion

                            #region lync初始化

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

                            //签入
                            if (Constant.lyncClient.State == ClientState.SigningIn || Constant.lyncClient.State == ClientState.SignedIn)
                            {
                                //先签出(lync控制)
                                Constant.lyncClient.BeginSignOut(null, null);
                            }
                            if (Constant.lyncClient.State == ClientState.SignedOut)
                            {
                                //可以签入
                                MainWindow.CanSigined = true;
                            }

                            #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
            {
            }
        }