private bool ChangeCurrentCore(object newCurrent, ItemInfo?info, bool cancelable, bool scrollToCurrent) { // Raise CurrentChanging first bool cancel = this.PreviewCancelCurrentChanging(cancelable); if (cancel || this.Owner.animationSurvice.IsAnimating(info)) { // the change is canceled return(false); } var oldCurrent = this.currentItem; this.updatingCurrent = true; this.currentItem = newCurrent; this.currentItemInfo = info; this.Owner.ChangePropertyInternally(RadListView.CurrentItemProperty, this.currentItem); if (this.isSynchronizedWithCurrent) { this.Owner.SelectedItem = this.currentItem; } this.UpdateState(scrollToCurrent); if (!object.ReferenceEquals(oldCurrent, this.currentItem)) { this.OnCurrentChanged(EventArgs.Empty); } this.updatingCurrent = false; return(true); }
internal ItemInfo?FindDataItemFromIndex(int index, object dataItem = null) { var enumerator = this.layoutController.strategy.Layout.GetLines(index, true).GetEnumerator(); ItemInfo?info = null; while (enumerator.MoveNext()) { foreach (var item in enumerator.Current) { if (item.ItemType == GroupType.BottomLevel) { if (dataItem == null || object.Equals(item.Item, dataItem)) { info = item; break; } } } if (info != null) { break; } } return(info); }
/// <summary> /// Retrieves a UI Automation provider for each child element that is selected. /// </summary> public IRawElementProviderSimple[] GetSelection() { List <IRawElementProviderSimple> providerSamples = new List <IRawElementProviderSimple>(); foreach (object selected in this.ListViewOwner.SelectedItems) { ItemInfo?info = this.ListViewOwner.Model.FindItemInfo(selected); if (!info.HasValue) { continue; } GeneratedItemModel generatedModel = this.ListViewOwner.Model.GetDisplayedElement(info.Value.Slot, info.Value.Id); RadListViewItem container = null; if (generatedModel != null) { container = generatedModel.Container as RadListViewItem; } if (container == null) { continue; } AutomationPeer itemPeer = (RadListViewItemAutomationPeer)FrameworkElementAutomationPeer.CreatePeerForElement(container); if (itemPeer != null) { providerSamples.Add(this.ProviderFromPeer(itemPeer)); } } return(providerSamples.ToArray()); }
internal bool IsAnimating(ItemInfo?info) { return(this.runningAnimations.Values.Any(tuple => { var model = tuple.Item1 as GeneratedItemModel; return model != null && model.ItemInfo.Equals(info); })); }
internal bool MoveCurrentToLast() { ItemInfo?lastItem = this.Owner.Model.FindLastDataItemInView(); if (lastItem == null) { return(false); } this.ChangeCurrentItem(lastItem, true, true); return(object.ReferenceEquals(this.currentItem, lastItem.Value.Item)); }
private bool MoveCurrentToLastOrFirst(bool isLast) { int index = isLast ? this.Owner.Model.ItemsCount - 1 : 0; ItemInfo?nextInfo = this.Owner.Model.FindDataItemFromIndex(index, null); if (nextInfo.HasValue) { return(this.MoveCurrentTo(nextInfo.Value.Item)); } return(false); }
internal bool ChangeCurrentItem(ItemInfo?info, bool cancelable, bool scrollToCurrent) { if (this.updatingCurrent) { return(false); } var newCurrent = info == null ? null : info.Value.Item; if (object.ReferenceEquals(this.currentItem, newCurrent)) { return(true); } return(this.ChangeCurrentCore(newCurrent, info, cancelable, scrollToCurrent)); }
internal void OnDataViewChanged(ViewChangedEventArgs args) { if (this.currentItem == null) { return; } this.currentItemInfo = null; // TODO: Update the CurrentItem switch (args.Action) { case CollectionChange.ItemRemoved: break; } }
internal bool IsAnimating(ItemInfo?info) { var models = this.runningAnimations.Values.Where((tuple) => { var model = tuple.Item1 as GeneratedItemModel; if (model != null && model.ItemInfo.Equals(info)) { return(true); } return(false); }); if (models.Count() > 0) { return(true); } return(false); }
private void RaiseCellPeerFocusChangedEvent(ItemInfo?info) { var dataGridPeer = FrameworkElementAutomationPeer.FromElement(this) as RadDataGridAutomationPeer; if (dataGridPeer != null && dataGridPeer.childrenCache != null) { if (dataGridPeer.childrenCache.Count == 0) { dataGridPeer.GetChildren(); } var cellPeer = dataGridPeer.childrenCache.FirstOrDefault(a => a.Row == info.Value.Slot && a.Column == 0) as DataGridCellInfoAutomationPeer; if (cellPeer != null && cellPeer.ChildTextBlockPeer != null) { cellPeer.RaiseAutomationEvent(AutomationEvents.AutomationFocusChanged); } } }
internal ItemInfo?FindPageUpOrDownDataItem(object pivotItem, bool pageDown) { if (!this.IsDataReady) { return(null); } int index = 0; int viewportItemCount = this.RowPool.ViewportItemCount; var info = this.FindItemInfo(pivotItem); if (info != null) { index = info.Value.LayoutInfo.Line; viewportItemCount -= this.rowLayout.GetCollapsedSlotsCount(0, index); } else { index = this.GetItemGroupIndex(pivotItem); } int itemCount = 0; var enumerator = this.rowLayout.GetLines(index, pageDown).GetEnumerator(); ItemInfo?result = null; while (enumerator.MoveNext()) { var lastItem = enumerator.Current.LastOrDefault(); if (lastItem.ItemType == GroupType.BottomLevel) { result = lastItem; } itemCount++; if (itemCount == viewportItemCount) { break; } } return(result); }
private ItemInfo?FindDataItemFromIndex(int index, bool next, object dataItem = null) { var enumerator = this.rowLayout.GetLines(index, next).GetEnumerator(); ItemInfo?info = null; while (enumerator.MoveNext()) { var lastItem = enumerator.Current.LastOrDefault(); if (lastItem.ItemType == GroupType.BottomLevel) { if (dataItem == null || object.ReferenceEquals(lastItem.Item, dataItem)) { info = lastItem; break; } } } return(info); }
private bool ChangeCurrentCore(object newCurrent, ItemInfo?info, bool cancelable, bool scrollToCurrent) { // Raise CurrentChanging first bool cancel = this.PreviewCancelCurrentChanging(cancelable); if (cancel) { // the change is canceled return(false); } var oldCurrent = this.currentItem; this.updatingCurrent = true; this.currentItem = newCurrent; this.currentItemInfo = info; this.Owner.ChangePropertyInternally(RadDataGrid.CurrentItemProperty, this.currentItem); if (this.isSynchronizedWithCurrent) { this.Owner.SelectedItem = this.currentItem; if (this.itemsSourceAsCollectionView != null) { this.itemsSourceAsCollectionView.MoveCurrentTo(this.currentItem); } } this.UpdateState(scrollToCurrent); if (!object.ReferenceEquals(oldCurrent, this.currentItem)) { this.OnCurrentChanged(EventArgs.Empty); } this.updatingCurrent = false; return(true); }
private void UpdateState(bool scrollToCurrent) { if (this.currentItem == null) { this.isCurrentInView = false; this.Owner.visualStateService.UpdateCurrentDecoration(-1); return; } this.Owner.updateService.RegisterUpdate(new DelegateUpdate <UpdateFlags>(() => { if (this.currentItemInfo == null) { this.currentItemInfo = this.Owner.Model.FindItemInfo(this.currentItem); } if (this.currentItemInfo == null) { this.isCurrentInView = false; this.Owner.visualStateService.UpdateCurrentDecoration(-1); } else { this.Owner.Model.UpdateEditRow(this.currentItemInfo.Value.LayoutInfo.Line); this.isCurrentInView = true; if (scrollToCurrent) { this.ScrollToCurrent(); } else { this.Owner.visualStateService.UpdateCurrentDecoration(this.currentItemInfo.Value.Slot); } } })); }
private bool MoveCurrentToNextOrPrev(bool isNext) { int index; if (this.CurrentItemInfo == null) { // Current is set the item after (before) the focused one like in MS ListView. index = this.Owner.currentLogicalIndex; } else { index = this.CurrentItemInfo.Value.Slot; } int increment = isNext ? 1 : -1; ItemInfo?nextInfo = this.Owner.Model.FindDataItemFromIndex(index + increment, null); if (nextInfo.HasValue) { return(this.MoveCurrentTo(nextInfo.Value.Item)); } return(false); }
private static bool DefaultBlockRightClickedHandler(World world, Coordinates3D coordinates, BlockInfo block, BlockFace face, ItemInfo?item) { return(true); }
public static bool RightClickBlock(this World world, Coordinates3D coordinates, BlockFace face, Coordinates3D cursor, ItemInfo?item) { return(Block.OnBlockRightClicked(world, coordinates, face, cursor, item)); }
internal void OnDataBindingComplete(bool scrollToCurrent) { // TODO: this.currentItemInfo = null; this.UpdateState(scrollToCurrent); }
internal void HandleKeyDown(KeyRoutedEventArgs e) { if (e == null || e.Handled) { return; } // HACK: Workaround for WinRT issue with KeyDown raised twice for VirtualKey.Enter if (e.Key == VirtualKey.Enter && e.KeyStatus.RepeatCount > 0) { return; } ItemInfo?info = null; switch (e.Key) { case VirtualKey.Escape: if (this.editService.IsEditing) { e.Handled = true; this.CancelEdit(ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.F2: if (!this.editService.IsEditing) { e.Handled = true; this.BeginEdit(this.CurrentItem, ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.Tab: break; case VirtualKey.Down: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, true); } break; case VirtualKey.Up: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, false); } break; case VirtualKey.PageDown: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, true); } break; case VirtualKey.PageUp: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, false); } break; case VirtualKey.Home: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindFirstDataItemInView(); } break; case VirtualKey.End: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindLastDataItemInView(); } break; case VirtualKey.Enter: e.Handled = true; if (this.editService.IsEditing) { this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Keyboard, e.Key); } else { bool shiftPressed = KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift); info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, !shiftPressed); } break; } if (info != null) { this.CurrencyService.ChangeCurrentItem(info.Value.Item, true, true); } }
internal void HandleKeyDown(KeyRoutedEventArgs e) { if (e == null || e.Handled) { return; } ItemInfo?info = null; switch (e.Key) { case VirtualKey.Escape: if (this.editService.IsEditing) { e.Handled = true; this.CancelEdit(ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.F2: if (!this.editService.IsEditing) { e.Handled = true; this.BeginEdit(this.CurrentItem, ActionTrigger.Keyboard, e.Key); } break; case VirtualKey.Tab: if (e.OriginalSource is RadDataGrid) { if (!this.editService.IsEditing) { e.Handled = true; info = this.CurrencyService.CurrentItemInfo == null? this.model.FindFirstDataItemInView() : this.CurrencyService.CurrentItemInfo; #pragma warning disable CS4014 Dispatcher.RunAsync( Windows.UI.Core.CoreDispatcherPriority.Low, () => { var xamlVisualStateLayer = this.visualStateLayerCache as XamlVisualStateLayer; if (xamlVisualStateLayer != null) { var currencyVisual = xamlVisualStateLayer.CurrencyVisual as DataGridCurrencyControl; if (currencyVisual != null && currencyVisual.Visibility == Visibility.Visible) { currencyVisual.Focus(FocusState.Keyboard); this.RaiseCellPeerFocusChangedEvent(info); } } }); #pragma warning restore CS4014 } } break; case VirtualKey.Down: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, true); } break; case VirtualKey.Up: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, false); } break; case VirtualKey.PageDown: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, true); } break; case VirtualKey.PageUp: if (!this.editService.IsEditing) { e.Handled = true; info = this.model.FindPageUpOrDownDataItem(this.CurrentItem, false); } break; case VirtualKey.Home: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindFirstDataItemInView(); } break; case VirtualKey.End: if (!this.editService.IsEditing && KeyboardHelper.IsModifierKeyDown(VirtualKey.Control)) { e.Handled = true; info = this.model.FindLastDataItemInView(); } break; case VirtualKey.Enter: e.Handled = true; if (this.editService.IsEditing) { this.CommitEdit(new DataGridCellInfo(this.CurrentItem, null), ActionTrigger.Keyboard, e.Key); } else { bool shiftPressed = KeyboardHelper.IsModifierKeyDown(VirtualKey.Shift); info = this.model.FindPreviousOrNextDataItem(this.CurrentItem, !shiftPressed); } break; case VirtualKey.Space: if (e.OriginalSource is RadDataGrid) { if (this.SelectionUnit == DataGridSelectionUnit.Row) { info = this.model.FindItemInfo(this.CurrentItem); if (info != null) { var cell = this.model.CellsController.GetCellsForRow(info.Value.Slot).First(); if (cell != null) { this.OnCellTap(new DataGridCellInfo(cell)); } } } } break; } if (info != null) { this.CurrencyService.ChangeCurrentItem(info.Value.Item, true, true); if (e.Key != VirtualKey.Tab) { this.RaiseCellPeerFocusChangedEvent(info); } } }
internal static bool OnBlockRightClicked(World world, Coordinates3D coordinates, BlockFace face, Coordinates3D cursor, ItemInfo?item) { var info = world.GetBlockInfo(coordinates); if (BlockRightClickedHandlers.ContainsKey(info.BlockId)) { return(BlockRightClickedHandlers[info.BlockId](world, coordinates, info, face, cursor, item)); } else { return(DefaultBlockRightClickedHandler(world, coordinates, info, face, item)); } }