/// <summary> /// Loads an effect definition from a file /// </summary> /// <param name="fileName">The name of the effect file</param> /// <returns>The effect definition</returns> #endregion public static EffectDefinition FromFile(string fileName) { EffectDefinition effect = FileManager.XmlDeserialize <EffectDefinition>(fileName); string directory = FileManager.GetDirectory(fileName); for (int i = 0; i < effect.Components.Count; i++) { effect.Components[i] = directory + effect.Components[i]; } return(effect); }
public EditorForm() { InitializeComponent(); mEffectDefinition = new EffectDefinition("NewEffect"); // Allow model drag-drop modelViewPanel.AllowDrop = true; modelViewPanel.DragEnter += new DragEventHandler(modelViewPanel_DragEnter); modelViewPanel.DragDrop += new DragEventHandler(modelViewPanel_DragDrop); // Allow effect drag-drop effectEditBox.AllowDrop = true; effectEditBox.DragEnter += new DragEventHandler(effectEditBox_DragEnter); effectEditBox.DragDrop += new DragEventHandler(effectEditBox_DragDrop); modelViewPanel.ModelLoaded = ModelLoaded; hlslInfoBox.ReadOnly = true; hlslInfoBox.Clear(); effectParametersList.Parameters = mEffectDefinition.Parameters; UpdateStandardParameters(); effectComponentsList.DataSource = mEffectDefinition.Components; effectTechniquesList.DataSource = mEffectDefinition.Techniques; // populate shader profiles boxes in techniques tab string[] shaderProfiles = Enum.GetNames(typeof(ShaderProfile)); for (int i = 0; i < shaderProfiles.Length; i++) { if (shaderProfiles[i].Contains("VS")) passVertexShaderProfileBox.Items.Add(shaderProfiles[i]); if (shaderProfiles[i].Contains("PS")) passPixelShaderProfileBox.Items.Add(shaderProfiles[i]); } mLoadedComponents = new List<EffectComponent>(); vertexShaderEditor.AllowComponentUsage = true; pixelShaderEditor.AllowComponentUsage = true; }
private void loadEffectToolStripMenuItem_Click(object sender, EventArgs e) { if (openEffectDialog.ShowDialog() == DialogResult.OK) { mEffectDefinition = EffectDefinition.FromFile(openEffectDialog.FileName); this.SuspendLayout(); effectComponentsList.DataSource = null; effectComponentsList.DataSource = mEffectDefinition.Components; UpdateAvailableComponents(); effectParametersList.Parameters = mEffectDefinition.Parameters; UpdateStandardParameters(); effectEdit_vertexShaderListChanged(null, new EventArgs()); effectEdit_pixelShaderListChanged(null, new EventArgs()); if (mEffectDefinition.VertexShaders.Count > 0) vertexShadersList.SelectedIndex = 0; if (mEffectDefinition.PixelShaders.Count > 0) pixelShadersList.SelectedIndex = 0; effectTechniquesList.DataSource = null; effectTechniquesList.DataSource = mEffectDefinition.Techniques; this.ResumeLayout(); } }