/// <summary>
        ///     Method which tries to scroll a cell for given index into the scroll view
        /// </summary>
        /// <param name="index"></param>
        internal void ScrollCellIntoView(int index)
        {
            DataGridCellsPanel itemsHost = InternalItemsHost as DataGridCellsPanel;

            if (itemsHost != null)
            {
                itemsHost.InternalBringIndexIntoView(index);
                return;
            }
        }
Ejemplo n.º 2
0
        // Token: 0x06005CAA RID: 23722 RVA: 0x001A112C File Offset: 0x0019F32C
        internal void ScrollCellIntoView(int index)
        {
            DataGridCellsPanel dataGridCellsPanel = this.InternalItemsHost as DataGridCellsPanel;

            if (dataGridCellsPanel != null)
            {
                dataGridCellsPanel.InternalBringIndexIntoView(index);
                return;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Helper method which returns the clip for the cell based on whether it overlaps with frozen columns or not
        /// </summary>
        /// <param name="cell">The cell or header.</param>
        /// <returns></returns>
        public static Geometry GetFrozenClipForCell(IProvideDataGridColumn cell)
        {
            DataGridCellsPanel panel = GetParentPanelForCell(cell);

            if (panel != null)
            {
                return(panel.GetFrozenClipForChild((UIElement)cell));
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Helper method which returns the parent DataGridCellPanel's offset from the scroll viewer
        ///     for a cell or Header
        /// </summary>
        /// <param name="cell">The cell or header.</param>
        /// <returns>Parent Panel's offset with respect to scroll viewer</returns>
        public static double GetParentCellsPanelHorizontalOffset(IProvideDataGridColumn cell)
        {
            DataGridCellsPanel panel = GetParentPanelForCell(cell);

            if (panel != null)
            {
                return(panel.ComputeCellsPanelHorizontalOffset());
            }

            return(0.0);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Called when the Framework <see cref="M:OnApplyTemplate" /> is called. Inheritors should override this method should they have some custom template-related logic.
        /// This is done to ensure that the <see cref="P:IsTemplateApplied" /> property is properly initialized.
        /// </summary>
        protected override bool ApplyTemplateCore()
        {
            bool applied = base.ApplyTemplateCore();

            this.scrollViewer = this.GetTemplatePartField <ScrollViewer>("PART_ScrollViewer");
            applied           = applied && this.scrollViewer != null;

            this.columnHeadersPanel = this.GetTemplatePartField <DataGridColumnHeaderPanel>("PART_ColumnHeadersHost");
            applied = applied && this.columnHeadersPanel != null;

            this.cellsPanel = this.GetTemplatePartField <DataGridCellsPanel>("PART_CellsHost");
            applied         = applied && this.cellsPanel != null;

            this.rootPanel = this.GetTemplatePartField <DataGridRootPanel>("PART_TableRoot");
            applied        = applied && this.rootPanel != null;

            this.servicePanel = this.GetTemplatePartField <DataGridServicePanel>("PART_ServicePanel");
            applied           = applied && this.servicePanel != null;

            this.decorationsHost = this.GetTemplatePartField <Panel>("PART_DecorationsHost");
            applied = applied && this.decorationsHost != null;

            this.FrozenDecorationsHost = this.GetTemplatePartField <Panel>("PART_FrozenDecorationsHost");
            applied = applied && this.FrozenDecorationsHost != null;

            this.GroupHeadersHost = this.GetTemplatePartField <Panel>("PART_GroupHeadersHost");
            applied = applied && this.GroupHeadersHost != null;

            this.frozenGroupHeadersHost = this.GetTemplatePartField <Panel>("PART_HeadersHost");
            applied = applied && this.frozenGroupHeadersHost != null;

            this.adornerHostPanel = this.GetTemplatePartField <Panel>("PART_AdornerHost");
            applied = applied && this.adornerHostPanel != null;

            this.scrollableAdornerHostPanel = this.GetTemplatePartField <Panel>("PART_ScrollableAdornerHost");
            applied = applied && this.scrollableAdornerHostPanel != null;

            this.frozenColumnsHost = this.GetTemplatePartField <Panel>("PART_FrozenColumnsHost");
            applied = applied && this.frozenColumnsHost != null;

            this.frozenColumnHeadersHost = this.GetTemplatePartField <Panel>("PART_FrozenColumnHeadersHost");
            applied = applied && this.frozenColumnHeadersHost != null;

            this.contentFlyout = this.GetTemplatePartField <DataGridContentFlyout>("PART_GridFlyout");
            applied            = applied && this.contentFlyout != null;

            this.columnReorderServicePanel = this.GetTemplatePartField <DataGridColumnReorderServicePanel>("PART_ColumnReorderServicePanel");
            applied = applied && this.columnReorderServicePanel != null;

            return(applied);
        }
        /*
         * Drawing the digit using the image pixels
         */
        private void DrawDigits(float[] pixels)
        {
            PixelGrid = new Grid();

            for (int i = 0; i < 28; i++)
            {
                PixelGrid.RowDefinitions.Add(new RowDefinition()
                {
                    Height = new GridLength(10)
                });
                PixelGrid.ColumnDefinitions.Add(new ColumnDefinition()
                {
                    Width = new GridLength(10)
                });
            }

            int pixelCount = 0;

            for (int i = 0; i < PixelGrid.RowDefinitions.Count; i++)
            {
                for (int j = 0; j < PixelGrid.ColumnDefinitions.Count; j++)
                {
                    Panel cellPanel = new DataGridCellsPanel();
                    byte  rgbValue  = (byte)pixels[pixelCount];
                    cellPanel.Background = new SolidColorBrush(Color.FromRgb(rgbValue, rgbValue, rgbValue));
                    Grid.SetRow(cellPanel, i);
                    Grid.SetColumn(cellPanel, j);
                    PixelGrid.Children.Add(cellPanel);
                    pixelCount++;
                }
            }


            this.Content = this.PixelGrid;

            this.SizeToContent = SizeToContent.WidthAndHeight;
        }
 public static IObservable <EventPattern <ContextMenuEventArgs> > ContextMenuClosingObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <ContextMenuEventHandler, ContextMenuEventArgs>(h => This.ContextMenuClosing += h, h => This.ContextMenuClosing -= h));
 }
 public static IObservable <EventPattern <ToolTipEventArgs> > ToolTipClosingObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <ToolTipEventHandler, ToolTipEventArgs>(h => This.ToolTipClosing += h, h => This.ToolTipClosing -= h));
 }
 public static IObservable <EventPattern <ManipulationCompletedEventArgs> > ManipulationCompletedObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationCompletedEventArgs>, ManipulationCompletedEventArgs>(h => This.ManipulationCompleted += h, h => This.ManipulationCompleted -= h));
 }
 public static IObservable <EventPattern <ManipulationBoundaryFeedbackEventArgs> > ManipulationBoundaryFeedbackObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationBoundaryFeedbackEventArgs>, ManipulationBoundaryFeedbackEventArgs>(h => This.ManipulationBoundaryFeedback += h, h => This.ManipulationBoundaryFeedback -= h));
 }
 public static IObservable <EventPattern <SizeChangedEventArgs> > SizeChangedObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <SizeChangedEventHandler, SizeChangedEventArgs>(h => This.SizeChanged += h, h => This.SizeChanged -= h));
 }
 public static IObservable <EventPattern <GiveFeedbackEventArgs> > GiveFeedbackObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <GiveFeedbackEventHandler, GiveFeedbackEventArgs>(h => This.GiveFeedback += h, h => This.GiveFeedback -= h));
 }
 public static IObservable <EventPattern <TextCompositionEventArgs> > TextInputObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <TextCompositionEventHandler, TextCompositionEventArgs>(h => This.TextInput += h, h => This.TextInput -= h));
 }
 public static IObservable <EventPattern <EventArgs> > LayoutUpdatedObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler, EventArgs>(h => This.LayoutUpdated += h, h => This.LayoutUpdated -= h));
 }
 public static IObservable <EventPattern <RoutedEventArgs> > UnloadedObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.Unloaded += h, h => This.Unloaded -= h));
 }
 public static IObservable <EventPattern <TouchEventArgs> > TouchLeaveObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.TouchLeave += h, h => This.TouchLeave -= h));
 }
 public static IObservable <EventPattern <TouchEventArgs> > PreviewTouchUpObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler <TouchEventArgs>, TouchEventArgs>(h => This.PreviewTouchUp += h, h => This.PreviewTouchUp -= h));
 }
 public static IObservable <EventPattern <DragEventArgs> > DropObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.Drop += h, h => This.Drop -= h));
 }
 public static IObservable <EventPattern <DragEventArgs> > PreviewDragLeaveObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <DragEventHandler, DragEventArgs>(h => This.PreviewDragLeave += h, h => This.PreviewDragLeave -= h));
 }
 public static IObservable <EventPattern <MouseButtonEventArgs> > PreviewMouseUpObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.PreviewMouseUp += h, h => This.PreviewMouseUp -= h));
 }
 public static IObservable <EventPattern <MouseButtonEventArgs> > MouseLeftButtonDownObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <MouseButtonEventHandler, MouseButtonEventArgs>(h => This.MouseLeftButtonDown += h, h => This.MouseLeftButtonDown -= h));
 }
