public CellValidationError( 
   CellValidationRule ruleInError, 
   Cell cellInError, 
   object errorContent, 
   Exception exception )
 {
   m_ruleInError = ruleInError;
   m_cellInError = cellInError;
   m_errorContent = errorContent;
   m_exception = exception;
 }
예제 #2
0
    internal void EnsurePosition( DataGridContext dataGridContext, Cell changedCell )
    {
      if( dataGridContext == null )
        throw new ArgumentNullException( "dataGridContext" );

      DataGridCollectionViewBase dataGridCollectionViewBase =
        dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

      if( dataGridCollectionViewBase != null )
      {
        this.EnsurePosition( dataGridContext );
      }
      else
      {
        string fieldName = changedCell.FieldName;

        foreach( GroupLevelDescription groupInfo in dataGridContext.GroupLevelDescriptions )
        {
          if( groupInfo.FieldName == fieldName )
          {
            this.EnsureRegroup( dataGridContext );
            break;
          }
        }

        SortDescriptionCollection sortDescriptions = dataGridContext.Items.SortDescriptions;

        foreach( SortDescription sortDescription in sortDescriptions )
        {
          if( sortDescription.PropertyName == fieldName )
          {
            this.EnsureResort( dataGridContext );
            break;
          }
        }
      }
    }
예제 #3
0
 protected override bool IsValidCellType( Cell cell )
 {
   return ( cell is DataCell );
 }
 public CellValidationContext( object dataItem, Cell cell )
 {
   m_cell = cell;
   m_dataItem = dataItem;
 }
 /// <summary>
 /// Find ScrollViewer from cell and subscribe to it scroll changed event.
 /// </summary>
 /// <param name="cell">Cell.</param>
 private void _SubscribeOnScroller(Cell cell)
 {
     _scrollViewer = XceedVisualTreeHelper.FindScrollViewer(cell);
     if (_scrollViewer != null)
         _scrollViewer.ScrollChanged += new System.Windows.Controls.
             ScrollChangedEventHandler(_ScrollViewerScrollChanged);
 }
        /// <summary>
        /// Get visible part of the cell.
        /// </summary>
        /// <param name="cell">Cell with error.</param>
        /// <param name="row">Row with error.</param>
        /// <returns>Rect, representing visible part of the cell.</returns>
        private Rect _GetCellVisibleRectangle(Cell cell, Row row)
        {
            // Get top left and bottom right points of the cell.
            var topLeft = cell.PointToScreen(new Point(0, 0));
            var bottomRight = cell.PointToScreen(new Point(cell.ActualWidth, cell.ActualHeight));

            // If both points isnt inside of the grid, thath mean that cell isnt visible.
            if (!_IsPointInsideGrid(row, topLeft) && !_IsPointInsideGrid(row, bottomRight))
                return Rect.Empty;

            // Calculate vertical offset.
            double verticalOffset;
            // If cell is in insertion row or if grid have no insertion row -
            // offset is equal to the height of the grid heading row.
            if (row == _dataGrid.InsertionRow || _dataGrid.InsertionRow == null)
                verticalOffset = HEADING_ROW_HEIGHT;
            else
                verticalOffset = _gridHeadingRowAndInsertionRowHeight;

            // Detect grid first row top left point.
            var gridTopLeftPoint = _dataGrid.PointToScreen(new Point(0, verticalOffset));
            // Translate this point to cell coordinate.
            var cellGridTopLeftPoint = cell.PointFromScreen(gridTopLeftPoint);
            // Correct cell visible rectangle if necessary.
            if (cellGridTopLeftPoint.X > 0)
                topLeft.X = gridTopLeftPoint.X;
            if (cellGridTopLeftPoint.Y > 0)
                topLeft.Y = gridTopLeftPoint.Y;

            // Detect grid bottom right point.
            var gridRightEdge = _dataGrid.PointToScreen(
                new Point(_dataGrid.ActualWidth, _dataGrid.ActualHeight));
            // Translate this point to cell coordinate.
            var cellGridRightEdge = cell.PointFromScreen(gridRightEdge);
            // Correct cell visible rectangle if necessary.
            if (cellGridRightEdge.X < cell.ActualWidth)
                bottomRight.X = gridRightEdge.X;
            if (cellGridRightEdge.Y < cell.ActualHeight)
                bottomRight.Y = gridRightEdge.Y;

            return new Rect(topLeft, bottomRight);
        }
