Esempio n. 1
0
        /// <summary>
        /// Create a cell (for a row), depending on the column type.
        /// </summary>
        /// <param name="column"></param>
        /// <returns></returns>
        public IGridCell CreateCell(IDynDataGrid dataGrid, IGridColumn column, IGridRow row)
        {
            // create a cell matching the type of the column
            IGridColumnString colString = column as IGridColumnString;

            if (colString != null)
            {
                // set a default value
                return(new GridCellString(colString, row, "", dataGrid.GridCellChangedProvider));
            }

            //IGridColumnInt colInt = column as GridColumnInt;
            //if (colInt != null)
            //{
            //    // set a default value
            //    return new GridCellInt(colInt, 0);
            //}

            IGridColumnCheckBox colCheckBox = column as IGridColumnCheckBox;

            if (colCheckBox != null)
            {
                return(new GridCellCheckBox(colCheckBox, row, false, dataGrid.GridCellChangedProvider));
            }


            throw new Exception("Factory.CreateCell(): type not yet implemented.");
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="dynDatagrid"></param>
        public DynDataGridVM(IDynDataGridFactory gridFactory, IDynDataGrid dynDatagrid)
        {
            _gridFactory = gridFactory;

            _collCell = new GridMappingCell(gridFactory, dynDatagrid);

            _dynDataGrid = dynDatagrid;
            Init();
        }
Esempio n. 3
0
        /// <summary>
        /// Create a row in the data grid, create empty cells matching the columns.
        /// </summary>
        /// <param name="DataGrid"></param>
        /// <returns></returns>
        public IGridRow CreateRowWithCells(IDynDataGrid dataGrid, object obj)
        {
            IGridRow row = new GridRow(dataGrid, obj);

            // create a cell for each column
            foreach (IGridColumn column in dataGrid.ListColumn)
            {
                IGridCell cell = CreateCell(dataGrid, column, row);
                row.AddCell(cell);
            }

            dataGrid.AddRow(row);
            return(row);
        }
Esempio n. 4
0
        /// <summary>
        /// Check the name of the column, should be: not null, not empty, not already used by another column.
        /// </summary>
        /// <param name="newColName"></param>
        /// <param name="errCode"></param>
        /// <returns></returns>
        public DynDataGridErrCode CheckColumnName(IDynDataGrid dataGrid, string newColName)
        {
            newColName = newColName.Trim();
            if (string.IsNullOrWhiteSpace(newColName))
            {
                return(DynDataGridErrCode.ColumnNameWrong);
            }

            if (dataGrid.ListColumn.Where(c => c.Name.Equals(newColName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault() != null)
            {
                return(DynDataGridErrCode.ColumnNameAlreadyUsed);
            }

            return(DynDataGridErrCode.Ok);
        }
Esempio n. 5
0
        /// <summary>
        /// create the col in the data model, depending on the type.
        /// Provide an object to attach to the column.
        /// </summary>
        /// <param name="typeCol"></param>
        /// <param name="newColName"></param>
        /// <returns></returns>
        public DynDataGridErrCode CreateColumn(IDynDataGrid dataGrid, GridColumnType typeCol, string newColName, object colObj, out IGridColumn column)
        {
            column = null;

            // check the name
            DynDataGridErrCode errCode = CheckColumnName(dataGrid, newColName);

            if (errCode != DynDataGridErrCode.Ok)
            {
                return(errCode);
            }

            column = CreateColumn(typeCol, newColName, colObj);
            dataGrid.AddColumn(column);

            return(DynDataGridErrCode.Ok);
        }
Esempio n. 6
0
        private void CreateDataGrid2(IDynDataGridFactory dynDataGridFactory)
        {
            DataGrid2 = new DynDataGrid();

            //----create columns
            IGridColumn columnId;

            dynDataGridFactory.CreateColumn(DataGrid2, GridColumnType.String, "Id", out columnId);
            // this column cells are read-only
            columnId.IsEditionReadOnly = true;

            //----create a data row, with empty cells
            //IGridRow row = dynDataGridFactory.CreateRowWithCells(DataGrid2);

            //----create data cells
            //DataGrid2.SetCellValue(row, columnId, "Id");
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 public GridMappingCell(IDynDataGridFactory gridFactory, IDynDataGrid datagrid)
 {
     _gridFactory = gridFactory;
     _datagrid    = datagrid;
 }
Esempio n. 8
0
 public IGridRow CreateRowWithCells(IDynDataGrid dataGrid)
 {
     return(CreateRowWithCells(dataGrid, null));
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="datagrid"></param>
        public EditComponentDynDataGridVM(ICommonDlg commonDlg, IDynDataGridFactory gridFactory, IDynDataGrid datagrid)
        {
            // connect a callback to know when agrid cell content is modified
            AppCtrlProvider.AppCtrl.DataGrid.GridCellChangedProvider.GridCellChanged = GridCellChanged;

            //AppCtrlProvider.AppCtrl.ActionGridValueModifiedInUI = ActionGridValueModifiedInUI;
            _commonDlg = commonDlg;
            //_gridFactory = gridFactory;

            //_collCell = new GridMappingCell(gridFactory, datagrid);

            //_datagrid = datagrid;

            DynDataGridVM = new DynDataGridVM(gridFactory, datagrid);

            Init();
        }
Esempio n. 10
0
 public GridRow(IDynDataGrid datagrid, object obj)
 {
     Datagrid = datagrid;
     Object   = obj;
 }
Esempio n. 11
0
 public GridRow(IDynDataGrid datagrid)
 {
     Datagrid = datagrid;
     Object   = null;
 }