Ejemplo n.º 1
0
 internal void OnCellHolding(DataGridCellInfo cellInfo, HoldingState holdingState)
 {
     if (cellInfo.Column.IsCellFlyoutEnabled && holdingState == HoldingState.Started)
     {
         this.CommandService.ExecuteCommand(Telerik.UI.Xaml.Controls.Grid.Commands.CommandId.CellFlyoutAction, new CellFlyoutActionContext(cellInfo, true, CellFlyoutGesture.Holding));
     }
 }
Ejemplo n.º 2
0
        internal bool BeginEdit(ItemInfo info, ActionTrigger trigger, object parameter)
        {
            var cell     = this.model.CellsController.GetCellsForRow(info.Slot).First();
            var cellInfo = new DataGridCellInfo(cell);

            return(this.BeginEdit(cellInfo, trigger, parameter));
        }
Ejemplo n.º 3
0
        internal override void TryFocusCell(DataGridCellInfo cellInfo, FocusState state)
        {
            base.TryFocusCell(cellInfo, state);

            if (cellInfo.Cell == null)
            {
                return;
            }

            var element = cellInfo.Cell.Container as FrameworkElement;

            if (element != null)
            {
                var control = element as Control;
                if (control != null)
                {
                    control.Focus(state);
                }
                else
                {
                    var firstControl = ElementTreeHelper.FindVisualDescendant <Control>(element);
                    if (firstControl != null)
                    {
                        firstControl.Focus(state);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        internal bool CommitEdit(DataGridCellInfo cellInfo, ActionTrigger trigger, object parameter)
        {
            var context = new EditContext(cellInfo, trigger, parameter);

            this.CommandService.ExecuteCommand(CommandId.CommitEdit, context);

            return(context.IsSuccessful);
        }
Ejemplo n.º 5
0
        internal void SelectCellInfo(DataGridCellInfo cellInfo, bool select, bool uiSelect)
        {
            if (!this.CanSelectCellInfo(cellInfo))
            {
                return;
            }

            this.SelectCellUnit(cellInfo, select, uiSelect);
            this.OnSelectionChanged();
        }
Ejemplo n.º 6
0
        private void SelectSingleCellUnit(DataGridCellInfo cellInfo, bool select)
        {
            this.selectedCellsSet.Clear();

            this.SelectSingleItemCore(cellInfo, select);

            if (select)
            {
                this.selectedCellsSet.Add(cellInfo);
            }
        }
Ejemplo n.º 7
0
        internal bool BeginEdit(DataGridCellInfo cellInfo, ActionTrigger trigger, object parameter)
        {
            if ((this.editService.IsEditing && !this.CommitEdit()) || !this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, false, true))
            {
                return(false);
            }

            var context = new EditContext(cellInfo, trigger, parameter);

            this.CommandService.ExecuteCommand(CommandId.BeginEdit, context);
            return(context.IsSuccessful);
        }
Ejemplo n.º 8
0
 private void SelectMultipleCellUnits(DataGridCellInfo cellInfo, bool select, bool uiSelect)
 {
     if (!select || (uiSelect && this.selectedCellsSet.Contains(cellInfo)))
     {
         this.selectedCellsSet.Remove(cellInfo);
         this.selectedItems.Remove(cellInfo);
     }
     else if (select)
     {
         this.selectedCellsSet.Add(cellInfo);
         this.selectedItems.Add(cellInfo);
     }
 }
Ejemplo n.º 9
0
        internal void OnCellTap(DataGridCellInfo cellInfo)
        {
            if (this.editService.IsEditing)
            {
                if (this.UserEditMode == DataGridUserEditMode.External)
                {
                    this.CancelEdit();
                }
                else if (!this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Tap, null))
                {
                    return;
                }
            }

            switch (this.SelectionMode)
            {
            case DataGridSelectionMode.Single:
            case DataGridSelectionMode.Multiple:
                this.selectionService.Select(cellInfo.Cell);
                this.itemToSelectFrom = cellInfo;
                break;

            case DataGridSelectionMode.Extended:
                if (KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift))
                {
                    var startColumnAndRow = this.GetExtendedSelectionStartRowAndColumn();
                    this.selectionService.SelectRange(startColumnAndRow.Item1, startColumnAndRow.Item2, cellInfo.Column.ItemInfo.Slot, cellInfo.RowItemInfo.Slot);
                }
                else if (KeyboardHelper.IsModifierKeyDown(VirtualKey.Control))
                {
                    this.selectionService.Select(cellInfo.Cell);
                    this.itemToSelectFrom = cellInfo;
                }
                else
                {
                    this.selectionService.ClearSelection();
                    this.selectionService.Select(cellInfo.Cell);
                    this.itemToSelectFrom = cellInfo;
                }
                break;
            }

            this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, true, true);

            if (cellInfo.Column != null)
            {
                cellInfo.Column.TryFocusCell(cellInfo, FocusState.Pointer);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Removes the selection for the grid cell defined by the specified cell info.
        /// </summary>
        public void DeselectCell(DataGridCellInfo item)
        {
            var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this) as RadDataGridAutomationPeer;

            if (dataGridPeer != null && dataGridPeer.childrenCache != null && dataGridPeer.childrenCache.Count > 0)
            {
                var cellPeer = dataGridPeer.childrenCache.Where(a => a.Row == item.RowItemInfo.Slot && a.Column == item.Column.ItemInfo.Slot).FirstOrDefault() as DataGridCellInfoAutomationPeer;
                if (cellPeer != null && cellPeer.ChildTextBlockPeer != null)
                {
                    cellPeer.RaiseValuePropertyChangedEvent(true, false);
                }
            }

            this.selectionService.SelectCellInfo(item, false, false);
        }
Ejemplo n.º 11
0
        private Style ComposeCellDecorationStyle(GridCellModel cell)
        {
            if (this.cellDecorationStyleCache != null)
            {
                return(this.cellDecorationStyleCache);
            }

            if (this.cellDecorationStyleSelectorCache != null)
            {
                var parentRow     = cell.parent as GridRowModel;
                var selectContext = new DataGridCellInfo(parentRow.ItemInfo.Item, cell.Column);
                return(this.cellDecorationStyleSelectorCache.SelectStyle(selectContext, null));
            }

            return(null);
        }
Ejemplo n.º 12
0
        internal void Select(GridCellModel gridCellModel)
        {
            switch (this.Owner.SelectionUnit)
            {
            case DataGridSelectionUnit.Row:
                this.SelectItem((gridCellModel.Parent as GridRowModel).ItemInfo.Item, true, true);
                break;

            case DataGridSelectionUnit.Cell:
                var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column);
                this.SelectCellInfo(cellInfo, true, true);
                break;

            default:
                throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit");
            }
        }
