コード例 #1
0
ファイル: CrossThread.cs プロジェクト: riguelbf/portalSureg
 public static void EnableDisableButton(Button button, bool enabled)
 {
     if (button.InvokeRequired)
     {
         EnableDisableButtonDelegate button2 = new EnableDisableButtonDelegate(EnableDisableButton);
         button.Invoke(button2, new object[] { button, enabled });
     }
     else
     {
         button.Enabled = enabled;
     }
 }
コード例 #2
0
        /// <summary>
        /// Handles the event raised when the active conversation is terminated and removed from the collection of conversations
        /// on ConversationManager.Conversations
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ConversationManager_ConversationRemoved(object sender, ConversationManagerEventArgs e)
        {
            //If the removed conversation is the conversation hosted by this window then resume listening for new conversations.
            if (_conversation == e.Conversation)
            {
                EnableDisableButtonDelegate buttonDelegate = new EnableDisableButtonDelegate(EnableDisableButton);
                this.Invoke(new SetContactSelectionModeDelegate(SetContactSelectionMode), new object[] { SelectionMode.MultiSimple });
                this.Invoke(buttonDelegate, new object[] { EndConversation_Button, false });
                this.Invoke(buttonDelegate, new object[] { Disconnect_Button, false });
                this.Invoke(buttonDelegate, new object[] { Request_Button, false });
                this.Invoke(buttonDelegate, new object[] { StartSharingResource_Button, false });
                this.Invoke(buttonDelegate, new object[] { Start_Button, true });
                this.Invoke(new ChangeLabelTextDelegate(ChangeLabelText), new object[] { ContactList_Label, "1) Choose contacts" });
                this.Invoke(new UpdateSharedResourcesListboxDelegate(UpdateSharedResourcesListbox));

                this.Invoke(new LoadAllContactsDelegate(LoadAllContacts));


                //Un-register for participant events on the conversation that is terminated.
                _conversation.ParticipantAdded   -= _conversation_ParticipantAdded;
                _conversation.ParticipantRemoved -= _conversation_ParticipantRemoved;
                _conversation.StateChanged       -= _conversation_StateChanged;

                //Unregister for events on the terminated conversation's sharing modality events.
                _sharingModality.ModalityStateChanged        -= _sharingModality_ModalityStateChanged;
                _sharingModality.ControlRequestReceived      -= _sharingModality_ControlRequestReceived;
                _sharingModality.LocalSharedResourcesChanged -= _sharingModality_LocalSharedResourcesChanged;
                _sharingModality.ControllerChanged           -= _sharingModality_ControllerChanged;
                _sharingModality.ActionAvailabilityChanged   -= _sharingModality_ActionAvailabilityChanged;



                //Unregister for the application sharing events on each and every participant in the terminated
                //conversation
                foreach (string contactUri in _selectedContacts.Keys)
                {
                    ApplicationSharingModality participantSharingModality = (ApplicationSharingModality)_participantSharingModalities[contactUri];
                    participantSharingModality.ActionAvailabilityChanged -= _sharingModality_ActionAvailabilityChanged;
                }


                //Resume listening for new conversations
                _LyncClient.ConversationManager.ConversationAdded += ConversationManager_ConversationAdded;
                //de-reference the class state
                _conversation = null;
                _ResourceControllingContact = null;
                _sharingModality            = null;
                _participantSharingModalities.Clear();
            }
        }