예제 #7
0
파일: Row.cs 프로젝트: Torion/WpfExToolkit
    private void UpdateCellFocusableStatus( Cell cell )
    {
      if( cell == null )
        return;

      bool cellFocusable = true;

      ColumnBase parentColumn = cell.ParentColumn;

      if( !this.IsBeingEdited )
      {
        switch( this.NavigationBehavior )
        {
          case NavigationBehavior.None:
            cellFocusable = false;
            break;
          case NavigationBehavior.RowOnly:
            cellFocusable = false;
            break;
          case NavigationBehavior.RowOrCell:
            cellFocusable = true;
            break;
          case NavigationBehavior.CellOnly:
            cellFocusable = true;
            break;
        }
      }

      //force an update of the NavigationBehavior characteristics
      cell.Focusable = ( cellFocusable && cell.GetCalculatedCanBeCurrent() );
    }
예제 #8
0
파일: Cell.cs 프로젝트: Torion/WpfExToolkit
    internal static bool IsCellEditorDisplayConditionsSet( Cell cell, CellEditorDisplayConditions condition )
    {
      if( ( cell.CellEditorDisplayConditions & condition ) == condition )
        return true;

      return false;
    }
예제 #9
0
파일: Row.cs 프로젝트: Torion/WpfExToolkit
 protected abstract bool IsValidCellType( Cell cell );
 /// <summary>
 /// Unsubscribes from the events from the cell in the insertion row.
 /// </summary>
 /// <param name="cell">Cell.</param>
 private void _UnsubscribeFromCellInInsertionRow(Cell cell)
 {
     cell.PreviewMouseDown -= _FocusCellInInsertionRowPreviewMouseDown;
     var dpd = DependencyPropertyDescriptor.FromProperty(Cell.IsCurrentProperty, typeof(Cell));
     if (dpd != null)
         dpd.RemoveValueChanged(cell, _CellIsCurrentChanged);
 }
 /// <summary>
 /// Subscribe to the following events of the cell from the insertion row:
 /// 1. IsCurrent property changed.
 /// 2. Preview mouse down.
 /// </summary>
 /// <param name="cell">Cell.</param>
 private void _SubscribeOnCellInInsertionRow(Cell cell)
 {
     cell.PreviewMouseDown +=
         new MouseButtonEventHandler(_FocusCellInInsertionRowPreviewMouseDown);
     var dpd = DependencyPropertyDescriptor.FromProperty(Cell.IsCurrentProperty, typeof(Cell));
     dpd.AddValueChanged(cell, _CellIsCurrentChanged);
 }
예제 #12
0
파일: Cell.cs 프로젝트: Torion/WpfExToolkit
      public void Dispose()
      {
        if( m_cell == null )
          return;

        m_cell.m_preventMakeVisibleCount--;

        if( m_cell.m_preventMakeVisibleCount == 0 )
          m_cell.PreventMakeVisible = false;

        m_cell = null;
      }
예제 #13
0
파일: Cell.cs 프로젝트: Torion/WpfExToolkit
      public PreventMakeVisibleDisposable( Cell cell )
      {
        if( cell == null )
          throw new ArgumentNullException( "cell" );

        m_cell = cell;
        m_cell.PreventMakeVisible = true;
        m_cell.m_preventMakeVisibleCount++;
      }
