DoOnUIThread() public static method

public static DoOnUIThread ( UIElement element, System.Action action ) : void
element System.Windows.UIElement
action System.Action
return void
Beispiel #1
0
        /// <summary>
        /// Retrieves a list of the available video devices, their resolutions and pixel formats.
        /// </summary>
        private void LoadVideoDevices()
        {
            var videoDevices    = _mediaManager.GetVideoDevices();
            var videoDeviceKeys = new List <KeyValuePair <string, VideoMode> >();

            if (videoDevices != null && videoDevices.Count > 0)
            {
                for (int index = 0; index < videoDevices.Count; index++)
                {
                    if (_supportedVideoModes.Contains(MFVideoSubTypes.FindVideoSubTypeForGuid(videoDevices[index].VideoSubType)))
                    {
                        var    videoSubType  = MFVideoSubTypes.FindVideoSubTypeForGuid(videoDevices[index].VideoSubType);
                        string videoModeName = String.Format("{0} {1} x {2} {3}", videoDevices[index].DeviceFriendlyName, videoDevices[index].Width, videoDevices[index].Height, videoSubType.GetSubTypeDescription());

                        videoDeviceKeys.Add(new KeyValuePair <string, VideoMode>(videoModeName, videoDevices[index]));
                        //_localVideoDevices.Items.Add();
                    }
                }
            }

            UIHelper.DoOnUIThread(this, delegate
            {
                _localVideoDevices.ItemsSource = videoDeviceKeys;
                _localVideoDevices.IsEnabled   = true;
            });
        }
Beispiel #2
0
        public SoftPhone()
        {
            InitializeComponent();

            // Do some UI initialisation.
            m_uasGrid.Visibility      = Visibility.Collapsed;
            m_cancelButton.Visibility = Visibility.Collapsed;
            m_byeButton.Visibility    = Visibility.Collapsed;

            // Set up the SIP client. It can receive calls and initiate outgoing calls.
            _sipClient = new SIPClient();
            _sipClient.IncomingCall  += SIPCallIncoming;
            _sipClient.CallAnswer    += SIPCallAnswered;
            _sipClient.CallEnded     += ResetToCallStartState;
            _sipClient.StatusMessage += (message) => { SetStatusText(m_signallingStatus, message); };

            // If a STUN server hostname has been specified start the STUN client to lookup and periodically update the public IP address of the host machine.
            if (!SIPSoftPhoneState.STUNServerHostname.IsNullOrBlank())
            {
                _stunClient = new SoftphoneSTUNClient(SIPSoftPhoneState.STUNServerHostname);
                _stunClient.PublicIPAddressDetected += (ip) =>
                {
                    SIPSoftPhoneState.PublicIPAddress = ip;
                    UIHelper.DoOnUIThread(this, delegate
                    {
                        publicIPAddress.Content = $"Public IP: {ip}";
                    });
                };
                _stunClient.Run();
            }

            Initialise();
        }
Beispiel #3
0
 /// <summary>
 /// Set up the UI to present options for an establisehd SIP call, i.e. hide the cancel
 /// button and display they hangup button.
 /// </summary>
 private void SIPCallAnswered()
 {
     UIHelper.DoOnUIThread(this, delegate
     {
         m_callButton.Visibility   = Visibility.Collapsed;
         m_cancelButton.Visibility = Visibility.Collapsed;
         m_byeButton.Visibility    = Visibility.Visible;
     });
 }
Beispiel #4
0
        /// <summary>
        /// Set up the UI to present the options for an incoming SIP call.
        /// </summary>
        private void SIPCallIncoming()
        {
            _activeClient = _sipClient;

            UIHelper.DoOnUIThread(this, delegate
            {
                m_uacGrid.Visibility = Visibility.Collapsed;
                m_uasGrid.Visibility = Visibility.Visible;
            });
        }
Beispiel #5
0
        /// <summary>
        /// Reset the UI elements to their initial state at the end of a call.
        /// </summary>
        private void ResetToCallStartState()
        {
            UIHelper.DoOnUIThread(this, delegate
            {
                m_callButton.Visibility     = Visibility.Visible;
                m_cancelButton.Visibility   = Visibility.Collapsed;
                m_byeButton.Visibility      = Visibility.Collapsed;
                m_answerButton.Visibility   = Visibility.Visible;
                m_rejectButton.Visibility   = Visibility.Visible;
                m_redirectButton.Visibility = Visibility.Visible;
                m_hangupButton.Visibility   = Visibility.Visible;
                m_uacGrid.Visibility        = Visibility.Visible;
                m_uasGrid.Visibility        = Visibility.Collapsed;
            });

            _activeClient = null;
        }
Beispiel #6
0
 private void LocalVideoError(string error)
 {
     UIHelper.DoOnUIThread(this, delegate
     {
         if (error.NotNullOrBlank())
         {
             _localVideoStatus.Text             = error;
             _localVideoStatusBorder.Visibility = System.Windows.Visibility.Visible;
             _startLocalVideoButton.IsEnabled   = true;
             _stopLocalVideoButton.IsEnabled    = false;
             _localVideoDevices.IsEnabled       = true;
         }
         else
         {
             _localVideoStatus.Text             = null;
             _localVideoStatusBorder.Visibility = System.Windows.Visibility.Collapsed;
         }
     });
 }
Beispiel #7
0
 /// <summary>
 /// Set the text on one of the status text blocks. Status messages are used to indicate how the call is
 /// progressing or events related to it.
 /// </summary>
 private void SetStatusText(TextBlock textBlock, string text)
 {
     logger.Debug(text);
     UIHelper.DoOnUIThread(this, delegate { textBlock.Text = text; });
 }