private void Current_LeavingBackground(object sender, LeavingBackgroundEventArgs e)
 {
     if (Windows.System.Power.PowerManager.EnergySaverStatus != Windows.System.Power.EnergySaverStatus.On)
     {
         if ((int)NepApp.Network.ConnectionType > 1) //wifi or ethernet
         {
             remoteSystemWatcher.Start();
         }
     }
 }
Ejemplo n.º 2
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();
            }
        }
Ejemplo n.º 3
0
        /// <summary>

        /// Signs in the current user.

        /// </summary>

        /// <returns></returns>



        private async void discoverDevices()
        {
            //Describes what happens when the button in the application is clicked
            //Verify Access for Remote Systems
            //RequestAccessAsync() is a method within the
            //RemoteSystem class that gets the status of calling app's access to the RemoteSystem feature
            RemoteSystemAccessStatus accessStat = await RemoteSystem.RequestAccessAsync();

            int accessInt = (int)accessStat;

            if (accessStat == RemoteSystemAccessStatus.Allowed)
            {
                //build a watcher to monitor for remote systems
                remoteSystemWatcher = RemoteSystem.CreateWatcher();
                // Start the watcher.
                remoteSystemWatcher.Start();
                //events for changes in remote system discovery
                remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
            }
            else
            {
                var errDialog = new MessageDialog("Cannot access Remote Systems.." + accessInt.ToString());
                await errDialog.ShowAsync();
            }
        }
        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();
        }
        private async void DiscoverDevices()
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = RemoteSystem.CreateWatcher();

                //Add RemoteSystem to DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemAdded += async(sender, args) =>
                                                          await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Add(args.RemoteSystem));

                //Remove RemoteSystem from DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemRemoved += async(sender, args) =>
                                                            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystemId)));

                //Update RemoteSystem on DeviceList (on the UI Thread)
                _remoteSystemWatcher.RemoteSystemUpdated += async(sender, args) =>
                                                            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                {
                    DeviceList.Remove(DeviceList.FirstOrDefault(system => system.Id == args.RemoteSystem.Id));
                    DeviceList.Add(args.RemoteSystem);
                });

                _remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 6
0
        private void SearchByRemoteSystemWatcher()
        {
            if (FilterSearch.IsChecked.Value)
            {
                // Build a watcher to continuously monitor for filtered remote systems.
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher(BuildFilters());
            }
            else
            {
                // Build a watcher to continuously monitor for all remote systems.
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
            }

            // Subscribing to the event that will be raised when a new remote system is found by the watcher.
            m_remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

            // Subscribing to the event that will be raised when a previously found remote system is no longer available.
            m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

            // Subscribing to the event that will be raised when a previously found remote system is updated.
            m_remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

            // Start the watcher.
            m_remoteSystemWatcher.Start();

            UpdateStatus("Searching for systems...", NotifyType.StatusMessage);
            SystemListBox.Visibility = Visibility.Visible;
        }
        /// <summary>
        /// Initiate Enumeration with specific RemoteSystemKind with Filters
        /// </summary>
        private async void GenerateSystemsWithFilterAsync(List <IRemoteSystemFilter> filter)
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = filter != null?RemoteSystem.CreateWatcher(filter) : RemoteSystem.CreateWatcher();

                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                if (ApiInformation.IsEventPresent("Windows.System.RemoteSystems.RemoteSystemWatcher", "EnumerationCompleted"))
                {
                    _remoteSystemWatcher.EnumerationCompleted += RemoteSystemWatcher_EnumerationCompleted;
                }
                else
                {
                    ThreadPoolTimer.CreateTimer(
                        (e) =>
                    {
                        RemoteSystemWatcher_EnumerationCompleted(_remoteSystemWatcher, null);
                    }, TimeSpan.FromSeconds(2));
                }

                _remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 8
