private ComboBox CreateFormatBox(IInstruction op) { ComboBox cb = new ComboBox(); foreach (string s in Enum.GetNames(typeof(Scrutinizer.TexelFormat))) { cb.Items.Add(s); } cb.Width = 80; cb.SelectedIndex = (int)(op as ITextureInstruction).Format; cb.DropDownStyle = ComboBoxStyle.DropDownList; cb.SelectedIndexChanged += delegate(object s, EventArgs e) { if (op is ITextureInstruction) { ITextureInstruction samp = op as ITextureInstruction; samp.Format = (TexelFormat)cb.SelectedIndex; if (this.TexelFormatChanged != null) { this.TexelFormatChanged(samp); } } }; return(cb); }
public void AddInstructionToPanel(InstructionWidget widget, IInstruction op) { m_InstructionIndexMap.Add(op, m_InstructionWidgets.Count); m_InstructionWidgets.Add(op, widget); widget.Click += delegate(object s, EventArgs e) { this.OnInstructionClick(widget, e as MouseEventArgs); }; // change format on all selected instructions whenever one of them is changed widget.TexelFormatChanged += delegate(ITextureInstruction inst) { if (!widget.Selected) { return; } foreach (InstructionWidget s in m_SelectedOps) { ITextureInstruction tx = s.Instruction as ITextureInstruction; if (tx != null && tx != inst) { tx.Format = inst.Format; } s.RefreshInstruction(); } }; // change filter on all selected instructions whenever one of them is changed widget.FilterChanged += delegate(ISamplingInstruction inst) { if (!widget.Selected) { return; } foreach (InstructionWidget s in m_SelectedOps) { ISamplingInstruction tx = s.Instruction as ISamplingInstruction; if (tx != null && tx != inst) { tx.Filter = inst.Filter; } s.RefreshInstruction(); } }; panel1.Controls.Add(widget); }