/// <summary>
        /// 打开本地文件
        /// </summary>
        /// <param name="dialog"></param>
        /// <param name="fileNameWithoutExtension"></param>
        public void OpenLocalFileHelper(string fileName)
        {
            //获取文件名称(不包含扩展名称)
            var fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(fileName);

            ProcessManage.OpenFileByLocalAddressReturnHandel(fileName, new Action <int, IntPtr>((processID, intptr) =>
            {
                //获取共享模型
                var shareModality = ((ApplicationSharingModality)(LyncHelper.MainConversation.Conversation.Modalities[ModalityTypes.ApplicationSharing]));

                //遍历可以共享的资源
                foreach (var item in shareModality.ShareableResources)
                {
                    //&& intptr != new IntPtr(0)
                    //指定要共享的程序名称
                    if (item.Id.Equals(processID))
                    {
                        //判断是否可以进行共享该程序
                        if (shareModality.CanShare(item.Type))
                        {
                            this.ShareAndSync(intptr, shareModality, item);
                            break;
                        }
                    }
                    else if (item.Id == intptr.ToInt32())
                    {
                        //判断是否可以进行共享该程序
                        if (shareModality.CanShare(item.Type))
                        {
                            this.ShareAndSync(intptr, shareModality, item);
                            break;
                        }
                    }
                    else if (item.Name.Contains(fileNameWithoutExtension))
                    {
                        //判断是否可以进行共享该程序
                        if (shareModality.CanShare(item.Type))
                        {
                            this.ShareAndSync(intptr, shareModality, item);
                            break;
                        }
                    }
                }
            }));
        }
Beispiel #2
0
        /// <summary>
        /// 本地资源共享
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void btnLocalResource_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (LyncHelper.MainConversation != null)
                {
                    //打开选项对话框
                    OpenFileDialog dialog = new OpenFileDialog();
                    //指定显示的文件类型
                    //dialog.Filter = "所有文件";
                    //设置为多选
                    dialog.Multiselect = false;
                    if (dialog.ShowDialog() == true)
                    {
                        //获取扩展名
                        string fileExtension = System.IO.Path.GetExtension(dialog.FileName);
                        if (fileExtension.Equals(".pptx") || fileExtension.Equals(".ppt"))
                        {
                            //共享前释放资源
                            this.ShareBeforeDisposeResrouce();
                            //打开ppt共享辅助
                            PPtShareHelper(dialog.FileName);
                        }
                        else
                        {
                            //获取文件名称(不包含扩展名称)
                            var fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(dialog.FileName);
                            ////文件移动
                            //System.IO.File.Copy(dialog.FileName, Constant.LocalTempRoot + "\\" + fileNameWithoutExtension + fileExtension, true);
                            //Thread.Sleep(1000);
                            //通过进程打开一个文件
                            ProcessManage.OpenFileByLocalAddressReturnHandel(dialog.FileName, new Action <int, IntPtr>((processID, intptr) =>
                            {
                                //获取共享模型
                                var shareModality = ((ApplicationSharingModality)(LyncHelper.MainConversation.Conversation.Modalities[ModalityTypes.ApplicationSharing]));

                                //遍历可以共享的资源
                                foreach (var item in shareModality.ShareableResources)
                                {
                                    //&& intptr != new IntPtr(0)
                                    //指定要共享的程序名称
                                    if (item.Id.Equals(processID))
                                    {
                                        //判断是否可以进行共享该程序
                                        if (shareModality.CanShare(item.Type))
                                        {
                                            this.ShareAndSync(intptr, shareModality, item);
                                            break;
                                        }
                                    }
                                    else if (item.Id == intptr.ToInt32())
                                    {
                                        //判断是否可以进行共享该程序
                                        if (shareModality.CanShare(item.Type))
                                        {
                                            this.ShareAndSync(intptr, shareModality, item);
                                            break;
                                        }
                                    }
                                    else if (item.Name.Contains(fileNameWithoutExtension))
                                    {
                                        //判断是否可以进行共享该程序
                                        if (shareModality.CanShare(item.Type))
                                        {
                                            this.ShareAndSync(intptr, shareModality, item);
                                            break;
                                        }
                                    }
                                }
                            }));
                        }
                    }
                }
                else
                {
                    MessageBox.Show("使用桌面共享之前先选择一个会话", "操作提示", MessageBoxButton.OK, MessageBoxImage.Information);
                }
            }
            catch (Exception ex)
            {
                LogManage.WriteLog(this.GetType(), ex);
            }
            finally
            {
            }
        }