private void OnBoneDatabaseBrowse(object sender, EventArgs e) { mBoneDatabasePathTextBox.Text = FormatModuleUtilities.SelectModuleImport <BoneDatabase>( "Select a bone database file. (bone_data.bin/bone_data.bon)", SelectedConfiguration?.BoneDatabaseFilePath) ?? mBoneDatabasePathTextBox.Text; }
private void OnTextureDatabaseBrowse(object sender, EventArgs e) { mTextureDatabasePathTextBox.Text = FormatModuleUtilities.SelectModuleImport <TextureDatabase>( "Select a texture database file. (tex_db.bin)", SelectedConfiguration?.TextureDatabaseFilePath) ?? mTextureDatabasePathTextBox.Text; }
private void OnObjectDatabaseBrowse(object sender, EventArgs e) { mObjectDatabasePathTextBox.Text = FormatModuleUtilities.SelectModuleImport <ObjectDatabase>( "Select an object database file. (obj_db.bin)", SelectedConfiguration?.ObjectDatabaseFilePath) ?? mObjectDatabasePathTextBox.Text; }
public void EnsureNotNull() { if (mStream == null) { mStream = FormatModuleUtilities.ExportToStream(mName, mObject); mStream.Position = 0; } }
public static DataNode Create(Stream source, IEnumerable <Type> typesToCheck, string fileName = null) { var module = FormatModuleUtilities.GetModuleForImport(source, typesToCheck, fileName); if (module != null && DataNodeTypes.ContainsKey(module.ModelType)) { return(Create(module.ModelType, fileName, module.Import(source, fileName))); } return(new StreamNode(fileName, source)); }
public static DataNode Create(string filePath, IEnumerable <Type> typesToCheck) { IFormatModule module; using (var stream = File.OpenRead(filePath)) module = FormatModuleUtilities.GetModuleForImport(stream, typesToCheck, Path.GetFileName(filePath)); if (module != null && DataNodeTypes.ContainsKey(module.ModelType)) { return(Create(module.ModelType, Path.GetFileName(filePath), module.Import(filePath))); } return(new StreamNode(Path.GetFileName(filePath), File.OpenRead(filePath))); }
public void OpenFile() { using (var dialog = new OpenFileDialog()) { dialog.AutoUpgradeEnabled = true; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.Filter = FormatModuleUtilities.GetFilter( FormatModuleRegistry.ModelTypes.Where(x => typeof(IBinaryFile).IsAssignableFrom(x) && x.IsClass && !x.IsAbstract), FormatModuleFlags.Import); dialog.Title = "Select a file to open."; dialog.ValidateNames = true; dialog.AddExtension = true; if (dialog.ShowDialog() == DialogResult.OK) { OpenFile(dialog.FileName); } } }