<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<UIX
  xmlns="http://schemas.microsoft.com/2007/uix"
  xmlns:iris="assembly://UIX/Microsoft.Iris"
  xmlns:zune="assembly://ZuneShell/ZuneUI"
  xmlns:data="res://ZuneShellResources!LibraryData.schema.xml"
  xmlns:spreadsheet="res://ZuneShellResources!SpreadSheetViewBase.uix"
  xmlns:style="res://ZuneShellResources!Style.uix"
  xmlns:styles="res://ZuneShellResources!Styles.uix"
  xmlns:lv="res://ZuneShellResources!ListViewPanel.uix"
  xmlns:core="res://ZuneShellResources!Controls.uix"
  xmlns:dialog="res://ZuneShellResources!Dialog.uix"
  xmlns:lib="res://ZuneShellResources!Library.uix"  
  xmlns:me="Me">


  
  <Class Name="TracksPanelListModel" Base="lib:LibraryListModel">
    <Properties>
      <Boolean Name="ShowTrackNumber" Boolean="$Required"/>
    </Properties>
  </Class>
  
  <Class Name="Constants" Shared="True">
    <Properties>
      <Inset Name="SyncCellPadding" Inset="2,2,0,0"/>
      <Inset Name="SyncHeaderPadding" Inset="4,1,0,0"/>
    </Properties>
  </Class>

  
  <Class Name="BrowseViewData" Shared="True">
    <Properties>

      

      <spreadsheet:ColumnInfo Name="TrackStatusColumn"
                CellType="{typeof(me:LibraryMediaStatusCell)}"
                Resizable="false"
                CellPadding="4,1,0,0"
                HighlightHeader="false">
        <ColumnSize>
          <SharedSize Size="21,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      <spreadsheet:ColumnInfo Name="TitleColumn"
            HeaderType="{typeof(me:BrowseViewSongHeader)}"
            CellType="{typeof(me:BrowseViewSongCell)}"
            CellEditType="{typeof(me:BrowseViewEditSongCell)}"
            Resizable="false"
            CellPadding="5,0,5,0"
            ShowDivider="false">
        <ColumnSize>
          <SharedSize Size="9999,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="Medium" MinimumSize="150,0"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      
      <spreadsheet:ColumnInfo Name="ArtistColumn"
            Header="{zune:Shell.LoadString(zune:StringId.IDS_ARTIST_COLUMN_HEADER)}"
            CellType="{typeof(me:ArtistCell)}"
            CellEditType="{typeof(me:ArtistEditCell)}"
            Resizable="false"
            Visible="false">
        <ColumnSize>
          <SharedSize Size="120,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      <spreadsheet:ColumnInfo Name="TimeColumn"
            Header="{zune:Shell.LoadString(zune:StringId.IDS_LENGTH_COLUMN_HEADER)}"
            CellType="{typeof(me:LengthCell)}"
            Resizable="false">
        <ColumnSize>
          <SharedSize Size="75,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      <spreadsheet:ColumnInfo Name="RatingColumn"
            Header="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_HEADER)}"
            HeaderIcon="{styles:Styles.RatingHeader}"
            CellType="{typeof(me:RatingCell)}"
            CellPadding="4,0,4,0"
            SortBy="{me:SortInfo.UserRating}"
            Resizable="false">
        <ColumnSize>
          <SharedSize Size="25,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      <spreadsheet:ColumnInfo Name="SyncColumn"
            Header="{zune:Shell.LoadString(zune:StringId.IDS_SYNC_STATUS_COLUMN_HEADER)}"
            HeaderIcon="{styles:Styles.SyncHeader}"
            CellType="{typeof(me:SyncCell)}"
            CellPadding="{me:Constants.SyncCellPadding}"
            HeaderPadding="{me:Constants.SyncHeaderPadding}"
            Resizable="false">
        <ColumnSize>
          <SharedSize Size="25,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>

      <spreadsheet:ColumnInfo Name="SizeOnDeviceColumn" Header="{zune:Shell.LoadString(zune:StringId.IDS_SIZE_COLUMN_HEADER)}"
               CellType="{typeof(me:SizeOnDeviceCell)}"
               Resizable="false">
        <ColumnSize>
          <SharedSize Size="75,0"/>
        </ColumnSize>
        <LayoutInput>
          <StackLayoutInput Priority="High"/>
        </LayoutInput>
      </spreadsheet:ColumnInfo>
      
      <spreadsheet:ColumnData Name="ColumnData" HideColumns="true">
        <Columns>
          
          <spreadsheet:ColumnInfo ColumnInfo="{TrackStatusColumn}"/>
          <spreadsheet:ColumnInfo ColumnInfo="{TitleColumn}"/>
          <spreadsheet:ColumnInfo ColumnInfo="{ArtistColumn}"/>
          
          <spreadsheet:ColumnInfo ColumnInfo="{RatingColumn}"/>
          <spreadsheet:ColumnInfo ColumnInfo="{SyncColumn}"/>
          <spreadsheet:ColumnInfo ColumnInfo="{SizeOnDeviceColumn}"/>
        </Columns>
      </spreadsheet:ColumnData>
    </Properties>
  </Class>

  <Class Name="DetailedViewData" Shared="True" >
    <Properties>
      
      <spreadsheet:ColumnData Name="ColumnData" SortedColumn="{me:SortInfo.Title}"
                              CanReorderColumns="true" FixedColumns="2" 
                              SaveKeyPrefix="TrackList" SaveColumnWidths="true" 
                              SaveColumnOrder="true" SaveColumnVisibility="true" >
        <Columns>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_STATUS_COLUMN_HEADER)}"
                         HeaderType="{typeof(spreadsheet:Cell)}"
                         CellType="{typeof(me:LibraryMediaStatusCell)}"
                         Resizable="false" Removable="false"
                         CellPadding="4,1,0,0" HighlightHeader="false">
            <ColumnSize>
              <SharedSize Size="21,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_SONG_COLUMN_HEADER)}"
                         CellType="{typeof(me:SongCell)}"
                         CellEditType="{typeof(me:SongEditCell)}"
                         CellPadding="5,0,5,0" 
                         SortBy="{me:SortInfo.Title}"
                         Removable="false"
                         ShowDivider="false">
            <ColumnSize>
              <SharedSize Size="200,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_ARTIST_COLUMN_HEADER)}"
                         CellType="{typeof(me:ArtistCell)}"
                         CellEditType="{typeof(me:ArtistEditCell)}"
                         SortBy="{me:SortInfo.DisplayArtist}">
            <ColumnSize>
              <SharedSize Size="150,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_ALBUM_COLUMN_HEADER)}"
                         CellType="{typeof(me:AlbumCell)}"
                         CellEditType="{typeof(me:AlbumEditCell)}"
                         SortBy="{me:SortInfo.WM_AlbumTitle}">
            <ColumnSize>
              <SharedSize Size="200,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_GENRE_COLUMN_HEADER)}"
                         CellType="{typeof(me:GenreCell)}"
                         CellEditType="{typeof(me:GenreEditCell)}"
                         SortBy="{me:SortInfo.WM_Genre}">
            <ColumnSize>
              <SharedSize Size="120,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_LENGTH_COLUMN_HEADER)}"
                         CellType="{typeof(me:LengthCell)}"
                         SortBy="{me:SortInfo.Duration}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="75,0" MinimumSize="50,0" MaximumSize="100,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_HEADER)}"
                         HeaderIcon="{styles:Styles.RatingHeader}"
                         CellType="{typeof(me:RatingCell)}"
                         SortBy="{me:SortInfo.UserRating}"
                         SortAscendingDefault="false"
                         CellPadding="4,0,4,0"
                         Resizable="false" Removable="false">
            <ColumnSize>
              <SharedSize Size="25,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_SYNC_STATUS_COLUMN_HEADER)}"
                        HeaderIcon="{styles:Styles.SyncHeader}"
                        CellType="{typeof(me:SyncCell)}"
                        SortBy="{null}"
                        CellPadding="{me:Constants.SyncCellPadding}"
                        HeaderPadding="{me:Constants.SyncHeaderPadding}"
                        Resizable="false" Removable="false">
            <ColumnSize>
              <SharedSize Size="25,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_DATE_ADDED_COLUMN_HEADER)}"
                         CellType="{typeof(me:DateAddedCell)}"
                         SortBy="{me:SortInfo.DateAdded}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="100,0" MinimumSize="50,0" MaximumSize="150,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_ALBUM_ARTIST_COLUMN_HEADER)}"
                         CellType="{typeof(me:AlbumArtistCell)}"
                         CellEditType="{typeof(me:AlbumArtistEditCell)}"
                         SortBy="{me:SortInfo.WM_AlbumArtist}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="150,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>
          
          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_CONTRIBUTING_ARTISTS_COLUMN_HEADER)}"
                         CellType="{typeof(me:ContributingArtistsCell)}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="150,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>
          
          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_DATE_LAST_PLAYED_COLUMN_HEADER)}"
                         CellType="{typeof(me:DateLastPlayedCell)}"
                         SortBy="{me:SortInfo.UserLastPlayedDate}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="100,0" MinimumSize="50,0" MaximumSize="150,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_PLAY_COUNT_COLUMN_HEADER)}"
                         CellType="{typeof(me:PlayCountCell)}"
                         SortBy="{me:SortInfo.UserPlayCount}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="60,0" MinimumSize="40,0" MaximumSize="100,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_SIZE_COLUMN_HEADER)}"
                         CellType="{typeof(me:FileSizeCell)}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="75,0" MinimumSize="50,0" MaximumSize="150,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_SONG_NUMBER_COLUMN_HEADER)}"
                         CellType="{typeof(me:TrackNumberCell)}"
                         SortBy="{me:SortInfo.WM_TrackNumber}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="60,0" MinimumSize="40,0" MaximumSize="100,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_RELEASE_YEAR_COLUMN_HEADER)}"
                         CellType="{typeof(me:ReleaseYearCell)}"
                         SortBy="{me:SortInfo.WM_Year}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="75,0" MinimumSize="50,0" MaximumSize="100,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_COMPOSER_COLUMN_HEADER)}"
                         CellType="{typeof(me:ComposerCell)}"
                         SortBy="{me:SortInfo.WM_Composer}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="100,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

      







          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_PROTECTED_COLUMN_HEADER)}"
                         CellType="{typeof(me:ProtectedCell)}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="40,0" MinimumSize="35,0" MaximumSize="75,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

      







          <spreadsheet:ColumnInfo Header="{zune:Shell.LoadString(zune:StringId.IDS_CONDUCTOR_COLUMN_HEADER)}"
                         CellType="{typeof(me:ConductorCell)}"
                         SortBy="{me:SortInfo.WM_Conductor}"
                         Visible="false">
            <ColumnSize>
              <SharedSize Size="100,0" MinimumSize="50,0" MaximumSize="500,0"/>
            </ColumnSize>
          </spreadsheet:ColumnInfo>

      







        </Columns>
      </spreadsheet:ColumnData>
      
    </Properties>
  </Class>

  
  <UI Name="BrowseViewSongHeader" Base="spreadsheet:Cell">
    <Properties>
      <me:TracksPanelListModel Name="ListModel" TracksPanelListModel="$Required"/>
    </Properties>
    <Scripts>
      <Script> Header.Sorts = [ListModel.Sorts]; </Script>
    </Scripts>
    <Content>
      <lv:ColumnPanelHeader Name="Header" ToggleSelectAll="{ListModel.ToggleSelectAllCommand}" Sorts="{ListModel.Sorts}"/>
    </Content>
  </UI>


  
  <UI Name="BrowseViewSongCell" Base="spreadsheet:NumberTitleCell">
    <Properties>
      <me:TracksPanelListModel Name="ListModel" TracksPanelListModel="$Required"/>
    </Properties>

    <Scripts>
      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(((data:Track)Model).TrackNumber)]
        [DeclareTrigger(((data:Track)Model).Title)]
      
        data:Track track = (data:Track)Model;
        Number = track.TrackNumber;
        Title = track.Title;
        AccessibleDescription = "{0} {1}".Format(track.TrackNumber, track.Title);
      </Script>

      <Script> ShowNumber = [ListModel.ShowTrackNumber]; </Script>
    </Scripts>
  </UI>

  
  <UI Name="BrowseViewEditSongCell" Base="spreadsheet:NumberTitleEditCell">
    <Properties>
      <me:TracksPanelListModel Name="ListModel" TracksPanelListModel="$Required"/>
    </Properties>

    <Scripts>
      <Script>
        data:Track track = (data:Track)Model;
        Number = track.TrackNumber;
        EditableText.Value = track.Title;
      </Script>

      <Script> ShowNumber = [ListModel.ShowTrackNumber]; </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Track)Model).Title = EditableText.Value;
      </Script>

    </Scripts>
  </UI>


  
  <UI Name="SongCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>Content = [((data:Media)Model).Title];</Script>
    </Scripts>
  </UI>

  
  <UI Name="SongEditCell" Base="spreadsheet:LabelEditCell">
    <Scripts>
      <Script>
        EditableText.Value = ((data:Media)Model).Title;
      </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Media)Model).Title = EditableText.Value;
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="TrackNumberCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).TrackNumber].ToString();</Script>
    </Scripts>
  </UI>

  
  <UI Name="ArtistCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).ArtistName];</Script>
    </Scripts>
  </UI>

  
  <UI Name="ArtistEditCell" Base="spreadsheet:LabelEditCell">
    <Scripts>
      <Script>
        EditableText.Value = ((data:Track)Model).ArtistName;
      </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Track)Model).ArtistName = EditableText.Value;
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="AlbumCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).AlbumName];</Script>
    </Scripts>
  </UI>


  <UI Name="AlbumEditCell" Base="spreadsheet:LabelEditCell">
    <Scripts>
      <Script>
        EditableText.Value = ((data:Track)Model).AlbumName;
      </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Track)Model).AlbumName = EditableText.Value;
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="GenreCell" Base="spreadsheet:FallbackCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).Genre];</Script>
    </Scripts>
  </UI>

  <UI Name="GenreEditCell" Base="spreadsheet:LabelEditCell">
    <Scripts>
      <Script>
        EditableText.Value = ((data:Track)Model).Genre;
      </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Track)Model).Genre = EditableText.Value;
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="LengthCell" Base="spreadsheet:LengthCell">
    <Scripts>
      <Script>Length = [((data:Track)Model).Duration];</Script>
    </Scripts>
  </UI>
  
  
  <UI Name="RatingCellBase" Base="spreadsheet:ToolTipCell">
    <Properties>
      <Int32 Name="UserRating"/>
      <style:StatefulCompositeStyle Name="Style" StatefulCompositeStyle="$Required"/>
      <style:Style Name="ToolTipStyle" Style="{styles:SharedStyles.ToolTipStyle}"/>
      <PlacementMode Name="ToolTipPlacement" PlacementMode="MouseBottom"/>
    </Properties>

    <Locals>
      <iris:Command Name="ChangeRating"/>
    </Locals>

    <Scripts>
      <Script>
        if ([UserRating] == me:RatingConstants.Unrated)
        {
          ToolTipText       = me:Strings.RatingToolTipUnrated;
          Rating.Image      = styles:Styles.RatingNotRatedDefault;
          Rating.HoverImage = styles:Styles.RatingNotRatedHover;       

          
          
          if ([Style.State.Hovered] &amp;&amp; ChangeRating.Available)
            Rating.Image      = styles:Styles.RatingNotRated;
          Rating.PressedImage = styles:Styles.RatingNotRatedPressed;
        }
        else if (UserRating &lt;= me:RatingConstants.MaxHateIt)
        {
          ToolTipText         = me:Strings.RatingToolTipHate;
          
          if ([Style.State.Selected] || Style.State.Hovered)
            Rating.Image      = styles:Styles.RatingHateItSelected;
          else
            Rating.Image      = styles:Styles.RatingHateIt;
            
          Rating.HoverImage   = styles:Styles.RatingHateItHover;
          Rating.PressedImage = styles:Styles.RatingHateItPressed;
        }
        else 
        {
          ToolTipText         = me:Strings.RatingToolTipLove;
          
          if (Style.State.Selected || Style.State.Hovered)
            Rating.Image      = styles:Styles.RatingLikeItSelected;
          else
            Rating.Image      = styles:Styles.RatingLikeIt;
          
          Rating.HoverImage   = styles:Styles.RatingLikeItHover;
          Rating.PressedImage = styles:Styles.RatingLikeItPressed;
        }
      </Script>

      
      <Script>
        [DeclareTrigger(ChangeRating.Invoked)]
        if (UserRating == me:RatingConstants.Unrated)
        {
          
          UserRating = me:RatingConstants.LoveIt;
        }
        else if (UserRating &lt;= me:RatingConstants.MaxHateIt)
        {
          
          UserRating = me:RatingConstants.Unrated;
        }
        else 
        {
          
          UserRating = me:RatingConstants.HateIt;
        }
      </Script>
    </Scripts>

    <Content>
      <Panel Name="ToolTipOrigin">
        <Children>
          
          <core:IconButton Name="Rating" Model="{ChangeRating}"
                  Margins="0,2,0,0"
                  KeyInteractiveNStuff="false"
                  AllowDoubleClicks="false"/>
          
        </Children>
      </Panel>
    </Content>
  </UI>

  <UI Name="RatingCell" Base="me:RatingCellBase">
    <Properties>
      <data:RateableMedia Name="Model" RateableMedia="$Required"/>
      <Int32 Name="UserRating" Int32="{Model.UserRating}"/>
    </Properties>
    <Scripts>
      <Script>
        [DeclareTrigger(Model.UserRating)]
        UserRating = Model.UserRating;
      </Script>
      <Script>
        [DeclareTrigger(UserRating)]
        if (Model.UserRating != UserRating)
          Model.UserRating = UserRating;
      </Script>
      
      <Script>
        [DeclareTrigger(ChangeRating.Invoked)]
        
        
        
        if (ListModel.SelectionManager != null &amp;&amp;
            ListModel.SelectionManager.IsSelected(RowIndex.Value))
        {
          foreach (data:RateableMedia media in ListModel.SelectionManager.SelectedItems)
          {
            if (media.UserRating != UserRating)
              media.UserRating = UserRating;
          }
        }
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="SyncCell" Base="spreadsheet:IconCell">
    <Properties>
      <data:Media Name="Model" Media="$Required"/>
    </Properties>
    <Scripts>
      <Script>
        <![CDATA[
        [DeclareTrigger(Model.SyncState)]
        [DeclareTrigger(zune:SyncControls.Instance.SyncProgressed.Invoked)]
        [InitialEvaluate(true)]

        Int32 state = Model.SyncState;

        
        if (state < 0 ||
            state >= styles:Styles.SyncIconImages.Count)
        {
          state = styles:Styles.SyncIconImages.Count - 1;
        }
        
        bool hover = false;
        
        if (Style is style:StatefulCompositeStyle)
        {
          hover = [((style:StatefulCompositeStyle)Style).State.Selected] || 
                  [((style:StatefulCompositeStyle)Style).State.Hovered];
        }
        
        if (hover)
        {
          Icon = (Image)styles:Styles.SyncIconHoverImages.GetItem(state);
        }
        else
        {
          Icon = (Image)styles:Styles.SyncIconImages.GetItem(state);
        }
        
        ToolTipText = (String)me:Strings.SyncIconToolTips.GetItem(state);
        ]]>
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="DateAddedCell" Base="spreadsheet:DateCell">
    <Scripts>
      <Script> Date = ((data:Track)Model).DateAdded;</Script>
    </Scripts>
  </UI>

  
  <UI Name="AlbumArtistCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).AlbumArtistName];</Script>
    </Scripts>
  </UI>
  
  
  <UI Name="AlbumArtistEditCell" Base="spreadsheet:LabelEditCell">
    <Scripts>
      <Script>
        EditableText.Value = ((data:Track)Model).AlbumArtistName;
      </Script>

      <Script>
        [DeclareTrigger(CommitValue.Invoked)]
        ((data:Track)Model).AlbumArtistName = EditableText.Value;
      </Script>
    </Scripts>
  </UI>
  
  
  <UI Name="ContributingArtistsCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script>
        string content = "";
        
        List artists = (List)((data:Track)Model).ContributingArtistNames;
        
        string separator = me:Strings.ContributingArtistSeparator;
        
        if (!List.IsNullOrEmpty(artists))
        {
          foreach (string name in artists)
          {
            if (content.Length == 0)
              content = name;
            else
              content = separator.Format(content, name);
          }
        }
        
        Content = content;
      </Script>
    </Scripts>
  </UI>

  
  <UI Name="DateLastPlayedCell" Base="spreadsheet:DateCell">
    <Scripts>
      <Script> Date =[((data:Track)Model).DateLastPlayed];</Script>
    </Scripts>
  </UI>

  
  <UI Name="PlayCountCell" Base="spreadsheet:LabelCell">
    <Scripts>
      <Script> Content = [((data:Track)Model).PlayCount].ToString();</Script>
    </Scripts>
  </UI>

  
  <UI Name="SizeCell" Base="spreadsheet:LabelCell">
    <Properties>
      <Int64 Name="SizeData" Int64="{(Int64)0}"/>
      <String Name="FormatString"/>
    </Properties>

    <Scripts>
      <Script> <![CDATA[
        if ([SizeData] > (Int64)0)
        {
          float bytesPerK = 1024.0;
          float size = (float)SizeData / bytesPerK;
          if (size < 1.0)
            size = 1.0;

          string units;
          string format = "{0:#,0.#} {1}";
          if (size < bytesPerK)
          {
            
            format = "{0:#,0} {1}";
            units = "KB";
          }
          else
          {
            size = size / bytesPerK;
            if (size < bytesPerK)
            {
              units = "MB";
            }
            else
            {
              size = size / bytesPerK;
              units = "GB";
            }
          }

          Content = format.Format(size, units);
          
          if (!String.IsNullOrEmpty(FormatString))
          {
            Content = FormatString.Format(Content);
          }
        }
        else
        {
          Content = "";
        }
   ]]></Script>
    </Scripts>
  </UI>

  <UI Name="FileSizeCell" Base="me:SizeCell">
    <Properties>
      <data:Track Name="Model" Track="$Required"/>
      <Int64 Name="SizeData" Int64="{Model.FileSize}"/>
    </Properties>
    <Scripts>
      <Script>SizeData = [Model.FileSize];</Script>
    </Scripts>
  </UI>

  <UI Name="SizeOnDeviceCell" Base="me:SizeCell">
    <Properties>
      <data:Media Name="Model" Media="$Required"/>
      <Int64 Name="SizeData" Int64="{Model.DeviceFileSize}"/>
    </Properties>
    <Scripts>
      <Script>SizeData = [Model.DeviceFileSize];</Script>
    </Scripts>
  </UI>
  
  
  <UI Name="ReleaseYearCell" Base="spreadsheet:DateCell">
     <Properties>
      <String Name="Format" String="yyyy"/>
    </Properties>
    <Scripts>
      <Script> Date = [((data:Track)Model).ReleaseDate];</Script>
    </Scripts>
  </UI>
  
  
  <UI Name="ComposerCell" Base="spreadsheet:FallbackCell">
    <Scripts>
      <Script>Content = ((data:Track)Model).ComposerName;</Script>
    </Scripts>
  </UI>

  
  





  
  <UI Name="ProtectedCell" Base="spreadsheet:FallbackCell">
    <Properties>
      <data:Track Name="Model" Track="$Required"/>
    </Properties>
    <Scripts>
      <Script>
        if ([Model.IsProtected] == 1)
          Content = zune:Shell.LoadString(zune:StringId.IDS_PROTECTED_YES);
        else if (Model.IsProtected == 0)
          Content = zune:Shell.LoadString(zune:StringId.IDS_PROTECTED_NO);
      </Script>
    </Scripts>
  </UI>

  
  





  
  <UI Name="ConductorCell" Base="spreadsheet:FallbackCell">
    <Scripts>
      <Script>Content = [((data:Track)Model).ConductorName];</Script>
    </Scripts>
  </UI>

  
  





  
  <UI Name="LibraryMediaStatusCell" Base="spreadsheet:MediaStatusCell">
    <Properties>
      <data:Media Name="Model" Media="$Required"/>
      <zune:MediaType Name="MediaType" MediaType="{zune:Shell.MapStringToMediaType(Model.Type)}"/>
      <Int32 Name="MediaId" Int32="{Model.LibraryId}"/>
    </Properties>

    <Scripts>
      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(zune:TransportControls.Instance.CurrentTrack)]
        IsNowPlaying = zune:TransportControls.Instance.IsCurrentLibraryTrack(MediaId, MediaType);
      </Script>
      
      <Script>
        [InitialEvaluate(true)]
        [DeclareTrigger(zune:TransportControls.Instance.ErrorCount)]
        ErrorCode = zune:TransportControls.Instance.GetLibraryErrorCode(MediaId, MediaType);
      </Script>
    </Scripts>
  </UI>


  <Class Name="SortInfo" Shared="true">
      <Properties>
          <spreadsheet:SortDescription Name="DateAdded"      Attribute="DateAdded"/>
          <spreadsheet:SortDescription Name="DisplayArtist"  Attribute="DisplayArtist"        SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="Duration"       Attribute="Duration"/>
          <spreadsheet:SortDescription Name="Title"          Attribute="Title"                SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="UserLastPlayedDate" Attribute="UserLastPlayedDate"/>
          <spreadsheet:SortDescription Name="UserPlayCount"  Attribute="UserPlayCount"/>
          <spreadsheet:SortDescription Name="UserRating"     Attribute="UserRating"/>
          <spreadsheet:SortDescription Name="WM_AlbumArtist" Attribute="WM/AlbumArtist"       SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="WM_AlbumTitle"  Attribute="WM/AlbumTitle"        SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="WM_Composer"    Attribute="WM/Composer"          SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="WM_Conductor"   Attribute="WM/Conductor"         SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="WM_Genre"       Attribute="WM/Genre"             SupportsJumpInList="true"/>
          <spreadsheet:SortDescription Name="WM_TrackNumber" Attribute="WM/TrackNumber"/>
          <spreadsheet:SortDescription Name="WM_Year"        Attribute="WM/Year"/>
      </Properties>
  </Class>

  <Class Name="RatingConstants" Shared="true">
    <Properties>   
      
      <Int32 Name="Unrated" Int32="0"/>
      <Int32 Name="HateIt"  Int32="2"/>
      <Int32 Name="LoveIt"  Int32="8"/>
      
      
      <Int32 Name="MaxHateIt" Int32="5"/>
      <Int32 Name="MaxLoveIt" Int32="10"/>
    </Properties>
  </Class>
  
  
  
  
  
  <Class Name="ColumnChooserDialog" Base="dialog:Dialog">
    <Properties>
      <String Name="ContentUI" String="res://ZuneShellResources!TracksPanelColumns.uix#ColumnChooserDialogUI"/>
    </Properties>
  </Class>
  
  
  
  
  
  
  <Class Name="ColumnChooserOption">
    <Properties>
      <spreadsheet:ColumnInfo Name="ColumnInfo" ColumnInfo="{null}"/>
      <iris:BooleanChoice Name="Visible"/>
    </Properties>
  </Class>
  
  
  
  
  <UI Name="ColumnChooserDialogUI" Base="dialog:DialogContentUI">
    <Properties>
      <me:ColumnChooserDialog Name="Dialog" ColumnChooserDialog="$Required"/> 
    </Properties>
    
    <Locals>
      <iris:Command Name="OK" Description="{zune:Shell.LoadString(zune:StringId.IDS_DIALOG_OK)}"/>
    </Locals>
    
    <Scripts>
      <Script>
        
        
        iris:ArrayListDataSet content = new iris:ArrayListDataSet();
        
        foreach(spreadsheet:ColumnInfo visible in me:DetailedViewData.ColumnData.OrderedColumns)
        {
          me:ColumnChooserOption option = new me:ColumnChooserOption();
          option.ColumnInfo = visible;
          option.Visible.Value = option.ColumnInfo.Visible;
          
          content.Add(option);
        }
                
        Spreadsheet.Content = content;
      </Script>
      
      <Script>
        [DeclareTrigger(OK.Invoked)]
        
        
        me:DetailedViewData.ColumnData.OrderedColumns.Clear();
        
        foreach(me:ColumnChooserOption option in Spreadsheet.Content)
        {
          me:DetailedViewData.ColumnData.OrderedColumns.Add(option.ColumnInfo);
          option.ColumnInfo.Visible = option.Visible.Value;
        }
        
        me:DetailedViewData.ColumnData.ColumnOrderChanged.Invoke();
       
        Dialog.Helper.Hide();
      </Script>
    </Scripts>
    
    <Content>
      <Panel Navigation="ContainAll,WrapAll" MaximumSize="360,0" Margins="10">
        <Layout>
          <AnchorLayout/>
        </Layout>
        <Children>
          
          <core:Label Name="Title" 
                Content="{zune:Shell.LoadString(zune:StringId.IDS_CHOOSE_COLUMN_TITLE)}"
                Style="{styles:SharedStyles.DialogHeaderStyle}">
             <LayoutInput>
              <AnchorLayoutInput Left="Parent,0" Top="Parent, 0"/>
            </LayoutInput>
          </core:Label>
          

          <me:ColumnReorderSpreadSheet Name="Spreadsheet" Margins="0,0,0,50" MaximumSize="200,0"
                                       FixedItems="{me:DetailedViewData.ColumnData.FixedColumns}">
            <LayoutInput>
              <AnchorLayoutInput Left="Parent,0" Top="Title,1,10"/>
            </LayoutInput>
          </me:ColumnReorderSpreadSheet>
          
          <Panel>
            <LayoutInput>
              <AnchorLayoutInput Left="Parent,0" Top="Spreadsheet,1,-40"/>
            </LayoutInput>
            <Layout>
              <DockLayout SizeToChildren="true" DefaultLayoutInput="Left,Near"/>
            </Layout>
            <Children>
              
              <core:ActionButton Model="{OK}" Margins="0,0,10,0" ToolTipEnabled="false"/>
              <core:ActionButton Model="{Dialog.Cancel}" Margins="10,0,10,0" ToolTipEnabled="false" FocusOrder="0"/>

            </Children>
          </Panel>

        </Children>
      </Panel>
    </Content>
  </UI>
    
  
  
  
  <UI Name="ColumnReorderSpreadSheet" Base="spreadsheet:SpreadSheet">
    <Properties>
      <Boolean Name="CanReorder" Boolean="true"/>
    
      <spreadsheet:ColumnData Name="ColumnData" >
        <Columns>
          <spreadsheet:ColumnInfo  CellType="{typeof(me:ColumnOptionCell)}"
                                   Resizable="false">
            <LayoutInput>
              <DockLayoutInput Position="Top"/>
            </LayoutInput>
          </spreadsheet:ColumnInfo>
        </Columns>
      </spreadsheet:ColumnData>
      
      <Boolean Name="ShowHeaders" Boolean="false"/>
      <SelectionManager Name="SelectionManager" SingleSelect="true"/>
      <Boolean Name="AllowHorizontalScrolling" Boolean="false"/>
      <Boolean Name="SizeToChildren" Boolean="true"/>
    </Properties>

    <Scripts>
      
      <Script>
        [DeclareTrigger(Target.Dropped)]

        object value = Target.GetValue();
        
        if (!(value is SelectionManager))
        {
          
        }
        else
        {
          SelectionManager selectionManager = (SelectionManager)value;
          int insertAt = InsertIndex.Value;
          
          if (insertAt >= 0)
          {
            iris:ArrayListDataSet list = (iris:ArrayListDataSet)Content;
            list.Reorder(selectionManager.SelectedIndices, insertAt);
          }
        }
      </Script>
    </Scripts>
  </UI>
  
  
  
  
  <UI Name="ColumnOptionCell" Base="spreadsheet:Cell">
    <Properties>
      <me:ColumnChooserOption Name="Model" ColumnChooserOption="$Required"/>
    </Properties>
    
    <Content>
      <Panel Layout="HorizontalFlow" MouseInteractive="true">
        <Children>
          
          <core:CheckBox Model="{Model.Visible}" Margins="0,0,10,0" Available="{Model.ColumnInfo.Removable}"/>
          <core:Label Content="{Model.ColumnInfo.Header}" Margins="0,0,5,0"/>
          <Graphic Content="{Model.ColumnInfo.HeaderIcon}" Margins="0,2,0,0"/>
          
        </Children>
      </Panel>
    </Content>
  </UI>

  
  
  
  <Class Name="Strings" Shared="true">
    <Properties>
      <string Name="ContributingArtistSeparator" string="{zune:Shell.LoadString(zune:StringId.IDS_CONTRIBUTING_ARTISTS_SEPARATOR)}" />
      <string Name="RatingToolTipHeader" string="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_HEADER_TOOLTIP)}" />
      <string Name="RatingToolTipUnrated" string="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_TOOLTIP_UNRATED)}" />
      <string Name="RatingToolTipLove" string="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_TOOLTIP_RATED_LOVE)}" />
      <string Name="RatingToolTipHate" string="{zune:Shell.LoadString(zune:StringId.IDS_RATING_COLUMN_TOOLTIP_RATED_HATE)}" />
      
      
      <List Name="SyncIconToolTips">
        <Source>
          <String String="{zune:Shell.LoadString(zune:StringId.IDS_SYNC_STATUS_COLUMN_TOOLTIP_SYNCING)}"/>
          <String String="{zune:Shell.LoadString(zune:StringId.IDS_SYNC_STATUS_COLUMN_TOOLTIP_ONDEVICE)}"/>
          <String String="{zune:Shell.LoadString(zune:StringId.IDS_SYNC_STATUS_COLUMN_TOOLTIP_EXCLUDED)}"/>
          <String String="{null}"/>
        </Source>
      </List>      
    </Properties>
  </Class>
  
</UIX>
