public bool TryAdd(TKey key, TValue value) { if (m_KeySet.Contains(key)) { return(false); } this.Add(key, value); return(true); }
/// <summary> /// Gets whether a down event occurred at any point between the previous flush and up to the last event process call for a key that was not down in the previous flush. /// </summary> /// <param name="key">Key to check.</param> /// <returns>True if the key was pressed in the latest event processing call, false otherwise.</returns> public bool WasPushed(Key key) { return(!previousDownedKeys.Contains(key) && anyDownedKeys.Contains(key)); }
/// <summary> /// Gets whether a key was down at the time of the previous flush. /// </summary> /// <param name="key">Key to check.</param> /// <returns>True if the key was down at the time of the previous flush, false otherwise.</returns> public bool WasDown(Key key) { return(previousDownedKeys.Contains(key)); }
/// <summary> /// Gets whether a key is currently pressed according to the latest event processing call. /// </summary> /// <param name="key">Key to check.</param> /// <returns>True if the key was pressed in the latest event processing call, false otherwise.</returns> public bool IsDown(Key key) { return(downedKeys.Contains(key)); }
/// <summary> /// 调用 OnQuery 回调方法获得数据源 /// </summary> protected async Task QueryData() { // https://gitee.com/LongbowEnterprise/BootstrapBlazor/issues/I29YK1 // 选中行目前不支持跨页 原因是选中行实例无法在翻页后保持 SelectedItems.Clear(); QueryData <TItem>?queryData = null; var queryOption = new QueryPageOptions() { IsPage = IsPagination, PageIndex = PageIndex, PageItems = PageItems, SearchText = SearchText, SortOrder = SortOrder, SortName = SortName, Filters = Filters.Values, Searchs = GetSearchs(), SearchModel = SearchModel }; if (OnQueryAsync != null) { queryData = await OnQueryAsync(queryOption); } else if (UseInjectDataService) { queryData = await GetDataService().QueryAsync(queryOption); } if (queryData != null) { Items = queryData.Items; if (IsTree) { KeySet.Clear(); if (TableTreeNode <TItem> .HasKey) { CheckExpandKeys(TreeRows); } if (KeySet.Count > 0) { TreeRows = new List <TableTreeNode <TItem> >(); foreach (var item in Items) { var node = new TableTreeNode <TItem>(item) { HasChildren = CheckTreeChildren(item), }; node.IsExpand = node.HasChildren && node.Key != null && KeySet.Contains(node.Key); if (node.IsExpand) { await RestoreIsExpand(node); } TreeRows.Add(node); } } else { TreeRows = Items.Select(item => new TableTreeNode <TItem>(item) { HasChildren = CheckTreeChildren(item) }).ToList(); } } TotalCount = queryData.TotalCount; IsFiltered = queryData.IsFiltered; IsSorted = queryData.IsSorted; IsSearch = queryData.IsSearch; // 外部未过滤,内部自行过滤 if (!IsFiltered && Filters.Any()) { Items = Items.Where(Filters.Values.GetFilterFunc <TItem>()); TotalCount = Items.Count(); } // 外部未处理排序,内部自行排序 if (!IsSorted && SortOrder != SortOrder.Unset && !string.IsNullOrEmpty(SortName)) { var invoker = SortLambdaCache.GetOrAdd(typeof(TItem), key => LambdaExtensions.GetSortLambda <TItem>().Compile()); Items = invoker(Items, SortName, SortOrder); } } if (SelectedRows != null) { SelectedItems.AddRange(Items.Where(i => SelectedRows.Contains(i))); } }