Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the Expander control #2578

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 33 additions & 30 deletions src/Eto/Forms/Controls/Expander.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
namespace Eto.Forms;

/// <summary>
/// A control with a panel that can be expanded or collapsed with a header and button.
/// A control that provides a way to expand or collapse a panel. It includes a header and button.
/// </summary>
/// <example>
/// <code>
/// var myClosedExpander = new Expander
/// {
/// Header = "This is closed by default",
/// Content = "Content 1"
/// }
/// var myOpenExpander = new Expander
/// {
/// Header = "This is opened by default",
/// Expanded = true,
/// Content = "Content 2"
/// }
/// </code>
/// </example>
[Handler(typeof(IHandler))]
public class Expander : Panel
{
Expand All @@ -14,7 +29,7 @@ public class Expander : Panel
public const string ExpandedChangedEvent = "Expander.ExpandedChanged";

/// <summary>
/// Occurs when the <see cref="Expanded"/> property changes.
/// Event that occurs when the <see cref="Expanded"/> property changes.
/// </summary>
public event EventHandler<EventArgs> ExpandedChanged
{
Expand All @@ -25,21 +40,21 @@ public event EventHandler<EventArgs> ExpandedChanged
/// <summary>
/// Raises the <see cref="ExpandedChanged"/> event.
/// </summary>
/// <param name="e">Event arguments</param>
/// <param name="e">Event arguments.</param>
protected virtual void OnExpandedChanged(EventArgs e)
{
Properties.TriggerEvent(ExpandedChangedEvent, this, e);
}

/// <summary>
/// Initializes a new instance of the <see cref="Expander"/> class.
/// </summary>
static Expander()
{
EventLookup.Register<Expander>(c => c.OnExpandedChanged(null), Expander.ExpandedChangedEvent);
}

/// <summary>
/// Gets an enumeration of controls that are directly contained by this container
/// </summary>
/// <value>The contained controls.</value>
/// <inheritdoc/>
public override System.Collections.Generic.IEnumerable<Control> Controls
{
get
Expand All @@ -53,19 +68,16 @@ public override System.Collections.Generic.IEnumerable<Control> Controls

static Callback callback = new Callback();

/// <summary>
/// Gets an instance of an object used to perform callbacks to the widget from handler implementations
/// </summary>
/// <returns>The callback.</returns>
/// <inheritdoc/>
protected override object GetCallback()
{
return callback;
}

/// <summary>
/// Gets or sets a value indicating whether the <see cref="Panel.Content"/> is expanded/visible.
/// Gets or sets a value indicating whether <see cref="Panel.Content"/> is currently expanded/visible.
/// </summary>
/// <value><c>true</c> if expanded; otherwise, <c>false</c>.</value>
/// <value><see langword="true"/> if expanded; otherwise, <see langword="false"/>.</value>
public bool Expanded
{
get { return Handler.Expanded; }
Expand All @@ -76,6 +88,7 @@ public bool Expanded
/// Gets or sets the header control.
/// </summary>
/// <value>The header control.</value>
/// <remarks>Note, that there will always be a small button appearing in the header.</remarks>
public Control Header
{
get { return Handler.Header; }
Expand All @@ -86,28 +99,24 @@ public Control Header
}

/// <summary>
/// Callback interface for the <see cref="Expander"/>
/// Callback interface for <see cref="Expander"/>.
/// </summary>
public new interface ICallback : Panel.ICallback
{
/// <summary>
/// Raises the expanded changed event.
/// Raises the <see cref="Expander.ExpandedChanged"/> event.
/// </summary>
/// <param name="widget">Widget to raise the event.</param>
/// <param name="e">Event arguments.</param>
void OnExpandedChanged(Expander widget, EventArgs e);
}

/// <summary>
/// Callback implementation for the <see cref="Expander"/>
/// Callback implementation for handlers of <see cref="Expander"/>.
/// </summary>
protected new class Callback : Panel.Callback, ICallback
{
/// <summary>
/// Raises the expanded changed event.
/// </summary>
/// <param name="widget">Widget to raise the event.</param>
/// <param name="e">Event arguments.</param>
/// <inheritdoc cref="ICallback.OnExpandedChanged"/>
public void OnExpandedChanged(Expander widget, EventArgs e)
{
using (widget.Platform.Context)
Expand All @@ -116,20 +125,14 @@ public void OnExpandedChanged(Expander widget, EventArgs e)
}

/// <summary>
/// Handler interface for platform implementations of the <see cref="Expander"/>.
/// Handler interface for platform implementations of <see cref="Expander"/>.
/// </summary>
public new interface IHandler : Panel.IHandler
{
/// <summary>
/// Gets or sets a value indicating whether the <see cref="Panel.IHandler.Content"/> is expanded/visible.
/// </summary>
/// <value><c>true</c> if expanded; otherwise, <c>false</c>.</value>
/// <inheritdoc cref="Expander.Expanded"/>
bool Expanded { get; set; }

/// <summary>
/// Gets or sets the header control.
/// </summary>
/// <value>The header control.</value>
/// <inheritdoc cref="Expander.Header"/>
Control Header { get; set; }
}
}
Loading