Example #1
0
        private async Task GetResults()
        {
            try
            {
                string url = "http://app.bilibili.com/x/splash?plat=0&build=414000&channel=master&width=1080&height=1920";
                bool   pc  = SettingHelper.IsPc();
                if (pc)
                {
                    img.Stretch = Stretch.Uniform;
                    url         = "http://app.bilibili.com/x/splash?plat=0&build=414000&channel=master&width=1920&height=1080";
                }

                string Result = await WebClientClass.GetResults(new Uri(url));

                LoadModel obj = JsonConvert.DeserializeObject <LoadModel>(Result);

                if (obj.code == 0)
                {
                    if (obj.data.Count != 0)
                    {
                        var buff = await WebClientClass.GetBuffer(new Uri(obj.data[0].image));

                        BitmapImage bit = new BitmapImage();
                        await bit.SetSourceAsync(buff.AsStream().AsRandomAccessStream());

                        if (!pc)
                        {
                            if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
                            {
                                var applicationView = ApplicationView.GetForCurrentView();
                                applicationView.SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

                                // StatusBar.GetForCurrentView().HideAsync();
                                StatusBar statusBar = StatusBar.GetForCurrentView();
                                statusBar.ForegroundColor   = Colors.Gray;
                                statusBar.BackgroundColor   = Color.FromArgb(255, 55, 63, 76);
                                statusBar.BackgroundOpacity = 0;
                            }
                        }
                        else
                        {
                            img_bg.Source = bit;
                            InitializedFrostedGlass(GlassHost);
                        }
                        img.Source = bit;
                        _url       = obj.data[0].param;
                        maxnum     = 5;
                        //await Task.Delay(3000);
                        //this.Frame.Navigate(typeof(MainPage), m);
                    }
                    else
                    {
                        // await Task.Delay(2000);
                    }
                }
                else
                {
                    // await Task.Delay(2000);
                    //this.Frame.Navigate(typeof(MainPage), m);
                }
            }
            catch (Exception)
            {
                // await Task.Delay(2000);
                //this.Frame.Navigate(typeof(MainPage), m);
            }
            finally
            {
            }
        }