protected void UpdateSourceEditors(IEnumerable <SoundEmitter> values) { int visibleElementCount = values.Where(o => o != null).Min(o => o.Sources.Count); // Add missing editors for (int i = 0; i < visibleElementCount; i++) { SoundEmitterSourcePropertyEditor elementEditor; if (i < this.soundSourceEditors.Count) { elementEditor = this.soundSourceEditors[i]; } else { elementEditor = new SoundEmitterSourcePropertyEditor(); this.ParentGrid.ConfigureEditor(elementEditor); this.soundSourceEditors.Add(elementEditor); this.AddPropertyEditor(elementEditor); } elementEditor.PropertyName = string.Format("Sources[{0}]", i); elementEditor.Getter = this.CreateSourceValueGetter(i); elementEditor.Setter = this.CreateSourceValueSetter(i); elementEditor.ParentEmitter = values; elementEditor.PerformGetValue(); } // Remove overflowing editors for (int i = this.soundSourceEditors.Count - 1; i >= visibleElementCount; i--) { this.RemovePropertyEditor(this.soundSourceEditors[i]); this.soundSourceEditors.RemoveAt(i); } }
protected void UpdateSourceEditors(IEnumerable<SoundEmitter> values) { int visibleElementCount = values.Where(o => o != null).Min(o => o.Sources.Count); // Add missing editors for (int i = 0; i < visibleElementCount; i++) { SoundEmitterSourcePropertyEditor elementEditor; if (i < this.soundSourceEditors.Count) elementEditor = this.soundSourceEditors[i]; else { elementEditor = new SoundEmitterSourcePropertyEditor(); this.ParentGrid.ConfigureEditor(elementEditor); this.soundSourceEditors.Add(elementEditor); this.AddPropertyEditor(elementEditor); } elementEditor.PropertyName = string.Format("Sources[{0}]", i); elementEditor.Getter = this.CreateSourceValueGetter(i); elementEditor.Setter = this.CreateSourceValueSetter(i); elementEditor.ParentEmitter = values; elementEditor.PerformGetValue(); } // Remove overflowing editors for (int i = this.soundSourceEditors.Count - 1; i >= visibleElementCount; i--) { this.RemovePropertyEditor(this.soundSourceEditors[i]); this.soundSourceEditors.RemoveAt(i); } }