protected IDataDescriptor GetDataDescriptor(UIElement element) { string targetName = Storyboard.GetTargetName(this); object targetObject = null; if (targetName == null) targetObject = element; else { INameScope ns = element.FindNameScope(); if (ns != null) targetObject = ns.FindName(targetName); if (targetObject == null) targetObject = element.FindElement(new NameMatcher(targetName)); if (targetObject == null) return null; } try { IDataDescriptor result = new ValueDataDescriptor(targetObject); if (_propertyExpression != null && _propertyExpression.Evaluate(result, out result)) return result; } catch (XamlBindingException e) { ServiceRegistration.Get<ILogger>().Warn("PropertyAnimationTimeline: Error evaluating expression '{0}' on target object '{1}'", e, _propertyExpression, targetObject); } return null; }
/// <summary> /// Searches the radio button group and adds this radio button to the specified /// group. /// </summary> protected void InitializeGroup() { if (_elementState != ElementState.Running && _elementState != ElementState.Preparing) { return; } if (_radioButtonGroup != null) { // Remove from last group, if the group name changed _radioButtonGroup.Remove(this); } _radioButtonGroup = null; if (!string.IsNullOrEmpty(GroupName)) { INameScope ns = FindGroupNamescope(); if (ns == null) { return; } _radioButtonGroup = ns.FindName(GroupName) as ICollection <RadioButton>; if (_radioButtonGroup == null) { _radioButtonGroup = new List <RadioButton>(); ns.RegisterName(GroupName, _radioButtonGroup); } if (!_radioButtonGroup.Contains(this)) { _radioButtonGroup.Add(this); } } }
private TargetKey GetClockTarget(AnimationTimelineClock clock, FrameworkElement containingObject, INameScope nameScope) { DependencyObject root = GetTarget(clock.Timeline); if (root == null) { string targetName = GetTargetName(clock.Timeline); if (targetName.IsNullOrEmpty()) { root = containingObject; } else { root = nameScope.FindName(targetName) as DependencyObject; if (root == null) { throw new Granular.Exception("Can't find Storyboard.TargetName \"{0}\" for element \"{1}\"", targetName, containingObject); } } } PropertyPath propertyPath = GetTargetProperty(clock.Timeline); DependencyObject target; DependencyProperty targetProperty; return(TryGetPropertyPathTarget(root, propertyPath, out target, out targetProperty) && target is IAnimatable ? new TargetKey((IAnimatable)target, targetProperty) : null); }
public object FindName(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (name.Length == 0) { throw new ArgumentException(SR.Get(SRID.NameScopeNameNotEmptyString)); } if (_underlyingNameScope != null) { return(_underlyingNameScope.FindName(name)); } else { if (_nameMap == null) { return(null); } return(_nameMap[name]); } }
/// <summary> /// Returns an object that has the provided identifying XAML name. /// </summary> /// <param name="name">The name identifier for the object being requested.</param> /// <returns>The object, if found. Returns nullNothingnullptra null reference if no object of that name was found.</returns> protected object FindName(string name) { if (_namescope != null) { return(_namescope.FindName(name)); } return(null); }
public UIElement FindElementInNamescope(string name) { INameScope nameScope = FindNameScope(); if (nameScope != null) { return(nameScope.FindName(name) as UIElement); } return(null); }
public object FindName(string name) { object obj = external != null?external.FindName(name) : null; if (obj != null) { return(obj); } return(table.TryGetValue(name, out obj) ? obj : null); }
public BeginStoryboard FindStoryboard(UIElement element) { INameScope ns = FindNameScope(); if (ns != null) { return(ns.FindName(BeginStoryboardName) as BeginStoryboard); } return(null); }
// internal version of FindName that returns the scope owner internal object FindName(string name, out DependencyObject scopeOwner) { INameScope nameScope = FrameworkElement.FindScope(this, out scopeOwner); if (nameScope != null) { return(nameScope.FindName(name)); } return(null); }
protected internal sealed override DependencyObject GetTemplateChild(string childName) { if (this.child != null) { INameScope nameScope = NameScope.GetNameScope(this.child); if (nameScope != null) { return(nameScope.FindName(childName) as DependencyObject); } } return(null); }
public object FindName(string name) { if (string.IsNullOrEmpty(name)) { throw Failure.NullOrEmptyString(nameof(name)); } var result = _items.GetValueOrDefault(name); if (result == null && _parent != null) { result = _parent.FindName(name); } return(result); }
public object FindName(string name) { object obj; if (_names != null && _names.TryGetValue(name, out obj)) { return(obj); } INameScope parent = FindParentNamescope(); if (parent != null) { return(parent.FindName(name)); } return(null); }
private static object GetRelativeSource(DependencyObject target, RelativeSource relativeSource, string elementName) { if (!elementName.IsNullOrEmpty()) { INameScope nameScope = NameScope.GetContainingNameScope(target); return(nameScope != null?nameScope.FindName(elementName) : null); } if (relativeSource == null || relativeSource.Mode == RelativeSourceMode.Self) { return(target); } if (relativeSource.Mode == RelativeSourceMode.TemplatedParent) { return(target is FrameworkElement ? ((FrameworkElement)target).TemplatedParent : null); } if (relativeSource.Mode == RelativeSourceMode.FindAncestor) { if (!(target is Visual)) { return(null); } Visual visual = (target as Visual).VisualParent; int level = relativeSource.AncestorLevel - 1; while (visual != null && (level > 0 || relativeSource.AncestorType != null && !relativeSource.AncestorType.IsInstanceOfType(visual))) { if (relativeSource.AncestorType == null || relativeSource.AncestorType.IsInstanceOfType(visual)) { level--; } visual = visual.VisualParent; } return(visual); } throw new Granular.Exception("RelativeSourceMode \"{0}\" is unexpected", relativeSource.Mode); }
void ResolvePendingReferences() { foreach (var fixup in pending_name_references) { foreach (var name in fixup.Names) { bool isFullyInitialized; // FIXME: sort out relationship between name_scope and name_resolver. (unify to name_resolver, probably) var obj = name_scope.FindName(name) ?? name_resolver.Resolve(name, out isFullyInitialized); if (obj == null) { throw new XamlObjectWriterException(String.Format("Unresolved object reference '{0}' was found", name)); } if (!AddToCollectionIfAppropriate(fixup.ParentType, fixup.ParentMember, fixup.ParentValue, obj, null)) // FIXME: is keyObj always null? { SetValue(fixup.ParentMember, fixup.ParentValue, obj); } } } }
public object FindName(string name) { if (name == null) throw new ArgumentNullException("name"); if (name == string.Empty) throw new ArgumentException(SR.Get(SRID.NameScopeNameNotEmptyString)); if (_underlyingNameScope != null) { return _underlyingNameScope.FindName(name); } else { if (_nameMap == null) { return null; } return _nameMap[name]; } }
void ResolvePendingReferences() { foreach (var fixup in pending_name_references) { foreach (var name in fixup.Names) { bool isFullyInitialized; // FIXME: sort out relationship between name_scope and name_resolver. (unify to name_resolver, probably) var obj = name_scope.FindName(name) ?? name_resolver.Resolve(name, out isFullyInitialized); if (obj == null) { throw new XamlObjectWriterException(String.Format("Unresolved object reference '{0}' was found", name)); } if (fixup.ListIndex != null) { ((IList)fixup.Value)[fixup.ListIndex.Value] = obj; } else if (!AddToCollectionIfAppropriate(fixup.Type, fixup.Member, fixup.Value, obj, fixup.KeyValue)) { SetValue(fixup.Member, fixup.Value, obj); } } } var handled_values = new HashSet <object>(); foreach (var fixup in pending_name_references) { if (fixup.Type.IsImmutable && !handled_values.Contains(fixup.Value)) { var value = fixup.Type.Invoker.ToImmutable(fixup.Value); SetValue(fixup.ParentMemberState.Member, fixup.ParentState.Value, value); handled_values.Add(fixup.Value); } } }
/// <inheritdoc/> public object Resolve(string name) { INameScope ns = null; var xamlObj = this.XamlObject; while (xamlObj != null) { ns = NameScopeHelper.GetNameScopeFromObject(xamlObj); if (ns != null) { var obj = ns.FindName(name); if (obj != null) { return(obj); } } xamlObj = xamlObj.ParentObject; } return(null); }
object INameScope.FindName(string name) { INameScope scope = GetNameScope(); return(null != scope?scope.FindName(name) : null); }
public object FindName(string name) { return(_scope.FindName(name)); }
private static object GetScopeElement(DependencyObject target, string elementName) { INameScope nameScope = NameScope.GetContainingNameScope(target); return(nameScope != null?nameScope.FindName(elementName) : ObservableValue.UnsetValue); }
private TargetKey GetClockTarget(AnimationTimelineClock clock, FrameworkElement containingObject, INameScope nameScope) { DependencyObject root = GetTarget(clock.Timeline); if (root == null) { string targetName = GetTargetName(clock.Timeline); if (targetName.IsNullOrEmpty()) { root = containingObject; } else { root = nameScope.FindName(targetName) as DependencyObject; if (root == null) { throw new Granular.Exception("Can't find Storyboard.TargetName \"{0}\" for element \"{1}\"", targetName, containingObject); } } } PropertyPath propertyPath = GetTargetProperty(clock.Timeline); DependencyObject target; DependencyProperty targetProperty; return TryGetPropertyPathTarget(root, propertyPath, out target, out targetProperty) && target is IAnimatable ? new TargetKey((IAnimatable)target, targetProperty) : null; }
public override void UpdateProperty(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode) { string instance; string str; IPropertyId shadowProperty; ReferenceStep referenceStep = propertyKey as ReferenceStep; ViewNode item = viewNode.Properties[propertyKey]; if (item != null && DocumentNodeUtilities.IsBinding(item.DocumentNode) && referenceStep != null) { ReferenceStep referenceStep1 = referenceStep; if (context.UseShadowProperties) { shadowProperty = DesignTimeProperties.GetShadowProperty(propertyKey, viewNode.DocumentNode.Type); } else { shadowProperty = null; } IPropertyId propertyId = shadowProperty; if (propertyId != null && DesignTimeProperties.UseShadowPropertyForInstanceBuilding(context.DocumentContext.TypeResolver, propertyId)) { referenceStep1 = propertyId as ReferenceStep; } if (referenceStep1 != null) { IInstantiatedElementViewNode instantiatedElementViewNode = viewNode as IInstantiatedElementViewNode; if (instantiatedElementViewNode == null) { referenceStep1.ClearValue(viewNode.Instance); } else { foreach (object instantiatedElement in instantiatedElementViewNode.InstantiatedElements) { referenceStep1.ClearValue(instantiatedElement); } } } } if (propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey) && InstanceBuilderOperations.GetIsInlinedResourceWithoutNamescope(viewNode)) { InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode); return; } INameScope nameScope = context.NameScope; bool flag = (nameScope == null ? false : propertyKey.DeclaringType.Metadata.IsNameProperty(propertyKey)); if (flag) { ViewNode item1 = viewNode.Properties[propertyKey]; if (item1 != null) { str = item1.Instance as string; } else { str = null; } string str1 = str; if (!string.IsNullOrEmpty(str1) && nameScope.FindName(str1) != null) { context.NameScope.UnregisterName(str1); } } if ((!context.IsSerializationScope || !(propertyKey is Event)) && (context.IsSerializationScope || !DesignTimeProperties.IsDocumentOnlyDesignTimeProperty(propertyKey))) { base.UpdateProperty(context, viewNode, propertyKey, valueNode); } else { InstanceBuilderOperations.UpdatePropertyWithoutApply(context, viewNode, propertyKey, valueNode); } if (flag) { ViewNode viewNode1 = viewNode.Properties[propertyKey]; if (viewNode1 != null) { instance = viewNode1.Instance as string; } else { instance = null; } string str2 = instance; if (!string.IsNullOrEmpty(str2)) { try { if (!str2.StartsWith("~", StringComparison.Ordinal) && !str2.Contains(".")) { if (nameScope.FindName(str2) != null) { nameScope.UnregisterName(str2); } nameScope.RegisterName(str2, viewNode.Instance); } } catch (ArgumentException argumentException1) { ArgumentException argumentException = argumentException1; ViewNodeManager viewNodeManager = viewNode1.ViewNodeManager; CultureInfo currentCulture = CultureInfo.CurrentCulture; string instanceBuilderUnableToRegisterName = ExceptionStringTable.InstanceBuilderUnableToRegisterName; object[] objArray = new object[] { str2 }; viewNodeManager.OnException(viewNode1, new InstanceBuilderException(string.Format(currentCulture, instanceBuilderUnableToRegisterName, objArray), argumentException, viewNode1.DocumentNode, viewNode), false); } } } }
public object FindName(string name) { INameScope nameScope = this.FindNameScope(this); return((nameScope != null) ? nameScope.FindName(name) : null); }
protected BeginStoryboard GetBeginStoryboard(FrameworkElement target) { INameScope nameScope = NameScope.GetContainingNameScope(target); return(nameScope != null?nameScope.FindName(BeginStoryboardName) as BeginStoryboard : null); }
public override object FindName(string name) { return(_other.FindName(name)); }
public object FindName(string name) { return(items.ContainsKey(name) ? items[name] : (parent != null ? parent.FindName(name) : null)); }
/// <summary> /// Finds a BeginStoryboard with the given name, following the rules /// governing Storyboard. Returns null if not found. /// </summary> /// <remarks> /// If a name scope is given, look there and nowhere else. In the /// absense of name scope, use Framework(Content)Element.FindName which /// has its own complex set of rules for looking up name scopes. /// /// This is a different set of rules than from that used to look up /// the TargetName. BeginStoryboard name is registered with the template /// INameScope on a per-template basis. So we look it up using /// INameScope.FindName(). This is a function completely different from /// Template.FindName(). /// </remarks> internal static BeginStoryboard ResolveBeginStoryboardName( string targetName, INameScope nameScope, FrameworkElement fe, FrameworkContentElement fce) { object namedObject = null; BeginStoryboard beginStoryboard = null; if( nameScope != null ) { namedObject = nameScope.FindName(targetName); if( namedObject == null ) { throw new InvalidOperationException( SR.Get(SRID.Storyboard_NameNotFound, targetName, nameScope.GetType().ToString())); } } else if( fe != null ) { namedObject = fe.FindName(targetName); if( namedObject == null ) { throw new InvalidOperationException( SR.Get(SRID.Storyboard_NameNotFound, targetName, fe.GetType().ToString())); } } else if( fce != null ) { namedObject = fce.FindName(targetName); if( namedObject == null ) { throw new InvalidOperationException( SR.Get(SRID.Storyboard_NameNotFound, targetName, fce.GetType().ToString())); } } else { throw new InvalidOperationException( SR.Get(SRID.Storyboard_NoNameScope, targetName)); } beginStoryboard = namedObject as BeginStoryboard; if( beginStoryboard == null ) { throw new InvalidOperationException(SR.Get(SRID.Storyboard_BeginStoryboardNameNotFound, targetName)); } return beginStoryboard; }