private void btnFolderName_Click(object sender, EventArgs e) { GlobalUserConfig config = new GlobalUserConfig(); GlobalUserConfig.ParentFolderPath = txtPath.Text.Trim(); List <DirectoryInfo> dir = null; DirectoryProcess dirProcess = new DirectoryProcess(); dir = dirProcess.GetDirectories(); List <string> fName = new List <string>(); StringBuilder strBuilder = new StringBuilder(); foreach (var folderName in dir) { strBuilder.Append("insert into MusicBand (FolderName) values ('"); strBuilder.Append(folderName.Name.Trim()); strBuilder.Append("');"); strBuilder.AppendLine(""); } txtMusicFolderName.Text = strBuilder.ToString(); //listBox1.DataSource = fName; }
internal static void LoadUserConfig() { // Load global user settings into memory UserConfig GlobalUserConfig = ModInstance.Helper.Data.ReadJsonFile <UserConfig>(UserConfigFilename); #if DEBUG //GlobalUserConfig = null; // Force full refresh of config file for testing purposes #endif if (GlobalUserConfig != null) { bool RewriteConfig = false; // Version 1.0.5 added additional settings to augmentor formulas if (GlobalUserConfig.CreatedByVersion < new Version(1, 0, 5)) { RewriteConfig = true; } if (RewriteConfig) { GlobalUserConfig.CreatedByVersion = CurrentVersion; ModInstance.Helper.Data.WriteJsonFile(UserConfigFilename, GlobalUserConfig); } } else { GlobalUserConfig = new UserConfig() { CreatedByVersion = CurrentVersion }; ModInstance.Helper.Data.WriteJsonFile(UserConfigFilename, GlobalUserConfig); } GlobalUserConfig.AfterLoaded(); UserConfig = GlobalUserConfig; }
private void btnProcess_Click(object sender, EventArgs e) { GlobalUserConfig config = new GlobalUserConfig(); GlobalUserConfig.ParentFolderPath = txtPath.Text.Trim(); Simile.Factory.MusicFileFactory mFileFactory = new Factory.MusicFileFactory(); mFileFactory.Process(); List <string> artistsTagValues = mFileFactory.ArtistsTagValue; List <TemplateMusicFileTag> listOfMusicFileTagTempData = mFileFactory.ListOfMusicFileTagTempData; dataGridView2.DataSource = listOfMusicFileTagTempData; //IEnumerable<TemplateMusicFileTag> result = from r in listOfMusicFileTagTempData // orderby r.ArtistTagVale // select new TemplateMusicFileTag // { ArtistTagVale = r.ArtistTagVale,IsArtist = r.IsArtist, IsAlbum = r.IsAlbum, IsBand = r.IsBand, // ErrorMessage = r.ErrorMessage, FileName = r.FileName} // ; //dataGridView2.DataSource = result.ToArray(); // listOfMusicFileTagTempData; dataGridView2.Columns[1].Width = 40; dataGridView2.Columns[2].Width = 40; dataGridView2.Columns[3].Width = 40; dataGridView2.Columns[4].Width = 85; }
private void btnGo_Click(object sender, EventArgs e) { GlobalUserConfig config = new GlobalUserConfig(); GlobalUserConfig.ParentFolderPath = txtPath.Text.Trim(); // DirectoryProcess dprocess = new DirectoryProcess(); ProcessMusicFiles processMFiles = new ProcessMusicFiles(); processMFiles.Process(); //TruncateSymbolFactory symbolFactory = new TruncateSymbolFactory(); //symbolFactory.Process(); // TagNameForFileName obj = new TagNameForFileName(); // obj.Process(); //TruncasteNumber obj = new TruncasteNumber(); //obj.Process(); }
public void Process(FileInfo musicFile) { DirectoryProcess dirProcess = new DirectoryProcess(); string currentFilePathAndName = ""; string musicFileName = ""; string artistName = ""; TagLib.File tagMusicFile = null; tagMusicFile = TagLib.File.Create(musicFile.FullName); string artistFolderPath = ""; musicFileName = musicFile.Name.Trim(); currentFilePathAndName = musicFile.FullName.Trim(); List <string> artists = GlobalUserConfig.GetArtist(tagMusicFile); foreach (string val in artists) { if (IsValidArtist(val.Trim())) { artistName = string.IsNullOrEmpty(artistName) ? val.Trim() : artistName + " & " + val; } //Create folder. if (!dirProcess.HasFolderExists(GlobalUserConfig.MusicFilesFolder + artistName)) { System.IO.Directory.CreateDirectory(GlobalUserConfig.MusicFilesFolder + artistName); } artistFolderPath = GlobalUserConfig.MusicFilesFolder + artistName + "\\"; //move music files to folder. //check file exists. if (!File.Exists(artistFolderPath + musicFileName)) { System.IO.File.Move(currentFilePathAndName, artistFolderPath + musicFileName); } } }
public override void Entry(IModHelper helper) { ModInstance = this; // Load global user settings into memory UserConfig GlobalUserConfig = helper.Data.ReadJsonFile <UserConfig>(UserConfigFilename); #if DEBUG //GlobalUserConfig = null; // Force full refresh of config file for testing purposes #endif if (GlobalUserConfig != null) { bool RewriteConfig = false; // Version 1.0.5 added additional settings to augmentor formulas if (GlobalUserConfig.CreatedByVersion < new Version(1, 0, 5)) { RewriteConfig = true; } if (RewriteConfig) { GlobalUserConfig.CreatedByVersion = CurrentVersion; helper.Data.WriteJsonFile(UserConfigFilename, GlobalUserConfig); } } else { GlobalUserConfig = new UserConfig() { CreatedByVersion = CurrentVersion }; helper.Data.WriteJsonFile(UserConfigFilename, GlobalUserConfig); } GlobalUserConfig.AfterLoaded(); UserConfig = GlobalUserConfig; // Load custom machine settings MachineConfig GlobalMachineConfig = helper.Data.ReadJsonFile <MachineConfig>(Path.Combine("assets", MachineConfigFilename)); #if DEBUG //GlobalMachineConfig = null; // Force full refresh of config file for testing purposes #endif if (GlobalMachineConfig == null) { GlobalMachineConfig = new MachineConfig(); helper.Data.WriteJsonFile(MachineConfigFilename, GlobalMachineConfig); } MachineConfig = GlobalMachineConfig; MachineInfo.LoadAugmentableMachineData(); MachineInfo.IsPrismaticToolsModInstalled = helper.ModRegistry.IsLoaded("stokastic.PrismaticTools"); Helper.Events.Display.RenderedWorld += Display_RenderedWorld; Helper.Events.GameLoop.Saving += GameLoop_Saving; Helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded; Helper.Events.GameLoop.UpdateTicked += GameLoop_UpdateTicked; Helper.Events.Input.CursorMoved += Input_CursorMoved; Helper.Events.Display.MenuChanged += Display_MenuChanged; helper.Events.GameLoop.DayStarted += GameLoop_DayStarted; #region Game Patches HarmonyInstance Harmony = HarmonyInstance.Create(this.ModManifest.UniqueID); // Patch Object.performObjectDropInAction, so that we can detect when items are put into a machine, and then modify the output based on attached augmentors Harmony.Patch( original: AccessTools.Method(typeof(Object), nameof(Object.performObjectDropInAction)), prefix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.PerformObjectDropInAction_Prefix)), postfix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.PerformObjectDropInAction_Postfix)) ); // Patch Object.checkForAction, so that we can detect when processed items are collected from machines that don't require input, // and then we can modify the new processed items based on attached augmentors Harmony.Patch( original: AccessTools.Method(typeof(Object), nameof(Object.checkForAction)), prefix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.CheckForAction_Prefix)), postfix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.CheckForAction_Postfix)) ); // Patch Object.draw, so that we can draw icons of the attached augmentors after the object is drawn to a tile of the game world Harmony.Patch( original: AccessTools.Method(typeof(Object), nameof(Object.draw), new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float) }), postfix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.Draw_Postfix)) ); // Patch GameLocation.monsterDrop, so that we can give a small chance of making monsters also drop augmentors Harmony.Patch( original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.monsterDrop)), postfix: new HarmonyMethod(typeof(GamePatches), nameof(GamePatches.MonsterDrop_Postfix)) ); #endregion Game Patches RegisterConsoleCommands(); }
private void btnGo_Click(object sender, EventArgs e) { DistilTitle distilTitle = new DistilTitle(); TitleExtract titleExtract = new TitleExtract(); GlobalUserConfig config = new GlobalUserConfig(); GlobalUserConfig.ParentFolderPath = txtPath.Text.Trim(); DirectoryProcess dProcess = new DirectoryProcess(); List <DirectoryInfo> dirList = dProcess.GetDirectories(); FileInfo[] musicFiles = null; TagLib.File tagMusicFile = null; Simile.Algorithm.AlgorithmFactory algFactory = new Algorithm.AlgorithmFactory(); //string newTitle = ""; // string artistOrBandName = ""; // Simile.SimileEnums.GroupCategory grpCategory = SimileEnums.GroupCategory.Unknown; Simile.DBProcess.MusicBand musicBand = new Simile.DBProcess.MusicBand(); Simile.DBProcess.MusicArtist musicArtist = new Simile.DBProcess.MusicArtist(); List <MusicFileViewModel> listMusicFileViewModel = new List <MusicFileViewModel>(); MusicFileViewModel musicFileViewModel = null; List <clsErrorRpt> errorRpts = new List <clsErrorRpt>(); clsErrorRpt errR = null; foreach (DirectoryInfo dir in dirList) { musicFiles = dir.GetFiles(GlobalUserConfig.FileType); foreach (FileInfo finfo in musicFiles) { try { FileInfo musicFile = finfo; // errR = new clsErrorRpt(); errR.FileName = musicFile.Name; errR.Path = musicFile.FullName; // tagMusicFile = TagLib.File.Create(musicFile.FullName); //if tag is null then avoid the file and get next file. if (tagMusicFile.Tag == null) { continue; } musicFileViewModel = new MusicFileViewModel(); musicFileViewModel.Title = tagMusicFile.Tag.Title.Trim(); // newTitle.Trim(); musicFileViewModel.FileName = musicFile.Name.Trim(); musicFileViewModel.Path = musicFile.DirectoryName.Trim(); var artistName = ""; var bandName = ""; //---------------------------- if (tagMusicFile.Tag.AlbumArtists != null && tagMusicFile.Tag.AlbumArtists.Count() > 0) { string tmpAlbArtists = ""; var test = tagMusicFile.Tag.AlbumArtists; foreach (var val in test) { tmpAlbArtists += val.Trim(); } if (!string.IsNullOrEmpty(tmpAlbArtists)) { using (var modelContext = new MusicPlayEntities3()) { Simile.MusicArtist tmpArtist = modelContext.MusicArtists.Where(r => r.ArtistName.ToUpper() == tmpAlbArtists.ToUpper()).FirstOrDefault(); if (tmpArtist != null) { musicFileViewModel.Artist = tmpArtist.ArtistName.Trim(); musicFileViewModel.ArtistId = tmpArtist.Id; } } using (var modelContext = new MusicPlayEntities3()) { Simile.MusicBand tmpBand = modelContext.MusicBands.Where(r => r.BandName.ToUpper() == tmpAlbArtists.ToUpper()).FirstOrDefault(); if (tmpBand != null) { musicFileViewModel.Band = tmpBand.BandName.Trim(); musicFileViewModel.BandId = tmpBand.Id; } } } } //----------------------------- ////////////////// if (musicFileViewModel.BandId == 0) { var tmpBandName = musicFile.Directory.Name.Trim(); using (var modelContext = new MusicPlayEntities3()) { Simile.MusicBand tmpBand = modelContext.MusicBands.Where(r => r.BandName.ToUpper() == tmpBandName.ToUpper()).FirstOrDefault(); if (tmpBand != null) { musicFileViewModel.Band = tmpBand.BandName.Trim(); musicFileViewModel.BandId = tmpBand.Id; } } } if (musicFileViewModel.ArtistId == 0) { var tmpArtistName = musicFile.Directory.Name.Trim(); using (var modelContext = new MusicPlayEntities3()) { Simile.MusicArtist tmpArtist = modelContext.MusicArtists.Where(r => r.ArtistName.ToUpper() == tmpArtistName.ToUpper()).FirstOrDefault(); if (tmpArtist != null) { musicFileViewModel.Artist = tmpArtist.ArtistName.Trim(); musicFileViewModel.ArtistId = tmpArtist.Id; } } } //////////////////// if (!string.IsNullOrEmpty(tagMusicFile.Tag.Comment)) { var splitComments = tagMusicFile.Tag.Comment.Split(';'); foreach (var val in splitComments) { var childSplit = val.ToString().Split('='); if (childSplit.Length == 2) { if (childSplit[0].Trim() == "Artist") { artistName = childSplit[1].Trim(); } if (childSplit[0].Trim() == "Band") { bandName = childSplit[1].Trim(); } } } } if (musicFileViewModel.BandId == 0 && !string.IsNullOrEmpty(bandName)) { using (var modelContext = new MusicPlayEntities3()) { Simile.MusicBand tmpBand = modelContext.MusicBands.Where(r => r.BandName.ToUpper() == bandName.ToUpper()).FirstOrDefault(); musicFileViewModel.Band = tmpBand.BandName.Trim(); musicFileViewModel.BandId = tmpBand.Id; } } if (musicFileViewModel.ArtistId == 0 && !string.IsNullOrEmpty(artistName)) { using (var modelContext = new MusicPlayEntities3()) { Simile.MusicArtist tmpArtist = modelContext.MusicArtists.Where(r => r.ArtistName.ToUpper() == artistName.ToUpper()).FirstOrDefault(); musicFileViewModel.Artist = tmpArtist.ArtistName.Trim(); musicFileViewModel.ArtistId = tmpArtist.Id; } } listMusicFileViewModel.Add(musicFileViewModel); } catch (Exception errMsg) { errR.Error = errMsg.Message; errorRpts.Add(errR); MessageBox.Show(errMsg.Message); } } // end of for loop } //end of dir for loop dgvMusicFiles.DataSource = listMusicFileViewModel; }