private void Execute_New(object sender, ExecutedRoutedEventArgs e) { var rci = new SpecRciCollection(); rci.Add(new SpecRciEntry()); this.SpecRci = rci; this.FileName = "New File"; }
private void OpenFile(string path) { try { this.SpecRci = SpecRciCollection.FromFile(path); this.FileName = path; this.ShipIdConverter.LoadShipList(path); } catch (Exception ex) { MessageBox.Show(ex.ToString(), ex.Source, MessageBoxButton.OK, MessageBoxImage.Error); } }
public static SpecRciCollection FromFile(string path) { SpecRciCollection rci = new SpecRciCollection(); FileStream filestream = null; try { filestream = new FileStream(path, FileMode.Open, FileAccess.Read); using (var file = new BinaryReader(filestream)) { filestream = null; bool end = false; while (!end) { try { int[] values = new int[12]; for (int i = 0; i < 12; i++) { values[i] = file.ReadInt32(); } rci.Add(new SpecRciEntry(values)); } catch (EndOfStreamException) { end = true; } } } } finally { if (filestream != null) { filestream.Dispose(); } } return(rci); }