feat(demos): take over the ten framework-independent samples from Hi.Sample.Wpf

Hi.WinForm and Hi.WpfPlus are being retired, and Hi.Sample.Wpf existed only to
demonstrate Hi.WpfPlus -- but ten of its fourteen files never touched WPF at all. Those
move here rather than leaving with it:

- The three displayees upgrading-to-3.2/breaking-changes.md tells callers to copy --
  MachiningProjectDisplayee, IsoCoordinateEntryDisplayee,
  HeidenhainCoordinateEntryDisplayee. They compose only public API over
  LocalProjectService, which is the point of shipping them as a starting sample; that doc
  now points at Hi.Sample/Disp/.
- Seven display demos -- Cylindroid, DiscreteRgb, Drawing, Pick1, Pick2, Pickable,
  Satellite. Their only WPF coupling was the closing DemoUtil.RunApplication call.

DemoUtil is rewritten for a project with no canvas. HiAPI ships none any more, so a
sample cannot end by opening a window; Present() initializes the app, reports the
displayee's type and bounding box, and shuts down, which makes the samples runnable and
checkable headlessly and puts the handover where it actually is -- the application
assigns the composed IDisplayee to its own canvas' DispEngine.

The four files that genuinely need WPF (DemoStl, the old DemoUtil, and the two Machining
demos) stay behind and retire with Hi.Sample.Wpf. Each moved file's own
[!code-csharp] doc-comment path was repointed from ~/../Hi.Sample.Wpf/Disp/ to
~/../Hi.Sample/Disp/. Builds clean at x64: 0 warnings, 0 errors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-21 11:48:33 +08:00
co-authored by Claude Opus 5
parent b27c36acb8
commit 40214ca6f4
11 changed files with 1046 additions and 0 deletions
+78
View File
@@ -0,0 +1,78 @@
using Hi.Geom;
using Hi.Disp;
using System;
using Hi.Coloring;
namespace Sample.Disp
{
/// <summary>
/// Demonstrates advanced object picking with multiple pickable objects.
/// Shows how to create and manage multiple pickable objects with different visual appearances.
/// Implements proper resource cleanup through the IDisposable interface.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Disp/DemoPick2.cs)]
/// </remarks>
public class DemoPick2 : IDisplayee, IDisposable
{
readonly Pickable pickableA = new ShowEventPickable { Tag = "A" };
readonly Pickable pickableB = new ShowEventPickable { Tag = "B" };
readonly Pickable pickableC = new ShowEventPickable { Tag = "C" };
/// <inheritdoc/>
public void Display(Bind bind)
{
bind.PickID = pickableA.PickingID;
bind.Rgb = ColorUtil.GetDiscreteRgb(1);
new Box3d(0, 0, 0, 1, 1, 1).DisplayFace(bind);
bind.PickID = pickableB.PickingID;
bind.Rgb = ColorUtil.GetDiscreteRgb(2);
new Box3d(0, 0, 1, 1, 1, 2).DisplayFace(bind);
bind.PickID = pickableC.PickingID;
bind.Rgb = ColorUtil.GetDiscreteRgb(3);
new Box3d(0, 0, 2, 1, 1, 3).DisplayFace(bind);
bind.PickID = 0;
}
/// <inheritdoc/>
public void ExpandToBox3d(Box3d dst)
{
dst.Expand(new Vec3d(0, 0, 0));
dst.Expand(new Vec3d(1, 1, 3));
}
#region IDisposable Support
private bool disposedValue = false; // To detect redundant calls
/// <inheritdoc/>
protected virtual void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
pickableA.Dispose();
pickableB.Dispose();
pickableC.Dispose();
}
disposedValue = true;
}
}
/// <inheritdoc/>
public void Dispose()
{
Dispose(true);
}
#endregion
/// <summary>
/// Entry point for the DemoPick2 example.
/// Creates and displays multiple pickable objects with distinct colors and positions.
/// Demonstrates separation of picking behavior from visual representation.
/// </summary>
static void Main()
{
DemoUtil.Present("DemoPick2", new DemoPick2());
}
}
}