internal static int GetNextVisibleFocusableColumnIndex( DataGridContext dataGridContext, Row targetRow, ColumnBase targetColumn )
    {
      if( ( dataGridContext == null ) || ( targetRow == null ) || ( targetColumn == null ) )
        return -1;

      var columns = dataGridContext.VisibleColumns;
      if( ( columns == null ) || ( columns.Count <= 0 ) )
        return -1;

      var columnIndex = columns.IndexOf( targetColumn );
      if( columnIndex < 0 )
        return -1;

      if( !dataGridContext.IsAFlattenDetail )
        return NavigationHelper.GetNextVisibleFocusableColumnIndex( dataGridContext, targetRow, columnIndex + 1 );

      var columnMap = dataGridContext.ItemPropertyMap;
      var masterColumnName = default( string );

      if( !columnMap.TryGetColumnFieldName( targetColumn, out masterColumnName ) )
        return -1;

      var masterDataGridContext = dataGridContext.RootDataGridContext;
      var masterColumn = masterDataGridContext.Columns[ masterColumnName ];

      if( masterColumn == null )
        return -1;

      var masterColumnIndex = masterDataGridContext.VisibleColumns.IndexOf( masterColumn );
      if( masterColumnIndex < 0 )
        return -1;

      return NavigationHelper.GetNextVisibleFocusableDetailColumnIndexFromMasterColumnIndex( dataGridContext, targetRow, masterColumnIndex + 1 );
    }
		public void Resize(ColumnBase column, double value) {
			BandGridColumnHeader columnHeader = null;
			foreach(BandGridColumnHeader ch in LayoutPanel.Children) {
				if((ColumnBase)ch.DataContext == column)
					columnHeader = ch;
			}
			double diff = value - columnHeader.ActualWidth;
			LayoutPanel.Resize(column, diff);
		}
    public DataGridItemCellAutomationPeer( DataGridItemAutomationPeer itemAutomationPeer, ColumnBase column )
    {

      if( itemAutomationPeer == null )
        throw new ArgumentNullException( "itemAutomationPeer" );

      if( column == null )
        throw new ArgumentNullException( "column" );

      m_itemAutomationPeer = itemAutomationPeer;
      m_column = column;

      // Call the GetWrapperPeer since it will force the events of the wrapped peer to be rerooted to us.
      AutomationPeer wrapperPeer = this.GetWrapperPeer();
    }
예제 #4
0
 internal CellEditorContext(ColumnBase parentColumn, ForeignKeyConfiguration configuration)
 {
     this.SetParentColumn(parentColumn);
     this.SetForeignKeyConfiguration(configuration);
 }
