From b68c5618ae748c45d9245b4099b87318deddbf2a Mon Sep 17 00:00:00 2001 From: iambossTC Date: Mon, 14 Apr 2025 17:03:39 +0800 Subject: [PATCH] migrate --- Disp/RenderingCanvas.cs | 9 +++++++++ Disp/RenderingWindow.cs | 33 +++++++++++++-------------------- Hi.Wpf.csproj | 9 ++++++--- Program.cs | 21 +++++++++++++++++++-- 4 files changed, 47 insertions(+), 25 deletions(-) diff --git a/Disp/RenderingCanvas.cs b/Disp/RenderingCanvas.cs index 6045689..5ae8f8e 100644 --- a/Disp/RenderingCanvas.cs +++ b/Disp/RenderingCanvas.cs @@ -13,6 +13,15 @@ using Hi.Geom; namespace Hi.Wpf.Disp { #region WPF Rendering Canvas + /// + /// Provides a WPF rendering canvas for 3D visualization of HiAPI components. + /// Handles user interactions, rendering, and integration with the DispEngine system. + /// + /// + /// This canvas provides the core rendering capabilities for WPF applications using HiAPI. + /// It manages mouse, keyboard, and touch events, and transforms them into appropriate + /// actions in the 3D environment. + /// public class RenderingCanvas : UserControl, IDisposable { #region Core_Properties diff --git a/Disp/RenderingWindow.cs b/Disp/RenderingWindow.cs index 2af8d94..35dbd09 100644 --- a/Disp/RenderingWindow.cs +++ b/Disp/RenderingWindow.cs @@ -11,6 +11,9 @@ namespace Hi.Wpf.Disp /// public class RenderingWindow : Window, IGetDispEngine { + /// + /// Gets the rendering canvas control used for displaying 3D content. + /// public RenderingCanvas RenderingCanvas => Content as RenderingCanvas; /// @@ -35,29 +38,19 @@ namespace Hi.Wpf.Disp /// public DispEngine GetDispEngine() => RenderingCanvas.DispEngine; /// - /// Run a simple application with given . + /// Gets or sets the current displayable 3D object. + /// When setting a new displayee, the view will be reset to home position if no previous displayee was set. /// - /// Title - /// displayees - /// return value of . - public static int RunApplication(string title, params IDisplayee[] displayees) + public IDisplayee Displayee { - License.LogInAll(); - DispEngine.Init(); - - Application app = new Application + get => GetDispEngine().Displayee; + set { - ShutdownMode = ShutdownMode.OnMainWindowClose - }; - app.Exit += (o, e) => - { - DispEngine.FinishDisp(); - License.LogOutAll(); - }; - RenderingWindow window = new RenderingWindow() { Title = title }; - window.RenderingCanvas.DispEngine.Displayee = new DispList(displayees); - window.RenderingCanvas.DispEngine.SetViewToHomeView(); - return app.Run(window); + var preDisplayee = GetDispEngine().Displayee; + GetDispEngine().Displayee = value; + if (preDisplayee == null) + RenderingCanvas.DispEngine.SetViewToHomeView(); + } } } } diff --git a/Hi.Wpf.csproj b/Hi.Wpf.csproj index 531b216..3f19106 100644 --- a/Hi.Wpf.csproj +++ b/Hi.Wpf.csproj @@ -12,16 +12,18 @@ HiAPI samples for windows platform. Debug;Release - 3 + 15 1.4.$(VersionBuild) + HiAPI + win-x64 $(AssemblyName) techcoordinate.ico - Copyright 2022 Tech Coordinate Co., Ltd. + Copyright 2025 Tech Coordinate Co., Ltd. Tech Coordinate Co., Ltd. Tech Coordinate Co., Ltd. - bin\$(Platform).$(Configuration)\ Hi.Wpf.Program + @@ -37,4 +39,5 @@ DEBUG;TRACE + \ No newline at end of file diff --git a/Program.cs b/Program.cs index 1c7b276..0f079b7 100644 --- a/Program.cs +++ b/Program.cs @@ -1,19 +1,36 @@ using Hi.Disp; using Hi.Disp.Flag; using Hi.Geom; +using Hi.Licenses; using Hi.Wpf.Disp; using System; +using System.Windows; namespace Hi.Wpf { static class Program { [STAThread] - public static void Main(string[] args) + public static int Main(string[] args) { + License.LogInAll(); DispEngine.Init(); - RenderingWindow.RunApplication("test", + + Application app = new Application + { + ShutdownMode = ShutdownMode.OnMainWindowClose + }; + app.Exit += (o, e) => + { + DispEngine.FinishDisp(); + License.LogOutAll(); + Console.WriteLine($"App exit."); + }; + RenderingWindow window = new RenderingWindow() { Title = "Demo WPF RenderingCanvas" }; + window.RenderingCanvas.DispEngine.Displayee = new DispList( new CoordinateDrawing(), new Stl(Box3d.CenterUnitBox).ToFaceDrawing()); + window.RenderingCanvas.DispEngine.SetViewToHomeView(); + return app.Run(window); } } }