private void bnRemove_Click(object sender, EventArgs e) { try { HalfAxis.HAxis currentAxis = SelectedFace; Texture currentTexture = SelectedTexture; _textures.RemoveAll(delegate(Pair <HalfAxis.HAxis, Texture> p) { return(p.first == currentAxis && p.second == currentTexture); }); // update bitmap control FillBitmapControl(SelectedFace); // select first texture available in list if (listBoxTextures.Items.Count > 0) { ListBoxImagesItem item = listBoxTextures.Items[0] as ListBoxImagesItem; SelectedTexture = item.Texture; } else { onSelectedTextureChanged(this, null); } // draw box DrawBox(); } catch (Exception ex) { _log.Error(ex.ToString()); } }
/// <summary> /// overrides ListBox.OnDrawItem /// </summary> /// <param name="e">event argument used to retrieve item by index</param> protected override void OnDrawItem(DrawItemEventArgs e) { // prevent Visual Designer errors if (this.Items.Count > 0) { ListBoxImagesItem item = (ListBoxImagesItem)this.Items[e.Index]; item.drawItem(e, this.Margin, this._imageSize, e.Index == SelectedIndex); } }