private void addVideoToolStripMenuItem_Click(object sender, EventArgs e) { try { if (!String.IsNullOrEmpty(playlistsList.Text)) { openFileDialog.Title = Langs.open + " - " + playlistsList.Text; if (openFileDialog.ShowDialog() == DialogResult.OK) { String SelectedPlaylistPath = Reference.PlaylistsPath + playlistsList.Text + "\\"; String SelectedPlaylistInfo = SelectedPlaylistPath + Path.GetFileNameWithoutExtension(openFileDialog.FileName) + ".info"; Rasu VideoInfo = new Rasu(SelectedPlaylistInfo); if (!File.Exists(SelectedPlaylistPath + Path.GetFileName(openFileDialog.FileName))) { // Copy video File.Copy(openFileDialog.FileName, SelectedPlaylistPath + Path.GetFileName(openFileDialog.FileName)); File.Create(SelectedPlaylistInfo).Dispose(); // Create info file File.WriteAllText(SelectedPlaylistInfo, Resources.video); // Set up video info file VideoInfo.Set("video_extension", Path.GetExtension(openFileDialog.FileName)); VideoInfo.Set("video_file_version", Application.ProductVersion); VideoInfo.SaveFile(); refreshList(); } else { MetroMessageBox.Show(this, Langs.videoExist, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MetroMessageBox.Show(this, Langs.selectPlaylist, "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MetroMessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Updates files (settings) public static void UpdateFiles() { try { // Update files Rasu SettingsTemplate = new Rasu(Resources.settings); Reference.RSettings.MergeFile(SettingsTemplate); SettingsTemplate.Set("version", Application.ProductVersion); File.WriteAllText(Reference.RSettings.GetFilePath(), SettingsTemplate.GetFileContent()); Reference.RSettings.ReloadFile(); } catch (Exception ex) { MetroMessageBox.Show(Program.mainForm, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// Apply edit private void editvideo_editvideobutton_Click(object sender, EventArgs e) { try { Rasu VideoInfo = new Rasu(wFile.Path + ".info"); if (editvideo_videodescription.Text != wFile.Description && !String.IsNullOrEmpty(editvideo_videodescription.Text)) { VideoInfo.Set("video_description", editvideo_videodescription.Text); } if (editvideo_videoname.Text != wFile.ToString() && !String.IsNullOrEmpty(editvideo_videoname.Text)) { String VideoPath = wFile.Path + wFile.Extension; File.Move(VideoPath, Reference.PlaylistsPath + playlistsList.Text + "\\" + editvideo_videoname.Text + wFile.Extension); File.Move(VideoInfo.GetFilePath(), Reference.PlaylistsPath + playlistsList.Text + "\\" + editvideo_videoname.Text + ".info"); } VideoInfo.SaveFile(); Settings.refreshTabs(); refreshList(); } catch (Exception ex) { MetroMessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public WatchFile(String name, String extension) { try { this.Name = name; this.Extension = extension; this.Path = Reference.PlaylistsPath + Program.mainForm.playlistsList.Text + "\\" + name; if (Extension != ".web") { var player = new WindowsMediaPlayer(); var clip = player.newMedia(this.Path + this.Extension); this.Duration = TimeSpan.FromSeconds(clip.duration).ToString(); } Rasu VideoInfo = new Rasu(this.Path + ".info"); // Check updates if (VideoInfo.Get("video_file_version") != Application.ProductVersion) { Rasu VideoInfoTemplate = new Rasu(Resources.video); VideoInfo.MergeFile(VideoInfoTemplate); VideoInfoTemplate.Set("video_file_version", Application.ProductVersion); File.WriteAllText(VideoInfo.GetFilePath(), VideoInfoTemplate.GetFileContent()); VideoInfo.ReloadFile(); } this.Description = VideoInfo.Get("video_description"); } catch (Exception ex) { MetroMessageBox.Show(Program.mainForm, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }