public int IndexOf(Visual visual) { if (visual == null) { throw new ArgumentNullException("visual"); } return List.IndexOf(visual); }
public void Insert(int index, Visual visual) { if (visual == null) { throw new ArgumentNullException("visual"); } List.Insert(index, visual); }
public void CopyTo(Visual[] array, int arrayIndex) { if (array == null) { throw new ArgumentNullException("array"); } List.CopyTo(array, arrayIndex); }
public bool Contains(Visual visual) { if (visual == null) { throw new ArgumentNullException("visual"); } return List.Contains(visual); }
public void Add(Visual visual) { if (visual == null) { throw new ArgumentNullException("visual"); } List.Add(visual); }
public bool Remove(Visual visual) { if (visual == null) { throw new ArgumentNullException("visual"); } if (List.Contains(visual) == false) { return false; } List.Remove(visual); return true; }
protected void RootChanged(Visual oldRoot, Visual newRoot) { PresentationSource oldSource = null; if (oldRoot == newRoot) { return; } // Always clear the RootSourceProperty on the old root. if (oldRoot != null) { oldSource = CriticalGetPresentationSourceFromElement(oldRoot, RootSourceProperty); oldRoot.ClearValue(RootSourceProperty); } // Always set the SourceProperty on the new root. if (newRoot != null) { newRoot.SetValue(RootSourceProperty, new SecurityCriticalDataForMultipleGetAndSet <PresentationSource>(this)); } UIElement oldRootUIElement = oldRoot as UIElement; UIElement newRootUIElement = newRoot as UIElement; // The IsVisible property can only be true if root visual is connected to a presentation source. // For Read-Only force-inherited properties, use a private update method. if (oldRootUIElement != null) { oldRootUIElement.UpdateIsVisibleCache(); } if (newRootUIElement != null) { newRootUIElement.UpdateIsVisibleCache(); } // Broadcast the Unloaded event starting at the old root visual if (oldRootUIElement != null) { oldRootUIElement.OnPresentationSourceChanged(false); } // Broadcast the Loaded event starting at the root visual if (newRootUIElement != null) { newRootUIElement.OnPresentationSourceChanged(true); } // To fire PresentationSourceChanged when the RootVisual changes; // rather than simulate a "parent" pointer change, we just walk the // collection of all nodes that need the event. foreach (DependencyObject element in _watchers) { // We only need to update those elements that are in the // same context as this presentation source. if (element.Dispatcher == Dispatcher) { PresentationSource testSource = CriticalGetPresentationSourceFromElement(element, CachedSourceProperty); // 1) If we are removing the rootvisual, then fire on any node whos old // PresetationSource was the oldSource. // 2) If we are attaching a rootvisual then fire on any node whos old // PresentationSource is null; if (oldSource == testSource || null == testSource) { UpdateSourceOfElement(element, null, null); } } } }
public static PresentationSource FromVisual(Visual visual) { SecurityHelper.DemandUIWindowPermission(); return(CriticalFromVisual(visual)); }