Пример #1
0
        public void MoveCalculationItem(CalculationItem item, CalculationGroupTable newCgt)
        {
            var name = item.Name;

            item.Delete();
            item.RenewMetadataObject();
            item.MetadataObject.Name = newCgt.CalculationItems.GetNewName(name);
            newCgt.CalculationItems.Add(item);
        }
Пример #2
0
        public CalculationItem AddCalculationItem(string name = null, string expression = null)
        {
            var item = CalculationItem.CreateNew(CalculationGroup, string.IsNullOrEmpty(name) ? "New Calculation" : name);

            if (expression != null)
            {
                item.Expression = expression;
            }
            return(item);
        }
        public CalculationItem AddCalculationItem(string name = null, string expression = null)
        {
            var item = CalculationItem.CreateNew(CalculationGroup, string.IsNullOrEmpty(name) ? "New Calculation" : name);

            if (expression != null)
            {
                item.Expression = expression;
            }
            if (CalculationItems.Any(i => i.Ordinal != -1))
            {
                item.Ordinal = CalculationItems.Max(i => i.Ordinal) + 1;
            }
            return(item);
        }
        internal void AddError(CalculationItem calculationItem)
        {
            if (ErrorMessage == null)
            {
                ErrorMessage = $"Error on \"{calculationItem.Name}\": {calculationItem.ErrorMessage}";
            }
            else
            {
                ErrorMessage += $"Error on \"{calculationItem.Name}\": {calculationItem.ErrorMessage}";
            }

            if (CalculationItemErrors == null)
            {
                CalculationItemErrors = $"Error on \"{calculationItem.Name}\": {calculationItem.ErrorMessage}";
            }
            else
            {
                CalculationItemErrors += $"Error on \"{calculationItem.Name}\": {calculationItem.ErrorMessage}";
            }

            Handler._errors.Add(calculationItem);
        }
        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);
        }