private void MenuItem_Click_1(object sender, RoutedEventArgs e) { string report = ""; foreach (MulFileSet set in m_mapFiles) { foreach (MulFile file in set.MulFiles) { if (file != null && file is StaIdxMulFile) { StaIdxMulFile staidxMul = (StaIdxMulFile)file; if (staidxMul.BadIndices.Count > 0) { report += string.Format("Staidx{0}.mul had the following errors:\r\n", file.Index); foreach (IndexForStaticBlock idx in staidxMul.BadIndices) { foreach (string s in idx.Errors) { report += string.Format(" Block {0} - {1}\r\n", idx.Block, s); } } } } } } if (report != "") { System.Windows.Forms.SaveFileDialog saveDialogue = new System.Windows.Forms.SaveFileDialog(); saveDialogue.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"; System.Windows.Forms.DialogResult result = saveDialogue.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { using (System.IO.StreamWriter writer = new System.IO.StreamWriter(saveDialogue.FileName)) { writer.Write(report); } } } }
private void ParseFiles() { Dictionary <int, List <MulFile> > mapSets = new Dictionary <int, List <MulFile> >(); System.Windows.Forms.FolderBrowserDialog folder = new System.Windows.Forms.FolderBrowserDialog(); string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); folder.SelectedPath = System.IO.Path.Combine(appDataPath, "UltimaLive"); System.Windows.Forms.DialogResult result = folder.ShowDialog(); if (result == System.Windows.Forms.DialogResult.OK) { string[] files = System.IO.Directory.GetFiles(folder.SelectedPath); foreach (string filepath in files) { string filename = System.IO.Path.GetFileName(filepath); if (filename.StartsWith("map") && filename.EndsWith(".mul")) { try { string numString = filename.Substring(3, filename.Length - 7); int index = Convert.ToInt32(numString); //int index = Convert.ToInt32(filename.Substring(3, filename.Length - 4)); if (!mapSets.ContainsKey(index)) { mapSets.Add(index, new List <MulFile>()); } MapMulFile mapMul = new MapMulFile(filepath); mapMul.Index = index; mapMul.StartNewOperationEvent += StartNewOperation; mapMul.UpdateOperationStatusEvent += UpdateOperationStatus; mapMul.StopOperationEvent += StopOperation; mapMul.CheckForBlockErrors(); mapSets[index].Add(mapMul); } catch (Exception mapException) { System.Windows.Forms.MessageBox.Show(mapException.Message + " ::: " + mapException.StackTrace); } } if (filename.StartsWith("statics") && filename.EndsWith(".mul")) { try { int index = Convert.ToInt32(filename.Substring(7, filename.Length - 11)); if (!mapSets.ContainsKey(index)) { mapSets.Add(index, new List <MulFile>()); } StaticsMulFile staticsMul = new StaticsMulFile(filepath); staticsMul.Index = index; mapSets[index].Add(staticsMul); } catch (Exception staticsException) { System.Windows.Forms.MessageBox.Show(staticsException.Message + " ::: " + staticsException.StackTrace); } } if (filename.StartsWith("staidx") && filename.EndsWith(".mul")) { try { int index = Convert.ToInt32(filename.Substring(6, filename.Length - 10)); if (!mapSets.ContainsKey(index)) { mapSets.Add(index, new List <MulFile>()); } StaIdxMulFile staidxMul = new StaIdxMulFile(filepath); staidxMul.Index = index; staidxMul.StartNewOperationEvent += StartNewOperation; staidxMul.UpdateOperationStatusEvent += UpdateOperationStatus; staidxMul.StopOperationEvent += StopOperation; staidxMul.CheckForBlockErrors(); mapSets[index].Add(staidxMul); } catch (Exception staidxException) { System.Windows.Forms.MessageBox.Show(staidxException.Message + " ::: " + staidxException.StackTrace); } } } updateTreeview(mapSets); } }