コード例 #1
0
        private async void Compile(object sender, RoutedEventArgs e)
        {
            progressbar.Text = "Compiling code";
            progressbar.ShowAsync();

            var edContent = await webv.InvokeScriptAsync("getContent", new List <string>());

            var bytes  = Encoding.UTF8.GetBytes(edContent);
            var base64 = System.Uri.EscapeUriString(Convert.ToBase64String(bytes)).Replace("+", "%2B").Replace("=", "%3D");

            Debug.WriteLine(base64);

            var cts    = new CancellationTokenSource();
            var client = new HttpClient();

            try
            {
                cts.CancelAfter(7500);
                var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/api/compile?Content=" + base64));

                var result = await response.Content.ReadAsStringAsync();

                outbox.Text = result;
            }
            catch
            {
                outbox.Text = "Timeout";
            }
            progressbar.HideAsync();
            CodeHub.ScrollToSection(HubInOut);
        }
コード例 #2
0
        private async void semesterComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            scheduleGrid.Children.Clear();
            searchResultLabelTextBlock.Text = name;
            if (semesterComboBox.SelectedItem is Semester)
            {
                await progressbar.ShowAsync();
                await GetSchedule(semesterComboBox.SelectedItem as Semester);

                await progressbar.HideAsync();
            }
        }
コード例 #3
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            _progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
          
            await _progressbar.ShowAsync();
            if ((e.Parameter != null) && (e.Parameter.GetType() == typeof(DeviceInformation)))
            {
                
                try
                {
                    _idDevice=((DeviceInformation)e.Parameter).Id;
                    _device = await BluetoothLEDevice.FromIdAsync(((DeviceInformation)e.Parameter).Id);
                    this.lblDeviceName.Text = ((DeviceInformation)e.Parameter).Name+" " + BLEHelper.AddressToString(_device.BluetoothAddress);
                    if (_device == null)
                        new MessageDialog("Could not connect to the selected device!", "Error").ShowAsync();

                    _services = _device.GattServices;
                    lstServices.ItemsSource = _services;
                }
                catch (Exception ex)
                {
                    new MessageDialog("Device enumeration error: " + ex.Message, "Error").ShowAsync();
                }
            }
            this.navigationHelper.OnNavigatedTo(e);
            await _progressbar.HideAsync();
          
            _dataTransferManager = DataTransferManager.GetForCurrentView();
            _dataTransferManager.DataRequested += OnDataRequested;

        }
コード例 #4
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            _progressbar = StatusBar.GetForCurrentView().ProgressIndicator;

            await _progressbar.ShowAsync();

            if ((e.Parameter != null) && (e.Parameter.GetType() == typeof(DeviceInformation)))
            {
                try
                {
                    _idDevice = ((DeviceInformation)e.Parameter).Id;
                    _device   = await BluetoothLEDevice.FromIdAsync(((DeviceInformation)e.Parameter).Id);

                    this.lblDeviceName.Text = ((DeviceInformation)e.Parameter).Name + " " + BLEHelper.AddressToString(_device.BluetoothAddress);
                    if (_device == null)
                    {
                        new MessageDialog("Could not connect to the selected device!", "Error").ShowAsync();
                    }

                    _services = _device.GattServices;
                    lstServices.ItemsSource = _services;
                }
                catch (Exception ex)
                {
                    new MessageDialog("Device enumeration error: " + ex.Message, "Error").ShowAsync();
                }
            }
            this.navigationHelper.OnNavigatedTo(e);
            await _progressbar.HideAsync();

            _dataTransferManager = DataTransferManager.GetForCurrentView();
            _dataTransferManager.DataRequested += OnDataRequested;
        }
コード例 #5
0
ファイル: ProgressIndicator.cs プロジェクト: mam59/Xbmc2ndScr
        private async void DoRefresh()
        {
            await Task.Delay(300);

            _refreshPending = false;
            if (_token.Count == 0)
            {
                _progressIndicator.ProgressValue = 0;
                await _progressIndicator.HideAsync();
            }
            else
            {
                _progressIndicator.ProgressValue = null;
                await _progressIndicator.ShowAsync();
            }
        }