예제 #5
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            bool isMouseCaptured = this.IsMouseCaptured;
            bool isPressed       = this.IsPressed;

            if (m_dragSourceManager != null)
            {
                m_dragSourceManager.ProcessMouseLeftButtonUp(e);
            }

            if (isMouseCaptured)
            {
                bool click = isPressed;

                if (click)
                {
                    // DataGridCollectionView always return true for CanSort
                    bool allowSort = true;

                    // Use the ParentDataGridContext to be sure to get a
                    // DataGridContext of the correct detail level since
                    // all the HierarchicalGroupByItem will share the same DataGridContext
                    // which is the one of the level where the HierarchicalGroupByControl
                    // is located
                    DataGridContext dataGridContext = this.ParentDataGridContext;

                    if ((dataGridContext != null) && (dataGridContext.SourceDetailConfiguration == null))
                    {
                        allowSort = dataGridContext.Items.CanSort;
                    }

                    if (allowSort)
                    {
                        ColumnCollection      columns   = this.ParentColumns;
                        GroupLevelDescription groupInfo = this.Content as GroupLevelDescription;

                        Debug.Assert((columns != null) && (groupInfo != null));

                        if ((columns != null) && (groupInfo != null))
                        {
                            ColumnBase column = columns[groupInfo.FieldName];

                            if ((column != null) && (column.AllowSort))
                            {
                                bool shiftUnpressed = ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift);

                                var toggleColumnSort = new HierarchicalGroupByItemToggleColumnSortCommand(this);

                                if (toggleColumnSort.CanExecute(column, shiftUnpressed))
                                {
                                    toggleColumnSort.Execute(column, shiftUnpressed);
                                }

                                e.Handled = true;
                            }
                        }
                    }
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
      public void BeginReordering( DataGridContext dataGridContext, int initialColumnVisiblePosition )
      {
        if( dataGridContext == null )
          throw new ArgumentNullException( "dataGridContext" );

        if( m_isProcessingReordering )
        {
          Debug.Assert( false, "Already processing Reordering... ensure to call EndReordering" );
        }

        this.InitialColumnVisiblePosition = initialColumnVisiblePosition;
        this.InitialFixedColumnCount = TableflowView.GetFixedColumnCount( dataGridContext );

        int columnsByVisiblePositionCount = dataGridContext.ColumnsByVisiblePosition.Count;
        ColumnBase[] columnsByVisiblePosition = new ColumnBase[ columnsByVisiblePositionCount ];
        dataGridContext.ColumnsByVisiblePosition.CopyTo( columnsByVisiblePosition, 0 );

        this.InitialColumnsByVisiblePosition = new List<ColumnBase>( columnsByVisiblePosition );

        this.ReorderedColumnsByVisiblePosition = new List<ColumnBase>();

        m_isProcessingReordering = true;
      }
 private AnimationClock AnimateColumn( ColumnBase column, double offset, Duration animationDuration )
 {
   return this.DoColumnAnimation( column, offset, animationDuration, false );
 }
예제 #8
0
        public static string EFSqlCodeType(this ColumnBase column)
        {
            string retVal;

            switch (column.DataType)
            {
            case System.Data.SqlDbType.BigInt: retVal = "Int64"; break;

            case System.Data.SqlDbType.Binary: retVal = "Binary"; break;

            case System.Data.SqlDbType.Bit: retVal = "Boolean"; break;

            case System.Data.SqlDbType.Char: retVal = "String"; break;

            case System.Data.SqlDbType.Date: retVal = "DateTime"; break;

            case System.Data.SqlDbType.DateTime: retVal = "DateTime"; break;

            case System.Data.SqlDbType.DateTime2: retVal = "DateTime"; break;

            case System.Data.SqlDbType.DateTimeOffset: retVal = "DateTimeOffset"; break;

            case System.Data.SqlDbType.Decimal: retVal = "Decimal"; break;

            case System.Data.SqlDbType.Float: retVal = "Double"; break;

            case System.Data.SqlDbType.Image: retVal = "Binary"; break;

            case System.Data.SqlDbType.Int: retVal = "Int32"; break;

            case System.Data.SqlDbType.Money: retVal = "Decimal"; break;

            case System.Data.SqlDbType.NChar: retVal = "String"; break;

            case System.Data.SqlDbType.NText: retVal = "String"; break;

            case System.Data.SqlDbType.NVarChar: retVal = "String"; break;

            case System.Data.SqlDbType.Real: retVal = "Single"; break;

            case System.Data.SqlDbType.SmallDateTime: retVal = "DateTime"; break;

            case System.Data.SqlDbType.SmallInt: retVal = "Int16"; break;

            case System.Data.SqlDbType.SmallMoney: retVal = "Decimal"; break;

            case System.Data.SqlDbType.Text: retVal = "String"; break;

            case System.Data.SqlDbType.Time: retVal = "Time"; break;

            case System.Data.SqlDbType.Timestamp: retVal = "Binary"; break;

            case System.Data.SqlDbType.TinyInt: retVal = "Byte"; break;

            case System.Data.SqlDbType.UniqueIdentifier: retVal = "Guid"; break;

            case System.Data.SqlDbType.VarBinary: retVal = "Binary"; break;

            case System.Data.SqlDbType.VarChar: retVal = "String"; break;

            case System.Data.SqlDbType.Xml: retVal = "String"; break;

            default: retVal = "String"; break;
            }
            return(retVal);
        }
            private static void RestoreLocalValue(Dictionary <DependencyProperty, object> store, ColumnBase column, DependencyProperty property)
            {
                Debug.Assert(store != null);
                Debug.Assert(column != null);
                Debug.Assert(property != null);

                object value;

                if (!store.TryGetValue(property, out value) || (value == DependencyProperty.UnsetValue))
                {
                    column.ClearValue(property);
                }
                else if (value is BindingBase)
                {
                    BindingOperations.SetBinding(column, property, ( BindingBase )value);
                }
                else
                {
                    column.SetValue(property, value);
                }
            }
 public ExcelReadingCellException(ColumnBase columnBase, long row, string message)
 {
     _columnBase = columnBase;
     _row        = row;
     _message    = message;
 }
 protected override Cell CreateCell(ColumnBase column)
 {
     return(new ModernColumnManagerCell());
 }
예제 #12
0
 public static void SetIsKey(ColumnBase obj, bool value)
 {
     obj.SetValue(IsKeyProperty, value);
 }
예제 #13
0
 public static bool GetIsKey(ColumnBase obj)
 {
     return((bool)obj.GetValue(IsKeyProperty));
 }
예제 #14
0
 public static void SetCremaTypeMembers(ColumnBase obj, IEnumerable value)
 {
     obj.SetValue(CremaTypeMembersProperty, value);
 }
    private static void SetCurrentColumnAndChangeSelection( DataGridContext dataGridContext, ColumnBase column )
    {
      Debug.Assert( dataGridContext != null );
      Debug.Assert( column != null );

      try
      {
        dataGridContext.SetCurrentColumnAndChangeSelection( column );
      }
      catch( DataGridException )
      {
        // We swallow the exception if it occurs because of a validation error or Cell was read-only or
        // any other GridException.
      }
    }
예제 #16
0
 private void SetParentColumn(ColumnBase value)
 {
     this.SetValue(CellEditorContext.ParentColumnPropertyKey, value);
 }
            private static void StoreLocalValue(Dictionary <DependencyProperty, object> store, ColumnBase column, DependencyProperty property)
            {
                Debug.Assert(store != null);
                Debug.Assert(column != null);
                Debug.Assert(property != null);

                var binding = BindingOperations.GetBindingBase(column, property);

                if (binding != null)
                {
                    store[property] = binding;
                }
                else
                {
                    var value = column.ReadLocalValue(property);
                    if (value != DependencyProperty.UnsetValue)
                    {
                        store[property] = value;
                    }
                    else
                    {
                        store.Remove(property);
                    }
                }
            }
예제 #18
0
 public void Remove(ColumnBase column)
 {
     throw new NotSupportedException();
 }
예제 #19
0
 public static string EFSqlDatabaseType(this ColumnBase column)
 {
     return(column.EFSqlDatabaseType(true));
 }
예제 #20
0
 public Action(List <Card> cards, CardPlace actionFrom, CardPlace actionTo, ColumnBase columnFrom, ColumnBase columnTo)
 {
     Cards      = cards;
     ActionFrom = actionFrom;
     ActionTo   = actionTo;
     ColumnFrom = columnFrom;
     ColumnTo   = columnTo;
 }
예제 #21
0
 public override bool Equals(ColumnBase other) => Equals(other as Variable);
예제 #22
0
 public override bool Equals(ColumnBase other) => other is JsonFieldColumn json && (Alias, Path, Column).Equals((json.Alias, json.Path, json.Column));
    private AnimationClock DoColumnAnimation( ColumnBase column, double toValue, Duration duration, bool isReverting )
    {
      if( column == null )
        return null;

      Cell draggedCell = this.DraggedElement as Cell;

      // Never animate the dragged Column to avoid flickering
      // effects on the ghosts because we compute its position
      // on each MouseMove event
      if( ( draggedCell != null ) && ( column == draggedCell.ParentColumn ) )
        return null;

      TranslateTransform transform = ColumnReorderingDragSourceManager.GetAnimatedColumnReorderingTranslation( column );

      if( transform == null )
      {
        transform = new TranslateTransform();
        ColumnReorderingDragSourceManager.SetAnimatedColumnReorderingTranslation( column, transform );
      }

      string fieldName = column.FieldName;

      AnimationClock animationClock = null;

      // Pause previously applied AnimationClock
      if( m_fieldNameToClock.TryGetValue( fieldName, out animationClock ) )
      {
        OffsetAnimation clockOffsetAnimation = animationClock.Timeline as OffsetAnimation;

        // If the target value is already the correct one, no need to stop animation and create another one
        if( ( clockOffsetAnimation != null ) && ( clockOffsetAnimation.To == toValue ) )
          return animationClock;

        // Stop the animation, do not simply pause it, so it resets correctly.
        animationClock.Controller.Stop();
        animationClock.Completed -= this.ColumnAnimationCompleted;

        m_fieldNameToClock.Remove( fieldName );
        m_clockToFieldName.Remove( animationClock );
      }

      OffsetAnimation animation = new OffsetAnimation( toValue, duration );
      animationClock = animation.CreateClock( true ) as AnimationClock;

      transform.ApplyAnimationClock( TranslateTransform.XProperty, animationClock, HandoffBehavior.SnapshotAndReplace );

      m_fieldNameToClock.Add( fieldName, animationClock );
      m_clockToFieldName.Add( animationClock, fieldName );

      if( isReverting )
      {
        animationClock.Completed += this.ColumnAnimationCompleted;
      }

      animationClock.Controller.Begin();

      return animationClock;
    }
예제 #24
0
 public virtual CellEditor SelectCellEditor(ColumnBase column, object item)
 {
     return(null);
 }
예제 #25
0
		public void Resize(ColumnBase gridColumn, double diff) {
			Rows rows = new Rows(this);
			CorrectColumnsWidth(rows);
			if(diff == 0d || double.IsNaN(diff)) {
				return;
			}
			int columnIndex = BandedViewBehavior.GetColumn(gridColumn);
			int rowIndex = BandedViewBehavior.GetRow(gridColumn);
			Row row = rows[rowIndex];
			row.SelectColumn(columnIndex);
			if(diff > 0) {
				DecreaseColumnsWidth(row, row.SelectedIndex + 1, ref diff);
				IncreaseSelectedColumnWidth(row, diff);
			}
			if(diff < 0) {
				diff *= -1;
				if(Math.Abs(row.SelectedCell.ActualWidth - row.SelectedCell.ColumnMinWidth) <= 0.5)
					return;
				DecreaseSelectedColumnWidth(row, ref diff);
				IncreaseColumnsWidth(row, row.SelectedIndex + 1, diff);
			}
			row.Foreach(row.SelectedIndex, (rowCell) => {
				double res = rowCell.NewWidth / row.RowWidth;
				rowCell.ColumnWidth = new GridLength(res, GridUnitType.Star);
			});
		}
예제 #26
0
        protected virtual void HandlePageHomeKey(KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            DataGridContext dataGridContext = null;

            if (e.OriginalSource != null)
            {
                dataGridContext = DataGridControl.GetDataGridContext(e.OriginalSource as DependencyObject);
            }
            else
            {
                dataGridContext = DataGridControl.GetDataGridContext(this);
            }

            if (dataGridContext == null)
            {
                return;
            }

            PagingBehavior     pagingBehavior     = dataGridContext.DataGridControl.PagingBehavior;
            NavigationBehavior navigationBehavior = dataGridContext.DataGridControl.NavigationBehavior;

            ColumnBase currentColumn = dataGridContext.CurrentColumn;

            if (((navigationBehavior == NavigationBehavior.CellOnly) ||
                 (navigationBehavior == NavigationBehavior.RowOrCell)) &&
                (currentColumn != null))
            {
                int oldCurrentIndex = currentColumn.Index;

                NavigationHelper.MoveFocusToFirstVisibleColumn(dataGridContext);

                var columnVirtualizationManager = dataGridContext.ColumnVirtualizationManager as TableViewColumnVirtualizationManagerBase;

                //if the first focusable column is is within the viewport, scroll so 0d offset, otherwise, bringIntoView
                bool isFixedColumn = (columnVirtualizationManager == null) ?
                                     false : columnVirtualizationManager.GetFixedFieldNames().Contains(currentColumn.FieldName);

                if (((this.IsCellsOffsetNeedReset(dataGridContext)) &&
                     (oldCurrentIndex == currentColumn.Index)) ||
                    (isFixedColumn))
                {
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(this.ScrollToLeftEnd));
                }

                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    if (pagingBehavior == PagingBehavior.TopToBottom)
                    {
                        this.ScrollToTop();
                    }
                    else
                    {
                        this.ScrollToLeftEnd();
                    }

                    this.HandlePageUpNavigation();
                }
            }
            else
            {
                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    this.ScrollToTop();
                    this.ScrollToLeftEnd();

                    //than handle new selection!
                    if (navigationBehavior != NavigationBehavior.None)
                    {
                        this.HandlePageUpNavigation();
                    }
                }
                else
                {
                    if (pagingBehavior == PagingBehavior.TopToBottom)
                    {
                        this.ScrollToLeftEnd();
                    }
                    else
                    {
                        this.ScrollToTop();
                    }
                }
            }

            e.Handled = true;
        }
