public void Update() { _header.Text = this.Value.Signature; foreach (var item in _listViewItemCollection.OfType <BoxTreeViewItem>().ToArray()) { if (!_value.Boxes.Any(n => object.ReferenceEquals(n, item.Value))) { _listViewItemCollection.Remove(item); } } foreach (var item in _value.Boxes) { if (!_listViewItemCollection.OfType <BoxTreeViewItem>().Any(n => object.ReferenceEquals(n.Value, item))) { var treeViewItem = new BoxTreeViewItem(item); treeViewItem.Parent = this; _listViewItemCollection.Add(treeViewItem); } } this.Sort(); }
private void Update_Header() { if (this.Value.Certificate == null) { _header.Text = string.Format("{0} ({1})", this.Value.Name, BoxTreeViewItem.GetTotalSeedCount(this.Value)); } else { _header.Text = string.Format("{0} ({1}) - {2}", this.Value.Name, BoxTreeViewItem.GetTotalSeedCount(this.Value), this.Value.Certificate.ToString()); } if (this.Parent != null) { if (this.Parent is BoxTreeViewItem) { var parentBoxTreeViewItem = (BoxTreeViewItem)this.Parent; parentBoxTreeViewItem.Update_Header(); } } }
public void Update() { this.Update_Header(); foreach (var item in _listViewItemCollection.OfType<BoxTreeViewItem>().ToArray()) { if (!_value.Boxes.Any(n => object.ReferenceEquals(n, item.Value))) { _listViewItemCollection.Remove(item); } } foreach (var item in _value.Boxes) { if (!_listViewItemCollection.OfType<BoxTreeViewItem>().Any(n => object.ReferenceEquals(n.Value, item))) { var treeViewItem = new BoxTreeViewItem(item); treeViewItem.Parent = this; _listViewItemCollection.Add(treeViewItem); } } this.Sort(); }