protected override void ClearItems() { try { _owningGrid.NoCurrentCellChangeCount++; if (ItemsInternal.Count > 0) { if (_owningGrid.InDisplayIndexAdjustments) { // We are within columns display indexes adjustments. We do not allow changing the column collection while adjusting display indexes. throw DataGridError.DataGrid.CannotChangeColumnCollectionWhileAdjustingDisplayIndexes(); } _owningGrid.OnClearingColumns(); for (int columnIndex = 0; columnIndex < ItemsInternal.Count; columnIndex++) { // Detach the column... ItemsInternal[columnIndex].OwningGrid = null; } ItemsInternal.Clear(); DisplayIndexMap.Clear(); AutogeneratedColumnCount = 0; _owningGrid.OnColumnCollectionChanged_PreNotification(false /*columnsGrew*/); base.ClearItems(); VisibleEdgedColumnsWidth = 0; _owningGrid.OnColumnCollectionChanged_PostNotification(false /*columnsGrew*/); } } finally { _owningGrid.NoCurrentCellChangeCount--; } }
public void SaveChanges() { foreach (var item in ItemsInternal.Where(i => GetKey(i) == 0)) { SetKey(item, ItemsInternal.Max(GetKey) + 1); } }
/// <summary> /// Moves the child node. /// </summary> /// <param name="fromIndex">From index.</param> /// <param name="toIndex">To index.</param> public void MoveChildNode(int fromIndex, int toIndex) { ItemsInternal.Move(fromIndex, toIndex); if (IsAttached) { InvalidateSceneGraph(); } }
/// <summary> /// Clears this instance. /// </summary> public virtual void Clear() { for (var i = 0; i < Items.Count; ++i) { Items[i].Detach(); Items[i].Parent = null; } itemHashSet.Clear(); ItemsInternal.Clear(); }
public void Remove(int productId) { var item = Items.SingleOrDefault(x => x.ProductId == productId); if (item == null) { return; } ItemsInternal.Remove(item); }
public override IEnumerator <TResult> GetEnumerator() { if (ObservableExtensions.KeepOrder) { return(ItemsInternal.GetEnumerator()); } else { return(ItemsUnordered.GetEnumerator()); } }
/// <summary> /// Clears this instance. /// </summary> public void Clear() { for (int i = 0; i < ItemsInternal.Count; ++i) { ItemsInternal[i].Detach(); ItemsInternal[i].Parent = null; } ItemsInternal.Clear(); itemHashSet.Clear(); Cleared?.Invoke(this, new OnChildNodeChangedArgs(null, Operation.Clear)); }
/// <summary> /// Transfers the child node from current group node to another group node. /// </summary> /// <param name="targetGroup">The target group.</param> /// <param name="node">The node.</param> /// <returns></returns> public bool TransferChildNode(SceneNode node, GroupNodeBase targetGroup) { if (targetGroup == this || !itemHashSet.Remove(node.GUID)) { return(false); } ItemsInternal.Remove(node); node.Parent = null; InvalidateSceneGraph(); ChildNodeRemoved?.Invoke(this, new OnChildNodeChangedArgs(node, Operation.Remove)); return(targetGroup.AddChildNode(node)); }
public DirItem FindTopLevelDir(DirectoryInfo dir) { while (dir != null) { var parent = ItemsInternal.FirstOrDefault(p => p.AbsolutePath == dir.FullName); if (parent != null) { return(parent as DirItem); } dir = dir.Parent; } return(null); }
protected override void InsertItem(int columnIndex, DataGridColumn dataGridColumn) { try { _owningGrid.NoCurrentCellChangeCount++; if (_owningGrid.InDisplayIndexAdjustments) { // We are within columns display indexes adjustments. We do not allow changing the column collection while adjusting display indexes. throw DataGridError.DataGrid.CannotChangeColumnCollectionWhileAdjustingDisplayIndexes(); } if (dataGridColumn == null) { throw new ArgumentNullException("dataGridColumn"); } int columnIndexWithFiller = columnIndex; if (dataGridColumn != RowGroupSpacerColumn && RowGroupSpacerColumn.IsRepresented) { columnIndexWithFiller++; } // get the new current cell coordinates DataGridCellCoordinates newCurrentCellCoordinates = _owningGrid.OnInsertingColumn(columnIndex, dataGridColumn); // insert the column into our internal list ItemsInternal.Insert(columnIndexWithFiller, dataGridColumn); dataGridColumn.Index = columnIndexWithFiller; dataGridColumn.OwningGrid = _owningGrid; dataGridColumn.RemoveEditingElement(); if (dataGridColumn.IsVisible) { VisibleEdgedColumnsWidth += dataGridColumn.ActualWidth; } // continue with the base insert _owningGrid.OnInsertedColumn_PreNotification(dataGridColumn); _owningGrid.OnColumnCollectionChanged_PreNotification(true /*columnsGrew*/); if (dataGridColumn != RowGroupSpacerColumn) { base.InsertItem(columnIndex, dataGridColumn); } _owningGrid.OnInsertedColumn_PostNotification(newCurrentCellCoordinates, dataGridColumn.DisplayIndex); _owningGrid.OnColumnCollectionChanged_PostNotification(true /*columnsGrew*/); } finally { _owningGrid.NoCurrentCellChangeCount--; } }
public void Add(int productId, int quantity = 1) { var item = Items.SingleOrDefault(x => x.ProductId == productId); if (item == null) { item = new ShoppingCartItem(productId, quantity); ItemsInternal.Add(item); } else { item.Quantity += quantity; } }
/// <summary> /// Removes the child node. /// </summary> /// <param name="node">The node.</param> /// <returns></returns> public virtual bool RemoveChildNode(SceneNode2D node) { if (itemHashSet.Remove(node.GUID)) { node.Detach(); ItemsInternal.Remove(node); node.Parent = null; return(true); } else { return(false); } }
/// <summary> /// Removes the child node. /// </summary> /// <param name="node">The node.</param> /// <returns></returns> public bool RemoveChildNode(SceneNode node) { if (node != null && itemHashSet.Remove(node.GUID)) { node.Detach(); ItemsInternal.Remove(node); node.Parent = null; ChildNodeRemoved?.Invoke(this, new OnChildNodeChangedArgs(node, Operation.Remove)); return(true); } else { return(false); } }
/// <summary> /// Inserts the child node. /// </summary> /// <param name="index">The index.</param> /// <param name="node">The node.</param> /// <returns></returns> public bool InsertChildNode(int index, SceneNode node) { if (node == null || node.IsAttached || itemHashSet.ContainsKey(node.GUID)) { return(false); } itemHashSet.Add(node.GUID, node); ItemsInternal.Insert(index, node); node.Parent = this; if (IsAttached) { node.Attach(EffectsManager); InvalidateSceneGraph(); } ChildNodeAdded?.Invoke(this, new OnChildNodeChangedArgs(node, Operation.Add)); return(true); }
public virtual bool AddChildNode(SceneNode2D node) { if (!itemHashSet.ContainsKey(node.GUID)) { itemHashSet.Add(node.GUID, node); ItemsInternal.Add(node); node.Parent = this; if (IsAttached) { node.Attach(RenderHost); } return(true); } else { return(false); } }
public void AddItem(Item item) { item.StateChanged += (ii, state) => { if (!ii.IsTransferEnd() || !ItemsInternal.All(iii => iii.IsTransferEnd())) { return; } TransferState = ItemsInternal.Any(iii => iii.TransferState == TransferState.Error) ?TransferState.Error : TransferState.Completed; if (TransferState == TransferState.Completed) { TransferredLength = Length; } }; ItemsInternal.Add(item); }
private void RemoveItemPrivate(int columnIndex, bool isSpacer) { try { _owningGrid.NoCurrentCellChangeCount++; if (_owningGrid.InDisplayIndexAdjustments) { // We are within columns display indexes adjustments. We do not allow changing the column collection while adjusting display indexes. throw DataGridError.DataGrid.CannotChangeColumnCollectionWhileAdjustingDisplayIndexes(); } int columnIndexWithFiller = columnIndex; if (!isSpacer && RowGroupSpacerColumn.IsRepresented) { columnIndexWithFiller++; } DataGridColumn dataGridColumn = ItemsInternal[columnIndexWithFiller]; DataGridCellCoordinates newCurrentCellCoordinates = _owningGrid.OnRemovingColumn(dataGridColumn); ItemsInternal.RemoveAt(columnIndexWithFiller); if (dataGridColumn.IsVisible) { VisibleEdgedColumnsWidth -= dataGridColumn.ActualWidth; } dataGridColumn.OwningGrid = null; dataGridColumn.RemoveEditingElement(); // continue with the base remove _owningGrid.OnRemovedColumn_PreNotification(dataGridColumn); _owningGrid.OnColumnCollectionChanged_PreNotification(false /*columnsGrew*/); if (!isSpacer) { base.RemoveItem(columnIndex); } _owningGrid.OnRemovedColumn_PostNotification(newCurrentCellCoordinates); _owningGrid.OnColumnCollectionChanged_PostNotification(false /*columnsGrew*/); } finally { _owningGrid.NoCurrentCellChangeCount--; } }
public AbstractFileItem FindItem(string itemId) { var item = ItemsInternal.FirstOrDefault(c => c.Id == itemId); if (item != null) { return(item as AbstractFileItem); } //如果不是顶层的Item,先找到顶层的Dir. var path = Util.FromBase64(itemId); var fi = new FileInfo(path); var dir = fi.Exists ? fi.Directory : new DirectoryInfo(path); if (!dir.Exists) { return(null); } var topLevelDir = FindTopLevelDir(dir); var af1 = topLevelDir?.FindChildRecursive(dir, itemId); return(af1); }
internal DataGridColumn GetNextColumn(DataGridColumn dataGridColumnStart, bool?isVisible, bool?isFrozen, bool?isReadOnly) { Debug.Assert(dataGridColumnStart != null); Debug.Assert(ItemsInternal.Contains(dataGridColumnStart)); Debug.Assert(ItemsInternal.Count == DisplayIndexMap.Count); int index = dataGridColumnStart.DisplayIndexWithFiller + 1; while (index < DisplayIndexMap.Count) { DataGridColumn dataGridColumn = GetColumnAtDisplayIndex(index); if ((isVisible == null || (dataGridColumn.IsVisible) == isVisible) && (isFrozen == null || dataGridColumn.IsFrozen == isFrozen) && (isReadOnly == null || dataGridColumn.IsReadOnly == isReadOnly)) { return(dataGridColumn); } index++; } return(null); }
/// <summary> /// OnPreRender event handler. /// </summary> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); // Create the breadcrumbs if (ItemsInternal.Count > 0) { if (!HideBreadcrumbs) { pnlBreadCrumbs.Visible = true; // Generate the breadcrumbs controls int breadCrumbsLength = ItemsInternal.Count; for (int i = 0; i < breadCrumbsLength; i++) { CreateBreadCrumbsItem(ItemsInternal[i], (i + 1 == breadCrumbsLength)); } } var last = ItemsInternal.Last(); if (String.IsNullOrEmpty(last.RedirectUrl)) { last.RedirectUrl = URLHelper.UrlEncodeQueryString(RequestContext.CurrentURL); } if (PropagateToMainNavigation) { // Register breadcrumbs data for client code and start BreadcrumbsDataSource JS module RequestContext.ClientApplication.Add("breadcrumbs", new { Reframe = ChangeTargetFrame, Data = ItemsInternal }); } } }
/// <summary> /// Adds the child node. /// </summary> /// <param name="node">The node.</param> /// <returns></returns> /// <exception cref="System.ArgumentException">SceneNode already attach to a different node</exception> public bool AddChildNode(SceneNode node) { if (node != null && !itemHashSet.ContainsKey(node.GUID)) { itemHashSet.Add(node.GUID, node); ItemsInternal.Add(node); if (node.Parent != NullSceneNode.NullNode && node.Parent != this) { throw new ArgumentException("SceneNode already attach to a different node"); } node.Parent = this; if (IsAttached) { node.Attach(EffectsManager); InvalidateSceneGraph(); } ChildNodeAdded?.Invoke(this, new OnChildNodeChangedArgs(node, Operation.Add)); return(true); } else { return(false); } }
protected virtual void Sort(IList <SceneNode> nodes, RenderContext context) { sortingTransparentCache.Clear(); sortingOpaqueCache.Clear(); notSorted.Clear(); Vector3 cameraPosition = context.Camera.Position; if (SortTransparentOnly) { for (int i = 0; i < nodes.Count; ++i) { if (nodes[i].RenderCore.RenderType == RenderType.Transparent) { sortingTransparentCache.Add(new SortStruct(GetDistance(nodes[i], ref cameraPosition), nodes[i])); } else { notSorted.Add(nodes[i]); } } sortingTransparentCache.Sort(delegate(SortStruct a, SortStruct b) { return(a.Key > b.Key ? -1 : a.Key < b.Key ? 1 : 0); }); } else { for (int i = 0; i < nodes.Count; ++i) { if (nodes[i].RenderCore.RenderType == RenderType.Transparent) { sortingTransparentCache.Add(new SortStruct(GetDistance(nodes[i], ref cameraPosition), nodes[i])); } else if (nodes[i].RenderCore.RenderType == RenderType.Opaque) { sortingOpaqueCache.Add(new SortStruct(GetDistance(nodes[i], ref cameraPosition), nodes[i])); } else { notSorted.Add(nodes[i]); } } if (sortingTransparentCache.Count > 50 && sortingOpaqueCache.Count > 50) { Parallel.Invoke(() => { sortingTransparentCache.Sort(delegate(SortStruct a, SortStruct b) { return(a.Key > b.Key ? -1 : a.Key < b.Key ? 1 : 0); }); }, () => { sortingOpaqueCache.Sort(delegate(SortStruct a, SortStruct b) { return(a.Key > b.Key ? 1 : a.Key < b.Key ? -1 : 0); }); }); } else { sortingTransparentCache.Sort(delegate(SortStruct a, SortStruct b) { return(a.Key > b.Key ? -1 : a.Key < b.Key ? 1 : 0); }); sortingOpaqueCache.Sort(delegate(SortStruct a, SortStruct b) { return(a.Key > b.Key ? 1 : a.Key < b.Key ? -1 : 0); }); } } ItemsInternal.Clear(); for (int i = 0; i < notSorted.Count; ++i) { ItemsInternal.Add(notSorted[i]); } for (int i = 0; i < sortingOpaqueCache.Count; ++i) { ItemsInternal.Add(sortingOpaqueCache[i].Value); } for (int i = 0; i < sortingTransparentCache.Count; ++i) { ItemsInternal.Add(sortingTransparentCache[i].Value); } sortingTransparentCache.Clear(); sortingOpaqueCache.Clear(); notSorted.Clear(); InvalidateSceneGraph(); }
public override IEnumerator <TResult> GetEnumerator() { return(ItemsInternal.GetEnumerator()); }
public IEnumerable <TEntity> EnumerateItems() { return(ItemsInternal.ToList()); }
private void Clear() { ItemsInternal.Clear(); UpdateItems(); }
public void UpdateItems() { ItemsInternal.RemoveAll(x => x.Quantity == 0); }