Ejemplo n.º 1
0
        private void Alb_ItemClicked(object sender, EventArgs e)
        {
            Album alb = (Album)sender;

            CurrentItems.Clear();
            TrackView.Items.Clear();
            for (int i = 0; alb.Data.Tracks.Length > i; i++)
            {
                LAPP.IO.FileItem fi = CreateItem(alb.Data, i);
                TrackView.Items.Add(fi.ListItem);
                CurrentItems.Add(fi);
            }

            ClearUC.Utils.AnimationHelper.Visible va = new ClearUC.Utils.AnimationHelper.Visible();
            int ind = Children.IndexOf(alb);

            if (ind == VisibleIndex)
            {
                VisibleIndex = -1;
                Current      = null;
                va.Animate(Config.Current.iValue[Enums.iValue.AlbumVisibleAnimation], TrackView, Visibility.Hidden);
                EditLabel.Visibility = Visibility.Hidden;
            }
            else
            {
                VisibleIndex = ind;
                Current      = alb.Data;
                va.Animate(Config.Current.iValue[Enums.iValue.AlbumVisibleAnimation], TrackView, Visibility.Visible);
                EditLabel.Visibility = Visibility.Visible;
            }
        }
Ejemplo n.º 2
0
        private LAPP.IO.FileItem CreateItem(AlbumData Data, int Index)
        {
            ClearUC.ListViewItems.ListSubItem lsi = new ClearUC.ListViewItems.ListSubItem();
            lsi.MainLabelText = Data.Tracks[Index].Title;
            lsi.SideItem      = ClearUC.ListViewItems.ListSubItem.SideItems.Number;

            if (Data.Tracks[Index].TrackNumber > 0)
            {
                lsi.NumberLabelText = Data.Tracks[Index].TrackNumber.ToString();
            }
            else
            {
                lsi.NumberLabelText = null;
            }

            string subl = "";

            if (!string.IsNullOrEmpty(Data.Artist))
            {
                subl += " - " + Data.Artist;
            }

            if (subl.Length > 3)
            {
                lsi.SubLabelVisibility = Visibility.Visible;
                lsi.SubLabelText       = subl.Remove(0, 3);
            }
            else
            {
                lsi.SubLabelVisibility = Visibility.Hidden;
            }

            return(new LAPP.IO.FileItem(new LAPP.IO.MediaFile(Data.Tracks[Index].Path), lsi, true));
        }
Ejemplo n.º 3
0
        public static AlbumData Read(string Path)
        {
            XmlSerializer des  = new XmlSerializer(typeof(AlbumData));
            StreamReader  sr   = new StreamReader(Path, System.Text.Encoding.UTF8);
            AlbumData     Data = null;

            try
            {
                Data = (AlbumData)des.Deserialize(sr);
            }
            catch (System.Exception) { return(null); }
            finally
            {
                sr.Close();
            }

            Data.Path = Path;

            if (Data.Tracks.Length - 1 >= Data.ArtworkIndex)
            {
                Data.Image = new MediaFile(Data.Tracks[Data.ArtworkIndex].Path).Artwork;
            }

            return(Data);
        }
Ejemplo n.º 4
0
        public static void Write(string Path, AlbumData Data)
        {
            XmlSerializer ser = new XmlSerializer(typeof(AlbumData));
            StreamWriter  sw  = new StreamWriter(Path, false, System.Text.Encoding.UTF8);

            try
            {
                ser.Serialize(sw, Data);
            }
            finally
            {
                sw.Close();
            }

            Data.Path = Path;
        }
Ejemplo n.º 5
0
 private void UpdateChildren()
 {
     av.Children.Clear();
     Directory.CreateDirectory(Config.Current.Path[Enums.Path.AlbumDirectory]);
     string[] files = Directory.GetFiles(Config.Current.Path[Enums.Path.AlbumDirectory], "*.xml");
     for (int i = 0; files.Length > i; i++)
     {
         try
         {
             AlbumData data = AlbumData.Read(files[i]);
             av.Children.Add(new Album()
             {
                 Data = data
             });
         }
         catch (Exception) { }
     }
 }