/// <summary> /// Handles the <see cref="ButtonBase.Click"/> event for the "Move Entity Up" <see /// cref="Button"/> on any tab page.</summary> /// <param name="sender"> /// The <see cref="Object"/> where the event handler is attached.</param> /// <param name="args"> /// A <see cref="RoutedEventArgs"/> object containing event data.</param> /// <remarks> /// <b>OnEntityDown</b> swaps the first selected item in the "Entity Stack" list view with /// its upper neighbor and sets the <see cref="DataChanged"/> flag.</remarks> private void OnEntityUp(object sender, RoutedEventArgs args) { args.Handled = true; ListView stackList; Action onDataChanged; if (args.Source == MoveTerrainUpButton) { stackList = TerrainList; onDataChanged = OnTerrainTabChanged; } else { stackList = EntityList; onDataChanged = OnOtherTabChanged; } // retrieve first selected item, if any if (stackList.SelectedItems.Count == 0 || stackList.Items.Count < 2) { return; } // move item up and re-select it object item = stackList.SelectedItem; int index = CollectionsUtility.MoveItemUntyped(stackList.Items, item, -1); stackList.SelectAndShow(Math.Max(0, index)); onDataChanged(); }
/// <summary> /// Handles the <see cref="ButtonBase.Click"/> event for the "Move Frame Right" <see /// cref="Button"/>.</summary> /// <param name="sender"> /// The <see cref="Object"/> where the event handler is attached.</param> /// <param name="args"> /// A <see cref="RoutedEventArgs"/> object containing event data.</param> /// <remarks> /// <b>OnFrameRight</b> swaps the selected item in the "Image Frames" list box with its /// right neighbor and sets the <see cref="DataChanged"/> flag.</remarks> private void OnFrameRight(object sender, RoutedEventArgs args) { args.Handled = true; // retrieve selected item object item = FrameList.SelectedItem; if (FrameList.Items.Count < 2 || item == null) { return; } // move item right and re-select it int index = CollectionsUtility.MoveItemUntyped(FrameList.Items, item, +1); FrameList.SelectAndShow(index); // frame list has changed DataChanged = true; }