private void btnCreateList_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtListName.Text)) { ListName = txtListName.Text; Cancelled = false; Close(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
public SearchFile(bool playerMode) { try { InitializeComponent(); this.playerMode = playerMode; if (playerMode) { Icon = Properties.Resources.music; Text += "Music"; } else { Icon = Properties.Resources.video; Text += "Video"; } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnLoadLogs_Click(object sender, EventArgs e) { try { if (dgvLogFiles.Rows.Count > 0) { Paths = dgvLogFiles.Rows .OfType <DataGridViewRow>() .Select(r => r.Cells[1].Value.ToString()) .Reverse().ToArray(); Close(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnAddFile_Click(object sender, EventArgs e) { try { FilePaths = dgvStatistic.SelectedRows .OfType <DataGridViewRow>() .Select(r => r.Cells[1].Value.ToString()) .ToArray(); Close(); } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnStartSearch_Click(object sender, EventArgs e) { try { if (CheckSearchContent()) { SearchContent = txtSearchContent.Text; Close(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnUpdateName_Click(object sender, EventArgs e) { try { string newListPath = System.IO.Directory.GetParent(listPath).FullName + @"\" + txtListName.Text + ".txt"; System.IO.File.Move(listPath, newListPath); listPath = newListPath; Text = "Edit " + listMode.Remove(listMode.Length - 1, 1) + " '" + System.IO.Path.GetFileNameWithoutExtension(listPath) + "'"; } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void EditFileList_FormClosing(object sender, FormClosingEventArgs e) { try { if (txtListName.Text != System.IO.Path.GetFileNameWithoutExtension(listPath)) { System.IO.File.Move(listPath, System.IO.Directory.GetParent(listPath).FullName + @"\" + txtListName.Text + ".txt"); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
public FileStatisticForm(string filePath, int occurrencesCount, Dictionary <string, int> playlistOccurrences, bool playerMode) { try { InitializeComponent(); this.filePath = filePath; this.playerMode = playerMode; this.playlistOccurrences = playlistOccurrences; if (playerMode) { Icon = Properties.Resources.music; } else { Icon = Properties.Resources.video; } Text = TagLib.File.Create(filePath).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(filePath) + " Statistic"; txtXPlayed.Text = occurrencesCount.ToString(); dgvXInPlaylists.DataSource = playlistOccurrences.ToList(); dgvXInPlaylists.Columns[0].HeaderText = "Playlist"; dgvXInPlaylists.Columns[1].HeaderText = "Occurred"; this.Focus(); } catch (ArgumentNullException nullEx) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", nullEx.Message, "An error occurred", true, true); } else { message = new PlayerMessageBox("error", nullEx.Message, "An error occurred", true, false); } message.ShowDialog(); } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occurred", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occurred", true, false); } message.ShowDialog(); } }
private void btnAddFile_Click(object sender, EventArgs e) { try { var fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; if (playerMode) { fileDialog.Filter = "Audio Files | *.mp3; *.wav"; fileDialog.InitialDirectory = Properties.Settings.Default.MusicPath; } else { fileDialog.Filter = "Video Files | *.mp4; *.mpeg; *.avi"; fileDialog.InitialDirectory = Properties.Settings.Default.VideoPath; } if (fileDialog.ShowDialog() == DialogResult.OK) { foreach (string path in fileDialog.FileNames) { System.IO.File.AppendAllText(listPath, path + Environment.NewLine); } lsbListFiles.DataSource = System.IO.File .ReadAllLines(listPath) .Select(p => TagLib.File.Create(p).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(p)) .ToList(); lsbListFiles.ClearSelected(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
public EditFileList(string listPath, bool playerMode) { try { InitializeComponent(); this.listPath = listPath; this.playerMode = playerMode; listMode = System.IO.Directory.GetParent(System.IO.Directory.GetParent(listPath).FullName).Name; if (playerMode) { Icon = Properties.Resources.music; } else { Icon = Properties.Resources.video; } Text = "Edit " + listMode.Remove(listMode.Length - 1, 1) + " '" + System.IO.Path.GetFileNameWithoutExtension(listPath) + "'"; txtListName.Text = System.IO.Path.GetFileNameWithoutExtension(listPath); lsbListFiles.DataSource = System.IO.File .ReadAllLines(listPath) .Select(p => TagLib.File.Create(p).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(p)) .ToList(); lsbListFiles.ClearSelected(); } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
public FileList(bool listMode, bool playerMode) { try { InitializeComponent(); this.playerMode = playerMode; this.listMode = listMode; if (listMode) { Text = "Create Playlist"; lblListName.Text = "Playlistname"; btnCreateList.Text = "Create Playlist"; } else { Text = "Create Backup"; lblListName.Text = "Backupname"; btnCreateList.Text = "Create Backup"; } if (playerMode) { Icon = Properties.Resources.music; } else { Icon = Properties.Resources.video; } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private bool CheckFilePaths(string filePath) { try { List <string> filePathList = System.IO.File.ReadAllLines(filePath).ToList(); List <string> removeFilePathList = new List <string>(); foreach (var path in filePathList) { if (!System.IO.File.Exists(path)) { removeFilePathList.Add(path); } } if (removeFilePathList.Count > 0) { foreach (var path in removeFilePathList) { filePathList.RemoveAll(p => p == path); } System.IO.File.WriteAllLines(filePath, filePathList); } return(true); } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); return(false); } }
private bool CheckSearchContent() { try { if (!string.IsNullOrEmpty(txtSearchContent.Text)) { return(true); } else { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("information", "Please insert Text to search...", "Search Input is empty", true, true); } else { message = new PlayerMessageBox("information", "Please insert Text to search...", "Search Input is empty", true, false); } message.ShowDialog(); return(false); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); return(false); } }
private void lblSoundcloudLink_Click(object sender, EventArgs e) { try { System.Diagnostics.Process.Start(@"https://soundcloud.com/doobieasdave"); } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void FileList_FormClosing(object sender, FormClosingEventArgs e) { if (Cancelled) { PlayerMessageBox message; if (listMode) { message = new PlayerMessageBox("question", "Dou you really want to cancel creating the Playlist?", "Cancel creating Playlist", false, true); } else { message = new PlayerMessageBox("question", "Dou you really want to cancel creating the Playlist?", "Cancel creating Playlist", false, true); } message.ShowDialog(); if (!message.ReturnMode) { e.Cancel = true; } } }
public PlayerMessageBox(string iconMode, string messageText, string messageTitle, bool buttonMode, bool playerMode) { try { InitializeComponent(); this.playerMode = playerMode; if (playerMode) { Icon = Properties.Resources.music; } else { Icon = Properties.Resources.video; } switch (iconMode) { case "success": pcbMessageIcon.Image = Properties.Resources.success; break; case "error": pcbMessageIcon.Image = Properties.Resources.error; break; case "information": pcbMessageIcon.Image = Properties.Resources.information; break; case "question": pcbMessageIcon.Image = Properties.Resources.question; break; case "dude": pcbMessageIcon.Image = Properties.Resources.dude2; lblSoundcloudLink.Visible = true; break; } if (buttonMode) { btnYes.Visible = false; btnNo.Visible = false; btnOK.Visible = true; } else { btnYes.Visible = true; btnNo.Visible = true; btnOK.Visible = false; } if (messageText.Split('\n').Length > 1) { txtMessageBox.Location = new Point(80, 25); } else { txtMessageBox.Location = new Point(80, 40); } txtMessageBox.Text = messageText; Text = messageTitle; } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
public PlayerLog(string filePath, bool playerMode) { try { InitializeComponent(); this.playerMode = playerMode; if (playerMode) { Text = "Music Log"; Icon = Properties.Resources.music; } else { Text = "Video Log"; Icon = Properties.Resources.video; } if (CheckFilePaths(filePath)) { List <FileInfo> fileInfoList = new List <FileInfo>(); using (System.IO.StreamReader reader = new System.IO.StreamReader(filePath)) { string path; while ((path = reader.ReadLine()) != null) { var file = new FileInfo(); file.Title = TagLib.File.Create(path).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(path); file.Path = path; fileInfoList.Add(file); } } if (fileInfoList.Count > 0) { dgvLogFiles.DataSource = fileInfoList; dgvLogFiles.Columns[1].Visible = false; dgvLogFiles.Rows[dgvLogFiles.Rows.Count - 1].Selected = true; dgvLogFiles.CurrentCell = dgvLogFiles.Rows[dgvLogFiles.Rows.Count - 1].Cells[0]; } else { btnLoadLogs.Enabled = false; btnLoadSelected.Enabled = false; } } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnRestore_Click(object sender, EventArgs e) { try { PlayerMessageBox alert; if (playerMode) { alert = new PlayerMessageBox("question", "Do you really want to remove all occurrencies in the Log or Playlists?", "Really want to restore", false, true); } else { alert = new PlayerMessageBox("question", "Do you really want to remove all occurrencies in the Log or Playlists?", "Really want to restore", false, false); } alert.ShowDialog(); if (alert.ReturnMode) { List <string> filePaths; if (playerMode) { filePaths = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Log\Music\Log.txt").ToList(); filePaths.RemoveAll(p => p == filePath); System.IO.File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Log\Music\Log.txt", filePaths); foreach (var pair in playlistOccurrences) { var playlistPaths = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Playlists\Music\" + pair.Key + @".txt").ToList(); playlistPaths.RemoveAll(p => p == filePath); System.IO.File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Playlists\Music\" + pair.Key + @".txt", playlistPaths); } } else { filePaths = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Log\Video\Log.txt").ToList(); filePaths.RemoveAll(q => q == filePath); System.IO.File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Log\Video\Log.txt", filePaths); foreach (var pair in playlistOccurrences) { var playlistPaths = System.IO.File.ReadAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Playlists\Video\" + pair.Key + @".txt").ToList(); playlistPaths.RemoveAll(p => p == filePath); System.IO.File.WriteAllLines(AppDomain.CurrentDomain.BaseDirectory + @"Playlists\Video\" + pair.Key + @".txt", playlistPaths); } } PlayerMessageBox success; if (playerMode) { success = new PlayerMessageBox("success", "The File has been removed from the Log and all the Playlists", "File removed from Log and Playlists", true, true); } else { success = new PlayerMessageBox("success", "The File has been removed from the Log and all the Playlists", "File removed from Log and Playlists", true, false); } success.ShowDialog(); Close(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occurred", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occurred", true, false); } message.ShowDialog(); } }
public PlayerStatistic(List <FileStatistic> fileStatList, bool statisticMode, bool playerMode) { try { InitializeComponent(); this.fileStatList = fileStatList; this.playerMode = playerMode; if (playerMode) { Icon = Properties.Resources.music; if (statisticMode) { Text = "Music - Most played"; } else { Text = "Music - Most hated"; } } else { Icon = Properties.Resources.video; if (statisticMode) { Text = "Video - Most played"; } else { Text = "Video - Most hated"; } } dgvStatistic.DataSource = fileStatList; if (statisticMode) { dgvStatistic.Columns[1].Visible = false; dgvStatistic.Columns[2].HeaderText = "Played"; } else { dgvStatistic.Columns[1].Visible = false; dgvStatistic.Columns[2].HeaderText = "Deleted"; } dgvStatistic.Columns[2].FillWeight = 25; dgvStatistic.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }
private void btnDeleteFile_Click(object sender, EventArgs e) { try { if (lsbListFiles.SelectedItems.Count > 0) { string[] remainingFileLines = System.IO.File.ReadAllLines(listPath) .Where(l => !lsbListFiles.SelectedItems .Contains(TagLib.File.Create(l).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(l))) .ToArray(); System.IO.File.WriteAllLines(listPath, remainingFileLines); lsbListFiles.DataSource = System.IO.File .ReadAllLines(listPath) .Select(p => TagLib.File.Create(p).Tag.Title ?? System.IO.Path.GetFileNameWithoutExtension(p)) .ToList(); lsbListFiles.ClearSelected(); if (remainingFileLines.Length == 0) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("question", "The " + listMode.Remove(listMode.Length - 1, 1) + " is now empty...\n\nDo you want to delete it?", listMode.Remove(listMode.Length - 1, 1) + " is empty", false, true); } else { message = new PlayerMessageBox("question", "The " + listMode.Remove(listMode.Length - 1, 1) + " is now empty...\n\nDo you want to delete it?", listMode.Remove(listMode.Length - 1, 1) + " is empty", false, false); } message.ShowDialog(); if (message.ReturnMode) { System.IO.File.Delete(listPath); if (System.IO.Directory.GetFiles(System.IO.Directory.GetParent(listPath).FullName).Count() == 0) { EmptyFolder = true; } Close(); } } } else { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("information", "Please select a File to delete from " + listMode.Remove(listMode.Length - 1, 1) + " '" + System.IO.Path.GetFileNameWithoutExtension(listPath) + "'...", "No File selected", true, true); } else { message = new PlayerMessageBox("information", "Please select a File to delete from " + listMode.Remove(listMode.Length - 1, 1) + " '" + System.IO.Path.GetFileNameWithoutExtension(listPath) + "'...", "No File selected", true, false); } message.ShowDialog(); } } catch (Exception ex) { PlayerMessageBox message; if (playerMode) { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, true); } else { message = new PlayerMessageBox("error", ex.Message, "An error occured", true, false); } message.ShowDialog(); } }