コード例 #6
0
        async private void GetDataFromWeb()
        {
            progressbar.Text = "Fetching new data";
            progressbar.ShowAsync();

            var client = new HttpClient();

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (!localSettings.Containers.ContainsKey("userInfo"))
            {
                MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu.");
                await msgbox.ShowAsync();

                return;
            }

            var lastcheck = localSettings.Containers["userInfo"].Values["lastcheckexamples"].ToString();

            Debug.WriteLine(System.Uri.EscapeUriString(lastcheck));
            var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/query/data?Timestamp=" + System.Uri.EscapeUriString(lastcheck) + "&Table=Examples"));

            var result = await response.Content.ReadAsStringAsync();

            result = result.Trim(new Char[] { '"' });
            Debug.WriteLine(result);

            DatabaseExample Db_Helper = new DatabaseExample();

            try
            {
                List <Examples> newex = JsonConvert.DeserializeObject <List <Examples> >(result);
                foreach (Examples ex in newex)
                {
                    try
                    {
                        Db_Helper.InsertExample(ex);
                    }
                    catch
                    {
                        Debug.WriteLine("DB error for item of id: " + ex.Id);
                    }
                }

                localSettings.Containers["userInfo"].Values["lastcheckexamples"] = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                progressbar.Text = "New items";
            }
            catch
            {
                Debug.WriteLine("No new items");
                progressbar.Text = "No New items";
            }
            finally
            {
                ReadExamples dbproblems = new ReadExamples();
                DB_ExampleList      = dbproblems.GetAllExamples();
                listBox.ItemsSource = DB_ExampleList.OrderByDescending(i => i.Id).ToList();
            }
            progressbar.HideAsync();
        }
コード例 #7
0
        private async void Login()
        {
            //Send GA Event
            App.Current.GATracker.SendEvent("Session", "Attempt Login", null, 0);

            string id = idTextBox.Text, password = passwordTextBox.Password;

            passwordTextBox.IsEnabled = loginAppBarButton.IsEnabled = false;
            idTextBox.IsReadOnly      = true;

            await progressbar.ShowAsync();

            var loginResult = await NPAPI.LoginNPortal(id, password);

            await progressbar.HideAsync();

            if (loginResult.Success)
            {
                //Store logged id, password
                var roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

                if (roamingSettings.Values.ContainsKey("id"))
                {
                    roamingSettings.Values["id"] = id;
                }
                else
                {
                    roamingSettings.Values.Add("id", id);
                }

                if (roamingSettings.Values.ContainsKey("password"))
                {
                    roamingSettings.Values["password"] = password;
                }
                else
                {
                    roamingSettings.Values.Add("password", password);
                }

                //Login Aps

                await NPAPI.LoginAps();

                //Go to previous page
                if (Frame.CanGoBack)
                {
                    Frame.GoBack();
                }
            }
            else
            {
                await new MessageDialog(loginResult.Message).ShowAsync();
            }

            passwordTextBox.IsEnabled = loginAppBarButton.IsEnabled = true;
            idTextBox.IsReadOnly      = false;
        }
コード例 #8
0
 private async void LoginButton_Click(object sender, RoutedEventArgs e)
 {
     progressIndicator = StatusBar.GetForCurrentView().ProgressIndicator;
     progressIndicator.Text = "Daxil olunur";
     await progressIndicator.ShowAsync();
     await Authentication.Current.Login(EmailBox.Text, PasswordBox.Password);
     await NavigateToHome();
     await progressIndicator.HideAsync();
 }
コード例 #9
0
        async private void GetDataFromWeb()
        {
            progressbar.Text = "Fetching new data";
            progressbar.ShowAsync();

            var client = new HttpClient();

            if (!localSettings.Containers.ContainsKey("userInfo"))
            {
                MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu.");
                await msgbox.ShowAsync();

                Frame.Navigate(typeof(Settings));
                return;
            }

            var lastcheck = localSettings.Containers["userInfo"].Values["lastcheckproblems"].ToString();

            Debug.WriteLine(System.Uri.EscapeUriString(lastcheck));
            var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/query/data?Timestamp=" + System.Uri.EscapeUriString(lastcheck) + "&Table=Problems"));

            var result = await response.Content.ReadAsStringAsync();

            result = result.Trim(new Char[] { '"' });
            Debug.WriteLine(result);

            DatabaseProblem Db_Helper = new DatabaseProblem();

            try
            {
                List <Problems> newprobs = JsonConvert.DeserializeObject <List <Problems> >(result);
                foreach (Problems prob in newprobs)
                {
                    try
                    {
                        Db_Helper.InsertProblem(prob);
                    }
                    catch
                    {
                        Debug.WriteLine("DB error for item of id: " + prob.Id);
                    }
                }
                localSettings.Containers["userInfo"].Values["lastcheckproblems"] = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ssZ");
                progressbar.Text = "New items";
            }
            catch
            {
                Debug.WriteLine("No new items");
                progressbar.Text = "No New items";
            }
            finally
            {
                assignToListBox();
            }
            progressbar.HideAsync();
        }
