Exemplo n.º 1
0
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (SelectedSystem == null)
            {
                args.Cancel = true;
                return;
            }

            Watcher.Stop();
        }
        private async void btnGetDevices_Click(object sender, RoutedEventArgs e)
        {
            RemoteSystems.Clear();
            // Verify access for Remote Systems.
            // Note: RequestAccessAsync needs to called from the UI thread.
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus != RemoteSystemAccessStatus.Allowed)
            {
                return;
            }

            if (remoteSystemWatcher != null)
            {
                remoteSystemWatcher.Stop();
                remoteSystemWatcher = null;
            }

            // Build a watcher to continuously monitor for all remote systems.
            remoteSystemWatcher = RemoteSystem.CreateWatcher();

            remoteSystemWatcher.RemoteSystemAdded   += M_remoteSystemWatcher_RemoteSystemAdded;
            remoteSystemWatcher.RemoteSystemRemoved += M_remoteSystemWatcher_RemoteSystemRemoved;
            remoteSystemWatcher.RemoteSystemUpdated += M_remoteSystemWatcher_RemoteSystemUpdated;

            // Start the watcher.
            remoteSystemWatcher.Start();
        }
Exemplo n.º 3
0
        public async Task BuildDeviceList()
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (DeviceList != null)
                {
                    DeviceList.Clear();
                }
                RaisePropertyChanged("ShowEmptyErrorMessage");
            });

            if (m_remoteSystemWatcher != null)
            {
                m_remoteSystemWatcher.Stop();
            }
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
                // Subscribing to the event raised when a new remote system is found by the watcher.
                m_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;
                // Subscribing to the event raised when a previously found remote system is no longer available.
                m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                m_remoteSystemWatcher.Start();
            }
        }
 private void SearchCleanup()
 {
     if (m_remoteSystemWatcher != null)
     {
         m_remoteSystemWatcher.Stop();
         m_remoteSystemWatcher = null;
     }
     DeviceList.Clear();
     DeviceMap.Clear();
 }
 private void SearchCleanup()
 {
     if (m_remoteSystemWatcher != null)
     {
         m_remoteSystemWatcher.Stop();
         m_remoteSystemWatcher = null;
     }
     m_rootPage.systemList.Clear();
     m_rootPage.systemMap.Clear();
 }
Exemplo n.º 6
0
 private void SearchCleanup()
 {
     if (m_remoteSystemWatcher != null)
     {
         m_remoteSystemWatcher.Stop();
         m_remoteSystemWatcher = null;
     }
     m_rootPage.systemList.Clear();
     m_rootPage.systemMap.Clear();
     DeviceInfoTextBlock.Visibility = Visibility.Collapsed;
     DeviceInfoTextBlock.Text       = "Select a device from the list to see its properties.";
 }
        public void OnStopDiscoverClick(object sender, RoutedEventArgs e)
        {
            if (devicesWatcher == null)
            {
                return;
            }

            devicesWatcher.Stop();
            devicesWatcher.RemoteSystemAdded   -= DevicesWatcher_RemoteSystemAdded;
            devicesWatcher.RemoteSystemRemoved -= DevicesWatcher_RemoteSystemRemoved;
            devicesWatcher.RemoteSystemUpdated -= DevicesWatcher_RemoteSystemUpdated;
            devicesWatcher.ErrorOccurred       -= DevicesWatcher_ErrorOccurred;
            devicesWatcher = null;
        }
Exemplo n.º 8
0
        private async void Timer_Tick(object state)
        {
            //Debug.WriteLine("Timer_Tick");

            if (firstTimeRefresh)
            {
                firstTimeRefresh = false;
                if (_remoteSystems.Count == 0)
                {
                    return;
                }
            }

            //Debug.WriteLine("Timer_Tick. Stopping watcher...");
            _remoteSystemWatcher.Stop();
            //Debug.WriteLine("Timer_Tick. Stopped watcher...");

            await Task.Delay(500);

            //Debug.WriteLine("Timer_Tick. Starting watcher...");
            _remoteSystemWatcher.Start();
            //Debug.WriteLine("Timer_Tick. Started watcher...");
        }
Exemplo n.º 9
0
        public void Dispose()
        {
            if (_remoteSystemWatcher != null)
            {
                foreach (var system in _availableRemoteSystems)
                {
                    system.Dispose();
                }

                _remoteSystemWatcher.RemoteSystemAdded   -= RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved -= RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated -= RemoteSystemWatcher_RemoteSystemUpdated;
                _remoteSystemWatcher.Stop();
                _remoteSystemWatcher = null;
            }
        }
Exemplo n.º 10
0
        private void DiscoverDevices()
        {
            if (remoteSystemWatcher != null)
            {
                remoteSystemWatcher.Stop();
            }

            var filters = new List <IRemoteSystemFilter> {
                new RemoteSystemKindFilter(remoteSystemKind), new RemoteSystemDiscoveryTypeFilter(remoteSystemDiscoveryKind)
            };

            remoteSystemWatcher = RemoteSystem.CreateWatcher(filters);

            remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcherOnRemoteSystemAdded;
            remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
            remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

            remoteSystemWatcher.Start();
        }
Exemplo n.º 11
0
 private void RemoteSystemWatcher_EnumerationCompleted(RemoteSystemWatcher sender, RemoteSystemEnumerationCompletedEventArgs args)
 {
     _remoteSystemWatcher.Stop();
 }
Exemplo n.º 12
0
 private void Timer_Tick(object state)
 {
     remoteSystemWatcher.Stop();
     remoteSystemWatcher.Start();
 }