浏览代码

Implement steps 4-6: Update Wizard and enable FluentExample POST_4148

- Added WasFinished convenience property to Wizard to check completion status
- Updated Wizard documentation to explain IRunnable integration
- Enabled POST_4148 in FluentExample to demonstrate fluent API with automatic disposal
- Wizard inherits from Dialog so it automatically has IRunnable<int?> support

Co-authored-by: tig <[email protected]>
copilot-swe-agent[bot] 3 周之前
父节点
当前提交
e43409f45e
共有 2 个文件被更改,包括 29 次插入3 次删除
  1. 1 0
      Examples/FluentExample/FluentExample.csproj
  2. 28 3
      Terminal.Gui/Views/Wizard/Wizard.cs

+ 1 - 0
Examples/FluentExample/FluentExample.csproj

@@ -4,6 +4,7 @@
     <TargetFramework>net8.0</TargetFramework>
     <LangVersion>preview</LangVersion>
     <Nullable>enable</Nullable>
+    <DefineConstants>$(DefineConstants);POST_4148</DefineConstants>
   </PropertyGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\Terminal.Gui\Terminal.Gui.csproj" />

+ 28 - 3
Terminal.Gui/Views/Wizard/Wizard.cs

@@ -7,9 +7,17 @@ namespace Terminal.Gui.Views;
 ///     navigate forward and backward through the Wizard.
 /// </summary>
 /// <remarks>
-///     The Wizard can be displayed either as a modal (pop-up) <see cref="Window"/> (like <see cref="Dialog"/>) or as
-///     an embedded <see cref="View"/>. By default, <see cref="Wizard.Modal"/> is <c>true</c>. In this case launch the
-///     Wizard with <c>Application.Run(wizard)</c>. See <see cref="Wizard.Modal"/> for more details.
+///     <para>
+///         The Wizard can be displayed either as a modal (pop-up) <see cref="Window"/> (like <see cref="Dialog"/>) or as
+///         an embedded <see cref="View"/>. By default, <see cref="Wizard.Modal"/> is <c>true</c>. In this case launch the
+///         Wizard with <c>Application.Run(wizard)</c>. See <see cref="Wizard.Modal"/> for more details.
+///     </para>
+///     <para>
+///         <b>Phase 2:</b> Since <see cref="Wizard"/> inherits from <see cref="Dialog"/>, which implements
+///         <see cref="IRunnable{TResult}"/> with <c>int?</c> result type, the wizard automatically provides result
+///         tracking through <see cref="Dialog.Result"/>. Use the <see cref="WasFinished"/> property to check if the
+///         wizard was completed or canceled.
+///     </para>
 /// </remarks>
 /// <example>
 ///     <code>
@@ -100,6 +108,23 @@ public class Wizard : Dialog
     /// <remarks>Use the <see cref="MovingBack"></see> event to be notified when the user attempts to go back.</remarks>
     public Button BackButton { get; }
 
+    /// <summary>
+    ///     Gets whether the wizard was completed (the Finish button was pressed and <see cref="Finished"/> event fired).
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         This is a convenience property that checks if <see cref="Dialog.Result"/> indicates the wizard was
+    ///         finished rather than canceled. Since <see cref="Wizard"/> inherits from <see cref="Dialog"/> which
+    ///         implements <see cref="IRunnable{TResult}"/> with <c>int?</c> result type, the <see cref="Dialog.Result"/>
+    ///         property contains the button index. The Finish button is added as the last button.
+    ///     </para>
+    ///     <para>
+    ///         Returns <see langword="true"/> if <see cref="Dialog.Result"/> is not <see langword="null"/> and equals
+    ///         the index of the Next/Finish button, <see langword="false"/> otherwise (canceled or Back button pressed).
+    ///     </para>
+    /// </remarks>
+    public bool WasFinished => Result is { } && _finishedPressed;
+
     /// <summary>Gets or sets the currently active <see cref="WizardStep"/>.</summary>
     public WizardStep? CurrentStep
     {