コード例 #3
0
        /// <summary>
        /// Handles the event raised when a user signs in to or out of the Lync client.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void _LyncClient_StateChanged(object sender, ClientStateChangedEventArgs e)
        {
            EnableDisableButtonDelegate buttonDelegate = new EnableDisableButtonDelegate(EnableDisableButton);

            //If the client has signed in then get the client's contact list and enable the conversation start button.
            if (e.NewState == ClientState.SignedIn)
            {
                this.Invoke(new LoadAllContactsDelegate(LoadAllContacts));
                this.Invoke(buttonDelegate, new object[] { Start_Button, true });
                this.Invoke(new UpdateSharedResourcesListboxDelegate(UpdateSharedResourcesListbox));
            }
            else
            {
                this.Invoke(new ClearAllContactsDelegate(ClearAllContacts));
                this.Invoke(buttonDelegate, new object[] { Start_Button, false });

                this.Invoke(new ChangeLabelTextDelegate(ChangeLabelText), new object[] { ClientStateString_Label, e.NewState.ToString() });
                this.Invoke(buttonDelegate, new object[] { EndConversation_Button, false });
                this.Invoke(buttonDelegate, new object[] { StartSharingResource_Button, false });
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles the event raised when a new conversation is added. This sample only hosts one conversation
        /// at a time. Once this event is handled, the sample un-registers for this event. The event is registered again when
        /// this conversation is removed from the ContactManager.Conversations collection upon termination of this conversation.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ConversationManager_ConversationAdded(object sender, Microsoft.Lync.Model.Conversation.ConversationManagerEventArgs e)
        {
            Boolean addedByThisProcess = true;

            try
            {
                //Suspend hosting new conversations until this conversation is ended
                _LyncClient.ConversationManager.ConversationAdded -= ConversationManager_ConversationAdded;
            }

            catch (Exception ex) { MessageBox.Show("Exception on de-register for ConversationAdded: " + ex.Message); }

            //If this class field is null then the new conversation was not started by this running process. It was
            //Started by the Lync client or by a remote user.
            if (_conversation == null)
            {
                addedByThisProcess = false;
                _conversation      = e.Conversation;
            }



            //Register for conversation state changes such as Active->Terminated.
            _conversation.StateChanged += _conversation_StateChanged;

            //Register for the application sharing modality event on the conversation itself
            _sharingModality = (ApplicationSharingModality)_conversation.Modalities[ModalityTypes.ApplicationSharing];

            //Register for state changes like connecting->connected
            _sharingModality.ModalityStateChanged += _sharingModality_ModalityStateChanged;

            //Register to catch requests from other participants for control of the locally owned sharing resource.
            _sharingModality.ControlRequestReceived += _sharingModality_ControlRequestReceived;
            _sharingModality.ControllerChanged      += _sharingModality_ControllerChanged;

            //Register to catch changes in the list of local sharable resources such as a process that starts up or terminates.
            _sharingModality.LocalSharedResourcesChanged += _sharingModality_LocalSharedResourcesChanged;

            //Register for changes in the availbility of resource controlling actions such as grant and revoke.
            _sharingModality.ActionAvailabilityChanged += _sharingModality_ActionAvailabilityChanged;

            //Register for changes in the local participant's mode of sharing participation
            // such as Viewing->Sharing, Requesting Control->Controlling.
            _sharingModality.ParticipationStateChanged += _sharingModality_ParticipationStateChanged;

            //Register for participant added events on the new conversation
            //The next important action in the chain of conversation intiating action happens in the ParticipantAdded event handler.
            _conversation.ParticipantAdded   += _conversation_ParticipantAdded;
            _conversation.ParticipantRemoved += _conversation_ParticipantRemoved;


            if (addedByThisProcess == true)
            {
                //Clear out the contact list on the UI to be replaced with only the contacts selected for the current conversation.
                this.Invoke(new ClearAllContactsDelegate(ClearAllContacts));

                //Iterate on the contact dictionary that is filled from the contact Sip addresses selected from the
                //contact list UI control. Add each selected contact to the conversation, causing an invitation to be
                //sent to each contact.
                foreach (Contact selectedContact in _selectedContacts.Values)
                {
                    Participant newParticipant = _conversation.AddParticipant(selectedContact);

                    //Register for events on the conversation participant's application sharing modality
                    ((ApplicationSharingModality)newParticipant.Modalities[ModalityTypes.ApplicationSharing]).ActionAvailabilityChanged += _sharingModality_ActionAvailabilityChanged;
                }
            }

            //Update the list of local sharable resources on the UI
            this.Invoke(new UpdateSharedResourcesListboxDelegate(UpdateSharedResourcesListbox));

            //Set the enabled state of the resource sharing button, end conversation button, and start conversation button.

            EnableDisableButtonDelegate buttonDelegate = new EnableDisableButtonDelegate(EnableDisableButton);

            this.Invoke(buttonDelegate, new object[] { StartSharingResource_Button, true });
            this.Invoke(buttonDelegate, new object[] { EndConversation_Button, true });
            this.Invoke(buttonDelegate, new object[] { Start_Button, false });
        }