예제 #27
0
        bool IDropTarget.CanDropElement(UIElement draggedElement)
        {
            bool canDrop = this.AllowGroupingModification;

            ColumnManagerCell       cell = null;
            HierarchicalGroupByItem hierarchicalGroupByItem = null;

            if (canDrop)
            {
                cell = draggedElement as ColumnManagerCell;

                if (cell != null)
                {
                    ColumnBase parentColumn = cell.ParentColumn;

                    if ((parentColumn == null) || (!parentColumn.AllowGroup))
                    {
                        return(false);
                    }

                    // Check if already grouped using the cell's DataGridContext
                    canDrop = !GroupingHelper.IsAlreadyGroupedBy(cell);

                    if (canDrop)
                    {
                        DataGridContext thisDataGridContext = DataGridControl.GetDataGridContext(this);

                        if (thisDataGridContext.Items != null)
                        {
                            canDrop = thisDataGridContext.Items.CanGroup;
                        }

                        if (canDrop)
                        {
                            canDrop = GroupingHelper.IsColumnManagerCellInDataGridContext(thisDataGridContext, cell);

                            if (canDrop == true)
                            {
                                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(DataGridControl.GetDataGridContext(draggedElement));
                            }
                        }
                    }
                }
                else
                {
                    hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem;

                    if (hierarchicalGroupByItem == null)
                    {
                        canDrop = false;
                    }

                    if (canDrop)
                    {
                        // Try to get the HierarchicalGroupByControlNode in which this HierarchicalGroupByItem can be added using the parent HierarchicalGroupByControl => null it can't
                        HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = this.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem);

                        if (draggedHierarchicalGroupByControlNode == null)
                        {
                            canDrop = false;
                        }
                    }
                }
            }

            bool returnedValue = ((cell != null) || (hierarchicalGroupByItem != null)) && // ColumnManagerCell or HierarchicalGroupByItem
                                 (canDrop);


            return(returnedValue);
        }
