コード例 #1
0
    public int IndexOf(Visual visual)
    {
      if (visual == null)
      {
        throw new ArgumentNullException("visual");
      }

      return List.IndexOf(visual);
    }
コード例 #2
0
    public void Insert(int index, Visual visual)
    {
      if (visual == null)
      {
        throw new ArgumentNullException("visual");
      }

      List.Insert(index, visual);
    }
コード例 #3
0
    public void CopyTo(Visual[] array, int arrayIndex)
    {
      if (array == null)
      {
        throw new ArgumentNullException("array");
      }

      List.CopyTo(array, arrayIndex);
    }
コード例 #4
0
    public bool Contains(Visual visual)
    {
      if (visual == null)
      {
        throw new ArgumentNullException("visual");
      }

      return List.Contains(visual);
    }
コード例 #5
0
    public void Add(Visual visual)
    {
      if (visual == null)
      {
        throw new ArgumentNullException("visual");
      }

      List.Add(visual);
    }
コード例 #6
0
    public bool Remove(Visual visual)
    {
      if (visual == null)
      {
        throw new ArgumentNullException("visual");
      }

      if (List.Contains(visual) == false)
      {
        return false;
      }

      List.Remove(visual);

      return true;
    }
コード例 #7
0
ファイル: PresentationSource.cs プロジェクト: yk2012985/wpf
        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);
                    }
                }
            }
        }
コード例 #8
0
ファイル: PresentationSource.cs プロジェクト: yk2012985/wpf
        public static PresentationSource FromVisual(Visual visual)
        {
            SecurityHelper.DemandUIWindowPermission();

            return(CriticalFromVisual(visual));
        }