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(); }
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(); }
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; }
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..."); }
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; } }
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(); }
private void RemoteSystemWatcher_EnumerationCompleted(RemoteSystemWatcher sender, RemoteSystemEnumerationCompletedEventArgs args) { _remoteSystemWatcher.Stop(); }
private void Timer_Tick(object state) { remoteSystemWatcher.Stop(); remoteSystemWatcher.Start(); }