/// <summary> /// Event handler that trigger a ItemSelect event when an item of the list is selected /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void listBox1_SelectedIndexChanged(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { SelectedSprite = Sprites.Find(p => p.Name == (string)listBox1.SelectedItem.ToString()); if (ItemSelected != null) { this.ItemSelected(this, new EventArgs()); } } }
/// <summary> /// Event handler that moves a sprite of an animation to the bottom of the list /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { if (listBox1.SelectedItem != null) { int index = listBox1.SelectedIndex; if (listBox1.SelectedIndex < listBox1.Items.Count - 1) { string tempItem = (string)listBox1.SelectedItem.ToString(); listBox1.Items[index] = listBox1.Items[index + 1]; listBox1.Items[index + 1] = tempItem; listBox1.SelectedIndex = index + 1; Sprite tempSprite = Sprites.Find(p => p.Name == tempItem); Sprites[index] = Sprites[index + 1]; Sprites[index + 1] = tempSprite; } } }
public Sprite Find(Func <Sprite, bool> subject) { return(Sprites.Find(i => subject(i))); }