コード例 #10
0
        async void ChosePlayer_Loaded(object sender, RoutedEventArgs e)
        {
            if (PlayersListBox.ItemsSource != null)
            {
                return;
            }

            ProgresIndicator.Text = "Trwa łączenie z bazą danych";
            await ProgresIndicator.ShowAsync();
        }
コード例 #11
0
        async void EditTeam_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (PlayersListBox.ItemsSource != null)
            {
                return;
            }

            ProgresIndicator.Text = "Trwa łączenie z bazą danych";
            await ProgresIndicator.ShowAsync();
        }
コード例 #12
0
 public async static Task SetStatusBarProgressIndicator(double?progressValue, string text)
 {
     if (!IfCanModifyStatusBar)
     {
         return;
     }
     progressIndicator.ProgressValue = progressValue;
     progressIndicator.Text          = text;
     await progressIndicator.ShowAsync();
 }
コード例 #13
0
        async void StatsWindow_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (SetViewModel.Instance.SetsCollection != null)
            {
                return;
            }

            ProgresIndicator.Text = "Trwa łączenie z bazą danych";
            await ProgresIndicator.ShowAsync();
        }
コード例 #14
0
        async void ChoseTeamDialog_Loaded(object sender, RoutedEventArgs e)
        {
            TeamsViewModel.Instance.RefreshTeams();
            if (ChoseTeamListView.ItemsSource != null)
            {
                return;
            }

            ProgresIndicator.Text = "Trwa łączenie z bazą danych";
            await ProgresIndicator.ShowAsync();
        }
コード例 #15
0
 private static async Task SetVisibility(StatusBarProgressIndicator progressIndicator, bool isVisible)
 {
     if (isVisible)
     {
         await progressIndicator.ShowAsync();
     }
     else
     {
         await progressIndicator.HideAsync();
     }
 }
コード例 #16
0
        private async Task populateSolvedData()
        {
            progressbar.Text = "Fetching data";
            progressbar.ShowAsync();

            var client   = new HttpClient();
            var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/users/getuserdata?Username="******"")
                    {
                        values.Add(Convert.ToInt32(value));
                        Debug.WriteLine("Adding " + value + " to list");
                    }
                }
                string serialized = JsonConvert.SerializeObject(values);
                localSettings.Containers["userInfo"].Values["PPsolved"] = serialized;
                localSettings.Containers["userInfo"].Values["Points"]   = udata[0].Points;

                Debug.WriteLine("Points: " + (int)localSettings.Containers["userInfo"].Values["Points"]);

                var ubox = FindChildControl <TextBlock>(LayoutRoot, "username_box") as TextBlock;
                Debug.WriteLine("u");
                var pbox = FindChildControl <TextBlock>(LayoutRoot, "points_box") as TextBlock;
                Debug.WriteLine("p");
                var sbox = FindChildControl <TextBlock>(LayoutRoot, "pp_box") as TextBlock;
                Debug.WriteLine("s");
                var tbox = FindChildControl <TextBlock>(LayoutRoot, "time_box") as TextBlock;
                Debug.WriteLine("t");
                ubox.Text = username;
                Debug.WriteLine("xu");
                pbox.Text = "Points: " + udata[0].Points.ToString();
                Debug.WriteLine("xp");
                tbox.Text = "Time spent coding: " + time;
                Debug.WriteLine("xt");
                sbox.Text = "Practice problems solved: " + count.ToString();
                Debug.WriteLine("xs");
            }
            catch
            {
                Debug.WriteLine("error");
            }
            progressbar.HideAsync();
        }
