private async void ListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            try
            {
                Frame          fr  = this.Parent as Frame;
                Grid           gr1 = e.ClickedItem as Grid;
                Model.Download cl  = gr1.DataContext as Model.Download;
                Uri = cl.video_uri;
                string[] str      = cl.video_uri.Split('/');
                string   filename = str[str.Length - 1];
                string   Path     = @"C:\Users\Jin\AppData\Local\Packages\39360532-96e5-4fa1-98dd-49dc39195039_bphk9g7bbxc1j\LocalCache\" + filename;
                Uri      uri      = new Uri(Path);
                if (Grid.GetColumnSpan(fr) == 2)
                {
                    if (this.Frame != null)
                    {
                        fr.Navigate(typeof(SecondFrame));
                        SecondFrame  sf1    = fr.Content as SecondFrame;
                        Grid         gr2    = sf1.Content as Grid;
                        Grid         gr3    = gr2.Children[1] as Grid;
                        MediaElement Player = gr3.Children[0] as MediaElement;
                        Player.Source = uri;
                    }
                    return;
                }
                else
                {
                    Grid     gr2      = fr.Parent as Grid;
                    Grid     gr3      = gr2.Parent as Grid;
                    MainPage mainpage = gr3.Parent as MainPage;
                    Grid     gr4      = mainpage.Content as Grid;
                    Grid     gr5      = gr4.Children[0] as Grid;
                    Frame    fr1      = gr5.Children[0] as Frame;
                    if (this.Frame != null)
                    {
                        fr1.Navigate(typeof(SecondFrame));
                    }
                    SecondFrame  fr2     = fr1.Content as SecondFrame;
                    Grid         gr6     = fr2.Content as Grid;
                    Grid         gr7     = gr6.Children[1] as Grid;
                    MediaElement player1 = gr7.Children[0] as MediaElement;

                    player1.Source = uri;
                }
            }
            catch (Exception)
            {
                var dialog = new MessageDialog("打开失败", "yoho");
                dialog.Commands.Add(new UICommand("确定", cmd => { }));
                dialog.Commands.Add(new UICommand("重新下载", new UICommandInvokedHandler(this.CommandInvokedHandler)));
                await dialog.ShowAsync();
            }
        }
예제 #2
0
        private void MyListView_ItemClick(object sender, ItemClickEventArgs e)
        {
            ListView    lv   = sender as ListView;
            Contentlist cl   = e.ClickedItem as Contentlist;
            Uri         uri  = new Uri(cl.video_uri);
            Grid        gr1  = lv.Parent as Grid;
            Grid        gr2  = gr1.Parent as Grid;
            Home        home = gr2.Parent as Home;
            Frame       fr   = home.Parent as Frame;

            if (Grid.GetColumnSpan(fr) == 2)
            {
                if (this.Frame != null)
                {
                    fr.Navigate(typeof(SecondFrame));
                    SecondFrame  sf2     = fr.Content as SecondFrame;
                    Grid         gr6     = sf2.Content as Grid;
                    Grid         gr7     = gr6.Children[1] as Grid;
                    MediaElement player2 = gr7.Children[0] as MediaElement;
                    player2.Source = uri;
                }
                return;
            }
            Grid         gr3    = fr.Parent as Grid;
            Frame        fr2    = gr3.Children[0] as Frame;
            SecondFrame  sf     = fr2.Content as SecondFrame;
            Grid         gr4    = sf.Content as Grid;
            Grid         gr5    = gr4.Children[1] as Grid;
            MediaElement player = gr5.Children[0] as MediaElement;

            player.Source = uri;
            sqliteHelper1.CreateDB();
            List <Model.History> His = sqliteHelper1.CheckData(cl.name);

            Model.History AddHistory = new Model.History();
            AddHistory.name          = cl.name;
            AddHistory.love          = cl.love;
            AddHistory.hate          = cl.hate;
            AddHistory.profile_image = cl.profile_image;
            AddHistory.text          = cl.text;
            AddHistory.video_uri     = cl.video_uri;
            AddHistory.create_time   = cl.create_time;
            AddHistory.time          = DateTime.Now.ToString();
            sqliteHelper1.AddData(AddHistory);
        }