private void btnExport_Click(object sender, EventArgs e) { try { if (DiskIO.IsValidPath(this.SelectedExportPath) && SelectedLanguages != null) { int i; if (DiskIO.DriveHasFreeSpace(SelectedExportPath, Program.currentProject.GetAllFilesVolume(out i))) { FileCopier[] allCopy = Program.currentProject.ExportTo(SelectedExportPath, SelectedLanguages); frmCopyProgress progressDlg = new frmCopyProgress(allCopy); if (progressDlg.ShowDialog(this) == DialogResult.OK) { this.DialogResult = DialogResult.OK; } } else { MessageBox.Show("There is no enough free space in selected drive. Please choose another location.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please choose proper location for export.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception exp) { Program.ShowExceptionData(exp); } }
internal void SaveMusicFilesInfos(string _path, string _fileName) { Dictionary <string, List <MusicFile> > toJsonItem = new Dictionary <string, List <MusicFile> >(); toJsonItem.Add("tracks", tracks); DiskIO.SaveAsJSONFile(toJsonItem, _path, _fileName); }
internal void SaveMoviesNonEnglishLibrary(Dictionary <string, MovieFile> _dictionary) { VideoFolder temp = new VideoFolder(this.location, this.title); foreach (var item in Enum.GetValues(typeof(Languages))) { if (_dictionary.ContainsKey(item.ToString())) { string header = item.ToString().Substring(0, 2); string fileName = "index." + header + ".json"; if (DiskIO.IsFileExist(ContentLocation, fileName)) { temp = DiskIO.DeserializeVideoFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasMovieWithID(_dictionary[item.ToString()].id)) { temp.RemoveMovieWithID(_dictionary[item.ToString()].id); } temp.library.Add(_dictionary[item.ToString()]); temp.SaveMoviesLibrary(fileName); } else { temp.library = new List <MovieFile>(); temp.library.Add(_dictionary[item.ToString()]); temp.SaveMoviesLibrary(fileName); } } } }
internal void ExportFilesTo(string contentLoc) { string newWorkArea = contentLoc + "\\" + title; DiskIO.CreateDirectory(newWorkArea); DiskIO.SaveAsJSONFile(this, newWorkArea, "index.en.json"); }
private void btnOpenProject_Click(object sender, EventArgs e) { try { var dlgOpen = new OpenFileDialog(); dlgOpen.Filter = "Mahan Content Management Files | *.mcm"; if (dlgOpen.ShowDialog() == DialogResult.OK && !string.IsNullOrEmpty(dlgOpen.FileName)) { if (ProjectFolder.IsValidProjectDirectory(DiskIO.GetDirectoryName(dlgOpen.FileName))) { //MessageBox.Show("sdadada"); Program.currentProject = new ProjectFolder(dlgOpen.FileName); Program.mcmFile = dlgOpen.FileName; frmSenarioMaker workDlg = new frmSenarioMaker(this); this.Hide(); workDlg.Show(); } else { throw new Exception(".MCM File or project directory is not valid."); } } } catch (Exception exp) { MessageBox.Show("Can not load existed project. Please review directory and .mcm file.\n" + "Details: " + exp.Source + " - " + exp.Message, "Loading Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
internal FileCopier[] ExportFilesTo(string contentLoc, string[] _languages) { string newWorkArea = contentLoc + "\\" + title; List <FileCopier> allFilesToCopy = new List <FileCopier>(); // create root folder DiskIO.CreateDirectory(newWorkArea); DiskIO.DeleteAllFiles(newWorkArea); foreach (MovieFile p in this.library) { // create each movie folder string movieNewLocation = newWorkArea + "\\" + p.id; DiskIO.CreateDirectory(movieNewLocation); // add video files to copy allFilesToCopy.Add(new FileCopier(p.video.path, movieNewLocation + "\\" + DiskIO.GetFileName(p.video.path))); // change the file path to the new path for further library json saving p.video.path = DiskIO.GetFileName(p.video.path); // add trailer if exist if (!string.IsNullOrEmpty(p.trailer.path)) { allFilesToCopy.Add(new FileCopier(p.trailer.path, movieNewLocation + "\\" + DiskIO.GetFileName(p.trailer.path))); p.trailer.path = DiskIO.GetFileName(p.trailer.path); } if (!string.IsNullOrEmpty(p.cover)) { // add video cover to copy allFilesToCopy.Add(new FileCopier(p.cover, movieNewLocation + "\\cover.jpg")); // change the cover path to the new path for further library json saving p.cover = "\\cover.jpg"; } } // save changed paths and music files into exported location this.SaveMovieLibraryAtLocation(newWorkArea, "index.en.json"); // copy all requested non-English langs foreach (string lang in _languages) { string abbriv = "index." + lang.Substring(0, 2).ToLower() + ".json"; if (DiskIO.IsFileExist(ContentLocation, abbriv)) { VideoFolder temp = DiskIO.DeserializeVideoFolderFromFile(ContentLocation, abbriv); foreach (MovieFile p in temp.library) { p.video.path = "\\" + DiskIO.GetFileName(p.video.path); if (!string.IsNullOrEmpty(p.trailer.path)) { p.trailer.path = "\\" + DiskIO.GetFileName(p.trailer.path); } if (!string.IsNullOrEmpty(p.cover)) { p.cover = "\\cover.jpg"; } } DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv); } } return(allFilesToCopy.ToArray()); }
internal static List <MusicFile> DeserializeFilesFromJSON(string _fullPath, string _fileName) { Dictionary <string, List <MusicFile> > retVal = new Dictionary <string, List <MusicFile> >(); if (DiskIO.IsFileExist(_fullPath, _fileName)) { retVal = DiskIO.DeserializeTracksFromFile(_fullPath, _fileName); } return(retVal["tracks"]); }
internal static bool IsValidProjectDirectory(string _pathTodirectory) { bool retVal = DiskIO.IsDirectoryExist(_pathTodirectory, "files") && DiskIO.IsFileExist(_pathTodirectory, "index.json") && DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", AUDIO_FOLDER_NAME) && DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", VIDEO_FOLDER_NAME) && DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", PDF_FOLDER_NAME) && DiskIO.IsDirectoryExist(_pathTodirectory + "\\" + "files", ANNOUNC_FOLDER_NAME); return(retVal); }
internal static PDFFolder SerializeFromJSON(string _pdfLocation, string _pdfFolderName, string _fileName) { PDFFolder retVal = new PDFFolder(_pdfLocation, _pdfFolderName); if (DiskIO.IsFileExist(_pdfLocation + "\\" + _pdfFolderName, _fileName)) { retVal = DiskIO.DeserializePDFFolderFromFile(_pdfLocation + "\\" + _pdfFolderName, _fileName); } retVal.SetLocationTitle(_pdfLocation, _pdfFolderName); return(retVal); }
internal static SurveyFolder SerializeFromJSON(string _surLocation, string _surFolderName, string _fileName) { SurveyFolder retVal = new SurveyFolder(_surLocation, _surFolderName); if (DiskIO.IsFileExist(_surLocation + "\\" + _surFolderName, _fileName)) { retVal = DiskIO.DeserializeSurveyFolderFromFile(_surLocation + "\\" + _surFolderName, _fileName); } retVal.SetLocationTitle(_surLocation, _surFolderName); return(retVal); }
public AudioFolder(string _location, string _title) { library = new List <MusicPlaylist>(); title = _title; location = _location; if (DiskIO.IsFileExist(ContentLocation, "index.en.json")) { // go back //DiskIO.DeserializeObjectFromJSONFile(this, ContentLocation, "index.en.json"); } }
internal static VideoFolder SerializeFromJSON(string _videoLocation, string _videoFolderName, string _fileName) { VideoFolder retVal = new VideoFolder(_videoLocation, _videoFolderName); if (DiskIO.IsFileExist(_videoLocation + "\\" + _videoFolderName, _fileName)) { retVal = DiskIO.DeserializeVideoFolderFromFile(_videoLocation + "\\" + _videoFolderName, _fileName); } retVal.SetLocationTitle(_videoLocation, _videoFolderName); return(retVal); }
internal static List <MusicFile> GetMusicFiles(string _playlistFolderPath) { string[] fileEntries = Directory.GetFiles(_playlistFolderPath, "*.mp3"); List <MusicFile> retVal = new List <MusicFile>(); foreach (string x in fileEntries) { retVal.Add(new MusicFile(x, DiskIO.GetFileTitle(x), GetMediaDuration(x))); } return(retVal); }
internal FileCopier[] ExportFilesTo(string _contentLoc, string[] _languages) { string newWorkArea = _contentLoc + "\\" + title; List <FileCopier> allFilesToCopy = new List <FileCopier>(); // create root folder DiskIO.CreateDirectory(newWorkArea); DiskIO.DeleteAllFiles(newWorkArea); // create each playlist folder foreach (MusicPlaylist p in this.library) { string playlistNewLocation = newWorkArea + "\\" + p.id; DiskIO.CreateDirectory(playlistNewLocation); // determine music files to copy foreach (MusicFile file in p.GetMusicFilesInfo()) { // add music file allFilesToCopy.Add(new FileCopier(file.file, playlistNewLocation + "\\" + DiskIO.GetFileName(file.file))); // change the file path to the new path for further library json saving file.file = DiskIO.GetFileName(file.file); } // add playlist cover to copy if (p.cover != "") { allFilesToCopy.Add(new FileCopier(p.cover, playlistNewLocation + "\\cover.jpg")); // change the cover path to the new path for further library json saving p.cover = "\\cover.jpg"; } p.playlist = "\\index.m3u"; } // save changed paths and music files into exported location this.SavePlaylistLibraryAtLocation(newWorkArea, "index.en.json"); // copy all requested non-English langs foreach (string lang in _languages) { string abbriv = "index." + lang.Substring(0, 2).ToLower() + ".json"; if (DiskIO.IsFileExist(ContentLocation, abbriv)) { AudioFolder temp = DiskIO.DeserializeAudioFolderFromFile(ContentLocation, abbriv); foreach (MusicPlaylist x in temp.library) { x.playlist = "\\index.m3u"; if (x.cover != "") { x.cover = "\\cover.jpg"; } } DiskIO.SaveAsJSONFile(temp, newWorkArea, abbriv); } } return(allFilesToCopy.ToArray()); }
private void SavePlaylistLibraryAtLocation(string _fullPath, string _fileName) { // save all playlists json file DiskIO.SaveAsJSONFile(this, _fullPath, _fileName); // create folder for each playlist and save their music tracks foreach (MusicPlaylist pls in this.library) { string playlistFolder = _fullPath + "\\" + pls.id; //DiskIO.CreateDirectory(playlistFolder); pls.SaveMusicFilesInfos(playlistFolder, "index.Json"); } }
internal void SavePlaylistLibrary() { // save all playlists json file DiskIO.SaveAsJSONFile(this, this.ContentLocation, "index.en.json"); // create folder for each playlist and save their music tracks foreach (MusicPlaylist pls in this.library) { string playlistFolder = this.ContentLocation + "\\" + pls.id; DiskIO.CreateDirectory(playlistFolder); pls.SaveMusicFilesInfos(playlistFolder, "index.Json"); } }
private void btnInsert_Click(object sender, EventArgs e) { try { if (this.FormCompleted() && EnglishMoreDataExist()) { this.playlistToComplete.SetPlaylist(txtDirectory.Text); this.playlistToComplete.cover = txtCover.Text; this.playlistToComplete.year = txtYear.Text == "" ? 0 : Convert.ToInt32(txtYear.Text); this.playlistToComplete.ageCategory = cmbAge.Items[cmbAge.SelectedIndex].ToString(); string[] str = new string[lstGenres.SelectedItems.Count]; int i = 0; foreach (object x in lstGenres.SelectedItems) { str[i++] = lstGenres.GetItemText(x); } this.playlistToComplete.genre = str; this.playlistToComplete.num_tracks = DiskIO.GetFilesNumber(this.playlistToComplete.playlist, "*.mp3"); // apply english language this.playlistToComplete.title = nonEngAdditionalData["English"].title; this.playlistToComplete.artist = nonEngAdditionalData["English"].artist; this.playlistToComplete.description = nonEngAdditionalData["English"].description; // apply for other languages nonEngAdditionalData.Remove("English"); foreach (KeyValuePair <string, MusicPlaylist> x in this.nonEngAdditionalData) { x.Value.id = this.playlistToComplete.id; x.Value.SetPlaylist(txtDirectory.Text); x.Value.cover = txtCover.Text; x.Value.year = txtYear.Text == "" ? 0 : Convert.ToInt32(txtYear.Text); x.Value.ageCategory = cmbAge.Items[cmbAge.SelectedIndex].ToString(); str = new string[lstGenres.SelectedItems.Count]; i = 0; foreach (object obj in lstGenres.SelectedItems) { str[i++] = lstGenres.GetItemText(obj); } x.Value.genre = str; x.Value.num_tracks = DiskIO.GetFilesNumber(this.playlistToComplete.playlist, "*.mp3"); } this.DialogResult = DialogResult.OK; } else { MessageBox.Show("Please fill Directory, Age, Genre and English Additional data first.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception exp) { Program.ShowExceptionData(exp); } }
private void CreateNewProjetFiles() { // create index.json file string path = location + @"\" + title; ProjectMethadata toFile = new ProjectMethadata(this.ContentLocation); DiskIO.SaveAsJSONFile(toFile, path, "index.json"); string mcmFileContent = string.Join(";", new string[2] { title, location }); DiskIO.SaveAsTextFile(mcmFileContent, path, title + ".mcm"); }
public void CreateNewProjectDirectories() { //create projet itslef files and folders DiskIO.CreateDirectory(location, title); DiskIO.CreateDirectory(ContentLocation); this.CreateNewProjetFiles(); //create subfolders for contents playlists.CreateNewAudioDirectory(); movies.CreateNewVideoDirectory(); articles.CreateNewPDFDirectory(); announces.CreateNewVideoDirectory(); questions.CreateNewSurveyDirectory(); }
internal static AudioFolder SerializeFromJSON(string _audioLocation, string _audioFolderName, string _fileName) { AudioFolder retVal = new AudioFolder(_audioLocation, _audioFolderName); if (DiskIO.IsFileExist(_audioLocation + "\\" + _audioFolderName, _fileName)) { retVal = DiskIO.DeserializeAudioFolderFromFile(_audioLocation + "\\" + _audioFolderName, _fileName); foreach (MusicPlaylist pls in retVal.library) { pls.LoadMusicFileInfos(_audioLocation + "\\" + _audioFolderName + "\\" + pls.id, "index.json"); } } retVal.SetLocationTitle(_audioLocation, _audioFolderName); return(retVal); }
internal FileCopier[] ExportTo(string _selectedExportPath, string[] _languages) { List <FileCopier> allFilesToCopy = new List <FileCopier>(); DiskIO.CreateDirectory(_selectedExportPath + "\\output"); DiskIO.CreateDirectory(_selectedExportPath + "\\output" + "\\files"); string contentLoc = _selectedExportPath + "\\output" + "\\files"; allFilesToCopy.AddRange(this.playlists.ExportFilesTo(contentLoc, _languages)); allFilesToCopy.AddRange(this.movies.ExportFilesTo(contentLoc, _languages)); allFilesToCopy.AddRange(this.announces.ExportFilesTo(contentLoc, _languages)); allFilesToCopy.AddRange(this.articles.ExportFilesTo(contentLoc, _languages)); this.questions.ExportFilesTo(contentLoc); return(allFilesToCopy.ToArray()); }
internal long GetFilesVolume(out int _numOfFiles) { long retval = 0; int numFiles = 0; foreach (ArticleFile a in this.library) { retval += DiskIO.GetFileSize(a.file); numFiles++; if (!string.IsNullOrEmpty(a.cover)) { retval += DiskIO.GetFileSize(a.cover); numFiles++; } } _numOfFiles = numFiles; return(retval); }
public ProjectFolder(string _mcmFilePath) { string mcmContent = DiskIO.ReadTextFile(_mcmFilePath); string[] tempArr = mcmContent.Split(';'); this.title = tempArr[0]; this.location = tempArr[1]; playlists = new AudioFolder(ContentLocation, AUDIO_FOLDER_NAME); playlists = AudioFolder.SerializeFromJSON(ContentLocation, AUDIO_FOLDER_NAME, "index.en.json"); movies = new VideoFolder(ContentLocation, VIDEO_FOLDER_NAME); movies = VideoFolder.SerializeFromJSON(ContentLocation, VIDEO_FOLDER_NAME, "index.en.json"); announces = new VideoFolder(ContentLocation, ANNOUNC_FOLDER_NAME); announces = VideoFolder.SerializeFromJSON(ContentLocation, ANNOUNC_FOLDER_NAME, "index.en.json"); articles = new PDFFolder(ContentLocation, PDF_FOLDER_NAME); articles = PDFFolder.SerializeFromJSON(ContentLocation, PDF_FOLDER_NAME, "index.en.json"); questions = new SurveyFolder(ContentLocation, SURVEY_FOLDER_NAME); questions = SurveyFolder.SerializeFromJSON(ContentLocation, SURVEY_FOLDER_NAME, "index.en.json"); }
internal void RemoveMovieNonEnglishData(int _id) { VideoFolder temp = new VideoFolder(this.location, this.title); foreach (var item in Enum.GetValues(typeof(Languages))) { string header = item.ToString().Substring(0, 2); string fileName = "index." + header + ".json"; if (DiskIO.IsFileExist(ContentLocation, fileName)) { temp = DiskIO.DeserializeVideoFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasMovieWithID(_id)) { temp.RemoveMovieWithID(_id); } DiskIO.SaveAsJSONFile(temp, this.ContentLocation, fileName); } } }
internal long GetFilesVolume(out int _numberOfFiles) { long retval = 0; int numFiles = 0; foreach (MusicPlaylist p in this.library) { foreach (MusicFile file in p.GetMusicFilesInfo()) { retval += DiskIO.GetFileSize(file.file); numFiles++; } if (p.cover != "") { retval += DiskIO.GetFileSize(p.cover); numFiles++; } } _numberOfFiles = numFiles; return(retval); }
internal long GetFilesVolume(out int _numOfFiles) { long retval = 0; int numFiles = 0; foreach (MovieFile m in this.library) { retval += DiskIO.GetFileSize(m.video.path); numFiles++; if (!string.IsNullOrEmpty(m.trailer.path)) { retval += DiskIO.GetFileSize(m.trailer.path); numFiles++; } if (!string.IsNullOrEmpty(m.cover)) { retval += DiskIO.GetFileSize(m.cover); numFiles++; } } _numOfFiles = numFiles; return(retval); }
internal Dictionary <string, MovieFile> ReadNonEnglishDataLibrary(int _id) { Dictionary <string, MovieFile> retVal = new Dictionary <string, MovieFile>(); VideoFolder temp = new VideoFolder(this.location, this.title); foreach (var item in Enum.GetValues(typeof(Languages))) { string header = item.ToString().Substring(0, 2); string fileName = "index." + header + ".json"; if (DiskIO.IsFileExist(ContentLocation, fileName)) { temp = DiskIO.DeserializeVideoFolderFromFile(ContentLocation, fileName); temp.SetLocationTitle(this.location, this.title); if (temp.HasMovieWithID(_id)) { retVal.Add(item.ToString(), temp.FindMovieWithID(_id)); } } } return(retVal); }
private void button1_Click(object sender, EventArgs e) { try { OpenFileDialog dlgBrowse = new OpenFileDialog(); while (dlgBrowse.ShowDialog() == DialogResult.OK) { if (DiskIO.IsVideoFile(dlgBrowse.FileName)) { txtTrailerFie.Text = dlgBrowse.FileName; break; } else { MessageBox.Show("This file is not a valid video file. Please Select another.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception exp) { Program.ShowExceptionData(exp); } }
private void btnBrowseCov_Click(object sender, EventArgs e) { try { OpenFileDialog dlgOpen = new OpenFileDialog(); while (dlgOpen.ShowDialog() == DialogResult.OK) { if (DiskIO.IsImageFile(dlgOpen.FileName)) { txtCover.Text = dlgOpen.FileName; break; } else { MessageBox.Show("This file is not an image file. Please Select another.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception exp) { Program.ShowExceptionData(exp); } }
private void btnBrowseDir_Click(object sender, EventArgs e) { try { OpenFileDialog dlgBrowse = new OpenFileDialog(); while (dlgBrowse.ShowDialog() == DialogResult.OK) { if (DiskIO.IsArticleFile(dlgBrowse.FileName)) { txtFile.Text = dlgBrowse.FileName; break; } else { MessageBox.Show("Selected file is not an article (.pdf) file. Please Select another.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } } catch (Exception exp) { Program.ShowExceptionData(exp); } }