Ejemplo n.º 22
0
        /// <summary>
        ///     Update all properties that get a value from the DataGrid
        /// </summary>
        /// <remarks>
        ///     See comment on DataGridRow.SyncProperties
        /// </remarks>
        internal void SyncProperties(bool forcePrepareCells)
        {
            var dataGridOwner = DataGridOwner;

            if (dataGridOwner == null)
            {
                return;
            }

            DataGridHelper.TransferProperty(this, HeightProperty);
            DataGridHelper.TransferProperty(this, MinHeightProperty);
            DataGridHelper.TransferProperty(this, VirtualizingPanel.IsVirtualizingProperty);

            // This is a convenient way to walk through all cells and force them to call CoerceValue(StyleProperty)
            NotifyPropertyChanged(this, new DependencyPropertyChangedEventArgs(DataGrid.CellStyleProperty, null, null), DataGridNotificationTarget.Cells);

            // We may have missed an Add / Remove of a column from the grid (DataGridRow.OnColumnsChanged)
            // Sync the MultipleCopiesCollection count and update the Column on changed cells
            MultipleCopiesCollection cellItems = ItemsSource as MultipleCopiesCollection;

            if (cellItems != null)
            {
                DataGridCell cell;
                ObservableCollection <DataGridColumn> columns = dataGridOwner.Columns;
                int  newColumnCount = columns.Count;
                int  oldColumnCount = cellItems.Count;
                int  dirtyCount     = 0;
                bool measureAndArrangeInvalidated = false;

                if (newColumnCount != oldColumnCount)
                {
                    cellItems.SyncToCount(newColumnCount);

                    // Newly added or removed containers will be updated by the generator via PrepareContainer.
                    // All others may have a different column
                    dirtyCount = Math.Min(newColumnCount, oldColumnCount);
                }
                else if (forcePrepareCells)
                {
                    dirtyCount = newColumnCount;
                }

                // if the DataGridCellsPanel missed out on some column virtualization
                // activity while the row was virtualized, it needs to be measured
                DataGridCellsPanel cellsPanel = InternalItemsHost as DataGridCellsPanel;
                if (cellsPanel != null)
                {
                    if (cellsPanel.HasCorrectRealizedColumns)
                    {
                        // This operation is performed when a DataGridRow is being prepared. So if we are working
                        // with a recycled DataGridRow we need to make sure to re-arrange it so that it picks up the
                        // correct CellsPanelHorizontalOffset. See Dev11 170908.
                        cellsPanel.InvalidateArrange();
                    }
                    else
                    {
                        InvalidateDataGridCellsPanelMeasureAndArrange();
                        measureAndArrangeInvalidated = true;
                    }
                }

                DataGridRow row = DataGridRowOwner;

                // Prepare the cells until dirtyCount is reached. Also invalidate the cells panel's measure
                // and arrange if there is a mismatch between cell.ActualWidth and Column.Width.DisplayValue
                for (int i = 0; i < dirtyCount; i++)
                {
                    cell = (DataGridCell)ItemContainerGenerator.ContainerFromIndex(i);
                    if (cell != null)
                    {
                        cell.PrepareCell(row.Item, this, row);
                        if (!measureAndArrangeInvalidated && !DoubleUtil.AreClose(cell.ActualWidth, columns[i].Width.DisplayValue))
                        {
                            InvalidateDataGridCellsPanelMeasureAndArrange();
                            measureAndArrangeInvalidated = true;
                        }
                    }
                }

                // Keep searching for the mismatch between cell.ActualWidth
                // and Column.Width.DisplayValue
                if (!measureAndArrangeInvalidated)
                {
                    for (int i = dirtyCount; i < newColumnCount; i++)
                    {
                        cell = (DataGridCell)ItemContainerGenerator.ContainerFromIndex(i);
                        if (cell != null)
                        {
                            if (!DoubleUtil.AreClose(cell.ActualWidth, columns[i].Width.DisplayValue))
                            {
                                InvalidateDataGridCellsPanelMeasureAndArrange();
                                break;
                            }
                        }
                    }
                }
            }
        }
 public static IObservable <EventPattern <RoutedEventArgs> > LostFocusObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <RoutedEventHandler, RoutedEventArgs>(h => This.LostFocus += h, h => This.LostFocus -= h));
 }
 public static IObservable <EventPattern <QueryContinueDragEventArgs> > QueryContinueDragObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <QueryContinueDragEventHandler, QueryContinueDragEventArgs>(h => This.QueryContinueDrag += h, h => This.QueryContinueDrag -= h));
 }
