private void pass_Changed(object sender, EventArgs e) { if (!mSuspendPassChange) { EffectPassDefinition pass = new EffectPassDefinition( passNameBox.Text, (passVertexShaderBox.SelectedIndex >= 0) ? mEffectDefinition.VertexShaders[passVertexShaderBox.SelectedIndex].Name : String.Empty, (passPixelShaderBox.SelectedIndex >= 0) ? mEffectDefinition.PixelShaders[passPixelShaderBox.SelectedIndex].Name : String.Empty, (passVertexShaderProfileBox.SelectedIndex >= 0) ? (ShaderProfile)Enum.Parse(typeof(ShaderProfile), (string)passVertexShaderProfileBox.SelectedItem, true) : ShaderProfile.VS_1_1, (passPixelShaderProfileBox.SelectedIndex >= 0) ? (ShaderProfile)Enum.Parse(typeof(ShaderProfile), (string)passPixelShaderProfileBox.SelectedItem, true) : ShaderProfile.PS_1_1); mEffectDefinition.Techniques[effectTechniquesList.SelectedIndex].Passes[effectTechniquePassesList.SelectedIndex] = pass; mSuspendPassChange = true; int nameBoxStart = passNameBox.SelectionStart; int nameBoxLen = passNameBox.SelectionLength; int selectedIndex = effectTechniquePassesList.SelectedIndex; effectTechniquePassesList.DataSource = null; effectTechniquePassesList.DataSource = mEffectDefinition.Techniques[effectTechniquesList.SelectedIndex].Passes; effectTechniquePassesList.SelectedIndex = selectedIndex; passNameBox.SelectionStart = nameBoxStart; passNameBox.SelectionLength = nameBoxLen; mSuspendPassChange = false; } }
private void effectTechniquePassesList_SelectedIndexChanged(object sender, EventArgs e) { if (!mSuspendPassChange) { removePassButton.Enabled = (effectTechniquePassesList.SelectedIndex >= 0); effectTechniquePassesEditor.Panel2.Enabled = (effectTechniquePassesList.SelectedIndex >= 0); if (effectTechniquePassesList.SelectedIndex >= 0) { EffectPassDefinition pass = ((EffectPassDefinition)effectTechniquePassesList.SelectedItem); passNameBox.Text = pass.Name; // vertex shaders int shaderIndex = -1; for (int i = 0; i < mEffectDefinition.VertexShaders.Count; i++) { if (mEffectDefinition.VertexShaders[i].Name == pass.VertexShaderName) { shaderIndex = i; } } passVertexShaderBox.SelectedIndex = shaderIndex; passVertexShaderProfileBox.SelectedIndex = (passVertexShaderProfileBox.Items.Contains(pass.VertexShaderProfile.ToString()) ? passVertexShaderProfileBox.Items.IndexOf(pass.VertexShaderProfile.ToString()) : -1); // pixel shaders shaderIndex = -1; for (int i = 0; i < mEffectDefinition.PixelShaders.Count; i++) { if (mEffectDefinition.PixelShaders[i].Name == pass.PixelShaderName) { shaderIndex = i; } } passPixelShaderBox.SelectedIndex = shaderIndex; passPixelShaderProfileBox.SelectedIndex = (passPixelShaderProfileBox.Items.Contains(pass.PixelShaderProfile.ToString()) ? passPixelShaderProfileBox.Items.IndexOf(pass.PixelShaderProfile.ToString()) : -1); } } }