コード例 #17
0
#pragma warning disable 1998
        public static async void ShowProgressBar(String label)
        {
#if WINDOWS_PHONE_APP
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                                                          async() =>
            {
                StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
                progressbar.Text = label;
                await progressbar.ShowAsync();
            }
                                                                          );
#endif
        }
コード例 #18
0
        static partial void OnIsVisibleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            bool isVisible = (bool)e.NewValue;

            if (isVisible)
            {
                AsyncHelpers.RunSync(async() => await _progressIndicator.ShowAsync());
            }
            else
            {
                AsyncHelpers.RunSync(async() => await _progressIndicator.HideAsync());
            }
        }
コード例 #19
0
        private async void ToggleProgressBar(bool toggle, string message = "")
        {
            StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;

            if (toggle)
            {
                progressbar.Text = message;
                await progressbar.ShowAsync();
            }
            else
            {
                await progressbar.HideAsync();
            }
        }
コード例 #20
0
        /// <summary>
        /// Rellena la página con el contenido pasado durante la navegación.  Cualquier estado guardado se
        /// proporciona también al crear de nuevo una página a partir de una sesión anterior.
        /// </summary>
        /// <param name="sender">
        /// El origen del evento; suele ser <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Datos de evento que proporcionan tanto el parámetro de navegación pasado a
        /// <see cref="Frame.Navigate(Type, Object)"/> cuando se solicitó inicialmente esta página y
        /// un diccionario del estado mantenido por esta página durante una sesión
        /// anterior. El estado será null la primera vez que se visite una página.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            var sb = StatusBar.GetForCurrentView();
            StatusBarProgressIndicator progress = sb.ProgressIndicator;

            progress.Text = "Downloading Processes...";
            progress.ShowAsync();
            if (!App.ViewModel.IsDataLoaded)
            {
                await App.ViewModel.LoadData();
            }
            DataContext = App.ViewModel;
            progress.HideAsync();
        }
コード例 #21
0
        private static async Task ToggleProgressBar(bool show)
        {
            StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;

            if (show)
            {
                progressbar.Text = "Loading...";
                await progressbar.ShowAsync();
            }
            else
            {
                progressbar.Text = string.Empty;
                await progressbar.HideAsync();
            }
        }
コード例 #22
0
        public static async void ManageSystemTray(bool isActive, string message = "Loading...")
        {
#if WINDOWS_PHONE_APP
            StatusBarProgressIndicator progressIndicator = StatusBar.GetForCurrentView().ProgressIndicator;
            progressIndicator.Text = message;
            if (isActive)
            {
                await progressIndicator.ShowAsync();
            }
            else
            {
                await progressIndicator.HideAsync();
            }
#endif
        }
コード例 #23
0
        protected async void OnDataRequested(DataTransferManager sender, DataRequestedEventArgs e)
        {
            var request  = e.Request;
            var deferral = request.GetDeferral();

            await _progressbar.ShowAsync();

            e.Request.Data.Properties.Title = _device.Name;
            var txt = await DumpDeviceInfo();

            e.Request.Data.SetText(txt);

            deferral.Complete();

            await _progressbar.HideAsync();
        }
コード例 #24
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(viewModel.MasterPassword) && !String.IsNullOrEmpty(viewModel.UserName))
            {
                viewModel.EditIsEnabled = false;
                StatusBarProgressIndicator statusBarIndicator = StatusBar.GetForCurrentView().ProgressIndicator;
                StatusBar.GetForCurrentView().ForegroundColor = Windows.UI.Colors.White;
                statusBarIndicator.Text = "Master Key is derived...";

                await statusBarIndicator.ShowAsync();

                await MasterKey.CreateMasterKeyAsync(viewModel.MasterPassword, viewModel.UserName);

                StatusBar.GetForCurrentView().BackgroundColor = Windows.UI.Colors.Green;
                statusBarIndicator.Text = "Derivation complete! Login successful";
                Frame.Navigate(typeof(SitePage), viewModel.UserName);
            }
        }
