Exemplo n.º 1
0
        //adds the nodes to the tree and fills the objects in
        private void prepareTree()
        {
            treeMain.Nodes[0].Nodes.Clear();
            List <InterpretDTO> interprets = new List <InterpretDTO>();
            List <String>       albums     = new List <string>();
            FunctionController  fc         = new FunctionController();

            interprets = fc.getAllInterprets();
            foreach (InterpretDTO i in interprets)
            {
                string interpretName = i.getName();
                string letter        = interpretName.Substring(0, 1);

                if (!(treeMain.Nodes[0].Nodes.ContainsKey(letter)))
                {
                    treeMain.Nodes[0].Nodes.Add(letter.ToUpper(), letter.ToUpper());
                }
                TreeNode[] currentNode = treeMain.Nodes[0].Nodes.Find(letter, true);
                currentNode[0].Nodes.Add(interpretName, interpretName);
                albums      = fc.getAlbumsByInterpret(interpretName);
                currentNode = treeMain.Nodes.Find(interpretName, true);
                foreach (String a in albums)
                {
                    currentNode[0].Nodes.Add(a);
                }
            }
            treeMain.Nodes[0].Expand();
        }
Exemplo n.º 2
0
        private void treeMain_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            FunctionController fc         = new FunctionController();
            string             typeOfNode = getTypeOfNode(e.Node);

            setDetailEditingPanelsInvisible();
            if (typeOfNode == "interpret")
            {
                String       interpretName = e.Node.Text;
                InterpretDTO iDTO          = fc.getInterpretByName(interpretName);
                löschenToolStripMenuItem.Enabled             = true;
                alsFavoritMarkierenToolStripMenuItem.Enabled = true;

                pnDetailEditingInterpret.Visible            = true;
                edDetailEditingInterpretName.Text           = iDTO.getName();
                edDetailEditingInterpretFoundationYear.Text = iDTO.getFoundationYear();
                edDetailEditingInterpretLand.Text           = iDTO.getLand();
                edDetailEditingInterpretNoOfAlbums.Text     = fc.getAlbumsByInterpret(iDTO.getName()).Count.ToString();
            }
            else if (typeOfNode == "album")
            {
                String         albumName = e.Node.Text;
                AlbumDTO       aDTO      = fc.getAlbumByName(albumName);
                List <SongDTO> songs     = new List <SongDTO>();
                listSongs.Items.Clear();

                pnDetailEditingAlbum.Visible       = true;
                edDetailEditingAlbumName.Text      = aDTO.getName();
                edDetailEditingAlbumInterpret.Text = fc.getInterpretNameById(aDTO.getInterpret());
                edDetailEditingAlbumYear.Text      = aDTO.getReleaseYear();
                edDetailEditingAlbumGenre.Text     = fc.getGenreById(aDTO.getGenre());
                if (aDTO.getCoverpath() != null && aDTO.getCoverpath() != "")
                {
                    pictureBox1.Image    = Image.FromFile(aDTO.getCoverpath());
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                }
                else
                {
                    pictureBox1.Image = null;
                }

                songs = fc.getAllSongsByAlbum(albumName);
                foreach (SongDTO song in songs)
                {
                    listSongs.Items.Add(song.getTrackNo() + " - " + song.getName() + " | " + song.getDuration());
                }
            }
        }