protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { base.PrepareContainerForItemOverride(element, item); if (CurrentItem != null && CurrentItem.Equals(item)) { LoadInlineElement(); } Control dataRow = element as Control; if (dataRow != null) { dataRow.MouseLeftButtonUp -= MouseLeftButtonUpEventHandler; dataRow.MouseLeftButtonUp += MouseLeftButtonUpEventHandler; Button drillDownButton = dataRow.Template.FindName("PART_DrillDownButton", dataRow) as Button; if (drillDownButton != null) { drillDownButton.Click -= DrillDownButtonClickEventHandler; drillDownButton.Click += DrillDownButtonClickEventHandler; } } if (ItemVirtualized != null) { ItemVirtualized(this, new ItemVirtualizedEventArgs(element, item)); } }
public virtual Boolean MoveNext() { Boolean result; if (!Completed) { if (ProgressQueue.Count > 0) { TreeNodeType node = ProgressQueue.Dequeue(); foreach (TreeNodeType child in node.Children) { ProgressQueue.Enqueue(child); } CurrentItem = node; } else // Enumeration is complete. { CurrentItem = InvalidItem; Completed = true; } result = !CurrentItem.Equals(InvalidItem); } else { result = false; } return(result); }
public virtual Boolean MoveNext() { Boolean result; if (!Completed) { if (CurrentItem.Equals(InvalidItem) && !Root.Equals(InvalidItem)) // Need to initialize the enumeration. { ProgressStack.Clear(); ITreeNode <NodeValueType, TreeNodeType> node = Root; while (node.HasChildren) { ProgressStack.Push(new List <TreeNodeType>(node.Children)); Int32 index = GetTargetIndex(node.Children); node = node.Children[index]; } } if (ProgressStack.Count > 0) { IList <TreeNodeType> nodes = ProgressStack.Peek(); while (nodes.Count == 0 && ProgressStack.Count > 0) { ProgressStack.Pop(); nodes = ProgressStack.Peek(); } if (nodes.Count > 0) { Int32 index = GetTargetIndex(nodes); CurrentItem = nodes[index]; nodes.RemoveAt(index); } else // Enumeration is complete. { CurrentItem = InvalidItem; Completed = true; } } result = !CurrentItem.Equals(InvalidItem); } else { result = false; } return(result); }
public void Update() { var preUpdateItem = CurrentItem; Sort(); if (!preUpdateItem.Equals(contents[currentTurn])) { currentTurn = 0; while (!CurrentItem.Equals(preUpdateItem)) { currentTurn++; } } }
public bool Remove(T target) { if (target.Equals(CurrentItem)) { return(contents.Remove(target)); } var preRemovalItem = CurrentItem; var wasRemoved = contents.Remove(target); if (wasRemoved && !CurrentItem.Equals(preRemovalItem)) { currentTurn--; } return(wasRemoved); }
/// <summary> /// Adds a new item of <typeparamref name="T"/> to the navigation history, and resets the forward history. /// </summary> /// <param name="item"></param> public void Add(T item) { lock (SyncRoot) { // Don't add same item twice... if (_index >= 0 && CurrentItem.Equals(item)) { return; } if (CanGoForward) { // Remove excess items. History.RemoveRange(_index + 1, Count - _index - 1); } History.Add(item); _index++; } }
public override List <int> ApplyRule(List <int> inputItems, int uniqueItemsCount) { InputItems = inputItems; OutputItems = new List <int>(InputItems); for (int i = 0; i < OutputItems.Count; i++) { CurrentIndex = i; while (i > 0 && i % 2 == 0 && CurrentItem.Equals(OutputItems[CurrentIndex - 2])) { int number = NextItem; if (number.Equals(NEGATIVE)) { number = GetNextRandomNumber(uniqueItemsCount); } OutputItems[CurrentIndex] = number; } } return(OutputItems); }