コード例 #25
0
ファイル: AppBar.cs プロジェクト: martinbojnansky/UWPTemplate
        public async Task ShowMobileProgressIndicatorAsync(string text = "")
        {
            if (ApiInformation.IsTypePresent(typeof(StatusBar).FullName))
            {
                var statusBar = StatusBar.GetForCurrentView();

                if (statusBar != null)
                {
                    StatusBarProgressIndicator progressIndicator = statusBar.ProgressIndicator;

                    if (!String.IsNullOrEmpty(text))
                    {
                        progressIndicator.Text = text;
                    }

                    await progressIndicator.ShowAsync();
                }
            }
        }
コード例 #26
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
            await progressbar.ShowAsync();

            if ((e.Parameter != null) && (e.Parameter.GetType() == typeof(GattDeviceService)))
            {
                _service = ((GattDeviceService)e.Parameter);
                this.lblDeviceName.Text     = _service.Device.Name;
                this.lblServiceName.Text    = (string)_conv.Convert(_service.Uuid, typeof(string), null, null);
                this.lblServiceAddress.Text = _service.Uuid.ToString();

                _characteristics = new List <CharacteristicWithValue>();
                foreach (var c in _service.GetAllCharacteristics())
                {
                    var val = new CharacteristicWithValue();
                    val.GattCharacteristic = c;


                    if (((int)c.CharacteristicProperties & (int)GattCharacteristicProperties.Read) != 0)
                    {
                        try
                        {
                            GattReadResult readResult = await c.ReadValueAsync();

                            if (readResult.Status == GattCommunicationStatus.Success)
                            {
                                val.Value = new byte[readResult.Value.Length];
                                DataReader.FromBuffer(readResult.Value).ReadBytes(val.Value);
                            }
                        }
                        catch { }
                    }
                    _characteristics.Add(val);
                }

                lstCharacteristics.ItemsSource = _characteristics;
            }

            this.navigationHelper.OnNavigatedTo(e);
            await progressbar.HideAsync();
        }
コード例 #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="text"></param>
        public async static void ShowStatusBarProgressIndicator(string text = "")
        {
            //Mobile customization
            if (ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
            {
                var statusBar = StatusBar.GetForCurrentView();

                if (statusBar != null)
                {
                    StatusBarProgressIndicator progressIndicator = statusBar.ProgressIndicator;

                    if (!String.IsNullOrEmpty(text))
                    {
                        progressIndicator.Text = text;
                    }

                    await progressIndicator.ShowAsync();
                }
            }
        }
コード例 #28
0
        async void RefreshDeviceList()
        {
            StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
            await progressbar.ShowAsync();

            try
            {
                bleDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromUuid(GattServiceUuids.GenericAccess));


                if (bleDevices.Count == 0)
                {
                    await new MessageDialog("No BLE devices were found or bluetooth disabled. Pair the device", "Info").ShowAsync();
                    Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings-bluetooth:", UriKind.RelativeOrAbsolute));
                }
                lstDevices.ItemsSource   = bleDevices;
                lstDevices.SelectedIndex = -1;
                // lstServices.ItemsSource = new List<string>();
            }
            catch { }
            await progressbar.HideAsync();
        }
コード例 #29
0
        private async void send(object sender, RoutedEventArgs e)
        {
            progressbar.Text = "Sending contribution";
            progressbar.ShowAsync();

            var client = new Windows.Web.Http.HttpClient();

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (!localSettings.Containers.ContainsKey("userInfo"))
            {
                MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu.");
                await msgbox.ShowAsync();

                progressbar.HideAsync();
                Frame.Navigate(typeof(Settings));
                return;
            }

            var username = localSettings.Containers["userInfo"].Values["userName"].ToString();

            HttpStringContent content = new HttpStringContent(
                "{ \"Username\": \"" + username + "\", \"Category\": \"" + category_box.Text + "\", \"Title\": \"" + title_box.Text + "\", \"Content\": \"" + content_box.Text + "\", \"AdditionalContent\": \"" + add_box.Text + "\" }",
                UnicodeEncoding.Utf8,
                "application/json");

            Debug.WriteLine(content);

            var uri = new Uri("http://codeinn-acecoders.rhcloud.com:8000/contribute");

            var response = await client.PostAsync(uri, content);

            var result = await response.Content.ReadAsStringAsync();

            MessageDialog msgbox1 = new MessageDialog(result + " Thanks a lot!");
            await msgbox1.ShowAsync();

            progressbar.HideAsync();
        }
