public bool MoveItemDown(CollapseItem itemToMove) { // if the item belongs to another item if (itemToMove.parentItem != null) { int num = itemToMove.parentItem.mItems.IndexOf(itemToMove); if (num == itemToMove.parentItem.mItems.Count - 1) { return(false); } itemToMove.parentItem.mItems.Remove(itemToMove); itemToMove.parentItem.mItems.Insert(num + 1, itemToMove); } else // item belongs to a ListBox { if (itemToMove.parentBox is CollapseListBox) { CollapseListBox parentAsCollapseListBox = itemToMove.parentBox as CollapseListBox; int num = parentAsCollapseListBox.Items.IndexOf(itemToMove); if (itemToMove.ParentItem != null && num == itemToMove.parentItem.mItems.Count - 1) { return(false); } parentAsCollapseListBox.Items.Remove(itemToMove); parentAsCollapseListBox.Items.Insert(num + 1, itemToMove); } else if (itemToMove.parentBox is ListBox) { ListBox parentAsListBox = itemToMove.parentBox as ListBox; int num = parentAsListBox.mItems.IndexOf(itemToMove); if (num == itemToMove.parentItem.mItems.Count - 1) { return(false); } parentAsListBox.mItems.Remove(itemToMove); parentAsListBox.mItems.Insert(num + 1, itemToMove); } } return(true); }
public ListBoxWindow() : base(GuiManager.Cursor) { #region Set "this" properties. GuiManager.AddWindow(this); SetPositionTL(97.3f, 25.2f); ScaleX = 13.1f; ScaleY = 19.505f; mName = "Keyframes"; mMoveBar = true; MinimumScaleX = ScaleX; MinimumScaleY = 7; this.Resizable = true; this.Resizing += AdjustPositionsAndScales; #endregion #region List Box mInstructionSetListBox = AddCollapseListBox(); mInstructionSetListBox.Highlight += new GuiMessage(UpdateAddButtonVisibility); mInstructionSetListBox.Highlight += HighlightInstructionSetListBox; mInstructionSetListBox.FocusUpdate += InstructionListHotkeyUpdate; #endregion #region AnimationSequence ListDisplayWindow mAnimationSequenceListBox = new ListDisplayWindow(mCursor); this.AddWindow(mAnimationSequenceListBox); mAnimationSequenceListBox.ListBox.Highlight += HighlightAnimationSequenceListBox; mAnimationSequenceListBox.ListBox.StrongSelect += DoubleClickAnimationSequenceListBox; mAnimationSequenceListBox.ListBox.FocusUpdate += new FocusUpdateDelegate(AnimationSequenceFocusUpdate); ListDisplayWindow.SetStringRepresentationMethod(typeof(TimedKeyframeList), GetTimedKeyframeListStringRepresentation); #endregion #region Add Keyframe List Button mAddKeyframeListButton = AddButton(); mAddKeyframeListButton.Text = "Add Animation"; mAddKeyframeListButton.Click += AddKeyframeListClick; // this will call UpdateVisibleWindows #endregion #region Add Keyframe Button mAddKeyframeButton = AddButton(); mAddKeyframeButton.Text = "Add Keyframe"; mAddKeyframeButton.Click += AddKeyframe; #endregion AdjustPositionsAndScales(null); }