public void SaveAsGrids() { if (!IsValid) { return; } BuildPicture(); DirectoryInfo exeDirectory = new DirectoryInfo(Service_Misc.GetExecutionPath()); DirectoryInfo newGridDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "NewGrids")); DirectoryInfo newGridBitmapDirectory = new DirectoryInfo(Path.Combine(exeDirectory.FullName, "NewGridsBitmap")); if (!newGridDirectory.Exists) { newGridDirectory.Create(); } if (!newGridBitmapDirectory.Exists) { newGridBitmapDirectory.Create(); } if (null != ClosestNode) { foreach (string itemName in ClosestNode.NodeItems) { string fileName = Service_Misc.UppercaseWords(itemName).Replace(" (Hidden)", "").Replace(" (Rare)", "").Trim() + " Grid"; fileName = fileName.Split(new string[] { "---" }, StringSplitOptions.None)[0] + ".txt"; Picture.Save(Path.Combine(newGridBitmapDirectory.FullName, fileName) + "_" + ClosestNodeDistance + ".png", ImageFormat.Png); string contentGrid = File.ReadAllText(GridFile.FullName); string correctedGrid = contentGrid; string correctedDescription = "[" + ClosestAetheryte.Zone.Trim() + " @" + ClosestAetheryte.Name.Trim() + "]"; string startDescription = "{\"description\":"; string endDescription = ",\"maxaway\""; if (!correctedGrid.Contains(startDescription) || !correctedGrid.Contains(endDescription)) { Status = "Bad format for automatic description"; return; } string beginGrid = contentGrid.Split(new string[] { startDescription }, StringSplitOptions.None)[0]; string endGrid = contentGrid.Split(new string[] { endDescription }, StringSplitOptions.None)[1]; ComputedDescription = correctedDescription; correctedGrid = beginGrid + startDescription + "\"" + correctedDescription + "\"" + endDescription + endGrid; File.WriteAllText(Path.Combine(newGridDirectory.FullName, Service_Misc.UppercaseWords(fileName)), correctedGrid); } } else { string fileName = Service_Misc.UppercaseWords(ItemName).Replace(" (Hidden)", "").Replace(" (Rare)", "").Trim() + " Grid"; fileName = fileName.Split(new string[] { "---" }, StringSplitOptions.None)[0] + ".txt"; Picture.Save(Path.Combine(newGridBitmapDirectory.FullName, fileName) + "_" + ClosestNodeDistance + ".png", ImageFormat.Png); string contentGrid = File.ReadAllText(GridFile.FullName); string correctedGrid = contentGrid; string correctedDescription = "[" + ClosestAetheryte.Zone.Trim() + " @" + ClosestAetheryte.Name.Trim() + "]"; string startDescription = "{\"description\":"; string endDescription = ",\"maxaway\""; if (!correctedGrid.Contains(startDescription) || !correctedGrid.Contains(endDescription)) { Status = "Bad format for automatic description"; return; } string beginGrid = contentGrid.Split(new string[] { startDescription }, StringSplitOptions.None)[0]; string endGrid = contentGrid.Split(new string[] { endDescription }, StringSplitOptions.None)[1]; ComputedDescription = correctedDescription; correctedGrid = beginGrid + startDescription + "\"" + correctedDescription + "\"" + endDescription + endGrid; File.WriteAllText(Path.Combine(newGridDirectory.FullName, Service_Misc.UppercaseWords(fileName)), correctedGrid); } }