Esempio n. 1
0
        public IValue Total(IValue ColumnIndex, bool IncludeChildren = false)
        {
            ValueTreeColumn Column = Columns.GetColumnByIIndex(ColumnIndex);
            decimal         Result = 0;

            foreach (ValueTreeRow row in _rows)
            {
                IValue current_value = row.Get(Column);
                if (current_value.DataType == Machine.DataType.Number)
                {
                    Result += current_value.AsNumber();
                }

                if (IncludeChildren)
                {
                    IValue children_total = row.Rows.Total(ColumnIndex, IncludeChildren);
                    if (children_total.DataType == Machine.DataType.Number)
                    {
                        Result += children_total.AsNumber();
                    }
                }
            }

            return(ValueFactory.Create(Result));
        }
        public IValue Total(IValue columnIndex, bool includeChildren = false)
        {
            ValueTreeColumn column = Columns.GetColumnByIIndex(columnIndex);
            decimal         result = 0;

            foreach (ValueTreeRow row in _rows)
            {
                IValue currentValue = row.Get(column);
                if (currentValue.DataType == Machine.DataType.Number)
                {
                    result += currentValue.AsNumber();
                }

                if (includeChildren)
                {
                    IValue childrenTotal = row.Rows.Total(columnIndex, includeChildren);
                    if (childrenTotal.DataType == Machine.DataType.Number)
                    {
                        result += childrenTotal.AsNumber();
                    }
                }
            }

            return(ValueFactory.Create(result));
        }
        public ValueTreeColumn GetColumnByIIndex(IValue index)
        {
            if (index.DataType == DataType.String)
            {
                ValueTreeColumn Column = FindColumnByName(index.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(index.AsString());
                }
                return(Column);
            }

            if (index.DataType == DataType.Number)
            {
                int i_index = Decimal.ToInt32(index.AsNumber());
                if (i_index < 0 || i_index >= Count())
                {
                    throw RuntimeException.InvalidArgumentValue();
                }

                ValueTreeColumn Column = FindColumnByIndex(i_index);
                return(Column);
            }

            if (index is ValueTreeColumn)
            {
                return(index as ValueTreeColumn);
            }

            throw RuntimeException.InvalidArgumentType();
        }
        internal List <ValueTreeColumn> GetProcessingColumnList(string ColumnNames)
        {
            List <ValueTreeColumn> processing_list = new List <ValueTreeColumn>();

            if (ColumnNames != null)
            {
                if (ColumnNames.Trim().Length == 0)
                {
                    // Передали пустую строку вместо списка колонок
                    return(processing_list);
                }

                string[] column_names = ColumnNames.Split(',');
                foreach (string name in column_names)
                {
                    ValueTreeColumn Column = FindColumnByName(name.Trim());

                    if (Column == null)
                    {
                        throw RuntimeException.PropNotFoundException(name.Trim());
                    }

                    processing_list.Add(Column);
                }
            }
            else
            {
                foreach (ValueTreeColumn Column in _columns)
                {
                    processing_list.Add(Column);
                }
            }
            return(processing_list);
        }
        public override int FindProperty(string name)
        {
            ValueTreeColumn Column = FindColumnByName(name);

            if (Column == null)
            {
                throw RuntimeException.PropNotFoundException(name);
            }
            return(Column.ID);
        }
Esempio n. 6
0
        private IValue TryValue(ValueTreeColumn Column)
        {
            IValue Value;

            if (_data.TryGetValue(Column, out Value))
            {
                return(Value);
            }
            return(ValueFactory.Create()); // TODO: Определять пустое значение для типа колонки
        }
        public IValue Find(string Name)
        {
            ValueTreeColumn Column = FindColumnByName(Name);

            if (Column == null)
            {
                return(ValueFactory.Create());
            }
            return(Column);
        }
Esempio n. 8
0
        private IValue TryValue(ValueTreeColumn column)
        {
            IValue value;

            if (_data.TryGetValue(column, out value))
            {
                return(value);
            }
            return(column.ValueType.AdjustValue());
        }
Esempio n. 9
0
        public override IValue GetPropValue(int propNum)
        {
            ValueTreeColumn C = Owner().Columns.FindColumnById(propNum);

            if (C == null)
            {
                var Prop = _properties.GetProperty(propNum);
                return(Prop.Getter(this));
            }
            return(TryValue(C));
        }
Esempio n. 10
0
        public override int FindProperty(string name)
        {
            ValueTreeColumn C = Owner().Columns.FindColumnByName(name);

            if (C == null)
            {
                return(_properties.FindProperty(name));
            }

            return(C.ID);
        }
        public ValueTreeColumn Insert(int index, string Name, IValue Type = null, string Title = null, int Width = 0)
        {
            if (FindColumnByName(Name) != null)
            {
                throw new RuntimeException("Неверное имя колонки " + Name);
            }

            ValueTreeColumn column = new ValueTreeColumn(this, ++_internal_counter, Name, Title, Type, Width);

            _columns.Insert(index, column);

            return(column);
        }
Esempio n. 12
0
        public override void SetPropValue(int propNum, IValue newVal)
        {
            ValueTreeColumn C = Owner().Columns.FindColumnById(propNum);

            if (C == null)
            {
                var Prop = _properties.GetProperty(propNum);
                Prop.Setter(this, newVal);
            }
            else
            {
                _data[C] = newVal;
            }
        }
Esempio n. 13
0
        private bool CheckFilterCriteria(ValueTreeRow Row, StructureImpl Filter)
        {
            foreach (KeyAndValueImpl kv in Filter)
            {
                ValueTreeColumn Column = Columns.FindColumnByName(kv.Key.AsString());
                if (Column == null)
                {
                    throw RuntimeException.PropNotFoundException(kv.Key.AsString());
                }

                IValue current = Row.Get(Column);
                if (!current.Equals(kv.Value))
                {
                    return(false);
                }
            }
            return(true);
        }
        public void Move(IValue column, int Offset)
        {
            ValueTreeColumn Column       = GetColumnByIIndex(column);
            int             index_source = _columns.IndexOf(Column);

            int index_dest = (index_source + Offset) % _columns.Count();

            while (index_dest < 0)
            {
                index_dest += _columns.Count();
            }


            if (index_source < index_dest)
            {
                _columns.Insert(index_dest + 1, Column);
                _columns.RemoveAt(index_source);
            }
            else
            {
                _columns.RemoveAt(index_source);
                _columns.Insert(index_dest, Column);
            }
        }
Esempio n. 15
0
 public void Set(ValueTreeColumn column, IValue value)
 {
     _data[column] = value;
 }
Esempio n. 16
0
 public void Set(ValueTreeColumn column, IValue value)
 {
     _data[column] = column.ValueType.AdjustValue(value);
 }
Esempio n. 17
0
 public IValue Get(ValueTreeColumn column)
 {
     return(TryValue(column));
 }
Esempio n. 18
0
        public override IValue GetIndexedValue(IValue index)
        {
            ValueTreeColumn C = GetColumnByIIndex(index);

            return(TryValue(C));
        }
 public int IndexOf(ValueTreeColumn column)
 {
     return(_columns.IndexOf(column));
 }
Esempio n. 20
0
 public IValue Get(ValueTreeColumn C)
 {
     return(TryValue(C));
 }
Esempio n. 21
0
 public void Set(ValueTreeColumn Column, IValue Value)
 {
     _data[Column] = Value;
 }