using Hi.Geom; using Hi.Disp; using System; using Hi.Coloring; namespace Sample.Disp { /// /// 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. /// /// /// ### Source Code /// [!code-csharp[SampleCode](~/../Hi.Sample.Wpf/Disp/DemoPick2.cs)] /// 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" }; /// 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; } /// 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 /// protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { pickableA.Dispose(); pickableB.Dispose(); pickableC.Dispose(); } disposedValue = true; } } /// public void Dispose() { Dispose(true); } #endregion /// /// 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. /// static void Main() { DemoUtil.RunApplication("DemoPick2", new DemoPick2()); } } }