Ejemplo n.º 13
0
        private Style ComposeCellContentStyle(FrameworkElement container, object item)
        {
            if (this.cellContentStyleCache != null)
            {
                return(this.cellContentStyleCache);
            }

            if (this.cellContentStyleSelectorCache != null)
            {
                var selectContext = new DataGridCellInfo(item, this);
                var style         = this.cellContentStyleSelectorCache.SelectStyle(selectContext, container);
                if (style != null)
                {
                    return(style);
                }
            }

            return(this.DefaultCellContentStyle);
        }
Ejemplo n.º 14
0
        internal async void Select(GridCellModel gridCellModel, bool uiSelect = true)
        {
            await this.RaiseAutomationSelection(gridCellModel);

            switch (this.Owner.SelectionUnit)
            {
            case DataGridSelectionUnit.Row:
                this.SelectItem(((GridRowModel)gridCellModel.Parent).ItemInfo.Item, true, uiSelect);
                break;

            case DataGridSelectionUnit.Cell:
                var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column);
                this.SelectCellInfo(cellInfo, true, uiSelect);
                break;

            default:
                throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit");
            }
        }
Ejemplo n.º 15
0
        private Style ComposeCellContentStyle(FrameworkElement container, GridCellModel cell)
        {
            if (this.cellContentStyleCache != null)
            {
                return(this.cellContentStyleCache);
            }

            if (this.cellContentStyleSelectorCache != null)
            {
                var parentRow     = cell.parent as GridRowModel;
                var selectContext = new DataGridCellInfo(parentRow.ItemInfo.Item, cell.Column);
                var style         = this.cellContentStyleSelectorCache.SelectStyle(selectContext, container);
                if (style != null)
                {
                    return(style);
                }
            }

            return(this.DefaultCellContentStyle);
        }
