예제 #1
0
        private void RemoveRowFromDataStructure(int index)
        {
            EditableRow row = _rows[index];

            row.RemoveControls();
            Controls.Remove(row);
            _rows.RemoveAt(index);
        }
예제 #2
0
        private EditableRow AddRowToDataStructure(BocListRow bocListRow, BocColumnDefinition[] columns)
        {
            EditableRow row = CreateEditableRow(bocListRow, columns);

            Controls.Add(row);
            _rows.Add(row);

            return(row);
        }
예제 #3
0
        private void CreateEditModeControls(BocColumnDefinition[] columns)
        {
            EnsureChildControls();

            Assertion.IsTrue(_rows.Count == 0, "Populating the editable rows only happens after the last edit mode was ended.");
            Assertion.IsTrue(Controls.Count == 0, "Populating the editable rows only happens after the last edit mode was ended.");

            var missingRowIDs = new List <string>();

            foreach (var editedRowID in _editedRowIDs)
            {
                var bocListRow = _editModeHost.RowIDProvider.GetRowFromItemRowID(_editModeHost.Value, editedRowID);
                if (bocListRow == null)
                {
                    if (IsListEditModeActive)
                    {
                        // Remove ViewState for missing row
                        var missingRow = new EditableRow(_editModeHost);
                        Controls.Add(missingRow);
                        Controls.Remove(missingRow);

                        missingRowIDs.Add(editedRowID);
                    }
                    else
                    {
                        throw new InvalidOperationException(
                                  string.Format(
                                      "Cannot create edit mode controls for the row with ID '{1}'. The BocList '{0}' does not contain the row in its Value collection.",
                                      _editModeHost.ID,
                                      editedRowID));
                    }
                }
                else
                {
                    AddRowToDataStructure(bocListRow, columns);
                }
            }

            _editedRowIDs.RemoveAll(missingRowIDs.Contains);

            _newRows = new List <BocListRow>();
            if (IsListEditModeActive && _editedRowIDs.Count < _editModeHost.Value.Count)
            {
                var availableRows = _editModeHost.Value.Cast <IBusinessObject>().Select((o, i) => new BocListRow(i, o));
                var editedRows    = _editedRowIDs.Select(rowID => _editModeHost.RowIDProvider.GetRowFromItemRowID(_editModeHost.Value, rowID));
                var newRows       = availableRows.Except(editedRows).ToList();

                foreach (var row in newRows)
                {
                    _editedRowIDs.Add(_editModeHost.RowIDProvider.GetItemRowID(row));
                    AddRowToDataStructure(row, columns);
                    _newRows.Add(row);
                }
            }
        }
예제 #4
0
        private void SetFocus(EditableRow row)
        {
            var firstControl = row.GetEditControlsAsArray().OfType <IFocusableControl>().FirstOrDefault(c => !string.IsNullOrEmpty(c.FocusID));

            if (firstControl == null)
            {
                return;
            }

            _editModeHost.SetFocus(firstControl);
        }
예제 #5
0
        private EditableRow CreateEditableRow(BocListRow bocListRow, BocColumnDefinition[] columns)
        {
            EditableRow row = new EditableRow(_editModeHost);

            row.ID = ID + "_Row_" + _editModeHost.RowIDProvider.GetControlRowID(bocListRow);

            row.DataSourceFactory = _editModeHost.EditModeDataSourceFactory;
            row.ControlFactory    = _editModeHost.EditModeControlFactory;

            row.CreateControls(bocListRow.BusinessObject, columns);

            return(row);
        }