Пример #1
0
        /// <summary>
        /// Get the next item in the datagrid, if exists.
        /// </summary>
        /// <param name="rowVM"></param>
        /// <returns></returns>
        public IGridRowVM GetNextRow(IGridRowVM rowVM)
        {
            if (rowVM == null)
            {
                return(null);
            }

            IEnumerator <IGridRowVM> enumRow = _collDataRow.GetEnumerator();

            enumRow.MoveNext();

            // find the current one
            while (enumRow.Current != null)
            {
                if (enumRow.Current == _selectedRow)
                {
                    break;
                }

                enumRow.MoveNext();
            }

            // no more next
            if (enumRow.Current == null)
            {
                return(null);
            }

            // now, next the next, if exist
            enumRow.MoveNext();
            return(enumRow.Current);
        }
Пример #2
0
        /// <summary>
        /// refresh a cell, by the col and row.
        /// (called because of a row relation: update the linked cell.
        /// </summary>
        /// <param name="columnVM"></param>
        /// <param name="rowVM"></param>
        public void RefreshCell(IGridColumnVM columnVM, IGridRowVM rowVM)
        {
            IGridCellVM value = this.Where(x => x.RowBinding == rowVM && x.ColumnBinding == columnVM).FirstOrDefault();

            if (value == null)
            {
                return;
            }

            value.Refresh();
        }
Пример #3
0
        /// <summary>
        /// Delete the row data model, delete also the corresponding View model.
        /// Update the UI.
        /// </summary>
        /// <param name="row"></param>
        public void DelRow(IGridRowVM row)
        {
            // get the next item in the datagrid, if exists
            IGridRowVM selectedRowVM = _selectedRow;

            // remove the VM
            GridRowVM rowVM = selectedRowVM as GridRowVM;

            _collDataRow.Remove(selectedRowVM);

            // remove the row from the datagrid
            _dynDataGrid.RemoveRow(rowVM.GridRow);
            RaisePropertyChanged("CollDataRow");

            // get the next one or the last, if exists
            _selectedRow = GetNextOrLast(selectedRowVM);
            RaisePropertyChanged("SelectedRow");
        }
Пример #4
0
        //=====================================================================
        #region Privates methods.

        /// <summary>
        /// Create a mapped value of a cell, between a col and a row.
        /// </summary>
        /// <param name="columnBinding"></param>
        /// <param name="rowBinding"></param>
        /// <returns></returns>
        private IGridCellVM Create(IGridColumnVM columnBinding, IGridRowVM rowBinding)
        {
            // find the cell in the row, by the column
            IGridCell cell = rowBinding.GridRow.FindCellByColumn(columnBinding.GridColumn);

            if (cell == null)
            {
                throw new Exception("The cell is not found in the dataGrid!");
            }

            // create the cellVM, can be a value or a component (button, combobox,...)
            IGridCellVM mapValue = _gridFactory.CreateCellVM(cell);

            mapValue.ColumnBinding = columnBinding;
            mapValue.RowBinding    = rowBinding;

            Add(mapValue);

            return(mapValue);
        }
Пример #5
0
        /// <summary>
        /// get the next one or the last, if exists.
        /// </summary>
        /// <param name="rowVM"></param>
        /// <returns></returns>
        public IGridRowVM GetNextOrLast(IGridRowVM rowVM)
        {
            if (rowVM == null)
            {
                return(null);
            }

            // nom more item
            if (_collDataRow.Count == 0)
            {
                return(null);
            }

            IGridRowVM nextRowVM = GetNextRow(rowVM);

            if (nextRowVM != null)
            {
                // the last item exists, return it
                return(nextRowVM);
            }

            // find the last one
            return(_collDataRow.Last());
        }