private void characterCopyMenuItem_Click(object sender, EventArgs e) { characterPasteMenuItem.Enabled = true; characterInVirtualClipBoard = characterSelector.SelectedItem as Character; }
private void characterSelector_DragDrop(object sender, DragEventArgs e) { CheckedListBox listBox = sender as CheckedListBox; if (e.Data.GetDataPresent(typeof(Character))) { if (e.Effect == DragDropEffects.Move) { Character c = e.Data.GetData(typeof(Character)) as Character; int index = listBox.IndexFromPoint(listBox.PointToClient(new Point(e.X, e.Y))); if (index > -1) { listBox.Items.Insert(index, c); characterCollection.Insert(index, c); int oldSelectedIndex = listBox.SelectedIndex; listBox.Items.RemoveAt(oldSelectedIndex); characterCollection.RemoveAt(oldSelectedIndex); listBox.SelectedItem = c; characterEditor.Character = c; FireDataChangedEvent(); } } else if (e.Effect == DragDropEffects.Copy) { Character c = e.Data.GetData(typeof(Character)) as Character; int index = listBox.IndexFromPoint(listBox.PointToClient(new Point(e.X, e.Y))); Character d = new Character(c.ToByteArray(), index); if (index > -1) { d.Index = (byte)index; listBox.Items.Insert(index, d); listBox.SetItemChecked(index, d.IsPresent); characterCollection.Insert(index, d); listBox.Items.RemoveAt(index + 1); characterCollection.RemoveAt(index + 1); listBox.SelectedItem = d; characterEditor.Character = d; FireDataChangedEvent(); } } } }