本文整理汇总了C#中MS.Internal.FrameworkObject.Reset方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkObject.Reset方法的具体用法?C# FrameworkObject.Reset怎么用?C# FrameworkObject.Reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS.Internal.FrameworkObject
的用法示例。
在下文中一共展示了FrameworkObject.Reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvalidateOnResourcesChange
/// <summary>
/// Invalidates all the properties on the nodes in the given sub-tree
/// that are referring to the resource[s] that are changing.
/// </summary>
internal static void InvalidateOnResourcesChange(
FrameworkElement fe,
FrameworkContentElement fce,
ResourcesChangeInfo info)
{
Debug.Assert(fe != null || fce != null, "Node with the resources change notification must be an FE or an FCE.");
// We're interested in changes to the Template property that occur during
// the walk - if the template has changed we don't need to invalidate
// template-driven properties a second time. The HasTemplateChanged property
// is cleared on the first visit to each node, so that it means "template
// changed during the walk". But one relevant node isn't visited during
// the walk - the templated parent of the initial node. So we handle that now.
FrameworkObject fo = new FrameworkObject(fe, fce);
fo.Reset(fo.TemplatedParent);
fo.HasTemplateChanged = false;
DependencyObject d = (fe != null) ? (DependencyObject)fe : (DependencyObject)fce;
if (HasChildren(fe, fce))
{
// Spin up a DescendentsWalker only when
// the current node has children to walk
DescendentsWalker<ResourcesChangeInfo> walker = new DescendentsWalker<ResourcesChangeInfo>(
TreeWalkPriority.LogicalTree, ResourcesChangeDelegate, info);
walker.StartWalk(d);
}
else
{
// Degenerate case when the current node is a leaf node and has no children.
OnResourcesChanged(d, info, true);
}
}
示例2: IsEffectiveAncestor
internal static bool IsEffectiveAncestor(DependencyObject d1, DependencyObject d2
#if TRACE_INHERITANCE_CONTEXT
, DependencyProperty dp
#endif
)
{
#if TRACE_INHERITANCE_CONTEXT
int depth = 0;
#endif
for ( FrameworkObject fo = new FrameworkObject(d2);
fo.DO != null;
fo.Reset(fo.EffectiveParent))
{
if (fo.DO == d1)
{
#if TRACE_INHERITANCE_CONTEXT
Log("{0} creates cycle at depth {1}", LogIC(d2, dp, d1), depth);
#endif
return true;
}
#if TRACE_INHERITANCE_CONTEXT
++depth;
#endif
}
return false;
}
示例3: InvalidateOnTreeChange
/// <summary>
/// Invalidate inheritable properties and resource
/// references during a tree change operation.
/// </summary>
internal static void InvalidateOnTreeChange(
FrameworkElement fe,
FrameworkContentElement fce,
DependencyObject parent,
bool isAddOperation)
{
Debug.Assert(fe != null || fce != null, "Node with the tree change notification must be an FE or an FCE.");
Debug.Assert(parent != null, "Must have a parent that the current node is connected to or disconnected from.");
// If the tree change is for a non-FE/FCE parent then we need to find
// the nearest FE/FCE parent inorder to propagate inheritance correctly.
FrameworkObject parentFO = new FrameworkObject(parent);
if (!parentFO.IsValid)
{
parent = parentFO.FrameworkParent.DO;
}
// We're interested in changes to the Template property that occur during
// the walk - if the template has changed we don't need to invalidate
// template-driven properties a second time. The HasTemplateChanged property
// is cleared on the first visit to each node, so that it means "template
// changed during the walk". But one relevant node isn't visited during
// the walk - the templated parent of the initial node. So we handle that now.
FrameworkObject fo = new FrameworkObject(fe, fce);
// Synchronize the ShouldLookupImplicitStyles flag with respect to the parent here
// because for the root node of a tree change UpdateStyleProperty happens right here
// in this method. And we need to have synchrnozed the ShouldLookupImplicitStyles
// before we re-query the Style property.
if (isAddOperation)
{
fo.SetShouldLookupImplicitStyles();
}
fo.Reset(fo.TemplatedParent);
fo.HasTemplateChanged = false;
DependencyObject d = (fe != null) ? (DependencyObject)fe : (DependencyObject)fce;
// during a tree walk to invalidate inherited properties, we typically
// call UpdateStyle from FE/FCE.InvalidateTreeDependentProperties. But
// for the root element of the tree change, we need to record old values
// for inherited properties before we've updated the inheritance parent;
// so do the updatestyle here before we record old values so that we
// capture any updates provided by styles.
if (fe != null)
{
if (fe.IsInitialized && !fe.HasLocalStyle)
{
// Clear the HasStyleChanged flag
fe.HasStyleChanged = false;
fe.HasStyleInvalidated = false;
fe.HasTemplateChanged = false;
fe.AncestorChangeInProgress = true;
fe.UpdateStyleProperty();
fe.AncestorChangeInProgress = false;
}
}
else
{
if (!fce.HasLocalStyle)
{
// Clear the HasStyleChanged flag
fce.HasStyleChanged = false;
fce.HasStyleInvalidated = false;
fce.AncestorChangeInProgress = true;
fce.UpdateStyleProperty();
fce.AncestorChangeInProgress = false;
}
}
if (HasChildren(fe, fce))
{
// Spin up a DescendentsWalker only when
// the current node has children to walk
// If there is another tree walk that has already visited the
// current node then we do not need to re-walk its sub-tree.
FrameworkContextData fcdata = FrameworkContextData.From(d.Dispatcher);
if (!fcdata.WasNodeVisited(d, TreeChangeDelegate))
{
// The TreeChangeInfo object is used here to track
// information that we have because we're doing a tree walk.
TreeChangeInfo parentInfo = new TreeChangeInfo(d, parent, isAddOperation);
// PrePostDescendentsWalker is used instead of the standard
// DescendentsWalker because we need a "post" callback to know when
// to pop the parent's InheritableProperties cache from the stack.
PrePostDescendentsWalker<TreeChangeInfo> walker = new PrePostDescendentsWalker<TreeChangeInfo>(
TreeWalkPriority.LogicalTree, TreeChangeDelegate, TreeChangePostDelegate, parentInfo);
fcdata.AddWalker(TreeChangeDelegate, walker);
//.........这里部分代码省略.........
示例4: GetContainingFrameworkElement
internal static FrameworkObject GetContainingFrameworkElement(DependencyObject current)
{
FrameworkObject fo = new FrameworkObject(current);
while (!fo.IsValid && fo.DO != null)
{
// The current object is neither a FrameworkElement nor a
// FrameworkContentElement. We will now walk the "core"
// tree looking for one.
Visual visual;
Visual3D visual3D;
ContentElement ce;
if ((visual = fo.DO as Visual) != null)
{
fo.Reset(VisualTreeHelper.GetParent(visual));
}
else if ((ce = fo.DO as ContentElement) != null)
{
fo.Reset(ContentOperations.GetParent(ce));
}
else if ((visual3D = fo.DO as Visual3D) != null)
{
fo.Reset(VisualTreeHelper.GetParent(visual3D));
}
else
{
// The parent could be an application.
fo.Reset(null);
}
}
return fo;
}
示例5: OnSourceUpdated
// raise the SourceUpdatedEvent event (explicit polymorphism)
internal static void OnSourceUpdated(DependencyObject d, DependencyProperty dp)
{
DataTransferEventArgs args = new DataTransferEventArgs(d, dp);
args.RoutedEvent = Binding.SourceUpdatedEvent;
FrameworkObject fo = new FrameworkObject(d);
if (!fo.IsValid && d != null)
{
fo.Reset(Helper.FindMentor(d));
}
fo.RaiseEvent(args);
}
示例6: FindAncestorOfType
private DependencyObject FindAncestorOfType(Type type, int level, DependencyObject d, bool isTracing)
{
if (type == null)
{
if (TraceData.IsEnabled)
TraceData.Trace(TraceEventType.Error, TraceData.RefAncestorTypeNotSpecified);
return null;
}
if (level < 1)
{
if (TraceData.IsEnabled)
TraceData.Trace(TraceEventType.Error, TraceData.RefAncestorLevelInvalid);
return null;
}
// initialize search to start at the parent of the given DO
FrameworkObject fo = new FrameworkObject(d);
fo.Reset(fo.GetPreferVisualParent(true).DO);
while (fo.DO != null)
{
if (isTracing)
{
TraceData.Trace(TraceEventType.Warning,
TraceData.AncestorLookup(
type.Name,
TraceData.Identify(fo.DO)));
}
if (type.IsInstanceOfType(fo.DO)) // found it!
{
if (--level <= 0)
break;
}
fo.Reset(fo.PreferVisualParent.DO);
}
return fo.DO;
}
示例7: GetObject
//-----------------------------------------------------
//
// Public Methods
//
//------------------------------------------------------
/// <summary> Returns the referenced object. </summary>
/// <param name="d">Element defining context for the reference. </param>
/// <param name="args">See ObjectRefArgs </param>
internal override object GetObject(DependencyObject d, ObjectRefArgs args)
{
if (d == null)
throw new ArgumentNullException("d");
object o = null;
if (args.ResolveNamesInTemplate)
{
// look in container's template (if any) first
FrameworkElement fe = d as FrameworkElement;
if (fe != null && fe.TemplateInternal != null)
{
o = Helper.FindNameInTemplate(_name, d);
if (args.IsTracing)
{
TraceData.Trace(TraceEventType.Warning,
TraceData.ElementNameQueryTemplate(
_name,
TraceData.Identify(d)));
}
}
if (o == null)
{
args.NameResolvedInOuterScope = true;
}
}
FrameworkObject fo = new FrameworkObject(d);
while (o == null && fo.DO != null)
{
DependencyObject scopeOwner;
o = fo.FindName(_name, out scopeOwner);
// if the original element is a scope owner, supports IComponentConnector,
// and has a parent, don't use the result of FindName. The
// element is probably an instance of a Xaml-subclassed control;
// we want to resolve the name starting in the next outer scope.
// (bug 1669408)
// Also, if the element's NavigationService property is locally
// set, the element is the root of a navigation and should use the
// inner scope (bug 1765041)
if (d == scopeOwner && d is IComponentConnector &&
d.ReadLocalValue(System.Windows.Navigation.NavigationService.NavigationServiceProperty) == DependencyProperty.UnsetValue)
{
DependencyObject parent = LogicalTreeHelper.GetParent(d);
if (parent == null)
{
parent = Helper.FindMentor(d.InheritanceContext);
}
if (parent != null)
{
o = null;
fo.Reset(parent);
continue;
}
}
if (args.IsTracing)
{
TraceData.Trace(TraceEventType.Warning,
TraceData.ElementNameQuery(
_name,
TraceData.Identify(fo.DO)));
}
if (o == null)
{
args.NameResolvedInOuterScope = true;
// move to the next outer namescope.
// First try TemplatedParent of the scope owner.
FrameworkObject foScopeOwner = new FrameworkObject(scopeOwner);
DependencyObject dd = foScopeOwner.TemplatedParent;
// if that doesn't work, we could be at the top of
// generated content for an ItemsControl. If so, use
// the (visual) parent - a panel.
if (dd == null)
{
Panel panel = fo.FrameworkParent.DO as Panel;
if (panel != null && panel.IsItemsHost)
{
dd = panel;
}
}
// next, see if we're in a logical tree attached directly
// to a ContentPresenter. This is the m---- equivalent of
//.........这里部分代码省略.........
示例8: ContainerFromElement
///<summary>
/// Return the container that owns the given element. If itemsControl
/// is not null, return a container that belongs to the given ItemsControl.
/// If itemsControl is null, return the closest container belonging to
/// any ItemsControl. Return null if no such container exists.
///</summary>
public static DependencyObject ContainerFromElement(ItemsControl itemsControl, DependencyObject element)
{
if (element == null)
throw new ArgumentNullException("element");
// if the element is itself the desired container, return it
if (IsContainerForItemsControl(element, itemsControl))
{
return element;
}
// start the tree walk at the element's parent
FrameworkObject fo = new FrameworkObject(element);
fo.Reset(fo.GetPreferVisualParent(true).DO);
// walk up, stopping when we reach the desired container
while (fo.DO != null)
{
if (IsContainerForItemsControl(fo.DO, itemsControl))
{
break;
}
fo.Reset(fo.PreferVisualParent.DO);
}
return fo.DO;
}