public static void autoCapitalise(IEnumerable <Mp3Lib.Mp3File> mp3s, bool checkFirst, bool capSpecials, bool spaceAfter) { var CWS = new List <string>(); if (capSpecials) { CWS.Add("dj"); CWS.Add("mc"); } foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; newData.Title = StringExtras.ToCamelCase(newData.Title, true, CWS, spaceAfter); newData.Album = StringExtras.ToCamelCase(newData.Album, true, CWS, spaceAfter); newData.Artist = StringExtras.ToCamelCase(newData.Artist, true, CWS, spaceAfter); if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) { return; } } }
public static void addText(IEnumerable<Mp3Lib.Mp3File> mp3s, bool checkFirst) { var AF = new addtext(); var newDataEX = new TagHandlerUpdate(mp3s.First()); AF.titleExample = newDataEX.Title; AF.albumExample = newDataEX.Album; AF.artistExample = newDataEX.Artist; AF.ShowDialog(); if (AF.result == null) return; foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (AF.titleoptionb) { newData.Title = StringExtras.AddText(newData.Title,AF.result, AF.isfront ); } else if (AF.albumoptionb) { newData.Album = StringExtras.AddText(newData.Album,AF.result, AF.isfront); } else if (AF.artistoptionb) { newData.Artist = StringExtras.AddText(newData.Artist,AF.result, AF.isfront); } if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) return; } }
/// <summary> /// Ask the user if they want changes to be made. if yes, then make the changes, if no, return true, if cancel, return false /// </summary> /// <param name="newData">the copied mp3files taghandler</param> /// <param name="orig">the original mp3file</param> /// <param name="checkFirst"></param> /// <returns>return false if the user wants to cancel all changes, true in any other case</returns> public static bool queryUserMakeChangesAndContinue(TagHandlerUpdate newData, Mp3Lib.Mp3File orig, bool checkFirst) { usercheck UC = null; if (checkFirst) { if (areThereDifferences(orig, newData) == false) { MessageBox.Show("No changes need to be made for this file"); } else { UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)), DictionaryExtras.DictToListOfListViewItems(newData.toDict())); UC.ShowDialog(); } if (UC == null || UC.cancelval) { return(false); } if (UC.makeChanges == false) { return(true); } } return(makeChangesAndContinue(newData, orig)); }
/// <summary> /// copy the newdata to the original. /// </summary> /// <param name="newData"></param> /// <param name="orig"></param> /// <returns>always true</returns> public static bool makeChangesAndContinue(TagHandlerUpdate newData, Mp3File orig) { newData.copy(orig.TagHandler); var retrycount = 0; var maxretry = 10; retry: try { orig.Update(); } catch (Exception ecp) { retrycount++; if (retrycount >= maxretry) { MessageBox.Show("Changes could not be made-" + ecp.ToString()); return(true); } System.Threading.Thread.Sleep(100); goto retry; } return(true); }
public static bool areThereDifferences(Mp3File orig, TagHandlerUpdate newData) { var UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)), DictionaryExtras.DictToListOfListViewItems(newData.toDict())); if (UC.noChanges) return false; return true; }
public static bool areThereDifferences(Mp3File orig, TagHandlerUpdate newData) { var UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)), DictionaryExtras.DictToListOfListViewItems(newData.toDict())); if (UC.noChanges) { return(false); } return(true); }
public static void replaceChar(IEnumerable <Mp3Lib.Mp3File> mp3s, bool checkFirst) { var RC = new replacechar(); var newDataEX = new TagHandlerUpdate(mp3s.First()); RC.titleExample = newDataEX.Title; RC.albumExample = newDataEX.Album; RC.artistExample = newDataEX.Artist; RC.ShowDialog(); if (RC.result1 == '\0') { return; } foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (RC.titleoptionb) { newData.Title = StringExtras.ReplaceAllChars(newData.Title, RC.result1, RC.result2); } else if (RC.albumoptionb) { newData.Album = StringExtras.ReplaceAllChars(newData.Album, RC.result1, RC.result2); } else if (RC.artistoptionb) { newData.Artist = StringExtras.ReplaceAllChars(newData.Artist, RC.result1, RC.result2); } if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) { return; } } }
public static void trimText(IEnumerable <Mp3Lib.Mp3File> mp3s, bool checkFirst) { var newDataEX = new TagHandlerUpdate(mp3s.First()); var TF = new trimform(); TF.titleExample = newDataEX.Title; TF.albumExample = newDataEX.Album; TF.artistExample = newDataEX.Artist; TF.ShowDialog(); if (TF.result == -1) { return; } foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (TF.titleoptionb) { newData.Title = StringExtras.ApplyTrim(newData.Title, TF.isfront, TF.result); } else if (TF.albumoptionb) { newData.Album = StringExtras.ApplyTrim(newData.Album, TF.isfront, TF.result); } else if (TF.artistoptionb) { newData.Artist = StringExtras.ApplyTrim(newData.Artist, TF.isfront, TF.result); } if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) { return; } } }
public static void autoCapitalise(IEnumerable<Mp3Lib.Mp3File> mp3s, bool checkFirst,bool capSpecials,bool spaceAfter) { var CWS = new List<string>(); if (capSpecials) { CWS.Add("dj"); CWS.Add("mc"); } foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; newData.Title = StringExtras.ToCamelCase(newData.Title, true, CWS, spaceAfter); newData.Album = StringExtras.ToCamelCase(newData.Album, true, CWS, spaceAfter); newData.Artist = StringExtras.ToCamelCase(newData.Artist, true, CWS, spaceAfter); if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) return; } }
public static void autoIncrement(IEnumerable <Mp3Lib.Mp3File> mp3s, bool checkFirst) { var trackno = 0; foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (trackno == 0) { var DR = MessageBox.Show("Do you want to start at the first tracks track number?", "question", MessageBoxButtons.YesNoCancel); if (DR == DialogResult.Cancel) { return; } if (newData.Track == null || newData.Track == "" || DR == DialogResult.No || int.Parse(newData.Track) < 1) { trackno = 1; } else { trackno = int.Parse(newData.Track); } } newData.Track = trackno.ToString(); trackno++; if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) { return; } } }
//title from path public static bool testTitles(IEnumerable <Mp3Lib.Mp3File> list, bool force, bool checkFirst) { foreach (var MF in list) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (orig.Title.Length == 0 || force) { var title = MF.FileName; title = title.Substring(title.LastIndexOf('\\') + 1); title = title.Substring(0, title.LastIndexOf('.')); newData.Title = title; if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) { return(false); } } } return(true); }
//title from path public static bool testTitles(IEnumerable<Mp3Lib.Mp3File> list, bool force, bool checkFirst) { foreach (var MF in list) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (orig.Title.Length == 0 || force) { var title = MF.FileName; title = title.Substring(title.LastIndexOf('\\') + 1); title = title.Substring(0, title.LastIndexOf('.')); newData.Title = title; if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) return false; } } return true; }
public static void replaceChar(IEnumerable<Mp3Lib.Mp3File> mp3s, bool checkFirst) { var RC = new replacechar(); var newDataEX = new TagHandlerUpdate(mp3s.First()); RC.titleExample = newDataEX.Title; RC.albumExample = newDataEX.Album; RC.artistExample = newDataEX.Artist; RC.ShowDialog(); if (RC.result1 == '\0') return; foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (RC.titleoptionb) { newData.Title = StringExtras.ReplaceAllChars(newData.Title, RC.result1, RC.result2); } else if (RC.albumoptionb) { newData.Album = StringExtras.ReplaceAllChars(newData.Album, RC.result1, RC.result2); } else if (RC.artistoptionb) { newData.Artist = StringExtras.ReplaceAllChars(newData.Artist, RC.result1, RC.result2); } if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) return; } }
/// <summary> /// Ask the user if they want changes to be made. if yes, then make the changes, if no, return true, if cancel, return false /// </summary> /// <param name="newData">the copied mp3files taghandler</param> /// <param name="orig">the original mp3file</param> /// <param name="checkFirst"></param> /// <returns>return false if the user wants to cancel all changes, true in any other case</returns> public static bool queryUserMakeChangesAndContinue(TagHandlerUpdate newData, Mp3Lib.Mp3File orig, bool checkFirst) { usercheck UC = null; if (checkFirst) { if (areThereDifferences(orig, newData) == false) { MessageBox.Show("No changes need to be made for this file"); } else { UC = new usercheck(DictionaryExtras.DictToListOfListViewItems(TagHandlerToDict(orig)), DictionaryExtras.DictToListOfListViewItems(newData.toDict())); UC.ShowDialog(); } if (UC==null||UC.cancelval) return false; if (UC.makeChanges == false) return true; } return makeChangesAndContinue(newData,orig); }
/// <summary> /// copy the newdata to the original. /// </summary> /// <param name="newData"></param> /// <param name="orig"></param> /// <returns>always true</returns> public static bool makeChangesAndContinue(TagHandlerUpdate newData, Mp3File orig) { newData.copy(orig.TagHandler); var retrycount = 0; var maxretry = 10; retry: try { orig.Update(); } catch (Exception ecp) { retrycount++; if (retrycount >= maxretry) { MessageBox.Show("Changes could not be made-" + ecp.ToString()); return true; } System.Threading.Thread.Sleep(100); goto retry; } return true; }
public static void cleanMP3(TagHandlerUpdate TH) { TH.Title = StringExtras.CleanString(TH.Title); TH.Album = StringExtras.CleanString(TH.Album); TH.Artist = StringExtras.CleanString(TH.Artist); }
public static void autoIncrement(IEnumerable<Mp3Lib.Mp3File> mp3s, bool checkFirst) { var trackno = 0; foreach (var MF in mp3s) { var newData = new TagHandlerUpdate(MF); var orig = MF.TagHandler; if (trackno == 0) { var DR = MessageBox.Show("Do you want to start at the first tracks track number?", "question", MessageBoxButtons.YesNoCancel); if (DR == DialogResult.Cancel) return; if (newData.Track == null || newData.Track == "" || DR == DialogResult.No || int.Parse(newData.Track) < 1) trackno = 1; else trackno = int.Parse(newData.Track); } newData.Track = trackno.ToString(); trackno++; if (queryUserMakeChangesAndContinue(newData, MF, checkFirst) == false) return; } }