Example #1
0
        private void deleteAnimationButton_Click(object sender, EventArgs e)
        {
            int selectedIndex = AnimationListBox.SelectedIndex;

            if (selectedIndex < 0)
            {
                return;
            }

            AnimationGroup selectedItem = (AnimationGroup)AnimationListBox.SelectedItem;

            // delete item
            selectedItem.DeleteFromData();

            // update list
            animationGroups.Remove(selectedItem);
            animationGroups.SaveToData();
            animationListBinding.ResetBindings(false);
            Loader.Global.SetSaveRequiredFlag(true, false);

            // get new selected item at the current index, if any
            selectedIndex = Math.Min(selectedIndex, AnimationListBox.Items.Count - 1);
            selectedItem  = selectedIndex < 0 ? null : (AnimationGroup)AnimationListBox.Items[selectedIndex];
            AnimationListBox.SelectedItem = selectedItem;
        }
Example #2
0
        private void deleteAnimationButton_Click(object sender, EventArgs e)
        {
            if (AnimationListBox.SelectedIndices.Count <= 0)
            {
                MessageBox.Show("Select at least one Animation Group");
                return;
            }

            //retrieve list of selected animation groups to delete
            List <AnimationGroup> deletedAnimationGroups = new List <AnimationGroup>();

            foreach (int selectedIndex in AnimationListBox.SelectedIndices)
            {
                if (selectedIndex < 0)
                {
                    return;
                }

                deletedAnimationGroups.Add((AnimationGroup)AnimationListBox.Items[selectedIndex]);
            }

            foreach (AnimationGroup deletedItem in deletedAnimationGroups)
            {
                // delete item
                deletedItem.DeleteFromData();

                // update list
                animationGroups.Remove(deletedItem);
            }

            animationGroups.SaveToData();
            animationListBinding.ResetBindings(false);
            Loader.Global.SetSaveRequiredFlag(true, false);

            // get new selected item at the current index, if any
            if (AnimationListBox.Items.Count > 0)
            {
                int            newIndex        = Math.Min(AnimationListBox.SelectedIndices[0], AnimationListBox.Items.Count - 1);
                AnimationGroup newSelectedItem = newIndex < 0 ? null : (AnimationGroup)AnimationListBox.Items[newIndex];
                AnimationListBox.SelectedItem = newSelectedItem;
            }
        }