예제 #14
0
파일: Cell.cs 프로젝트: Torion/WpfExToolkit
    internal static void AssignDataContext( Cell cell, object dataContext, UnboundDataItem unboundDataItemContext, ColumnBase parentColumn, out bool isNewDataContext )
    {
      Column column = parentColumn as Column;

      if( ( column != null ) && ( column.IsBoundToDataGridUnboundItemProperty ) )
      {
        if( unboundDataItemContext == null )
          UnboundDataItem.GetUnboundDataItemNode( dataContext, out unboundDataItemContext );

        dataContext = unboundDataItemContext;
      }

      // Read the LocalValue of the DataContext to avoid
      // getting the one inherited from the ParentRow.
      // This prevent the DataContext to become null
      // when the Cell is virtualized.
      object localDataContext = cell.ReadLocalValue( Cell.DataContextProperty );

      if( localDataContext != dataContext )
      {
        // The system will call Equals instead of RefEquals on the DataContext change.  If Equals has been overriden and returns true, the DataContext will not be updated.
        // Hence setting it to null will make sure the right DataContext is used by the cell, and thus the cell content will be correctly updated.
        // This would not have to be done if a reference to the old DataItem was not keeped, which DataItem may not be part of the source anymore.
        if( object.Equals( localDataContext, dataContext ) )
        {
          cell.DataContext = null;
        }
        cell.DataContext = dataContext;
        isNewDataContext = true;
      }
      else
      {
        isNewDataContext = false;
      }
    }
 protected override bool IsValidCellType( Cell cell )
 {
   return ( cell is ColumnManagerCell );
 }
예제 #16
0
파일: Row.cs 프로젝트: Torion/WpfExToolkit
    internal void UpdateHasErrorFlags( Cell errorChangedCell )
    {
      System.Diagnostics.Debug.Assert( ( errorChangedCell == null ) || ( errorChangedCell.ParentRow == this ) );

      RowValidationError itemValidationError = this.ValidationError;

      bool rowHasValidationError = ( itemValidationError != null );
      bool rowHasRestrictiveValidationError = ( rowHasValidationError ) ? Row.GetIsValidationErrorRestrictive( itemValidationError ) : false;

      if( ( !rowHasRestrictiveValidationError ) && ( errorChangedCell != null ) )
      {
        // We must check the passed cell since it might not yet be part of the row's Cells collection.
        // This can occur when initializing a cell and its Content binding already has a ValidationError.
        if( errorChangedCell.HasValidationError )
        {
          rowHasValidationError = true;

          if( errorChangedCell.IsValidationErrorRestrictive )
            rowHasRestrictiveValidationError = true;
        }

        if( !rowHasRestrictiveValidationError )
        {
          // Create a clone of the list to avoid concurrent access when iterating 
          // and a Cell is added to CreatedCells because of ColumnVirtualization
          List<Cell> createdCells = new List<Cell>( this.CreatedCells );

          foreach( Cell cell in createdCells )
          {
            if( cell == errorChangedCell )
              continue;

            if( cell.HasValidationError )
            {
              rowHasValidationError = true;

              if( cell.IsValidationErrorRestrictive )
              {
                rowHasRestrictiveValidationError = true;
                break;
              }
            }
          }
        }
      }

      this.SetHasValidationError( rowHasValidationError );
      this.SetIsValidationErrorRestrictive( rowHasRestrictiveValidationError );

      DataGridContext dataGridContext = DataGridControl.GetDataGridContext( this );

      DataGridControl gridControl = ( dataGridContext != null )
        ? dataGridContext.DataGridControl
        : null;

      if( gridControl != null )
      {
        bool gridHasValidationError = rowHasValidationError;

        if( !gridHasValidationError )
        {
          var generator = gridControl.CustomItemContainerGenerator;
          foreach( var item in generator.GetRealizedDataItems() )
          {
            var row = gridControl.GetContainerFromItem( item ) as Row;

            if( ( row != null ) && ( row.HasValidationError ) )
            {
              gridHasValidationError = true;
              break;
            }
          }
        }

        gridControl.SetHasValidationError( gridHasValidationError );
      }
    }
 protected override bool IsValidCellType(Cell cell)
 {
     return cell is RouteInsertionCell;
 }