0
        public async Task <bool> Initialize()
        {
            if (_remoteSystemWatcher != null)
            {
                return(true);
            }

            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                // Construct a user type filter that includes anonymous devices
                //RemoteSystemAuthorizationKindFilter authorizationKindFilter = new RemoteSystemAuthorizationKindFilter(RemoteSystemAuthorizationKind.Anonymous);
                //_remoteSystemWatcher = RemoteSystem.CreateWatcher((new IRemoteSystemFilter[] { authorizationKindFilter }));

                _remoteSystemWatcher = RemoteSystem.CreateWatcher();
                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                _remoteSystemWatcher.Start();

                if (timer == null)
                {
                    timer = new Timer(Timer_Tick, null, (int)delayBeforeTimerBegin.TotalMilliseconds, (int)refreshInterval.TotalMilliseconds);
                }

                return(true);
            }

            return(false);
        }
        public void StartDiscovery()
        {
            if (authStatus != AuthenticationStatus.Authenticated)
            {
                throw new InvalidOperationException("Can't discover until you are authenticated");
            }

            if (remoteSystemWatcher == null)
            {
                lock (instance)
                {
                    remoteSystemWatcher = RemoteSystem.CreateWatcher();

                    //hook up event handlers
                    remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;;
                    remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;;
                    remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;;
                    remoteSystemWatcher.Complete            += RemoteSystemWatcher_Complete;
                    //start watcher
                    try
                    {
                        remoteSystemWatcher.Start();
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message);
                    }
                }
            }
        }
Ejemplo n.º 10
0
        private async void StartWatch()
        {
            RemoteSystemAccessStatus Status = await RemoteSystem.RequestAccessAsync();

            Watcher = RemoteSystem.CreateWatcher();
            Watcher.RemoteSystemAdded   += Watcher_RemoteSystemAdded;
            Watcher.RemoteSystemRemoved += Watcher_RemoteSystemRemoved;
            Watcher.Start();
        }
Ejemplo n.º 11
0
        private void RefreshDevices()
        {
            remoteSystemWatcher = RemoteSystem.CreateWatcher();

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

            remoteSystemWatcher.Start();
        }
Ejemplo n.º 12
0
        public void DiscoverDevices()
        {
            _remoteSystemWatcher = RemoteSystem.CreateWatcher();

            _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemAdded;
            _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemRemoved;
            _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemUpdated;

            _remoteSystemWatcher.Start();
        }
        private void DiscoverDevicesAsync()
        {
            var filters = GetRemoteSystemFilter();

            // Filters 需要在建立 RemoteSystemWatcher 建構子一起傳入
            devicesWatcher = RemoteSystem.CreateWatcher(filters);
            devicesWatcher.RemoteSystemAdded   += DevicesWatcher_RemoteSystemAdded;
            devicesWatcher.RemoteSystemRemoved += DevicesWatcher_RemoteSystemRemoved;
            devicesWatcher.RemoteSystemUpdated += DevicesWatcher_RemoteSystemUpdated;
            //devicesWatcher.ErrorOccurred += DevicesWatcher_ErrorOccurred;

            devicesWatcher.Start();
        }
        private async void RemoteDevicePicker_Loading(FrameworkElement sender, object args)
        {
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                RemoteSystemWatcher m_remoteSystemWatcher = RemoteSystem.CreateWatcher();
                m_remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                m_remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                m_remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                m_remoteSystemWatcher.Start();
            }
            _progressRing.IsActive = true;
            UpdateList();
        }
        /// <summary>
        /// Initiate Enumeration with specific RemoteSysemKind with Filters
        /// </summary>
        private async void GenerateSystemsWithFilterAsync(List <IRemoteSystemFilter> filter)
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = filter != null?RemoteSystem.CreateWatcher(filter) : RemoteSystem.CreateWatcher();

                _remoteSystemWatcher.RemoteSystemAdded    += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved  += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated  += RemoteSystemWatcher_RemoteSystemUpdated;
                _remoteSystemWatcher.EnumerationCompleted += RemoteSystemWatcher_EnumerationCompleted;
                _remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 16