Ejemplo n.º 25
0
 /// <summary>
 /// Initializes a new instance of the DataGridCellsPanelAutomationPeer class.
 /// </summary>
 public DataGridCellsPanelAutomationPeer(DataGridCellsPanel owner)
     : base(owner)
 {
 }
 public static IObservable <EventPattern <KeyEventArgs> > KeyUpObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <KeyEventHandler, KeyEventArgs>(h => This.KeyUp += h, h => This.KeyUp -= h));
 }
 public static IObservable <EventPattern <DependencyPropertyChangedEventArgs> > FocusableChangedObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <DependencyPropertyChangedEventHandler, DependencyPropertyChangedEventArgs>(h => This.FocusableChanged += h, h => This.FocusableChanged -= h));
 }
 public static IObservable <EventPattern <KeyboardFocusChangedEventArgs> > PreviewLostKeyboardFocusObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <KeyboardFocusChangedEventHandler, KeyboardFocusChangedEventArgs>(h => This.PreviewLostKeyboardFocus += h, h => This.PreviewLostKeyboardFocus -= h));
 }
Ejemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the DataGridCellsPanelAutomationPeer class.
 /// </summary>
 public DataGridCellsPanelAutomationPeer(DataGridCellsPanel owner, RadDataGrid dataGrid)
     : this(owner)
 {
     this.dataGrid = dataGrid;
 }
 public static IObservable <EventPattern <ManipulationInertiaStartingEventArgs> > ManipulationInertiaStartingObserver(this DataGridCellsPanel This)
 {
     return(Observable.FromEventPattern <EventHandler <ManipulationInertiaStartingEventArgs>, ManipulationInertiaStartingEventArgs>(h => This.ManipulationInertiaStarting += h, h => This.ManipulationInertiaStarting -= h));
 }