Example #1
0
        public void AddItemListview(string[] arrString)
        {
            int dem = 0;
            int n = arrString.Length;
            try
            {
                for (int k = 0; k < n; k++)
                {
                    ListViewItem item = new ListViewItem();
                    string temp = arrString[k];
                    string path = temp;
                    if (temp.Contains("\r\n"))
                    {
                        path = "";
                        string delim = "\r\n";//luot bo khi no xuat hien trong chuoi temp
                        path = temp.Trim(delim.ToCharArray());
                    }

                    if (File.Exists(path))
                    {

                        ID3vDetails detail = new ID3vDetails(path);
                        item.Text = detail.Namemp3;
                        if (detail.Attach != null)
                        {
                            ListviewLibrary.SmallImageList.Images.Add(detail.Attach);
                            item.ImageIndex = ListviewLibrary.SmallImageList.Images.Count - 1;
                        }
                        else
                            item.ImageKey = "mp3";
                        item.Name = dem.ToString();
                        item.Tag = path;
                        string tile = detail.Title;
                        item.SubItems.Add(tile);
                        string artist = detail.Artist;
                        item.SubItems.Add(artist);
                        string album = detail.Album;
                        item.SubItems.Add(album);
                        string year = detail.Year;
                        item.SubItems.Add(year);
                        ListviewLibrary.Items.Add(item);
                        ++dem;
                    }
                }

            }
            catch (Exception ex)
            {
            }
            if (dem != n)
            {
                for (int k = dem + 1; k < n; k++)
                {
                    ListViewItem item = new ListViewItem();
                    string temp = arrString[k];
                    string path = temp;
                    if (temp.Contains("\r\n"))
                    {
                        path = "";
                        string delim = "\r\n";//luot bo khi no xuat hien trong chuoi temp
                        path = temp.Trim(delim.ToCharArray());
                    }

                    if (File.Exists(path))
                    {

                        ID3vDetails detail = new ID3vDetails(path);
                        item.Text = detail.Namemp3;
                        if (detail.Attach != null)
                        {
                            ListviewLibrary.SmallImageList.Images.Add(detail.Attach);
                            item.ImageIndex = ListviewLibrary.SmallImageList.Images.Count - 1;
                        }
                        else
                            item.ImageKey = "mp3";
                        item.Name = dem.ToString();
                        item.Tag = path;
                        string tile = detail.Title;
                        item.SubItems.Add(tile);
                        string artist = detail.Artist;
                        item.SubItems.Add(artist);
                        string album = detail.Album;
                        item.SubItems.Add(album);
                        string year = detail.Year;
                        item.SubItems.Add(year);
                        ListviewLibrary.Items.Add(item);
                        ++dem;
                    }
                }
            }
        }
Example #2
0
        public void AddItemListview3(string[] arrString, string[] info)
        {
            ListViewGroup[] listGroup = new ListViewGroup[info.Length];
            int i;
            int dem = 0;
            for (i = 0; i < info.Length; i++)
            {

                if (i < info.Length - 1)
                {
                    listGroup[i] = new ListViewGroup(info[i], HorizontalAlignment.Left);
                    listGroup[i].Header = info[i].ToString();
                }
                else
                {
                    listGroup[i] = new ListViewGroup("UnKnow", HorizontalAlignment.Left);
                    listGroup[i].Header = "UnKnow";
                }
                ListviewLibrary.Groups.Add(listGroup[i]);
            }
            int n = arrString.Length;
            try
            {
                for (int k = 0; k < n; k++)
                {
                    ListViewItem item = new ListViewItem();
                    string temp = arrString[k];
                    string path = temp;
                    if (temp.Contains("\r\n"))
                    {
                        path = "";
                        string delim = "\r\n";//luot bo khi no xuat hien trong chuoi temp
                        path = temp.Trim(delim.ToCharArray());
                    }
                    if (File.Exists(path))
                    {
                        ID3vDetails detail = new ID3vDetails(path);
                        ++dem;
                        item.Text = detail.Namemp3;
                        if (detail.Attach != null)
                        {
                            ListviewLibrary.SmallImageList.Images.Add(detail.Attach);
                            item.ImageIndex = ListviewLibrary.SmallImageList.Images.Count - 1;
                        }
                        else
                            item.ImageKey = "mp3";
                        item.Tag = path;
                        string tile = detail.Title;
                        item.SubItems.Add(tile);
                        string artist = detail.Artist;
                        item.SubItems.Add(artist);
                        string album = detail.Album;
                        item.SubItems.Add(album);
                        string year = detail.Year;
                        for (i = 0; i < info.Length; i++)
                        {
                            if (year == listGroup[i].Header)
                            {
                                item.Group = listGroup[i];
                                break;
                            }
                            else
                                item.Group = listGroup[info.Length - 1];
                        }
                        item.SubItems.Add(year);
                        ListviewLibrary.Items.Add(item);
                    }
                }
            }
            catch (Exception ex)
            { }
            if (dem != n)
            {
                for (int k = dem + 1; k < n; k++)
                {
                    ListViewItem item = new ListViewItem();
                    string temp = arrString[k];
                    string path = temp;
                    if (temp.Contains("\r\n"))
                    {
                        path = "";
                        string delim = "\r\n";//luot bo khi no xuat hien trong chuoi temp
                        path = temp.Trim(delim.ToCharArray());
                    }
                    if (File.Exists(path))
                    {
                        ID3vDetails detail = new ID3vDetails(path);
                        ++dem;
                        item.Text = detail.Namemp3;
                        if (detail.Attach != null)
                        {
                            ListviewLibrary.SmallImageList.Images.Add(detail.Attach);
                            item.ImageIndex = ListviewLibrary.SmallImageList.Images.Count - 1;
                        }
                        else
                            item.ImageKey = "mp3";
                        item.Tag = path;
                        string tile = detail.Title;
                        item.SubItems.Add(tile);
                        string artist = detail.Artist;
                        item.SubItems.Add(artist);
                        string album = detail.Album;
                        item.SubItems.Add(album);
                        string year = detail.Year;
                        for (i = 0; i < info.Length; i++)
                        {
                            if (year == listGroup[i].Header)
                            {
                                item.Group = listGroup[i];
                                break;
                            }
                            else
                                item.Group = listGroup[info.Length - 1];
                        }
                        item.SubItems.Add(year);
                        ListviewLibrary.Items.Add(item);
                    }
                }
            }
        }
Example #3
0
        private void ListviewLibrary_MouseClick(object sender, MouseEventArgs e)
        {
            try
            {
                if (ListviewLibrary.Items.Count > 0)
                {
                    int i = 0;
                    ListViewItem item = ListviewLibrary.SelectedItems[0];
                    //string[] arrString = readwrite.read("Data.txt");
                    //for (i = 0; i < arrString.Length; i++)
                    //{
                    //    if (readwrite.SearchSubString(arrString[i], item.Text))
                    //        break;
                    //}
                    ID3vDetails detail = new ID3vDetails(item.Tag.ToString());
                    if (detail.Attach != null)
                        ImagePicture.BackgroundImage = detail.Attach;
                    else
                        ImagePicture.BackgroundImage = global::WindowsFormsApplication9.Properties.Resources.music;

                }
            }
            catch (Exception ex)
            { }
        }