示例#1
0
        private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            if (podcast.Subscribed)
            {
                if (podcast.Count < 1)
                {
                    MainPage.Current.PopMessage("No enough podcast");
                    return;
                }

                var def = args.GetDeferral();

                var i = 0;
                var s = podcast[i];
                if (s.IsVideo)
                {
                    var videoWindowID = 0;
                    await CoreApplication.CreateNewView().Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        var frame     = new Frame();
                        videoWindowID = ApplicationView.GetForCurrentView().Id;
                        frame.Navigate(typeof(VideoPodcast), s.FilePath);
                        Window.Current.Content = frame;
                        Window.Current.Activate();
                        ApplicationView.GetForCurrentView().Title = s.Title;
                        CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
                        var titleBar = ApplicationView.GetForCurrentView().TitleBar;
                        titleBar.ButtonBackgroundColor         = Colors.Transparent;
                        titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
                        titleBar.ButtonHoverBackgroundColor    = Color.FromArgb(0x33, 0x00, 0x00, 0x00);
                        titleBar.ButtonForegroundColor         = Colors.Black;
                        titleBar.ButtonHoverForegroundColor    = Colors.White;
                        titleBar.ButtonInactiveForegroundColor = Colors.Gray;
                    });

                    bool viewShown = await ApplicationViewSwitcher.TryShowAsStandaloneAsync(videoWindowID);

                    return;
                }
                if (podcast.Count < i + 20)
                {
                    var k = podcast.Count < 20 ? podcast.ToList() : podcast.GetRange(podcast.Count - 20, 20);
                    await MainPageViewModel.Current.InstantPlayAsync(k, k.IndexOf(s));
                }
                else
                {
                    await MainPageViewModel.Current.InstantPlayAsync(podcast.GetRange(i, 20), 0);
                }

                def.Complete();
            }
            else
            {
                podcast.Subscribed = true;
                await podcast.SaveAsync();

                MainPage.Current.PopMessage(string.Format(podcast.Subscribed ? Consts.Localizer.GetString("PodcastSubscribe") : Consts.Localizer.GetString("PodcastUnSubscribe"), podcast.Title));
            }
        }