예제 #28
0
        protected virtual void HandlePageEndKey(KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            DataGridContext dataGridContext = null;

            if (e.OriginalSource != null)
            {
                dataGridContext = DataGridControl.GetDataGridContext(e.OriginalSource as DependencyObject);
            }
            else
            {
                dataGridContext = DataGridControl.GetDataGridContext(this);
            }

            if (dataGridContext == null)
            {
                return;
            }

            PagingBehavior     pagingBehavior     = dataGridContext.DataGridControl.PagingBehavior;
            NavigationBehavior navigationBehavior = dataGridContext.DataGridControl.NavigationBehavior;

            ColumnBase CurrentColumn = dataGridContext.CurrentColumn;

            if (((navigationBehavior == NavigationBehavior.CellOnly) ||
                 (navigationBehavior == NavigationBehavior.RowOrCell)) &&
                (CurrentColumn != null))
            {
                int oldCurrentIndex = CurrentColumn.Index;

                NavigationHelper.MoveFocusToLastVisibleColumn(dataGridContext);

                //if the last focusable column is is within the viewport, scroll to Extended offset, otherwise, bringIntoView

                if ((this.IsCellsOffsetNeedReset(dataGridContext)) && (oldCurrentIndex == CurrentColumn.Index))
                {
                    this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(this.ScrollToRightEnd));
                }

                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    if (pagingBehavior == PagingBehavior.TopToBottom)
                    {
                        this.ScrollToBottom();
                    }
                    else
                    {
                        this.ScrollToRightEnd();
                    }

                    this.HandlePageDownNavigation();
                }
            }
            else
            {
                if ((e.KeyboardDevice.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
                {
                    this.ScrollToBottom();
                    this.ScrollToRightEnd();

                    // Than handle new selection!
                    if (navigationBehavior != NavigationBehavior.None)
                    {
                        this.HandlePageDownNavigation();
                    }
                }
                else
                {
                    if (pagingBehavior == PagingBehavior.TopToBottom)
                    {
                        this.ScrollToRightEnd();
                    }
                    else
                    {
                        this.ScrollToBottom();
                    }
                }
            }

            e.Handled = true;
        }
예제 #29
0
		void PrepareChild(BandGridColumnHeader child, ColumnBase column) {
			int columnCorrectingCoef = BandedViewBehavior.GetIsLeftColumn(column) ? 0 : 1;
			int columnSpanCorrectingCoef = BandedViewBehavior.GetIsLeftColumn(column) ? 1 : 0;
			StdGrid.SetRow(child, BandedViewBehavior.GetRow(column));
			StdGrid.SetColumn(child, BandedViewBehavior.GetColumn(column) + columnCorrectingCoef);
			StdGrid.SetRowSpan(child, BandedViewBehavior.GetRowSpan(column));
			StdGrid.SetColumnSpan(child, BandedViewBehavior.GetColumnSpan(column) + columnSpanCorrectingCoef);
		}
예제 #30
0
    private static bool TouchColumnWidth( ColumnBase column )
    {
      bool modified = false;

      if( column != null )
      {
        double oldActualWidth = column.ActualWidth;

        // Assign a temporary value to DesiredWidth (different from ActualWidth) 
        // to force a new Measure pass.
        if( column.ActualWidth > column.MinWidth )
        {
          column.DesiredWidth = column.MinWidth;
        }
        else
        {
          column.DesiredWidth = column.ActualWidth + 1d;
        }

        modified = !Xceed.Utils.Math.DoubleUtil.AreClose( oldActualWidth, column.ActualWidth );
      }

      return modified;
    }
		public override void ApplyResize(ColumnBase resizeColumn, double newWidth, double maxWidth, double indentWidth, bool correctWidths) {
			ColumnsLayoutControl c = BandedViewBehavior.GetColumnsLayoutControl(resizeColumn);
			c.Resize(resizeColumn, newWidth);
		}
 private void RollbackColumnAnimation( ColumnBase column )
 {
   this.DoColumnAnimation( column, 0, m_columnAnimationDuration, true );
 }
      internal void BeginReordering( DataGridContext dataGridContext, int initialColumnVisiblePosition, int initialFixedColumnCount )
      {
        if( dataGridContext == null )
          throw new ArgumentNullException( "dataGridContext" );

        if( m_isProcessingReordering )
        {
          Debug.Assert( false, "Already processing Reordering... ensure to call EndReordering" );
        }

        this.InitialColumnVisiblePosition = initialColumnVisiblePosition;
        this.InitialFixedColumnCount = initialFixedColumnCount;

        ColumnBase[] columnsByVisiblePosition;
        HashedLinkedList<ColumnBase> sourceColumnList;
        sourceColumnList = dataGridContext.ColumnsByVisiblePosition;

        columnsByVisiblePosition = new ColumnBase[ sourceColumnList.Count ];
        sourceColumnList.CopyTo( columnsByVisiblePosition, 0 );

        this.InitialColumnsByVisiblePosition = new List<ColumnBase>( columnsByVisiblePosition );

        this.ReorderedColumnsByVisiblePosition = new List<ColumnBase>();

        this.RollbackReorderedColumnsAndFixedColumnCount();

        m_isProcessingReordering = true;
      }
      private void ExportDataItem( DataGridContext dataGridContext, int itemIndex, object item, int detailLevel, int[] exportedVisiblePositions,
                                   ColumnBase[] columnsByVisiblePosition )
      {
        Debug.WriteLine( string.Format( "ExportDataItem for detail level {0}, itemIndex {1}", detailLevel, itemIndex ) );

        foreach( ClipboardExporterBase clipboardExporter in m_clipboardExporters )
        {
          this.ExportDataItemCore( dataGridContext, clipboardExporter, itemIndex, item, exportedVisiblePositions, columnsByVisiblePosition );
        }
      }
      private ColumnBase[] GetVisibleColumnsArrayForContext( DataGridContext dataGridContext )
      {
        if( dataGridContext == null )
          throw new ArgumentNullException( "sourceContext" );

        int detailLevel = dataGridContext.DetailLevel;

        if( m_visitedDetailVisibleColumnsCache.ContainsKey( detailLevel ) )
          return m_visitedDetailVisibleColumnsCache[ detailLevel ];

        int columnsByVisiblePositionCount = dataGridContext.ColumnsByVisiblePosition.Count;
        ColumnBase[] columnsByVisiblePosition = new ColumnBase[ columnsByVisiblePositionCount ];
        dataGridContext.ColumnsByVisiblePosition.CopyTo( columnsByVisiblePosition, 0 );

        m_visitedDetailVisibleColumnsCache.Add( dataGridContext.DetailLevel, columnsByVisiblePosition );

        return columnsByVisiblePosition;
      }
예제 #36
0
        protected override List <AutomationPeer> GetChildrenCore()
        {
            DataRow dataRow = m_dataGridContext.CustomItemContainerGenerator.ContainerFromItem(m_item) as DataRow;

            if (dataRow == null)
            {
                return(null);
            }

            // Get child context ( Detail )
            DetailConfigurationCollection detailConfigurations = m_dataGridContext.DetailConfigurations;
            int detailConfigurationsCount = detailConfigurations.Count;

            ReadOnlyObservableCollection <ColumnBase> visibleColumns = m_dataGridContext.VisibleColumns;
            int visibleColumnsCount = visibleColumns.Count;

            if (visibleColumnsCount + detailConfigurationsCount <= 0)
            {
                return(null);
            }

            Hashtable             oldDataChildren = m_dataChildren;
            List <AutomationPeer> list            = new List <AutomationPeer>(visibleColumnsCount + detailConfigurationsCount);

            m_dataChildren = new Hashtable(visibleColumnsCount + detailConfigurationsCount);

            for (int i = 0; i < visibleColumnsCount; i++)
            {
                ColumnBase column = visibleColumns[i];

                DataGridItemCellAutomationPeer cellAutomationPeer =
                    oldDataChildren[column] as DataGridItemCellAutomationPeer;

                if (cellAutomationPeer == null)
                {
                    cellAutomationPeer = new DataGridItemCellAutomationPeer(this, column);
                }

                // Always resetting the ColumnIndex since the visible position can have changed
                cellAutomationPeer.ColumnIndex = i;

                list.Add(cellAutomationPeer);
                m_dataChildren[column] = cellAutomationPeer;
            }

            for (int i = 0; i < detailConfigurationsCount; i++)
            {
                DetailConfiguration           detailConfiguration = detailConfigurations[i];
                DataGridContextAutomationPeer detailDataGridContextAutomationPeer = null;

                detailDataGridContextAutomationPeer =
                    oldDataChildren[detailConfiguration] as DataGridContextAutomationPeer;

                if (detailDataGridContextAutomationPeer == null)
                {
                    detailDataGridContextAutomationPeer = new DataGridContextAutomationPeer(
                        m_dataGridContext.DataGridControl, m_dataGridContext, m_item, detailConfiguration);
                }

                list.Add(detailDataGridContextAutomationPeer);
                m_dataChildren[detailConfiguration] = detailDataGridContextAutomationPeer;
            }

            return(list);
        }
      private void ExportDataItemCore( DataGridContext dataGridContext, ClipboardExporterBase clipboardExporter, int itemIndex, object item, int[] exportedVisiblePositions,
                                       ColumnBase[] columnsByVisiblePosition )
      {
        DataGridCollectionViewBase dataGridCollectionViewBase = dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

        clipboardExporter.StartDataItem( dataGridContext, item );

        // Ensure the count does not exceeds the columns count
        int exportedVisiblePositionsCount = exportedVisiblePositions.Length;
        exportedVisiblePositionsCount = Math.Min( exportedVisiblePositionsCount, columnsByVisiblePosition.Length );

        HashSet<int> intersectedIndexes = this.GetIntersectedRangesForIndex( dataGridContext, itemIndex, exportedVisiblePositions, exportedVisiblePositionsCount );

        object fieldValue = null;
        Column column = null;

        for( int i = 0; i < exportedVisiblePositionsCount; i++ )
        {
          // Reset field value
          fieldValue = null;

          int visiblePosition = exportedVisiblePositions[ i ];

          // Export null if not intersected by a SelectionRange
          if( intersectedIndexes.Contains( visiblePosition ) )
          {
            // Only export visible data column
            column = columnsByVisiblePosition[ visiblePosition ] as Column;

            if( column == null )
              continue;

            // Use DataGridCollectionView directly since the DataGridItemProperty uses PropertyDescriptor which increase
            // the read of the field value
            DataGridItemPropertyBase dataGridItemProperty = null;

            // Try to get a DataGridItemProperty matching the column FieldName
            // and get the value from it
            if( dataGridCollectionViewBase != null )
            {
              dataGridItemProperty = dataGridCollectionViewBase.ItemProperties[ column.FieldName ];

              if( dataGridItemProperty != null )
              {
                fieldValue = dataGridItemProperty.GetValue( item );
              }
            }

            // If none was found, create a BindingPathValueExtractor from this column
            if( ( dataGridCollectionViewBase == null ) || ( dataGridItemProperty == null ) )
            {
              // We don't have a DataGridCollectionView, use a BindingPathValueExtractor
              // to create a binding to help us get the value for the Column in the 
              // data item
              BindingPathValueExtractor extractorForRead = null;

              if( m_columnToBindingPathExtractor.TryGetValue( column, out extractorForRead ) == false )
              {
                extractorForRead = dataGridContext.GetBindingPathExtractorForColumn( column, item );
                m_columnToBindingPathExtractor.Add( column, extractorForRead );
              }

              fieldValue = extractorForRead.GetValueFromItem( item );
            }
          }

          if( fieldValue != null )
          {
            //Verify if the value should be converted to the displayed value for exporting.
            ForeignKeyConfiguration foreignKeyConfiguration = column.ForeignKeyConfiguration;

            if( foreignKeyConfiguration != null && foreignKeyConfiguration.UseDisplayedValueWhenExporting )
            {
              fieldValue = foreignKeyConfiguration.GetDisplayMemberValue( fieldValue );
            }
            else if( column.DisplayedValueConverter != null )
            {
              fieldValue = column.DisplayedValueConverter.Convert( fieldValue, typeof( object ), column.DisplayedValueConverterParameter, column.GetCulture( column.DisplayedValueConverterCulture ) );
            }
            else if( !string.IsNullOrEmpty( column.CellContentStringFormat ) )
            {
              fieldValue = string.Format( column.GetCulture(), column.CellContentStringFormat, fieldValue );
            }
          }

          clipboardExporter.StartDataItemField( dataGridContext, column, fieldValue );
          clipboardExporter.EndDataItemField( dataGridContext, column, fieldValue );
        }

        clipboardExporter.EndDataItem( dataGridContext, item );
      }
예제 #38
0
        public DataGridItemCellAutomationPeer(DataGridItemAutomationPeer itemAutomationPeer, ColumnBase column)
        {
            if (itemAutomationPeer == null)
            {
                throw new ArgumentNullException("itemAutomationPeer");
            }

            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            m_itemAutomationPeer = itemAutomationPeer;
            m_column             = column;

            // Call the GetWrapperPeer since it will force the events of the wrapped peer to be rerooted to us.
            AutomationPeer wrapperPeer = this.GetWrapperPeer();
        }
예제 #39
0
        public void CalculateColumnStretchWidths(double widthToDistribute, ColumnStretchMode columnStretchMode, double columnStretchMinWidth)
        {
            if (m_columnStretchingDisabled)
            {
                return;
            }

            int             currentDataGridScrollViewerMeasureVersion = 0;
            DataGridControl dataGridControl = m_dataGridContext.DataGridControl;

            if (dataGridControl != null)
            {
                DataGridScrollViewer scrollViewer = dataGridControl.ScrollViewer as DataGridScrollViewer;

                if (scrollViewer != null)
                {
                    currentDataGridScrollViewerMeasureVersion = scrollViewer.MeasureVersion;
                }
            }

            this.ColumnStretchingCalculated = true;

            if (m_dataGridScrollViewerMeasureVersion != currentDataGridScrollViewerMeasureVersion)
            {
                // Reset the widthToDistribute since we are in a new pass of measure in the DataGridScrollViewer
                m_widthToDistribute = widthToDistribute;
                m_dataGridScrollViewerMeasureVersion = currentDataGridScrollViewerMeasureVersion;
            }
            else
            {
                if (widthToDistribute >= m_widthToDistribute)
                {
                    widthToDistribute = m_widthToDistribute;
                }
                else
                {
                    m_widthToDistribute = widthToDistribute;
                }
            }

            List <WorkingColumnWidth> excludedColumns = null;
            ColumnBase stretchedColumn = null;
            ReadOnlyObservableCollection <ColumnBase> visibleColumns = m_dataGridContext.VisibleColumns;

            if (visibleColumns.Count == 0)
            {
                return;
            }

            switch (columnStretchMode)
            {
            case ColumnStretchMode.First:
                stretchedColumn = visibleColumns[0];
                excludedColumns = new List <WorkingColumnWidth>(1);
                break;

            case ColumnStretchMode.Last:
                stretchedColumn = visibleColumns[visibleColumns.Count - 1];
                excludedColumns = new List <WorkingColumnWidth>(1);
                break;

            case ColumnStretchMode.All:
                excludedColumns = new List <WorkingColumnWidth>(visibleColumns.Count);
                foreach (ColumnBase column in visibleColumns)
                {
                    excludedColumns.Add(new WorkingColumnWidth(column, 1d, columnStretchMinWidth));
                }
                break;

            case ColumnStretchMode.None:
                foreach (ColumnBase column in visibleColumns)
                {
                    if (column.Width.UnitType == ColumnWidthUnitType.Star)
                    {
                        if (excludedColumns == null)
                        {
                            excludedColumns = new List <WorkingColumnWidth>();
                        }

                        excludedColumns.Add(new WorkingColumnWidth(column, column.Width.Value, columnStretchMinWidth));
                    }
                    else
                    {
                        column.ClearValue(Column.DesiredWidthProperty);
                        widthToDistribute -= column.ActualWidth;
                    }
                }
                break;
            }

            if (excludedColumns != null)
            {
                if (stretchedColumn != null)
                {
                    foreach (ColumnBase column in visibleColumns)
                    {
                        if (column == stretchedColumn)
                        {
                            excludedColumns.Add(new WorkingColumnWidth(column, 1, columnStretchMinWidth));
                        }
                        else
                        {
                            column.ClearValue(Column.DesiredWidthProperty);
                            widthToDistribute -= column.ActualWidth;
                        }
                    }
                }

                this.CalculateColumnDesiredWidth(widthToDistribute, excludedColumns);
            }
        }
예제 #40
0
      private void ExportDataItemCore(
        DataGridContext dataGridContext,
        ClipboardExporterBase clipboardExporter,
        int itemIndex,
        object item,
        int[] exportedVisiblePositions,
        ColumnBase[] columnsByVisiblePosition )
      {
        DataGridCollectionViewBase dataGridCollectionViewBase =
          dataGridContext.ItemsSourceCollection as DataGridCollectionViewBase;

        clipboardExporter.StartDataItem( dataGridContext, item );

        // Ensure the count does not exceeds the columns count
        int exportedVisiblePositionsCount = exportedVisiblePositions.Length;
        exportedVisiblePositionsCount = Math.Min( exportedVisiblePositionsCount, columnsByVisiblePosition.Length );

        HashSet<int> intersectedIndexes = this.GetIntersectedRangesForIndex( dataGridContext,
            itemIndex,
            exportedVisiblePositions,
            exportedVisiblePositionsCount );

        object fieldValue = null;
        Column column = null;

        for( int i = 0; i < exportedVisiblePositionsCount; i++ )
        {
          int visiblePosition = exportedVisiblePositions[ i ];

          // Export null if not intersected by a SelectionRange
          if( intersectedIndexes.Contains( visiblePosition ) )
          {
            // Only export visible data column
            column = columnsByVisiblePosition[ visiblePosition ] as Column;

            if( column == null )
              continue;

            // Reset field value
            fieldValue = null;

            // Use DataGridCollectionView directly since the DataGridItemProperty uses PropertyDescriptor which increase
            // the read of the field value
            DataGridItemPropertyBase dataGridItemProperty = null;

            // Try to get a DataGridItemProperty matching the column FieldName
            // and get the value from it
            if( dataGridCollectionViewBase != null )
            {
              dataGridItemProperty = dataGridCollectionViewBase.ItemProperties[ column.FieldName ];

              if( dataGridItemProperty != null )
                fieldValue = dataGridItemProperty.GetValue( item );
            }

            // If none was found, create a BindingPathValueExtractor from this column
            if( ( dataGridCollectionViewBase == null ) || ( dataGridItemProperty == null ) )
            {
              // We don't have a DataGridCollectionView, use a BindingPathValueExtractor
              // to create a binding to help us get the value for the Column in the 
              // data item
              BindingPathValueExtractor extractorForRead = null;

              if( m_columnToBindingPathExtractor.TryGetValue( column, out extractorForRead ) == false )
              {
                extractorForRead = dataGridContext.GetBindingPathExtractorForColumn( column, item );
                m_columnToBindingPathExtractor.Add( column, extractorForRead );
              }

              fieldValue = extractorForRead.GetValueFromItem( item );
            }
          }

          clipboardExporter.StartDataItemField( dataGridContext, column, fieldValue );
          clipboardExporter.EndDataItemField( dataGridContext, column, fieldValue );
        }

        clipboardExporter.EndDataItem( dataGridContext, item );
      }
        public override void ApplyResize(ColumnBase resizeColumn, double newWidth, double maxWidth, double indentWidth, bool correctWidths)
        {
            ColumnsLayoutControl c = BandedViewBehavior.GetColumnsLayoutControl(resizeColumn);

            c.Resize(resizeColumn, newWidth);
        }
예제 #42
0
		public InvalidColumnPropertyValueException(ColumnBase column, string propertyName) {
			GridColumn = column;
			GridColumnPropertyName = propertyName;
		}
    private static bool MoveFocusToPreviousVisibleColumn( DataGridContext dataGridContext, Row targetRow, ColumnBase targetColumn )
    {
      if( ( dataGridContext == null ) || ( targetRow == null ) )
        return false;

      var columnIndex = NavigationHelper.GetPreviousVisibleFocusableColumnIndex( dataGridContext, targetRow, targetColumn );
      if( columnIndex < 0 )
        return NavigationHelper.MoveFocusToLastVisibleColumn( dataGridContext, targetRow );

      var columns = dataGridContext.VisibleColumns;
      Debug.Assert( columns != null );

      NavigationHelper.SetCurrentColumnAndChangeSelection( dataGridContext, columns[ columnIndex ] );

      return true;
    }
    internal DataGridItemCellAutomationPeer GetDataGridItemCellPeer( ColumnBase column )
    {
      // Force the creation of the children caching (m_dataChildren).
      this.GetChildren();

      return m_dataChildren[ column ] as DataGridItemCellAutomationPeer;
    }
예제 #45
0
    internal static int GetPreviousVisibleFocusableColumnIndex( DataGridContext currentDataGridContext, ColumnBase currentColumn )
    {
      ReadOnlyColumnCollection visibleColumnsCollection = ( ReadOnlyColumnCollection )currentDataGridContext.VisibleColumns;
      int visibleColumnsCollectionCount = visibleColumnsCollection.Count;

      if( currentColumn != null )
      {
        Row currentRow = currentDataGridContext.CurrentRow;

        int currentColumnIndex = currentDataGridContext.VisibleColumns.IndexOf( currentColumn );
        int previousVisibleFocusableColumnIndex;

        for( previousVisibleFocusableColumnIndex = currentColumnIndex - 1; previousVisibleFocusableColumnIndex >= 0; previousVisibleFocusableColumnIndex-- )
        {
          if( currentRow.Cells[ visibleColumnsCollection[ previousVisibleFocusableColumnIndex ] ].GetCalculatedCanBeCurrent() )
          {
            return previousVisibleFocusableColumnIndex;
          }
        }
      }
      return DataGridScrollViewer.GetLastVisibleFocusableColumnIndex( currentDataGridContext );
    }
        bool IDropTarget.CanDropElement(UIElement draggedElement, RelativePoint mousePosition)
        {
            ColumnManagerCell       cell = null;
            HierarchicalGroupByItem hierarchicalGroupByItem = null;
            bool canDrop = this.AllowGroupingModification;

            if (canDrop)
            {
                cell = draggedElement as ColumnManagerCell;

                if (cell != null)
                {
                    ColumnBase parentColumn = cell.ParentColumn;

                    if ((parentColumn == null) || (!parentColumn.AllowGroup))
                    {
                        return(false);
                    }

                    // Check if already grouped using the cell's DataGridContext
                    canDrop = !GroupingHelper.IsAlreadyGroupedBy(cell);

                    if (canDrop)
                    {
                        // Get the HierarchicalGroupByControl for this HierarchicalGroupByControlNode
                        HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

                        if (parentGBC == null)
                        {
                            throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl.");
                        }

                        DataGridContext parentGBCDataGridContext = DataGridControl.GetDataGridContext(parentGBC);

                        Debug.Assert(parentGBCDataGridContext != null);

                        if (parentGBCDataGridContext.Items != null)
                        {
                            canDrop = parentGBCDataGridContext.Items.CanGroup;
                        }

                        if (canDrop)
                        {
                            canDrop = GroupingHelper.IsColumnManagerCellInDataGridContext(parentGBCDataGridContext, cell);

                            if (canDrop == true)
                            {
                                canDrop = GroupingHelper.ValidateMaxGroupDescriptions(DataGridControl.GetDataGridContext(draggedElement));
                            }
                        }
                    }
                }
                else
                {
                    hierarchicalGroupByItem = draggedElement as HierarchicalGroupByItem;

                    if (hierarchicalGroupByItem == null)
                    {
                        canDrop = false;
                    }

                    if (canDrop)
                    {
                        HierarchicalGroupByControl parentGBC = GroupingHelper.GetHierarchicalGroupByControl(this);

                        if (parentGBC == null)
                        {
                            throw new DataGridInternalException("The hierarchical group-by control node must be rooted by a HierarchicalGroupByControl.");
                        }

                        // Try to get the HierarchicalGroupByControlNode in which this HierarchicalGroupByItem can be added using the parent HierarchicalGroupByControl => null it can't
                        HierarchicalGroupByControlNode draggedHierarchicalGroupByControlNode = parentGBC.GetHierarchicalGroupByControlNodeFromHierarchicalGroupByItem(hierarchicalGroupByItem);

                        if (draggedHierarchicalGroupByControlNode == null)
                        {
                            canDrop = false;
                        }
                    }
                }
            }

            bool returnedValue = ((cell != null) || (hierarchicalGroupByItem != null)) &&// ColumnManagerCell or HierarchicalGroupByItem
                                 (canDrop);


            return(returnedValue);
        }
      private void ExportHeadersCore( DataGridContext dataGridContext, ClipboardExporterBase clipboardExporter, int[] exportedVisiblePositions,
                                      ColumnBase[] columnsByVisiblePosition )
      {
        clipboardExporter.StartHeader( dataGridContext );

        // Ensure the count does not exceeds the columns count
        int exportedVisiblePositionsCount = exportedVisiblePositions.Length;
        exportedVisiblePositionsCount = Math.Min( exportedVisiblePositionsCount, columnsByVisiblePosition.Length );

        for( int i = 0; i < exportedVisiblePositionsCount; i++ )
        {
          int visiblePosition = exportedVisiblePositions[ i ];

          // Only export visible data column
          Column column = columnsByVisiblePosition[ visiblePosition ] as Column;

          if( column == null )
            continue;

          clipboardExporter.StartHeaderField( dataGridContext, column );
          clipboardExporter.EndHeaderField( dataGridContext, column );
        }

        clipboardExporter.EndHeader( dataGridContext );
      }
예제 #48
0
        internal static void ToggleColumnSort(
            DataGridContext dataGridContext,
            SortDescriptionCollection sortDescriptions,
            ColumnCollection columns,
            ColumnBase column,
            bool shiftUnpressed)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            Debug.Assert((dataGridContext != null) || (column.ParentDetailConfiguration != null));

            if ((dataGridContext == null) && (column.ParentDetailConfiguration == null))
            {
                throw new DataGridInternalException("DataGridContext or ParentDetailConfiguration can't be null.");
            }

            DataGridContext parentDataGridContext = (dataGridContext == null) ? null : dataGridContext.ParentDataGridContext;

            // Defer the RestoreState of each DataGridContext of the same level
            // to ensure all the DataGridContext will be correctly restored once
            // all of them are completely resorted
            HashSet <IDisposable> deferRestoreStateDisposable = new HashSet <IDisposable>();

            if (parentDataGridContext != null)
            {
                foreach (DataGridContext childContext in parentDataGridContext.GetChildContexts())
                {
                    deferRestoreStateDisposable.Add(childContext.DeferRestoreState());
                }
            }

            IDisposable deferResortHelper = (dataGridContext == null) ? null :
                                            SortingHelper.DeferResortHelper(dataGridContext.ItemsSourceCollection, dataGridContext.Items, sortDescriptions);

            //this will ensure that all DataGridCollectionViews mapped to this SortDescriptions collection will only refresh their sorting once!
            SortDirection newSortDirection = column.SortDirection;

            if ((shiftUnpressed) &&
                ((column.SortIndex == -1) || (sortDescriptions.Count > 1)))
            {
                sortDescriptions.Clear();
            }

            switch (newSortDirection)
            {
            case SortDirection.None:
                newSortDirection = SortDirection.Ascending;
                break;

            case SortDirection.Ascending:
                newSortDirection = SortDirection.Descending;
                break;

            case SortDirection.Descending:
                newSortDirection = SortDirection.None;
                break;
            }

            SortingHelper.ApplyColumnSort(dataGridContext, sortDescriptions, columns, column, newSortDirection);

            if (deferResortHelper != null)
            {
                //end of the DeferResort(), any DataGridCollectionView listening to the SortDescriptions instance will refresh its sorting!
                deferResortHelper.Dispose();
            }

            foreach (IDisposable disposable in deferRestoreStateDisposable)
            {
                try
                {
                    // Try/Catch to ensure all contexts are restored
                    disposable.Dispose();
                }
                catch (Exception)
                {
                }
            }

            deferRestoreStateDisposable.Clear();
        }
      private void ExportHeaders( DataGridContext dataGridContext, int detailLevel, int[] exportedVisiblePositions, ColumnBase[] columnsByVisiblePosition )
      {
        // Master level was already exported, only update the lastExportedHeaderDetailLevel
        if( ( m_lastExportedHeaderDetailLevel != -1 ) && ( detailLevel == 0 ) )
        {
          m_lastExportedHeaderDetailLevel = 0;
          return;
        }

        // Headers are already exported for this detail level
        if( m_lastExportedHeaderDetailLevel == detailLevel )
          return;

        Debug.WriteLine( string.Format( "ExportHeaders for detail level {0}", detailLevel ) );

        foreach( ClipboardExporterBase clipboardExporter in m_clipboardExporters )
        {
          // We always add the headers for detail levels every time
          if( clipboardExporter.IncludeColumnHeaders )
          {
            this.ExportHeadersCore( dataGridContext, clipboardExporter, exportedVisiblePositions, columnsByVisiblePosition );
          }
        }

        m_lastExportedHeaderDetailLevel = detailLevel;
      }
