/// <summary> /// Runs the specified plug-in from the list of plug-ins. /// </summary> /// <param name="index">The plug-in to run.</param> /// <param name="type">The type of plug-in to run.</param> /// <param name="owner">The Form calling the plug-in.</param> public bool RunPlugIn(int index, DataInterfacing.PlugIns.PlugInTypes type, Form owner) { return(RunPlugInAuto(index, type, owner, null)); }
/// <summary> /// Runs the specified plug-in from the list of plug-ins. /// </summary> /// <param name="index">The plug-in to run.</param> /// <param name="type">The type of plug-in to run.</param> /// <param name="owner">The Form calling the plug-in.</param> /// <param name="filename">The filename to load into the plug-in.</param> public bool RunPlugInAuto(int index, DataInterfacing.PlugIns.PlugInTypes type, Form owner, string filename) { bool success = false; ArrayList plugins = null; switch (type) { case DataInterfacing.PlugIns.PlugInTypes.Textures: plugins = _plugins.TexturePlugIns; break; case DataInterfacing.PlugIns.PlugInTypes.Importing: plugins = _plugins.FileImportPlugIns; break; case DataInterfacing.PlugIns.PlugInTypes.Exporting: plugins = _plugins.FileExportPlugIns; break; case DataInterfacing.PlugIns.PlugInTypes.Vertices: default: plugins = _plugins.VertexPlugIns; break; } if (index > -1 && index < plugins.Count) { try { PlugIn plugin = (PlugIn)plugins[index]; ArrayList textures = new ArrayList(); DataCore.Texture tex, texCopy; if (_page != null) { foreach (DataCore.Texture t in _page.TerrainPatch.Textures) { textures.Add(t.Name); } } if (type != DataInterfacing.PlugIns.PlugInTypes.Importing) { plugin.SetPage(new TerrainPage(_page)); } plugin.StartPosition = FormStartPosition.CenterParent; plugin.SetOwner(owner); plugin.SetTextures(textures); LoadDesiredPlugInData(plugin); if (filename == null) { plugin.Run(); } else { ArrayList objects = new ArrayList(); objects.Add(filename); plugin.AutoRun(objects); } success = plugin.GetSuccess(); if (success) { StoreLastPage(plugin.GetPage(), plugin.GetName()); if (plugin.GetPage() != null && plugin.GetModifiedTextures()) { textures = plugin.GetTextures(); // Build new texture details for (int i = 0; i < textures.Count; i++) { texCopy = (Texture)textures[i]; tex = (DataCore.Texture)_page.TerrainPatch.Textures[i]; if (tex.DXTexture != null && !tex.DXTexture.Disposed) { tex.DXTexture.Dispose(); } tex.DXTexture = D3D.TextureLoader.FromFile(_viewport.Device, texCopy.FileName); tex.Name = texCopy.Name; tex.FileName = texCopy.FileName; tex.OperationText = texCopy.OperationText; tex.Operation = GetTextureOperation(tex.OperationText); tex.Mask = texCopy.Mask; tex.Scale = texCopy.Scale; tex.Shift = texCopy.Shift; _page.TerrainPatch.Textures[i] = tex; } } _page.TerrainPatch.CalculateNormals(); _buffers.RefreshIndexBuffer_Page(); } } catch (Exception e) { string message = "An exception has been thrown!\n\n"; message += "Source: " + e.Source + "\n"; message += "Error: " + e.Message; MessageBox.Show(null, message, "Error Running Application", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } } return(success); }
public void LoadPlugIn(DataInterfacing.PlugIns.PlugInTypes type) { _plugins.LoadPlugIn(type); }