Ejemplo n.º 1
0
        // Get the hosting Conversation object and application data, and register for event notification
        // and update the user interface to "Ready".
        private void Initialize()
        {
            String appData;
            try
            {
                _conversation = (Conversation)Microsoft.Lync.Model.LyncClient.GetHostingConversation();
            }

            catch (LyncClientException ex)
            {
                Logger("LyncClientException error: " + ex);
            }

            catch (Exception ex)
            {
                Logger("Other conversation initialization error: " + ex);
            }

            _conversation.ContextDataReceived += OnContextDataReceived;
            _conversation.ContextDataSent += OnContextDataSent;
            _conversation.InitialContextReceived += OnInitialContextReceived;
            _conversationWindow = _automation.GetConversationWindow(_conversation);

            appData = _conversation.GetApplicationData(_appId);
            Logger("Application data: " + appData);
            if (appData.Contains("open"))
            {
                channelStatus.Foreground = new SolidColorBrush(Colors.Green);
                channelStatus.Text = "Ready";
            }

        }
Ejemplo n.º 2
0
        private void conversationManager_ConversationAdded(object sender,
                                                           ConversationManagerEventArgs e)
        {
            e.Conversation.ParticipantAdded
                += new EventHandler <ParticipantCollectionChangedEventArgs>
                       (Conversation_ParticipantAdded);
            e.Conversation.AddParticipant
                (_client.ContactManager.GetContactByUri(_remoteUri));

            _conversationWindow = _automation.GetConversationWindow(e.Conversation);

            //wire up events
            _conversationWindow.NeedsSizeChange += _conversationWindow_NeedsSizeChange;
            _conversationWindow.NeedsAttention  += _conversationWindow_NeedsAttention;

            //dock conversation window
            _conversationWindow.Dock(formHost.Handle);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// This event is fired when the Conversation is created.  We use the automation
        /// API to get the ConversationWindow for the Conversation, and subscribe to important window events.”
        /// </summary>
        void HandleConversationAdded(object sender, ConversationManagerEventArgs e)
        {
            if (ConversationAddedEvent != null)
            {
                _conversation = e.Conversation;
                try
                {
                    Automation automation = LyncClient.GetAutomation();
                    _conversationWindow = automation.GetConversationWindow(_conversation);
                }
                catch (LyncClientException lyncClientException)
                {
                    Console.WriteLine(lyncClientException);
                }
                catch (SystemException systemException)
                {
                    if (IsLyncException(systemException))
                    {
                        // Log the exception thrown by the Lync Model API.
                        Console.WriteLine("Error: " + systemException);
                    }
                    else
                    {
                        // Rethrow the SystemException which did not come from the Lync Model API.
                        throw;
                    }
                }

                if (_conversationWindow != null)
                {
                    //Subscribe to ConversationWindows's NeedsAttention and NeedsSizeChanged events
                    _conversationWindow.NeedsAttention  += HandleNeedsAttention;
                    _conversationWindow.NeedsSizeChange += HandleNeedsSizeChange;
                    ConversationAddedEvent(this, null);
                }
            }
        }
Ejemplo n.º 4
0
        public static void ShowFullscreen(Automation automation, Conversation conversation, int display)
        {
            var window = automation.GetConversationWindow(conversation);

            ShowFullscreen(window, display);
        }
Ejemplo n.º 5
0
        private static void Execute(Func <IntPtr, bool> windowInteraction, Automation automation, Conversation conversation)
        {
            var window = automation.GetConversationWindow(conversation);

            windowInteraction(window.Handle);
        }
Ejemplo n.º 6
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            lync = LyncClient.GetAutomation();
            client = LyncClient.GetClient();
            ConversationManager mgr = client.ConversationManager;
            mgr.ConversationAdded += (s, evt) =>
            {
                meetNowConvo = evt.Conversation;
                meetNowConvo.PropertyChanged += (s3, e3) =>
                {
                    Debug.Print("> Conversation.PropertyChanged : Property:{0}, Value:{1}", e3.Property, e3.Value);
                    if (e3.Property == ConversationProperty.NumberOfParticipantsRecording && e3.Value.Equals(0))
                    {
                        if(ConversationEnded != null)
                        {
                            ConversationEnded(s3, e3);
                        }
                    }
                };
                ConversationWindow win = lync.GetConversationWindow(meetNowConvo);

                Modality m = meetNowConvo.Modalities[ModalityTypes.AudioVideo];
                            
                AVModality avm = (AVModality)m;

                avm.ModalityStateChanged += (s2, e2) =>
                {
                    Debug.Print("> AVModality.ModalityStateChanged : {0}", e2.NewState);
                    if (e2.NewState == ModalityState.Connected)
                    {
                        Debug.Print("** AV Connected**");
                        ApplicationSharingModality m1 = (ApplicationSharingModality)meetNowConvo.Modalities[ModalityTypes.ApplicationSharing];
                        m1.ModalityStateChanged += (s5, e5) =>
                        {
                            Debug.Print("> ApplicationSharingModality.ModalityChanged : {0}", e5.NewState);

                            if (e5.NewState == ModalityState.Connected)
                            {
                                Debug.Print("** Sharing Ok **");                                

                                Windowing.SetForegroundWindow(win.Handle);
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait("{TAB}");
                                SendKeys.SendWait(" ");
                                SendKeys.SendWait("r");

                                Windowing.ShowWindow(win.Handle, (int)Windowing.ShowCommands.SW_SHOWMINNOACTIVE);
                            }
                        };
                        
                        m1.BeginShareDesktop(GetNullAsyncCallback("ApplicationSharingModality.BeginShareDesktop"), null);
                        
                    }
                };

                avm.BeginConnect(GetNullAsyncCallback("AVModality.BeginConnect"), null);

            };
            
        }