Пример #1
0
        public void MoveItem(ElementSorterItem item, SortDirection direction)
        {
            var index = StackPanel.Children.IndexOf(item) + (direction == SortDirection.Up ? -1 : 1);

            if (index < 0)
            {
                index = 0;
            }
            else if (index > StackPanel.Children.Count - 1)
            {
                index = StackPanel.Children.Count - 1;
            }

            StackPanel.Children.Remove(item);
            StackPanel.Children.Insert(index, item);

            if (IsPlayer)
            {
                Config.Instance.DeckPanelOrderPlayer = StackPanel.Children.Cast <ElementSorterItem>().Select(x => x.Panel).ToArray();
            }
            else
            {
                Config.Instance.DeckPanelOrderOpponent = StackPanel.Children.Cast <ElementSorterItem>().Select(x => x.Panel).ToArray();
            }
        }
Пример #2
0
 public void AddItem(ElementSorterItem item) => StackPanel.Children.Add(item);