Esempio n. 1
0
        private void LoadDevices()
        {
            Loading = true;

            // Clear Lists
            DeviceListItems.Clear();
            overviewPage.ClearDevices();

            // Get the Connections URL to use
            var url = _apiUrl;

            // Get a list of all Connections available from TrakHound Api
            var connectionsRequest = new Task <List <ConnectionDefinition> >(() => Connections.Get(url, _apiToken).ToList());

            connectionsRequest.ContinueWith(x =>
            {
                var connections = x.Result;
                if (!connections.IsNullOrEmpty())
                {
                    // Add each Device to SavedDeviceList
                    foreach (var connection in x.Result)
                    {
                        LoadDevice(connection.DeviceId);
                    }
                }
                else
                {
                    Dispatcher.BeginInvoke(new Action(() =>
                    {
                        Loading = false;
                        if (!IsOptionsShown)
                        {
                            OpenOptionsPage();
                        }
                    }), System.Windows.Threading.DispatcherPriority.Background, null);
                }
            });
            connectionsRequest.Start();
        }