コード例 #30
0
        private async Task <ObservableCollection <Song> > GetLibraryCollection()
        {
            SocketClient client = new SocketClient();

            StatusBar statusbar = StatusBar.GetForCurrentView();

            StatusBarProgressIndicator progressIndicator = statusbar.ProgressIndicator;

            progressIndicator.Text = "Loading library...";
            await statusbar.ShowAsync();

            await progressIndicator.ShowAsync();

            // Get all songs in the song library with metadata
            string response = await client.Command("listallinfo");

            ObservableCollection <Song> library = FormatLibrary(response);

            await progressIndicator.HideAsync();

            return(library);
        }
コード例 #31
0
        async private void GetDataFromWeb()
        {
            progressbar.Text = "Fetching new data";
            progressbar.ShowAsync();

            var client = new HttpClient();

            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (!localSettings.Containers.ContainsKey("userInfo"))
            {
                MessageDialog msgbox = new MessageDialog("Please log-in first. Go to settings from the main menu.");
                await msgbox.ShowAsync();

                progressbar.HideAsync();
                Frame.Navigate(typeof(Settings));
                return;
            }

            var response = await client.GetAsync(new Uri("http://codeinn-acecoders.rhcloud.com:8000/leaderboard"));

            var result = await response.Content.ReadAsStringAsync();

            result = result.Trim(new Char[] { '"' });
            Debug.WriteLine(result);

            try
            {
                List <LeaderboardItem> leaders = JsonConvert.DeserializeObject <List <LeaderboardItem> >(result);
                progressbar.Text    = "New items";
                listBox.ItemsSource = leaders.OrderByDescending(i => i.Points).ToList();
            }
            catch
            {
                progressbar.Text = "Error";
            }
            progressbar.HideAsync();
        }
コード例 #32
0
        private async void RefreshAlarms()
        {
            StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;

            progressbar.Text = "Loading Alarms";
            await progressbar.ShowAsync();

            HttpClient client = new HttpClient();

            string response = await client.GetStringAsync(new Uri("https://timeprovider.azurewebsites.net/Api.ashx?action=get-alarms"));

            this.Alarms.Clear();
            var alarms = JsonConvert.DeserializeObject <List <AlarmViewModel> >(response);

            foreach (var alarm in alarms)
            {
                this.Alarms.Add(alarm);
            }

            this.AlarmsListView.ItemsSource = this.Alarms;

            await progressbar.HideAsync();
        }
コード例 #33
0
        private async Task getNewsFeed()
        {
            progressIndicator = StatusBar.GetForCurrentView().ProgressIndicator;
            progressIndicator.Text = "Yüklənir";
            await progressIndicator.ShowAsync();
            client = new HttpClient();
            try
            {
                response = await client.GetAsync(newsFeedUrl + "?userId=" + Authentication.currentUser + "&token=" + Authentication.token + "&offset=" + offset);
                string msg = await response.Content.ReadAsStringAsync();
                Windows.Data.Json.JsonArray jsonArray = Windows.Data.Json.JsonArray.Parse(msg);

                IAsyncAction asyncAction = Windows.System.Threading.ThreadPool.RunAsync(
                async (workItem) =>
                {
                    foreach (var postItem in jsonArray)
                    {
                        await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                                            CoreDispatcherPriority.High,
                                            new DispatchedHandler(() =>
                                            {
                                                Windows.Data.Json.JsonArray array2 = postItem.GetArray();
                                                string array = array2.Stringify();
                                                string userid = array2.GetNumberAt(0).ToString();
                                                string post = array2.GetStringAt(1);
                                                string posterName = array2.GetStringAt(2);
                                                string url;
                                                try
                                                {
                                                    url = array2.GetStringAt(3);
                                                }
                                                catch (Exception ex)
                                                {
                                                    url = "";
                                                }
                                                double likes = array2.GetNumberAt(4);
                                                double comments = array2.GetNumberAt(5);
                                                PostProfileUpdate prUpdate = new PostProfileUpdate(url, posterName, post, Convert.ToInt32(likes), Convert.ToInt32(comments));
                                                NewsFeedList.Items.Add(prUpdate);
                                            }));
                    }
                });
            }
            catch (HttpRequestException ex)
            {
                throw new Exception(ex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                client = null;
                response = null;
                await progressIndicator.HideAsync();
                isLoadingNewsFeed = false;
            }
        }