예제 #50
0
        private static void ApplyColumnSort(DataGridContext dataGridContext, SortDescriptionCollection sortDescriptions, ColumnCollection columns, ColumnBase column, SortDirection sortDirection)
        {
            if (column == null)
            {
                throw new ArgumentNullException("column");
            }

            Debug.Assert((dataGridContext != null) || (column.ParentDetailConfiguration != null));

            if ((dataGridContext == null) && (column.ParentDetailConfiguration == null))
            {
                throw new DataGridInternalException("DataGridContext or ParentDetailConfiguration cannot be null.");
            }

            if (!columns.Contains(column))
            {
                throw new ArgumentException("The specified column is not part of the DataGridContext.", "column");
            }

            string fieldName = column.FieldName;

            bool canSort = (dataGridContext != null) ? dataGridContext.Items.CanSort : true;

            if ((!string.IsNullOrEmpty(fieldName)) && (canSort == true))
            {
                SortDescription existingSort;
                int             sortDescriptionIndex = sortDescriptions.Count;

                for (int i = sortDescriptions.Count - 1; i >= 0; i--)
                {
                    existingSort = sortDescriptions[i];

                    if (existingSort.PropertyName == fieldName)
                    {
                        if (((existingSort.Direction == ListSortDirection.Ascending) && (sortDirection == SortDirection.Ascending)) ||
                            ((existingSort.Direction == ListSortDirection.Descending) && (sortDirection == SortDirection.Descending)))
                        {
                            // Nothing to change!
                            sortDescriptionIndex = -1;
                        }
                        else
                        {
                            sortDescriptionIndex = i;
                            sortDescriptions.Remove(existingSort);
                        }

                        break;
                    }
                }

                int maxDescriptions = (dataGridContext != null) ? dataGridContext.MaxSortLevels
          : column.ParentDetailConfiguration.MaxSortLevels;

                if ((maxDescriptions != -1) && (sortDescriptions.Count >= maxDescriptions))
                {
                    // Cannot insert sort description since it would go beyond the max sort description count.
                    sortDescriptionIndex = -1;
                    sortDirection        = SortDirection.None;
                }

                if ((sortDescriptionIndex > -1) && (sortDirection != SortDirection.None))
                {
                    SortDescription sortDescription = new SortDescription(fieldName,
                                                                          (sortDirection == SortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending);

                    sortDescriptions.Insert(sortDescriptionIndex, sortDescription);
                    column.SetSortIndex(sortDescriptionIndex);
                    column.SetSortDirection(sortDirection);
                }

                SortingHelper.SynchronizeSortIndexes(sortDescriptions, columns);
            }
        }
      public WorkingColumnWidth( ColumnBase column, double starValue, double columnStretchMinWidth )
      {
        bool unsetMinValue = ( column.ReadLocalValue( ColumnBase.MinWidthProperty ) == DependencyProperty.UnsetValue );

        this.Column = column;
        this.StarValue = starValue;
        m_maxWidth = column.MaxWidth;
        m_minWidth = column.MinWidth;
        m_columnStretchMinWidth = ( ( unsetMinValue ) && ( columnStretchMinWidth < m_maxWidth ) ) ? columnStretchMinWidth : -1d;
      }
예제 #52
0
파일: DataCell.cs 프로젝트: Drift2020/WPF
        protected override void InitializeCore(DataGridContext dataGridContext, Row parentRow, ColumnBase parentColumn)
        {
            ColumnBase oldParentColumn = this.ParentColumn;

            base.InitializeCore(dataGridContext, parentRow, parentColumn);

            //
            // For an unknown reason, when a recycled DataCell was added back to the VisualTree (added
            // to the CellsHostPanel in its ParentRow), the binding would fail to update when the XPath
            // expression contained a namespace prefix, even if the XmlNamespaceManager property is inherited
            // and querying for the value of this property after adding the DataCell to the VTree would return
            // a valid, non-null XmlNamespaceManager.
            //
            // Forcing a local value for the XmlNamespaceManager property solves this problem, but it is
            // not the best thing to do as we are effectively bypassing the inheritance behavior for this
            // property...
            this.SetValue(Binding.XmlNamespaceManagerProperty, dataGridContext.DataGridControl.GetValue(Binding.XmlNamespaceManagerProperty));

            //prevent the setup of the display member binding more than once on the same column!
            if ((!this.IsInternalyInitialized) || (oldParentColumn != parentColumn))
            {
                //call the helper function to setup the Cell's binding.
                this.SetupDisplayMemberBinding(dataGridContext);
            }
            else
            {
                BindingExpression binding = BindingOperations.GetBindingExpression(this, DataCell.ContentProperty);

                if (binding != null)
                {
                    binding.UpdateTarget();
                }
            }
        }
    private void DoColumnAnimation( ColumnBase column, double toValue, Duration duration, bool isReverting )
    {
      if( column == null )
        return;

      // Never animate the dragged Column to avoid flickering effects on the ghosts because we compute its position on each MouseMove event
      Cell draggedCell = this.DraggedElement as Cell;
      if( ( draggedCell != null ) && ( column == draggedCell.ParentColumn ) )
        return;

      TranslateTransform positionTransform = ColumnReorderingDragSourceManager.GetAnimatedColumnReorderingPositionTransform( column );
      List<AnimationClock> animationClocks;
      AnimationClock positionAnimationClock = null;

      // Pause previously applied AnimationClock
      if( m_fieldNameToClock.TryGetValue( column, out animationClocks ) )
      {
        // If the target value is already the correct one, no need to stop animation and create another one
        positionAnimationClock = animationClocks[ 0 ];
        OffsetAnimation positionTimeLine = positionAnimationClock.Timeline as OffsetAnimation;
        if( ( positionTimeLine != null ) && ( positionTimeLine.To == toValue ) )
          return;

        // Stop the animation, do not simply pause it, so it resets correctly.
        positionAnimationClock.Controller.Stop();
        positionAnimationClock.Completed -= this.ColumnAnimationCompleted;

        m_fieldNameToClock.Remove( column );
      }

      OffsetAnimation positionAnimation = new OffsetAnimation( toValue, duration );
      positionAnimationClock = positionAnimation.CreateClock( true ) as AnimationClock;
      positionTransform.ApplyAnimationClock( TranslateTransform.XProperty, positionAnimationClock, HandoffBehavior.SnapshotAndReplace );

      //Since we are dealing with regular Columns (i.e. not MergedColumns), no need for resize animation, so we can simply store a null value for the resize AnimationClock.
      m_fieldNameToClock.Add( column, new List<AnimationClock>() { positionAnimationClock, null } );

      if( isReverting )
      {
        positionAnimationClock.Completed += this.ColumnAnimationCompleted;
      }

      //Start the animation
      positionAnimationClock.Controller.Begin();
    }
        private static bool MoveColumnAfter(ColumnHierarchyManager columnsLayout, ColumnBase current, ColumnBase previous)
        {
            Debug.Assert(columnsLayout != null);

            var currentLocation = columnsLayout.GetColumnLocationFor(current);

            if (currentLocation == null)
            {
                return(false);
            }

            var pivotLocation = columnsLayout.GetColumnLocationFor(previous);

            if (pivotLocation == null)
            {
                return(false);
            }

            if (!currentLocation.CanMoveAfter(pivotLocation))
            {
                return(false);
            }

            currentLocation.MoveAfter(pivotLocation);
            return(true);
        }
 private void ProcessAnimatedCollectionAddition( ColumnBase animatedColumn, List<ColumnBase> animatedCollection )
 {
   animatedCollection.Add( animatedColumn );
 }
        private static bool MoveColumnUnder(ColumnHierarchyManager columnsLayout, ColumnCollection columns, ColumnBase current, ColumnBase parent)
        {
            Debug.Assert(columnsLayout != null);

            var currentLocation = columnsLayout.GetColumnLocationFor(current);

            if (currentLocation == null)
            {
                return(false);
            }

            var pivotLocation = default(ColumnHierarchyManager.ILocation);

            // Move the column under the orphan section.
            if (parent == null)
            {
                var columnCollection = current.ContainingCollection;
                if (columnCollection == null)
                {
                    return(false);
                }

                var mergedColumnCollection = default(ColumnCollection);

                if (columnCollection == columns)
                {
                    mergedColumnCollection = null;
                }

                if (mergedColumnCollection == null)
                {
                    return(false);
                }

                var levelMarkers = columnsLayout.GetLevelMarkersFor(mergedColumnCollection);
                if (levelMarkers == null)
                {
                    return(false);
                }

                pivotLocation = levelMarkers.Orphan;
            }
            else
            {
                pivotLocation = columnsLayout.GetColumnLocationFor(parent);
            }

            if (pivotLocation == null)
            {
                return(false);
            }

            if (!currentLocation.CanMoveUnder(pivotLocation))
            {
                return(false);
            }

            currentLocation.MoveUnder(pivotLocation);
            return(true);
        }
 private void SortData(ColumnBase column, ColumnSortOrder order)
 {
     Model.RefreshMessages(column.Tag as string, order == ColumnSortOrder.Ascending);
 }
예제 #58
0
    internal static int GetNextVisibleFocusableColumnIndex( DataGridContext currentDataGridContext, ColumnBase currentColumn )
    {
      ReadOnlyColumnCollection visibleColumnsCollection = ( ReadOnlyColumnCollection )currentDataGridContext.VisibleColumns;

      if( visibleColumnsCollection == null )
        return -1;

      int visibleColumnsCollectionCount = visibleColumnsCollection.Count;

      Row currentRow = currentDataGridContext.CurrentRow;

      if( currentRow != null )
      {
        int currentColumnIndex = currentDataGridContext.VisibleColumns.IndexOf( currentColumn );
        int NextVisibleFocusableColumnIndex;

        for( NextVisibleFocusableColumnIndex = currentColumnIndex + 1; NextVisibleFocusableColumnIndex < visibleColumnsCollectionCount; NextVisibleFocusableColumnIndex++ )
        {
          if( currentRow.Cells[ visibleColumnsCollection[ NextVisibleFocusableColumnIndex ] ].GetCalculatedCanBeCurrent() )
          {
            return NextVisibleFocusableColumnIndex;
          }
        }
      }

      return -1;
    }
 void SortData(ColumnBase column, ListSortDirection order)
 {
     Model.RefreshMessages(column.Tag as string, order == ListSortDirection.Ascending);
 }
예제 #60
-1
			public RowCell(ResizableGrid owner, ColumnBase gridColumn, ContentControl contentControl)
				: base(owner) {
				GridColumnControl = contentControl;
				GridColumn = gridColumn;
				Row = BandedViewBehavior.GetRow(GridColumn);
				RowSpan = BandedViewBehavior.GetRowSpan(GridColumn);
				Column = BandedViewBehavior.GetColumn(GridColumn);
				ColumnSpan = BandedViewBehavior.GetColumnSpan(GridColumn);
				ColumnDefinitions = new ColumnDefinitions();
				for(int i = Column; i < Column + ColumnSpan; i++)
					ColumnDefinitions.Add(Owner.BandBehavior.ColumnDefinitions[i]);
			}