Exemplo n.º 1
0
        /// <summary>
        /// Moves the specified group closer to the front (0-index) of the collection.
        /// </summary>
        /// <param name="group">The group to move</param>
        private void MoveGroupUp(Group group)
        {
            if (group == null)
            {
                return;
            }
            int index = _groups.IndexOf(group);

            if (index < 0)
            {
                throw new ArgumentException("Group " + group.Name + " does not exist");
            }
            if (index > 0)
            {
                int startIndex  = this.sessionService.BudgetValues.IndexOf(this.sessionService.BudgetValues.First(x => x.Group == group));
                int targetIndex = this.sessionService.BudgetValues.IndexOf(this.sessionService.BudgetValues.First(x => x.Group == _groups.ElementAt(index - 1)));
                int endIndex    = this.sessionService.BudgetValues.IndexOf(this.sessionService.BudgetValues.Last(x => x.Group == group));
                _groups.Move(index, index - 1);
                this.sessionService.MoveTotalRows(index, index - 1);
                int offset = targetIndex - startIndex;
                //Move each row in the Values grids
                for (int i = 0; i <= endIndex - startIndex; i++)
                {
                    this.sessionService.MoveValueRows(startIndex + i, startIndex + i + offset);
                }
                this.sessionService.RefreshListViews(); //Refresh grouping
                this.SelectedGroupItem = group;
            }
        }