0
        public static void DiscoverDevices()
        {
            RequestAccess();

            // Create Watcher for remote devices
            _watcher = RemoteSystem.CreateWatcher(BuildFilters());

            // Hook up event handlers
            _watcher.RemoteSystemAdded   += _watcher_RemoteSystemAdded;
            _watcher.RemoteSystemRemoved += _watcher_RemoteSystemRemoved;
            _watcher.RemoteSystemUpdated += _watcher_RemoteSystemUpdated;

            // Start the Watcher
            _watcher.Start();
            Events.TrackEvent(Events.StartRemoteSystemWatcher);
        }
Ejemplo n.º 17
0
        private async void BuildDeviceList()
        {
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();
            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                remoteSystemWatcher = RemoteSystem.CreateWatcher(BuildDeviceFilter());

                // Subscribing to the event raised when a new remote system is found by the watcher.
                remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

                // Subscribing to the event raised when a previously found remote system is no longer available.
                remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

                remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 18
0
        private async void SetupRemoteWatcher()
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                // Create and start the remote system
                _remoteSystemWatcher = RemoteSystem.CreateWatcher();

                // Bind methods
                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

                _remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 19
0
        private async void BuildDeviceList()
        {
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                remoteSystemWatcher = RemoteSystem.CreateWatcher(BuildDeviceFilter());

                // Subscribing to the event raised when a new remote system is found by the watcher.
                remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

                // Subscribing to the event raised when a previously found remote system is no longer available.
                remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

                remoteSystemWatcher.Start();
            }
        }
        private async Task ListDevicesAsync()
        {
            using (await _listDevicesAsyncLock.LockAsync())
            {
                RequestAccessError = string.Empty;
                var result = await RemoteSystem.RequestAccessAsync();

                if (result != RemoteSystemAccessStatus.Allowed)
                {
                    RequestAccessError = "Impossible de lister les périphériques : " + result;
                    return;
                }

                if (_watcher != null)
                {
                    _watcher.RemoteSystemAdded   -= OnWatcherRemoteSystemAdded;
                    _watcher.RemoteSystemRemoved -= OnWatcherRemoteSystemRemoved;
                    _watcher.RemoteSystemUpdated -= OnWatcher_RemoteSystemUpdated;
                }

                RemoteSystems = new ObservableCollection <RemoteSystem>();

                #region listing
                if (IsListingOnlyActiveDevices)
                {
                    var filter = new IRemoteSystemFilter[]
                    {
                        new RemoteSystemStatusTypeFilter(RemoteSystemStatusType.Available),
                        new RemoteSystemDiscoveryTypeFilter(RemoteSystemDiscoveryType.Any)
                    };
                    _watcher = RemoteSystem.CreateWatcher(filter);
                }
                else
                {
                    #endregion
                    _watcher = RemoteSystem.CreateWatcher();
                    _watcher.RemoteSystemAdded   += OnWatcherRemoteSystemAdded;
                    _watcher.RemoteSystemRemoved += OnWatcherRemoteSystemRemoved;
                }

                _watcher.RemoteSystemUpdated += OnWatcher_RemoteSystemUpdated;

                _watcher.Start();
            }
        }
Ejemplo n.º 21
0
        public async Task Initialize()
        {
            if (_remoteSystemWatcher != null)
            {
                return;
            }

            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                _remoteSystemWatcher = RemoteSystem.CreateWatcher(BuildFilters());
                _remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                _remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                _remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;
                _remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 22
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();
        }
Ejemplo n.º 23
0
        public async void initWatcher()
        {
            RemoteSystemAccessStatus status = await RemoteSystem.RequestAccessAsync();

            if (status == RemoteSystemAccessStatus.Allowed)
            {
                // <SnippetCreateWatcher>
                // store filter list
                List <IRemoteSystemFilter> listOfFilters = makeFilterList();

                // construct watcher with the list
                m_remoteSystemWatcher = RemoteSystem.CreateWatcher(listOfFilters);
                // </SnippetCreateWatcher>

                // assign to event handlers, etc...

                // start detecting
                m_remoteSystemWatcher.Start();
            }
        }
