zoukankan      html  css  js  c++  java
  • 豆瓣电台WP7客户端 开发记录6

    今天把导航改成HubTile模式了,见图:

     

    XAML:

    <Grid x:Name="ContentPanel" Grid.Row="1" 
                   HorizontalAlignment
    ="Left"
                   VerticalAlignment
    ="Center"
                  Margin
    ="10,0,10,0">
                
    <Grid.ColumnDefinitions>
                    
    <ColumnDefinition/>
                    
    <ColumnDefinition/>
                
    </Grid.ColumnDefinitions>
                
    <Grid.RowDefinitions>
                    
    <RowDefinition Height="Auto"/>
                    
    <RowDefinition Height="Auto"/>
                    
    <RowDefinition Height="Auto"/>
                
    </Grid.RowDefinitions>
                
    <toolkit:HubTile Grid.Row="0" Grid.Column="0" 
                                  Margin
    ="12,12,0,0"
                                 x:Name
    ="HY"  ManipulationCompleted="ManipulationCompleted"/>
                
    <toolkit:HubTile Grid.Row="0" Grid.Column="1"
                                  Margin
    ="12,12,0,0"
                                 x:Name
    ="OM"  ManipulationCompleted="ManipulationCompleted"/>
                
    <toolkit:HubTile Grid.Row="1" Grid.Column="0"
                                  Margin
    ="12,12,0,0"
                                 x:Name
    ="RY"  ManipulationCompleted="ManipulationCompleted"/>
                
    <toolkit:HubTile Grid.Row="1" Grid.Column="1"
                                  Margin
    ="12,12,0,0"
                                  x:Name
    ="HanY"  ManipulationCompleted="ManipulationCompleted"/>
                
    <toolkit:HubTile Grid.Row="2" Grid.Column="0"
                                  Margin
    ="12,12,0,0"
                                  x:Name
    ="YY" ManipulationCompleted="ManipulationCompleted" />
                
    <toolkit:HubTile Grid.Row="2" Grid.Column="1"
                                 Margin
    ="12,12,0,0" 
                                  x:Name
    ="FAV"  ManipulationCompleted="ManipulationCompleted" />

    </Grid> 

    cs:读取所有频道第一首歌的专辑封面

      1  public ChannelTile()
      2         {
      3             InitializeComponent();
      4             TouchPanel.EnabledGestures = GestureType.Tap | GestureType.HorizontalDrag;
      5             if (!PlayListHelper.IsInited)
      6             {
      7                 PlayListHelper.InitChannelComplete += new Action(PlayListHelper_InitChannelComplete);
      8                 PlayListHelper.InitChannel();//初始化播放列表
      9             }
     10         }
     11 
     12         /// <summary>
     13         /// 初始化tile的image跟title
     14         /// </summary>
     15         void PlayListHelper_InitChannelComplete()
     16         {
     17             var list = PlayListHelper.GetEachChannel1stSong();//获取所有频道的第一首歌曲
     18             var song = list.Where(s => s.channel == (int)ChannelType.华语).ToList();
     19             if (song != null && song.Count > 0)
     20             {
     21                 var s = song[0];
     22                 HY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     23                 HY.Title = ChannelType.华语.ToString();
     24                 HY.Message=s.artist+"-"+s.title;
     25             }
     26             else
     27             {
     28                 
    HY.Title = ChannelType.华语.ToString();
     29                 
    HY.Message = "No Song!";
     30             }
     31 
     32 
     33             song = list.Where(s => s.channel == (int)ChannelType.欧美).ToList();
     34             if (song != null && song.Count > 0)
     35             {
     36                 var s = song[0];
     37                 OM.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     38                 OM.Title = ChannelType.欧美.ToString();
     39                 OM.Message = s.artist + "-" + s.title;
     40             }
     41             else
     42             {
     43                 OM.Title = ChannelType.欧美.ToString();
     44                 OM.Message = "No Song!";
     45             }
     46 
     47 
     48             song = list.Where(s => s.channel == (int)ChannelType.韩语).ToList();
     49             if (song != null && song.Count > 0)
     50             {
     51                 var s = song[0];
     52                 HanY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     53                 HanY.Title = ChannelType.韩语.ToString();
     54                 HanY.Message = s.artist + "-" + s.title;
     55             }
     56             else
     57             {
     58                 HanY.Title = ChannelType.韩语.ToString();
     59                 HanY.Message = "No Song!";
     60             }
     61 
     62             song = list.Where(s => s.channel == (int)ChannelType.日语).ToList();
     63             if (song != null && song.Count > 0)
     64             {
     65                 var s = song[0];
     66                 RY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     67                 RY.Title = ChannelType.日语.ToString();
     68                 RY.Message = s.artist + "-" + s.title;
     69             }
     70             else
     71             {
     72                 RY.Title = ChannelType.日语.ToString();
     73                 RY.Message = "No Song!";
     74             }
     75 
     76             song = list.Where(s => s.channel == (int)ChannelType.粤语).ToList();
     77             if (song != null && song.Count > 0)
     78             {
     79                 var s = song[0];
     80                 YY.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     81                 YY.Title = ChannelType.粤语.ToString();
     82                 YY.Message = s.artist + "-" + s.title;
     83             }
     84             else
     85             {
     86                 YY.Title = ChannelType.粤语.ToString();
     87                 YY.Message = "No Song!";
     88             }
     89 
     90             song = list.Where(s => s.channel == (int)ChannelType.最爱).ToList();
     91             if (song != null&&song.Count>0)
     92             {
     93                 var s = song[0];
     94                 FAV.Source = new BitmapImage(new Uri(s.picture, UriKind.Absolute));
     95                 FAV.Title = ChannelType.最爱.ToString();
     96                 FAV.Message = s.artist + "-" + s.title;
     97             }
     98             else
     99             {
    100                 FAV.Title = ChannelType.最爱.ToString();
    101                 FAV.Message = "No Song!";
    102             }
    103                 

    104         }

    点击频道导航到MainPage:

     1 HubTile ht = sender as HubTile;  

    2 this.NavigationService.Navigate(new Uri("/MainPage.xaml?Channle=" + ht.Title, UriKind.Relative));

    QQ群:1022985150 VX:kklldog 一起探讨学习.NET技术
    作者:Agile.Zhou(kklldog)
    出处:http://www.cnblogs.com/kklldog/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    hdu 1280 排序水题
    hdu 3336 KMP+DP (仍不懂)
    懂点PS技巧,你会减少很多痛苦
    ajax返回值中有回车换行、空格的解决方法分享
    windows7系统下让所有文件夹都使用同一种视图的方法
    LINUX常用命令大全归纳篇
    js 运算符
    获取修改父页面元素
    while跟do...while的用法
    jQuery取得select选择的文本与值
  • 原文地址:https://www.cnblogs.com/kklldog/p/2172018.html
Copyright © 2011-2022 走看看