Ejemplo n.º 16
0
        private void SelectCellUnit(DataGridCellInfo cellInfo, bool select, bool uiSelect)
        {
            if (!this.CanSelectCellInfo(cellInfo))
            {
                return;
            }

            switch (this.Owner.SelectionMode)
            {
            case DataGridSelectionMode.Single:
                this.SelectSingleCellUnit(cellInfo, select);
                break;

            case DataGridSelectionMode.Multiple:
                this.SelectMultipleCellUnits(cellInfo, select, uiSelect);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 17
0
        internal async void Select(GridCellModel gridCellModel)
        {
            var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this.Owner) as RadDataGridAutomationPeer;

            if (dataGridPeer != null && dataGridPeer.childrenCache != null)
            {
                if (dataGridPeer.childrenCache.Count == 0)
                {
                    dataGridPeer.GetChildren();
                }

                var cellPeer = dataGridPeer.childrenCache.Where(a => a.Row == gridCellModel.ParentRow.ItemInfo.Slot && a.Column == gridCellModel.Column.ItemInfo.Slot).FirstOrDefault() as DataGridCellInfoAutomationPeer;
                if (cellPeer != null && cellPeer.ChildTextBlockPeer != null)
                {
                    await Dispatcher.RunAsync(
                        Windows.UI.Core.CoreDispatcherPriority.Normal,
                        () =>
                    {
                        cellPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged);
                        cellPeer.RaiseAutomationEvent(AutomationEvents.SelectionItemPatternOnElementAddedToSelection);
                        cellPeer.RaiseValuePropertyChangedEvent(false, true);
                    });
                }
            }

            switch (this.Owner.SelectionUnit)
            {
            case DataGridSelectionUnit.Row:
                this.SelectItem((gridCellModel.Parent as GridRowModel).ItemInfo.Item, true, true);
                break;

            case DataGridSelectionUnit.Cell:
                var cellInfo = new DataGridCellInfo(gridCellModel.ParentRow.ItemInfo, gridCellModel.Column);
                this.SelectCellInfo(cellInfo, true, true);
                break;

            default:
                throw new ArgumentException("Unknown selection unit type", "this.Owner.SelectionUnit");
            }
        }
Ejemplo n.º 18
0
        internal void OnCellTap(DataGridCellInfo cellInfo)
        {
            if (this.editService.IsEditing)
            {
                if (this.UserEditMode == DataGridUserEditMode.External)
                {
                    this.CancelEdit();
                }
                else if (!this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Tap, null))
                {
                    return;
                }
            }

            this.selectionService.Select(cellInfo.Cell);
            this.CurrencyService.ChangeCurrentItem(cellInfo.RowItemInfo.Item, true, true);

            if (cellInfo.Column != null)
            {
                cellInfo.Column.TryFocusCell(cellInfo, FocusState.Pointer);
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Selects the grid cell as defined by the specified cell info.
 /// </summary>
 /// <remarks>
 /// In order to select a cell, the <see cref="SelectionUnit"/> value should be <c>DataGridSelectionUnit.Cell</c>.
 /// </remarks>
 public void SelectCell(DataGridCellInfo item)
 {
     this.selectionService.SelectCellInfo(item, true, false);
 }
Ejemplo n.º 20
0
 internal void OnCellDoubleTap(DataGridCellInfo cell)
 {
     this.BeginEdit(cell, ActionTrigger.DoubleTap, null);
 }
Ejemplo n.º 21
0
 internal virtual void TryFocusCell(DataGridCellInfo cellInfo, FocusState state)
 {
 }
Ejemplo n.º 22
0
 private bool CanSelectCellInfo(DataGridCellInfo cell)
 {
     return(cell != null && this.Owner.SelectionMode != DataGridSelectionMode.None && this.Owner.SelectionUnit == DataGridSelectionUnit.Cell);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Selects the grid cell as defined by the specified cell info.
 /// </summary>
 /// <remarks>
 /// In order to select a cell, the <see cref="SelectionUnit"/> value should be <c>DataGridSelectionUnit.Cell</c>.
 /// </remarks>
 public void SelectCell(DataGridCellInfo item)
 {
     this.UpdateItemToSelectFrom(item);
     this.selectionService.SelectCellInfo(item, true, false);
 }