Ejemplo n.º 24
0
        private async Task BuildDeviceListAsync()
        {
            var accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                watcher = GetWatcher();

                // Subscribing to the event raised when a new remote system is found by the watcher.
                watcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

                // Subscribing to the event raised when a previously found remote system is no longer available.
                watcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

                watcher.Start();
            }
            else
            {
                //throw new UnauthorizedAccessException("Remote system not allowed " + accessStatus);
            }
        }
        private async Task StartWatcherAsync()
        {
            RemoteSystemAccessStatus accessStatus = await RemoteSystem.RequestAccessAsync();

            if (accessStatus == RemoteSystemAccessStatus.Allowed)
            {
                remoteSystemWatcher = RemoteSystem.CreateWatcher();

                remoteSystemWatcher.RemoteSystemAdded += RemoteSystemWatcher_RemoteSystemAdded;

                remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;

                remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

                remoteSystemWatcher.Start();
            }
            else
            {
                Debug.WriteLine("Access to Remote Systems is " + accessStatus.ToString());
                Debug.WriteLine("Make sure you have set the Remote System capability");
            }
        }
Ejemplo n.º 26
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...");
        }
Ejemplo n.º 27
0
        public async Task InitializeAsync()
        {
            if (IsInitialized)
            {
                return;
            }

            IsSupported = Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.RemoteSystems.RemoteSystem");

            if (!IsSupported)
            {
                return;
            }

            if (!await CheckRemoteAppServiceEnabledAsync())
            {
                //app service listing got removed while building for store.
                IsSupported = false;

#if DEBUG
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    System.Diagnostics.Debugger.Break();
                }
#endif

                return;
            }


            RemoteSystemAccess = await await App.Dispatcher.RunAsync(() => RemoteSystem.RequestAccessAsync());

            systemList        = new ObservableCollection <RemoteSystem>();
            RemoteSystemsList = new ReadOnlyObservableCollection <RemoteSystem>(systemList);

            IsInitialized = true;

            if (RemoteSystemAccess == RemoteSystemAccessStatus.Allowed)
            {
                remoteSystemWatcher = RemoteSystem.CreateWatcher(new IRemoteSystemFilter[] {
                    new RemoteSystemDiscoveryTypeFilter(RemoteSystemDiscoveryType.Any),
                    new RemoteSystemAuthorizationKindFilter(RemoteSystemAuthorizationKind.SameUser),
                    new RemoteSystemStatusTypeFilter(RemoteSystemStatusType.Available)
                });
                remoteSystemWatcher.RemoteSystemAdded   += RemoteSystemWatcher_RemoteSystemAdded;
                remoteSystemWatcher.RemoteSystemRemoved += RemoteSystemWatcher_RemoteSystemRemoved;
                remoteSystemWatcher.RemoteSystemUpdated += RemoteSystemWatcher_RemoteSystemUpdated;

                App.Current.EnteredBackground += Current_EnteredBackground;
                App.Current.LeavingBackground += Current_LeavingBackground;


                if (Windows.System.Power.PowerManager.EnergySaverStatus != Windows.System.Power.EnergySaverStatus.On)
                {
                    if ((int)NepApp.Network.ConnectionType > 1) //wifi or ethernet
                    {
                        remoteSystemWatcher.Start();            //auto runs for 30 seconds. stops when app is suspended - https://docs.microsoft.com/en-us/uwp/api/windows.system.remotesystems.remotesystemwatcher
                    }
                }
            }
        }
Ejemplo n.º 28
0
 private void Timer_Tick(object state)
 {
     remoteSystemWatcher.Stop();
     remoteSystemWatcher.Start();
 }