public void SelectNeightbourCell(MoveDirection d) { //BlazorWindowHelper.BWHJsInterop.jsRuntime = BvgJsInterop.jsRuntime; //BlazorWindowHelper.BlazorTimeAnalyzer.Reset(); //BlazorWindowHelper.BlazorTimeAnalyzer.Add("A1", MethodBase.GetCurrentMethod()); int StepSize = 1; //After refresh from JS bvgCell for this component is old because we don't do component refresh //So we will depend Active cell data because it is always up to date. BvgCell <TItem> bvgActiveCell = bvgCell.bvgGrid.ActiveBvgCell; int sn = 0; ColProp a = new ColProp(); int index = 0; switch (d) { case MoveDirection.right: a = bvgActiveCell.bvgGrid.ColumnsOrderedList.Single(x => x.prop.Name.Equals(bvgActiveCell.bvgColumn.prop.Name)); index = bvgActiveCell.bvgGrid.ColumnsOrderedList.ToList().IndexOf(a); if (index < bvgActiveCell.bvgGrid.ColumnsOrderedList.Count() - StepSize) { if (bvgActiveCell.bvgRow.Cells.Any(x => x.bvgColumn.prop.Name.Equals(bvgActiveCell.bvgGrid.ColumnsOrderedList[index + StepSize].prop.Name))) { BvgCell <TItem> c = bvgActiveCell.bvgRow.Cells.Single(x => x.bvgColumn.prop.Name.Equals(bvgActiveCell.bvgGrid.ColumnsOrderedList[index + StepSize].prop.Name)); bvgActiveCell.bvgGrid.SelectCell(c, true); } else { NavigationHelper <TItem> .SelectAndScrollIntoViewHorizontal(false, bvgActiveCell.bvgGrid.ColumnsOrderedList[index + StepSize].prop.Name, bvgActiveCell.bvgRow.IndexInSource, bvgActiveCell.bvgGrid); } } break; case MoveDirection.left: a = bvgActiveCell.bvgGrid.ColumnsOrderedList.Single(x => x.prop.Name.Equals(bvgActiveCell.bvgColumn.prop.Name)); index = bvgActiveCell.bvgGrid.ColumnsOrderedList.ToList().IndexOf(a); if (index > 0) { if (bvgActiveCell.bvgRow.Cells.Any(x => x.bvgColumn.prop.Name.Equals(bvgActiveCell.bvgGrid.ColumnsOrderedList[index - StepSize].prop.Name))) { BvgCell <TItem> c = bvgActiveCell.bvgRow.Cells.Single(x => x.bvgColumn.prop.Name.Equals(bvgActiveCell.bvgGrid.ColumnsOrderedList[index - StepSize].prop.Name)); bvgActiveCell.bvgGrid.SelectCell(c, true); } else { NavigationHelper <TItem> .SelectAndScrollIntoViewHorizontal(true, bvgActiveCell.bvgGrid.ColumnsOrderedList[index - StepSize].prop.Name, bvgActiveCell.bvgRow.IndexInSource, bvgActiveCell.bvgGrid); } } break; case MoveDirection.up: sn = bvgActiveCell.bvgRow.ID - StepSize; if (bvgActiveCell.bvgGrid.Rows.Any(x => x.ID == sn)) { BvgCell <TItem> c = bvgActiveCell.bvgGrid.Rows.Single(x => x.ID == sn).Cells.Single(x => x.bvgColumn.ID == bvgActiveCell.bvgColumn.ID); bvgActiveCell.bvgGrid.SelectCell(c, true); } else { if (bvgActiveCell.bvgRow.IndexInSource > 1) { if (bvgActiveCell.bvgRow.IndexInSource > StepSize) { NavigationHelper <TItem> .ScrollIntoViewVertical(true, (ushort)(bvgActiveCell.bvgRow.IndexInSource - StepSize), bvgActiveCell.bvgColumn.prop.Name, bvgActiveCell.bvgGrid); } } } break; case MoveDirection.down: int MaxID = bvgActiveCell.bvgGrid.Rows.Max(x => x.ID); sn = bvgActiveCell.bvgRow.ID + StepSize; if (bvgActiveCell.bvgGrid.Rows.Any(x => x.ID == sn) && sn < MaxID - 1) { BvgCell <TItem> c = bvgActiveCell.bvgGrid.Rows.Single(x => x.ID == sn).Cells.Single(x => x.bvgColumn.ID == bvgActiveCell.bvgColumn.ID); bvgActiveCell.bvgGrid.SelectCell(c, true); } else { if (bvgActiveCell.bvgRow.IndexInSource < bvgCell.bvgGrid.RowsTotalCount) { int tmpindex = bvgCell.bvgGrid.ActiveBvgCell.bvgRow.IndexInSource; NavigationHelper <TItem> .ScrollIntoViewVertical(false, (ushort)(bvgActiveCell.bvgRow.IndexInSource + 1), bvgActiveCell.bvgColumn.prop.Name, bvgActiveCell.bvgGrid); if (tmpindex == bvgCell.bvgGrid.ActiveBvgCell.bvgRow.IndexInSource) { NavigationHelper <TItem> .ScrollIntoViewVertical(false, (ushort)(bvgActiveCell.bvgRow.IndexInSource + 2), bvgActiveCell.bvgColumn.prop.Name, bvgActiveCell.bvgGrid); } if (tmpindex == bvgCell.bvgGrid.ActiveBvgCell.bvgRow.IndexInSource) { SelectCornerCell(d); } } } break; default: break; } // BlazorWindowHelper.BlazorTimeAnalyzer.Log(); }
public void RenderGridColumns(double Scrollposition, bool UpdateUI, bool RequestedFromResize = false) { LastHorizontalScrollPosition = Scrollposition; int skip = Scrollposition == 0 ? 0 : GetSkipedColumns(Scrollposition); if (skip != LastHorizontalSkip || RequestedFromResize) { //BlazorWindowHelper.BlazorTimeAnalyzer.Reset(); //BlazorWindowHelper.BlazorTimeAnalyzer.Add("prepare cols", MethodBase.GetCurrentMethod()); LastHorizontalSkip = skip; IEnumerable <ColProp> ActiveRegularProps; if (skip > 0) { ActiveRegularProps = bvgGrid.ColumnsOrderedListNonFrozen.Skip(skip).Take(bvgGrid.DisplayedColumnsCount); } else { ActiveRegularProps = bvgGrid.ColumnsOrderedListNonFrozen.Take(bvgGrid.DisplayedColumnsCount); } bvgGrid.ActiveProps = new PropertyInfo[bvgGrid.ColumnsOrderedListFrozen.Count() + ActiveRegularProps.Count()]; ColProp[] ListProps = new ColProp[bvgGrid.ActiveProps.Count()]; int j = 0; for (int i = 0; i < bvgGrid.ColumnsOrderedListFrozen.Count(); i++) { bvgGrid.ActiveProps[j] = bvgGrid.ColumnsOrderedListFrozen[i].prop; ListProps[j] = bvgGrid.ColumnsOrderedListFrozen[i]; j++; } foreach (var item in ActiveRegularProps) { bvgGrid.ActiveProps[j] = item.prop; ListProps[j] = item; j++; } //BlazorWindowHelper.BlazorTimeAnalyzer.Add("get columns", MethodBase.GetCurrentMethod()); GenericAdapter <TItem> .GetColumns(ListProps, bvgGrid, SortedRowsListActual, UpdateUI); //BlazorWindowHelper.BlazorTimeAnalyzer.Log(); bvgGrid.cssHelper.UpdateStyle2(bvgGrid); //if (bvgGrid.SortState.Item1) //{ // if (bvgGrid.Columns.Any(x => x.prop.Name.Equals(bvgGrid.SortState.Item2, StringComparison.InvariantCultureIgnoreCase))) // { // if (bvgGrid.Columns.Single(x => x.prop.Name.Equals(bvgGrid.SortState.Item2, StringComparison.InvariantCultureIgnoreCase)).IsFrozen == false) // { // bvgGrid.bvgAreaColumnsNonFrozen.InvokePropertyChanged(); // } // } //} bvgGrid.bvgAreaColumnsNonFrozen.InvokePropertyChanged(); } }