private void Panel_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { IGridView child = e.Child as IGridView; if (child != null) { if (e.ChangeOperation == ItemsChangeOperation.Inserted) { child.Initialize(this, this.template.MasterViewInfo); if (this.currentView == null) { IRowView rowView = child as IRowView; if (rowView != null) { this.currentView = rowView; } } } if (e.ChangeOperation == ItemsChangeOperation.Removed) { child.Detach(); if (child == this.CurrentView) { this.CurrentView = (IRowView)null; } } } if (e.ChangeOperation != ItemsChangeOperation.Cleared) { return; } this.CurrentView = (IRowView)null; }
private void rows_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { if (e.ChangeOperation != ItemsChangeOperation.Inserted) { return; } ((GridRowElement)e.Child).InitializeRowView(this.TableElement); }
private void wrapLayout_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { if (e.ChangeOperation != ItemsChangeOperation.Inserted && e.ChangeOperation != ItemsChangeOperation.Removed && e.ChangeOperation != ItemsChangeOperation.Cleared) { return; } this.cachedHasOverflowedItems = this.layout.Children.Count > 0; int num = (int)this.SetValue(RadCommandBarOverflowButton.HasOverflowedItemsProperty, (object)(this.layout.Children.Count > 0)); }
void wrapLayout_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { if (e.ChangeOperation == ItemsChangeOperation.Inserted || e.ChangeOperation == ItemsChangeOperation.Removed || e.ChangeOperation == ItemsChangeOperation.Cleared) { this.cachedHasOverflowedItems = (layout.Children.Count > 0); this.SetValue(HasOverflowedItemsProperty, layout.Children.Count > 0); } }
void folder_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { if (!folderIsIndexed) { lock (this) { currentChildren = folder.Children; } } if (onChildrenChanged != null) { onChildrenChanged(); } }
public void ChildrenChangedEvent() { ChildrenChangedEventArgs <StringIntNode, String, int> e1 = null; int count = tree.Root.GetChildren(int.MaxValue).Count(); tree.FindNode("root:N1:N11").ChildrenChanged += (s, e) => e1 = e; var node = tree.FindNode("root:N1:N11").CreateChild <StringIntNode>("N111"); Assert.AreEqual("N111", e1.Child.Name); Assert.AreEqual("root:N1:N11:N111", e1.Child.Path); Assert.AreEqual(ChildrenChangeAction.Added, e1.Action); Assert.AreEqual(count + 1, tree.Root.GetChildren(int.MaxValue).Count()); tree.FindNode("root:N1:N11").RemoveChild(node); Assert.AreEqual(ChildrenChangeAction.Removed, e1.Action); Assert.AreEqual(count, tree.Root.GetChildren(int.MaxValue).Count()); }
/// <summary> /// Handles the LibraryChanged event of the Kernel /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MediaBrowser.Controller.Library.ChildrenChangedEventArgs" /> instance containing the event data.</param> void Instance_LibraryChanged(object sender, ChildrenChangedEventArgs e) { if (e.Folder is AggregateFolder && e.HasAddOrRemoveChange) { if (e.ItemsRemoved != null) { foreach (var item in e.ItemsRemoved.OfType <Folder>()) { StopWatchingPath(item.Path); } } if (e.ItemsAdded != null) { foreach (var item in e.ItemsAdded.OfType <Folder>()) { StartWatchingPath(item.Path); } } } }
private void Columns_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { GridCellElement child = e.Child as GridCellElement; if (child == null) { return; } if (!this.RowInfo.IsCurrent) { if (child.ColumnInfo is GridViewIndentColumn || child.ColumnInfo is GridViewRowHeaderColumn) { return; } child.Visibility = ElementVisibility.Hidden; } else { child.Visibility = ElementVisibility.Visible; } }
/// <summary> /// Handles the LibraryChanged event of the libraryManager control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param> void libraryManager_LibraryChanged(object sender, ChildrenChangedEventArgs e) { var newItems = e.ItemsAdded.Where(i => !i.IsFolder).ToList(); // Use a timer to prevent lots of these notifications from showing in a short period of time if (newItems.Count > 0) { lock (_newlyAddedItems) { _newlyAddedItems.AddRange(newItems); if (NewItemTimer == null) { NewItemTimer = new Timer(NewItemTimerCallback, null, NewItemDelay, Timeout.Infinite); } else { NewItemTimer.Change(NewItemDelay, Timeout.Infinite); } } } }
protected virtual void OnViewElementChildrenChanged(ChildrenChangedEventArgs e) { NotifyCollectionChangedAction action = NotifyCollectionChangedAction.Reset; RadTokenizedTextItem tokenizedTextItem = (RadTokenizedTextItem)null; bool flag = false; if (e.ChangeOperation == ItemsChangeOperation.Clearing) { if (this.Items.Count > 0) { this.OnClearBlocks(); flag = true; } } else if (e.Child is TokenizedTextBlockElement) { ITextBlock child = e.Child as ITextBlock; if (e.ChangeOperation == ItemsChangeOperation.Inserted) { tokenizedTextItem = this.OnInsertBlock(child); flag = true; action = NotifyCollectionChangedAction.Add; } else if (e.ChangeOperation == ItemsChangeOperation.Removed) { tokenizedTextItem = this.OnRemoveBlock(child); flag = true; action = NotifyCollectionChangedAction.Remove; } } if (!flag) { return; } this.OnCollectionChanged(new NotifyCollectionChangedEventArgs(action, (object)tokenizedTextItem)); }
/// <summary> /// Handles the LibraryChanged event of the libraryManager control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param> void libraryManager_LibraryChanged(object sender, ChildrenChangedEventArgs e) { _serverManager.SendWebSocketMessage("LibraryChanged", () => DtoBuilder.GetLibraryUpdateInfo(e)); }
/// <summary> /// Raises the <see cref="E:LibraryChanged" /> event. /// </summary> /// <param name="args">The <see cref="ChildrenChangedEventArgs" /> instance containing the event data.</param> public void ReportLibraryChanged(ChildrenChangedEventArgs args) { EventHelper.QueueEventIfNotNull(LibraryChanged, this, args, _logger); }
private void OnViewElementChildrenChanged(object sender, ChildrenChangedEventArgs e) { this.OnViewElementChildrenChanged(e); }
/// <summary> /// Compare our current children (presumably just read from the repo) with the current state of the file system and adjust for any changes /// ***Currently does not contain logic to maintain items that are unavailable in the file system*** /// </summary> /// <param name="progress">The progress.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="recursive">if set to <c>true</c> [recursive].</param> /// <returns>Task.</returns> protected async virtual Task ValidateChildrenInternal(IProgress <double> progress, CancellationToken cancellationToken, bool?recursive = null) { // Nothing to do here if (LocationType != LocationType.FileSystem) { return; } cancellationToken.ThrowIfCancellationRequested(); var changedArgs = new ChildrenChangedEventArgs(this); //get the current valid children from filesystem (or wherever) var nonCachedChildren = GetNonCachedChildren(); if (nonCachedChildren == null) { return; //nothing to validate } progress.Report(5); //build a dictionary of the current children we have now by Id so we can compare quickly and easily var currentChildren = ActualChildren.ToDictionary(i => i.Id); //create a list for our validated children var validChildren = new ConcurrentBag <Tuple <BaseItem, bool> >(); cancellationToken.ThrowIfCancellationRequested(); Parallel.ForEach(nonCachedChildren, child => { BaseItem currentChild; if (currentChildren.TryGetValue(child.Id, out currentChild)) { currentChild.ResolveArgs = child.ResolveArgs; //existing item - check if it has changed if (currentChild.HasChanged(child)) { EntityResolutionHelper.EnsureDates(currentChild, child.ResolveArgs); changedArgs.AddUpdatedItem(currentChild); validChildren.Add(new Tuple <BaseItem, bool>(currentChild, true)); } else { validChildren.Add(new Tuple <BaseItem, bool>(currentChild, false)); } } else { //brand new item - needs to be added changedArgs.AddNewItem(child); validChildren.Add(new Tuple <BaseItem, bool>(child, true)); } }); // If any items were added or removed.... if (!changedArgs.ItemsAdded.IsEmpty || currentChildren.Count != validChildren.Count) { var newChildren = validChildren.Select(c => c.Item1).ToList(); //that's all the new and changed ones - now see if there are any that are missing changedArgs.ItemsRemoved = currentChildren.Values.Except(newChildren).ToList(); foreach (var item in changedArgs.ItemsRemoved) { Logger.Info("** " + item.Name + " Removed from library."); } var childrenReplaced = false; if (changedArgs.ItemsRemoved.Count > 0) { ActualChildren = new ConcurrentBag <BaseItem>(newChildren); childrenReplaced = true; } var saveTasks = new List <Task>(); foreach (var item in changedArgs.ItemsAdded) { Logger.Info("** " + item.Name + " Added to library."); if (!childrenReplaced) { _children.Add(item); } saveTasks.Add(Kernel.Instance.ItemRepository.SaveItem(item, CancellationToken.None)); } await Task.WhenAll(saveTasks).ConfigureAwait(false); //and save children in repo... Logger.Info("*** Saving " + newChildren.Count + " children for " + Name); await Kernel.Instance.ItemRepository.SaveChildren(Id, newChildren, CancellationToken.None).ConfigureAwait(false); } if (changedArgs.HasChange) { //force the indexes to rebuild next time IndexCache.Clear(); //and fire event LibraryManager.ReportLibraryChanged(changedArgs); } progress.Report(10); cancellationToken.ThrowIfCancellationRequested(); await RefreshChildren(validChildren, progress, cancellationToken, recursive).ConfigureAwait(false); progress.Report(100); }
private void radButtonElementAddMilestone_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { }
protected void OnChildrenChanged(ChildrenChangedEventArgs args) { Sort(sortOrder, false); if (ChildrenChanged != null) { ChildrenChanged(this, args); } }
private void radCalendar1_RootElement_ChildrenChanged(object sender, ChildrenChangedEventArgs e) { if (e.ChangeOperation == ItemsChangeOperation.Inserted) { } }