Пример #1
0
        private Grid CreateImageView(double width, MoreChannel template, double height)
        {
            VideoViewModel videoData = new VideoViewModel
            {
                width     = (int)width,
                hight     = (int)height,
                name      = template.name,
                videoId   = template.videoId,
                picUrl    = template.image,
                tag       = template.tag,
                playCount = template.playCount
            };

            if (string.IsNullOrEmpty(xaml))
            {
                using (Stream stream = Application.GetResourceStream(new Uri("/MangGuoTv;component/Views/MoreChannelImageView.xaml", UriKind.Relative)).Stream)
                {
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        xaml = reader.ReadToEnd();
                    }
                }
            }
            Grid imageGrid = (Grid)XamlReader.Load(xaml);

            imageGrid.Width       = width;
            imageGrid.Height      = height;
            imageGrid.DataContext = videoData;
            imageGrid.Tap        += new EventHandler <System.Windows.Input.GestureEventArgs>(GridImage_Tap);
            return(imageGrid);
        }
Пример #2
0
        private void AddChannelView(List <MoreChannel> list, double gridImageHeight, int lineCount)
        {
            stackPanel.Children.Clear();
            Grid myGrid = new Grid();

            myGrid.Height = gridImageHeight * Math.Ceiling((double)list.Count / lineCount);
            myGrid.HorizontalAlignment = HorizontalAlignment.Center;
            myGrid.ShowGridLines       = false;
            // Define the Columns
            for (int i = 0; i < lineCount; i++)
            {
                ColumnDefinition colDef = new ColumnDefinition();
                myGrid.ColumnDefinitions.Add(colDef);
            }
            for (int i = 0; i < Math.Ceiling((double)list.Count / lineCount); i++)
            {
                RowDefinition rowDef = new RowDefinition();
                myGrid.RowDefinitions.Add(rowDef);
            }


            for (int i = 0; i < list.Count; i++)
            {
                MoreChannel template   = list[i];
                double      imageWidth = (double)(PopupManager.screenWidth - 20 - 5 * lineCount) / lineCount;
                Grid        imageGrid  = CreateImageView(imageWidth, template, gridImageHeight - 10);
                imageGrid.Margin = new Thickness(5, 5, 5, 5);
                Grid.SetColumn(imageGrid, i % lineCount);
                Grid.SetRow(imageGrid, i / lineCount);
                myGrid.Children.Add(imageGrid);
            }
            stackPanel.Children.Add(myGrid);
            stackPanel.Children.Add(addTipGrid);
            scrollView.ScrollToVerticalOffset(0);
        }
Пример #3
0
        private void HotSearch_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MoreChannel template = HotSearch.SelectedItem as MoreChannel;

            if (template != null && !string.IsNullOrEmpty(template.name))
            {
                BeginSearch(template.name);
            }
        }
Пример #4
0
        private void SerachInfo_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            MoreChannel template = SerachInfo.SelectedItem as MoreChannel;

            if (template != null)
            {
                App.PlayerModel.VideoId     = template.videoId;
                App.PlayerModel.currentType = ViewModels.PlayerViewModel.PlayType.VideoType;
                this.NavigationService.Navigate(new Uri(CommonData.PlayerPageName, UriKind.Relative));
            }
        }
Пример #5
0
 private Grid CreateImageView(double width, MoreChannel template, double height)
 {
     VideoViewModel videoData = new VideoViewModel
     {
         width = (int)width,
         hight = (int)height,
         name = template.name,
         videoId = template.videoId,
         picUrl = template.image,
         tag = template.tag,
         playCount = template.playCount
     };
     if (string.IsNullOrEmpty(xaml))
     {
         using (Stream stream = Application.GetResourceStream(new Uri("/MangGuoTv;component/Views/MoreChannelImageView.xaml", UriKind.Relative)).Stream)
         {
             using (StreamReader reader = new StreamReader(stream))
             {
                 xaml = reader.ReadToEnd();
             }
         }
     }
     Grid imageGrid = (Grid)XamlReader.Load(xaml);
     imageGrid.Width = width;
     imageGrid.Height = height;
     imageGrid.DataContext = videoData;
     imageGrid.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(GridImage_Tap);
     return imageGrid;
 }
Пример #6
0
        private void LoadChannelCompleted(IAsyncResult ar)
        {
            string result = HttpHelper.SyncResultTostring(ar);

            if (result != null)
            {
                MoreChannelResult channelDetails = null;
                try
                {
                    channelDetails = JsonConvert.DeserializeObject <MoreChannelResult>(result);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("LoadChannelCompleted   json 解析错误" + ex.Message);
                    App.HideLoading();
                }
                if (channelDetails != null && channelDetails.err_code == HttpHelper.rightCode)
                {
                    this.Dispatcher.BeginInvoke(() =>
                    {
                        App.HideLoading();
                        //loadGrid.Visibility = Visibility.Collapsed;
                        ////if (pageCount > 0)
                        ////{
                        ////    stackPanel.Children.Remove(addTipGrid);
                        ////}
                        //AddChannelView(channelDetails.data, 200, 2);
                        List <VideoViewModel> TemplateListData = new List <VideoViewModel>();

                        for (int i = 0; i < channelDetails.data.Count; i = i + 2)
                        {
                            if (channelDetails.data.Count > i + 1)
                            {
                                MoreChannel template1    = channelDetails.data[i];
                                MoreChannel template2    = channelDetails.data[i + 1];
                                VideoViewModel videoData = new VideoViewModel
                                {
                                    //stupid func
                                    name     = template1.name,
                                    tag      = template1.tag,
                                    desc     = template1.desc,
                                    picUrl   = template1.image,
                                    videoId  = template1.videoId,
                                    name1    = template2.name,
                                    tag1     = template2.tag,
                                    desc1    = template2.desc,
                                    videoId1 = template2.videoId,
                                    picUrl1  = template2.image,
                                };
                                TemplateListData.Add(videoData);
                            }
                            else
                            {
                                MoreChannel template1    = channelDetails.data[i];
                                VideoViewModel videoData = new VideoViewModel
                                {
                                    name    = template1.name,
                                    tag     = template1.tag,
                                    desc    = template1.desc,
                                    videoId = template1.videoId,
                                };
                                TemplateListData.Add(videoData);
                            }
                        }
                        moreChannelInfo.ItemsSource = TemplateListData;
                        pageCount++;
                    });
                }
            }
            else
            {
                //App.ShowToast("获取数据失败,请检查网络或重试");
                App.HideLoading();
                this.Dispatcher.BeginInvoke(() =>
                {
                    reLoadGrid.Visibility = Visibility.Visible;
                });
            }
        }