Browse Source

Removed ITreeDataTemplate.IsExpanded.

pull/396/head
Steven Kirk 11 years ago
parent
commit
bf30371721
  1. 5
      samples/TestApplicationShared/App.cs
  2. 63
      src/Perspex.Controls/Templates/FuncTreeDataTemplate.cs
  3. 55
      src/Perspex.Controls/Templates/FuncTreeDataTemplate`1.cs
  4. 7
      src/Perspex.Controls/Templates/ITreeDataTemplate.cs
  5. 3
      tests/Perspex.LeakTests/ControlTests.cs

5
samples/TestApplicationShared/App.cs

@ -21,11 +21,8 @@ namespace TestApplication
{ {
new FuncTreeDataTemplate<Node>( new FuncTreeDataTemplate<Node>(
x => new TextBlock {Text = x.Name}, x => new TextBlock {Text = x.Name},
x => x.Children, x => x.Children),
x => true),
}; };
} }
} }
} }

63
src/Perspex.Controls/Templates/FuncTreeDataTemplate.cs

@ -14,8 +14,6 @@ namespace Perspex.Controls.Templates
{ {
private readonly Func<object, IEnumerable> _itemsSelector; private readonly Func<object, IEnumerable> _itemsSelector;
private readonly Func<object, bool> _isExpanded;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class. /// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
/// </summary> /// </summary>
@ -35,30 +33,6 @@ namespace Perspex.Controls.Templates
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
/// </summary>
/// <param name="type">The type of data which the data template matches.</param>
/// <param name="build">
/// A function which when passed an object of <paramref name="type"/> returns a control.
/// </param>
/// <param name="itemsSelector">
/// A function which when passed an object of <paramref name="type"/> returns the child
/// items.
/// </param>
/// <param name="isExpanded">
/// A function which when passed an object of <paramref name="type"/> returns the the
/// initial expanded state of the node.
/// </param>
public FuncTreeDataTemplate(
Type type,
Func<object, IControl> build,
Func<object, IEnumerable> itemsSelector,
Func<object, bool> isExpanded)
: this(o => IsInstance(o, type), build, itemsSelector, isExpanded)
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class. /// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
/// </summary> /// </summary>
@ -75,46 +49,9 @@ namespace Perspex.Controls.Templates
Func<object, bool> match, Func<object, bool> match,
Func<object, IControl> build, Func<object, IControl> build,
Func<object, IEnumerable> itemsSelector) Func<object, IEnumerable> itemsSelector)
: this(match, build, itemsSelector, _ => false)
{
_itemsSelector = itemsSelector;
}
/// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate"/> class.
/// </summary>
/// <param name="match">
/// A function which determines whether the data template matches the specified data.
/// </param>
/// <param name="build">
/// A function which when passed a matching object returns a control.
/// </param>
/// <param name="itemsSelector">
/// A function which when passed a matching object returns the child items.
/// </param>
/// <param name="isExpanded">
/// A function which when passed a matching object returns the the initial expanded state
/// of the node.
/// </param>
public FuncTreeDataTemplate(
Func<object, bool> match,
Func<object, IControl> build,
Func<object, IEnumerable> itemsSelector,
Func<object, bool> isExpanded)
: base(match, build) : base(match, build)
{ {
_itemsSelector = itemsSelector; _itemsSelector = itemsSelector;
_isExpanded = isExpanded;
}
/// <summary>
/// Checks to see if the item should be initially expanded.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>True if the item should be initially expanded, otherwise false.</returns>
public bool IsExpanded(object item)
{
return this?._isExpanded(item) ?? false;
} }
/// <summary> /// <summary>

55
src/Perspex.Controls/Templates/FuncTreeDataTemplate`1.cs

@ -32,32 +32,6 @@ namespace Perspex.Controls.Templates
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate{T}"/> class.
/// </summary>
/// <param name="build">
/// A function which when passed an object of <typeparamref name="T"/> returns a control.
/// </param>
/// <param name="itemsSelector">
/// A function which when passed an object of <typeparamref name="T"/> returns the child
/// items.
/// </param>
/// <param name="isExpanded">
/// A function which when passed an object of <typeparamref name="T"/> returns the the
/// initial expanded state of the node.
/// </param>
public FuncTreeDataTemplate(
Func<T, Control> build,
Func<T, IEnumerable> itemsSelector,
Func<T, bool> isExpanded)
: base(
typeof(T),
Cast(build),
Cast(itemsSelector),
Cast(isExpanded))
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate{T}"/> class. /// Initializes a new instance of the <see cref="FuncTreeDataTemplate{T}"/> class.
/// </summary> /// </summary>
@ -81,35 +55,6 @@ namespace Perspex.Controls.Templates
{ {
} }
/// <summary>
/// Initializes a new instance of the <see cref="FuncTreeDataTemplate{T}"/> class.
/// </summary>
/// <param name="match">
/// A function which determines whether the data template matches the specified data.
/// </param>
/// <param name="build">
/// A function which when passed a matching object returns a control.
/// </param>
/// <param name="itemsSelector">
/// A function which when passed a matching object returns the child items.
/// </param>
/// <param name="isExpanded">
/// A function which when passed a matching object returns the the initial expanded state
/// of the node.
/// </param>
public FuncTreeDataTemplate(
Func<T, bool> match,
Func<T, Control> build,
Func<T, IEnumerable> itemsSelector,
Func<T, bool> isExpanded)
: base(
CastMatch(match),
Cast(build),
Cast(itemsSelector),
Cast(isExpanded))
{
}
/// <summary> /// <summary>
/// Casts a typed match function to an untyped match function. /// Casts a typed match function to an untyped match function.
/// </summary> /// </summary>

7
src/Perspex.Controls/Templates/ITreeDataTemplate.cs

@ -10,13 +10,6 @@ namespace Perspex.Controls.Templates
/// </summary> /// </summary>
public interface ITreeDataTemplate : IDataTemplate public interface ITreeDataTemplate : IDataTemplate
{ {
/// <summary>
/// Checks to see if the item should be initially expanded.
/// </summary>
/// <param name="item">The item.</param>
/// <returns>True if the item should be initially expanded, otherwise false.</returns>
bool IsExpanded(object item);
/// <summary> /// <summary>
/// Selects the child items of an item. /// Selects the child items of an item.
/// </summary> /// </summary>

3
tests/Perspex.LeakTests/ControlTests.cs

@ -273,8 +273,7 @@ namespace Perspex.LeakTests
{ {
new FuncTreeDataTemplate<Node>( new FuncTreeDataTemplate<Node>(
x => new TextBlock { Text = x.Name }, x => new TextBlock { Text = x.Name },
x => x.Children, x => x.Children)
x => true)
}, },
Items = nodes Items = nodes
} }

Loading…
Cancel
Save