private void HandleNewFile(string fileName) { EdataFileType type; using (var fs = new FileStream(fileName, FileMode.Open)) { var headerBuffer = new byte[12]; fs.Read(headerBuffer, 0, headerBuffer.Length); type = EdataManager.GetFileTypeFromHeaderData(headerBuffer); if (type == EdataFileType.Ndfbin) { var buffer = new byte[fs.Length]; fs.Seek(0, SeekOrigin.Begin); fs.Read(buffer, 0, buffer.Length); var detailsVm = new NdfEditorMainViewModel(buffer); var view = new NdfbinView { DataContext = detailsVm }; view.Show(); } } if (type == EdataFileType.Package) { AddFile(fileName); } }
protected void EditNdfbinExecute(object obj) { var vm = CollectionViewSource.GetDefaultView(OpenFiles).CurrentItem as EdataFileViewModel; if (vm == null) { return; } var ndf = vm.FilesCollectionView.CurrentItem as EdataContentFile; if (ndf == null) { return; } var dispatcher = Dispatcher.CurrentDispatcher; Action <ViewModelBase, ViewModelBase> open = DialogProvider.ProvideView; Action <string> report = msg => StatusText = msg; var s = new Task(() => { try { dispatcher.Invoke(() => IsUIBusy = true); dispatcher.Invoke(report, "Decompiling ndf binary..."); var detailsVm = new NdfEditorMainViewModel(ndf, vm); dispatcher.Invoke(open, detailsVm, this); } catch (Exception ex) { Trace.TraceError("Unhandeled exception in Thread occoured: {0}", ex.ToString()); } finally { dispatcher.Invoke(() => IsUIBusy = false); dispatcher.Invoke(report, "Ready"); } }); s.Start(); }
private void EditGameModeLogicExecute(object obj) { var ndfEditor = new NdfEditorMainViewModel(ScenarioFile.NdfBinary); DialogProvider.ProvideView(ndfEditor, this); }
private void EditTextureBindingsExecute(object obj) { var ndfEditor = new NdfEditorMainViewModel(MeshFile.TextureBindings); DialogProvider.ProvideView(ndfEditor, this); }