Exemple #1
0
        /// <summary>
        /// Shares the resource selected by the user.
        /// </summary>
        private void ShareSelectedResource(Int32 selectedResource)
        {
            //Get the type of resource selected by the user
            SharingResourceType selectedResourceType = ((SharingResource)_sharingModality.ShareableResources[selectedResource]).Type;

            CanShareDetail sharingDetail;

            if (!_sharingModality.CanShare(selectedResourceType, out sharingDetail))
            {
                switch (sharingDetail)
                {
                case CanShareDetail.DisabledByOrganizerPolicy:
                    MessageBox.Show("The conversation organizer has disallowed sharing");
                    break;

                case CanShareDetail.DisabledByPolicy:
                    MessageBox.Show("Sharing resources is not allowed ");
                    break;

                case CanShareDetail.DisabledByRole:
                    MessageBox.Show("Conference attendees cannot share resources");
                    break;
                }
                return;
            }
            if (selectedResourceType == SharingResourceType.Desktop)
            {
                _sharingModality.BeginShareDesktop((ar) =>
                {
                    _sharingModality.EndShareDesktop(ar);
                }
                                                   , null);
            }
            else
            {
                _sharingModality.BeginShareResources((SharingResource)_sharingModality.ShareableResources[selectedResource], (ar) =>
                {
                    try
                    {
                        _sharingModality.EndShareResources(ar);
                    }
                    catch (OperationException oe) { throw oe; }
                    catch (LyncClientException lce) { throw lce; }
                }
                                                     , null);
            }
        }
Exemple #2
0
        /// <summary>
        /// Shares the resource selected by the user.
        /// </summary>
        private void ShareSelectedResource(SharingResourceType selectedResourceType)
        {
            //If there is no active conversation to share this resource in, return from handler
            if (Conversation == null)
            {
                return;
            }
            _log.Debug("StartSharingResource");

            //If there is no sharing modality stored locally on the active conversation, get it from the active conversation and store it.
            if (_sharingModality == null)
            {
                _sharingModality = Conversation.Modalities[ModalityTypes.ApplicationSharing] as ApplicationSharingModality;
            }



            SharingResource sharingResource = null;

            if (_sharingModality.ShareableResources == null)
            {
                _log.Debug("ShareableResources is null");
                return;
            }

            //foreach (SharingResource s in _sharingModality.ShareableResources)
            //{
            //    //if (s.Id == selectedResource.ResourceId)
            //    //{
            //    //    //Get the type of resource selected by the user
            //    //    selectedResourceType = s.Type;
            //    //    sharingResource = s;
            //    //    break;
            //    //}
            //}

            CanShareDetail sharingDetail;

            if (!_sharingModality.CanShare(selectedResourceType, out sharingDetail))
            {
                _log.Debug("sharingDetail:{0}", sharingDetail);
                switch (sharingDetail)
                {
                case CanShareDetail.DisabledByOrganizerPolicy:
                    MessageBox.Show("The conversation organizer has disallowed sharing");
                    break;

                case CanShareDetail.DisabledByPolicy:
                    MessageBox.Show("Sharing resources is not allowed ");
                    break;

                case CanShareDetail.DisabledByRole:
                    MessageBox.Show("Conference attendees cannot share resources");
                    break;
                }
                return;
            }

            _log.Debug("selectedResourceType: {0}", selectedResourceType.ToString());

            if (selectedResourceType == SharingResourceType.Desktop)
            {
                _sharingModality.BeginShareDesktop((ar) =>
                {
                    _sharingModality.EndShareDesktop(ar);
                }
                                                   , null);
            }
            else if (selectedResourceType == SharingResourceType.Monitor)
            {
                _sharingModality.BeginShareResources(sharingResource, (ar) =>
                {
                    _sharingModality.EndShareResources(ar);
                }, null);
            }
            else
            {
                _sharingModality.BeginShareResources(sharingResource, (ar) =>
                {
                    try
                    {
                        _sharingModality.EndShareResources(ar);
                    }
                    catch (OperationException oe) { throw oe; }
                    catch (LyncClientException lce) { throw lce; }
                }
                                                     , null);
            }
        }
        /// <summary>
        /// Shares the resource selected by the user.
        /// </summary>
        private void ShareSelectedResource(Int32 selectedResource)
        {
            //Get the type of resource selected by the user
            SharingResourceType selectedResourceType = ((SharingResource)_sharingModality.ShareableResources[selectedResource]).Type;

            CanShareDetail sharingDetail;

            if (!_sharingModality.CanShare(selectedResourceType, out sharingDetail))
            {
                switch (sharingDetail)
                {
                case CanShareDetail.DisabledByOrganizerPolicy:
                    MessageBox.Show("The conversation organizer has disallowed sharing");
                    break;

                case CanShareDetail.DisabledByPolicy:
                    MessageBox.Show("Sharing resources is not allowed ");
                    break;

                case CanShareDetail.DisabledByRole:
                    MessageBox.Show("Conference attendees cannot share resources");
                    break;
                }
                return;
            }

            switch (selectedResourceType)
            {
            case SharingResourceType.Desktop:
                //Share the desktop if allowed
                try
                {
                    _sharingModality.BeginShareDesktop(ShareDesktopCallback, _sharingModality);
                }
                catch (InvalidCastException) { MessageBox.Show("Invalid cast on share desktop"); }
                break;

            case SharingResourceType.Monitor:

                //Share the primary monitor if allowed
                //Iterate on all system displays and find the primary display
                for (int i = 0; i < System.Windows.Forms.Screen.AllScreens.Length; i++)
                {
                    //If this screen is the primary display,
                    if (((Screen)System.Windows.Forms.Screen.AllScreens[i]).Primary)
                    {
                        //Share the primary display using a 1-based index value
                        try
                        {
                            _sharingModality.BeginShareMonitor(i + 1, ShareMonitorCallback, _sharingModality);
                        }
                        catch (InvalidCastException) { }
                        break;
                    }
                }
                break;

            case SharingResourceType.Process:

                //Share a process if allowed
                try
                {
                    //SharingResource shareResource = (SharingResource)_sharingModality.ShareableResources[selectedResource];

                    ////Create a new list to be passed as first argument of BeginShareResources.
                    ////The list will contain the process resouce selected by the user
                    //IList<SharingResource> resourceListToBeShared = new List<SharingResource>();
                    //resourceListToBeShared.Add(shareResource);
                    _sharingModality.BeginShareResources((SharingResource)_sharingModality.ShareableResources[selectedResource], ShareResourcesCallback, _sharingModality);
                }
                catch (InvalidCastException) { }
                catch (ArgumentException)   {  }
                break;
            }
        }