コード例 #1
0
        private void CreateBtn_Click(object sender, EventArgs e)
        {
            CreatePlaylistForm CPF = new CreatePlaylistForm();

            CPF.Show();
            this.Close();
        }
コード例 #2
0
        private void AddPlaylistButton_ButtonClick()
        {
            CreatePlaylistForm DialogAddNewPlaylist = new CreatePlaylistForm();

            DialogAddNewPlaylist.ShowDialog();
            switch (DialogAddNewPlaylist.DialogResult)
            {
            case true:
                PlaylistModel newPlaylist = new PlaylistModel();
                newPlaylist.PlaylistKey  = "PL" + MyUtilites.MyFunction.GenerateCode();
                newPlaylist.PlaylistName = DialogAddNewPlaylist.PlaylistName;

                //di chuyển hình ảnh playlist của người dùng
                string ImageFilePath = DialogAddNewPlaylist.ImagePath;
                if (File.Exists(ImageFilePath))
                {
                    string sourceFile = ImageFilePath;
                    string destFile   = $@"{GeneralDataManagement.ImageFolderPath}\{System.IO.Path.GetFileName(sourceFile)}";
                    try
                    {
                        if (File.Exists(destFile) == false)
                        {
                            System.IO.File.Copy(sourceFile, destFile, true);
                        }
                        newPlaylist.ImagePath = destFile.Replace($@"{GeneralDataManagement.ImageFolderPath}\", "");
                    }
                    catch (Exception)
                    {
                    }
                }

                SongDataAccess.InsertNewPlaylistToDatabase(newPlaylist);
                ListPlaylists.Add(newPlaylist);
                UpdatePlaylistCard();
                break;

            case false:
                break;

            default:
                break;
            }
        }