示例#1
0
 public ValueTreeRow(ValueTree owner, ValueTreeRow parent, int level)
 {
     _owner  = owner;
     _parent = parent;
     _level  = level;
     _rows   = new ValueTreeRowCollection(owner, this, level + 1);
 }
示例#2
0
        public ValueTreeRow Insert(int index)
        {
            ValueTreeRow row = new ValueTreeRow(Owner(), _parent, _level);

            _rows.Insert(index, row);
            return(row);
        }
示例#3
0
 public ValueTreeRow(ValueTree owner, ValueTreeRow parent, int level)
 {
     _owner = owner;
     _parent = parent;
     _level = level;
     _rows = new ValueTreeRowCollection(owner, this, level + 1);
 }
示例#4
0
        public ValueTreeRow Add()
        {
            ValueTreeRow row = new ValueTreeRow(Owner(), _parent, _level);

            _rows.Add(row);
            return(row);
        }
示例#5
0
        internal void CopyFrom(ValueTreeRowCollection src)
        {
            _rows.Clear();
            ValueTreeColumnCollection Columns = Owner().Columns;

            foreach (ValueTreeRow row in src._rows)
            {
                ValueTreeRow new_row = Add();
                foreach (ValueTreeColumn Column in Columns)
                {
                    new_row.Set(Column, row.Get(ValueFactory.Create(Column.Name)));
                }
                new_row.Rows.CopyFrom(row.Rows);
            }
        }
示例#6
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);
        }
示例#7
0
        public void Move(IValue Row, int Offset)
        {
            Row = Row.GetRawValue();

            int index_source;

            if (Row is ValueTreeRow)
            {
                index_source = _rows.IndexOf(Row as ValueTreeRow);
            }
            else if (Row.DataType == Machine.DataType.Number)
            {
                index_source = decimal.ToInt32(Row.AsNumber());
            }
            else
            {
                throw RuntimeException.InvalidArgumentType();
            }

            if (index_source < 0 || index_source >= _rows.Count())
            {
                throw RuntimeException.InvalidArgumentValue();
            }

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

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

            ValueTreeRow tmp = _rows[index_source];

            if (index_source < index_dest)
            {
                _rows.Insert(index_dest + 1, tmp);
                _rows.RemoveAt(index_source);
            }
            else
            {
                _rows.RemoveAt(index_source);
                _rows.Insert(index_dest, tmp);
            }
        }
示例#8
0
 public ValueTreeRowCollection(ValueTree owner, ValueTreeRow parent, int level)
 {
     _owner  = owner;
     _parent = parent;
     _level  = level;
 }