public void CompactLevelOrdinals() { var ordinal = 0; foreach (var l in CalculationItems.OrderBy(l => l.Ordinal)) { l.MetadataObject.Ordinal = ordinal; ordinal++; } }
public void FixItemOrder(CalculationItem item, int newOrdinal) { if (_reordering) { return; } var before = CalculationItems.OrderBy(l => l.Ordinal).ToList(); var ordinal = 0; foreach (var l in CalculationItems.OrderBy(l => (l == item ? newOrdinal : l.Ordinal) * 2 - (l == item ? 1 : 0))) { l.MetadataObject.Ordinal = newOrdinal == -1 ? -1 : ordinal; ordinal++; } var after = CalculationItems.OrderBy(l => l.Ordinal).ToList(); Handler.UndoManager.Add(new UndoCalculationItemsOrderAction(this, before, newOrdinal == -1 ? null : after)); _reordering = false; Handler.Tree.OnStructureChanged(this); }