committed by
GitHub
31 changed files with 916 additions and 698 deletions
@ -0,0 +1,32 @@ |
|||
using System; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Represents an element which hosts resources.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// This interface is implemented by <see cref="StyledElement"/> and `Application`.
|
|||
/// </remarks>
|
|||
public interface IResourceHost : IResourceNode |
|||
{ |
|||
/// <summary>
|
|||
/// Raised when the resources change on the element or an ancestor of the element.
|
|||
/// </summary>
|
|||
event EventHandler<ResourcesChangedEventArgs> ResourcesChanged; |
|||
|
|||
/// <summary>
|
|||
/// Notifies the resource host that one or more of its hosted resources has changed.
|
|||
/// </summary>
|
|||
/// <param name="e">The event args.</param>
|
|||
/// <remarks>
|
|||
/// This method will be called automatically by the framework, you should not need to call
|
|||
/// this method yourself. It is called when the resources hosted by this element have
|
|||
/// changed, and is usually called by a resource dictionary or style hosted by the element
|
|||
/// in response to a resource being added or removed.
|
|||
/// </remarks>
|
|||
void NotifyHostedResourcesChanged(ResourcesChangedEventArgs e); |
|||
} |
|||
} |
|||
@ -1,15 +1,35 @@ |
|||
using System; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Represents resource provider in a tree.
|
|||
/// Represents an object that can be queried for resources.
|
|||
/// </summary>
|
|||
public interface IResourceNode : IResourceProvider |
|||
/// <remarks>
|
|||
/// The interface represents a common interface for both controls that host resources
|
|||
/// (<see cref="IResourceHost"/>) and resource providers such as <see cref="ResourceDictionary"/>
|
|||
/// (see <see cref="IResourceProvider"/>).
|
|||
/// </remarks>
|
|||
public interface IResourceNode |
|||
{ |
|||
/// <summary>
|
|||
/// Gets the parent resource node, if any.
|
|||
/// Gets a value indicating whether the object has resources.
|
|||
/// </summary>
|
|||
bool HasResources { get; } |
|||
|
|||
/// <summary>
|
|||
/// Tries to find a resource within the object.
|
|||
/// </summary>
|
|||
IResourceNode ResourceParent { get; } |
|||
/// <param name="key">The resource key.</param>
|
|||
/// <param name="value">
|
|||
/// When this method returns, contains the value associated with the specified key,
|
|||
/// if the key is found; otherwise, null.
|
|||
/// </param>
|
|||
/// <returns>
|
|||
/// True if the resource if found, otherwise false.
|
|||
/// </returns>
|
|||
bool TryGetResource(object key, out object? value); |
|||
} |
|||
} |
|||
|
|||
@ -1,33 +1,42 @@ |
|||
using System; |
|||
using Avalonia.Styling; |
|||
|
|||
#nullable enable |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Represents an object that can be queried for resources.
|
|||
/// Represents an object that can be queried for resources but does not appear in the logical tree.
|
|||
/// </summary>
|
|||
public interface IResourceProvider |
|||
/// <remarks>
|
|||
/// This interface is implemented by <see cref="ResourceDictionary"/>, <see cref="Style"/> and
|
|||
/// <see cref="Styles"/>
|
|||
/// </remarks>
|
|||
public interface IResourceProvider : IResourceNode |
|||
{ |
|||
/// <summary>
|
|||
/// Raised when resources in the provider are changed.
|
|||
/// Gets the owner of the resource provider.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// If multiple owners are added, returns the first.
|
|||
/// </remarks>
|
|||
IResourceHost? Owner { get; } |
|||
|
|||
/// <summary>
|
|||
/// Raised when the <see cref="Owner"/> of the resource provider changes.
|
|||
/// </summary>
|
|||
event EventHandler<ResourcesChangedEventArgs> ResourcesChanged; |
|||
event EventHandler OwnerChanged; |
|||
|
|||
/// <summary>
|
|||
/// Gets a value indicating whether the element has resources.
|
|||
/// Adds an owner to the resource provider.
|
|||
/// </summary>
|
|||
bool HasResources { get; } |
|||
/// <param name="owner">The owner.</param>
|
|||
void AddOwner(IResourceHost owner); |
|||
|
|||
/// <summary>
|
|||
/// Tries to find a resource within the provider.
|
|||
/// Removes a resource provider owner.
|
|||
/// </summary>
|
|||
/// <param name="key">The resource key.</param>
|
|||
/// <param name="value">
|
|||
/// When this method returns, contains the value associated with the specified key,
|
|||
/// if the key is found; otherwise, null.
|
|||
/// </param>
|
|||
/// <returns>
|
|||
/// True if the resource if found, otherwise false.
|
|||
/// </returns>
|
|||
bool TryGetResource(object key, out object value); |
|||
/// <param name="owner">The owner.</param>
|
|||
void RemoveOwner(IResourceHost owner); |
|||
} |
|||
} |
|||
|
|||
@ -1,27 +0,0 @@ |
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// Defines an interface through which an <see cref="IResourceNode"/>'s parent can be set.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// You should not usually need to use this interface - it is for internal use only.
|
|||
/// </remarks>
|
|||
public interface ISetResourceParent : IResourceNode |
|||
{ |
|||
/// <summary>
|
|||
/// Sets the resource parent.
|
|||
/// </summary>
|
|||
/// <param name="parent">The parent.</param>
|
|||
void SetParent(IResourceNode parent); |
|||
|
|||
/// <summary>
|
|||
/// Notifies the resource node that a change has been made to the resources in its parent.
|
|||
/// </summary>
|
|||
/// <param name="e">The event args.</param>
|
|||
/// <remarks>
|
|||
/// This method will be called automatically by the framework, you should not need to call
|
|||
/// this method yourself.
|
|||
/// </remarks>
|
|||
void ParentResourcesChanged(ResourcesChangedEventArgs e); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue