Compare commits
69
Commits
c4961becfb
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60dea348d2 | ||
|
|
85d5515a97 | ||
|
|
c25bd820c3 | ||
|
|
a5a778fb1c | ||
|
|
f9a85f0e33 | ||
|
|
2097cc6bb3 | ||
|
|
277c87ad3d | ||
|
|
c1b86be4aa | ||
|
|
24c85e3cde | ||
|
|
c72b1f48c3 | ||
|
|
56bd2cd85f | ||
|
|
ee455c013c | ||
|
|
66c927e0b7 | ||
|
|
f688e555a8 | ||
|
|
0bc34dfdd5 | ||
|
|
84ee564a2e | ||
|
|
65ede317da | ||
|
|
0208886310 | ||
|
|
83f0d467d8 | ||
|
|
f974500f05 | ||
|
|
8dba25293b | ||
|
|
53f98aa71d | ||
|
|
95187d7c37 | ||
|
|
7dd5044f19 | ||
|
|
84cc69a34f | ||
|
|
198eb8c0dd | ||
|
|
140e446569 | ||
|
|
d014fb52f2 | ||
|
|
698583fa06 | ||
|
|
64272c0ada | ||
|
|
bb92237613 | ||
|
|
68736b79fb | ||
|
|
c1f3fefdc0 | ||
|
|
688762ab70 | ||
|
|
0e0adaa98f | ||
|
|
aa85e54a44 | ||
|
|
aad9fb1a8d | ||
|
|
65ae47b3a8 | ||
|
|
f577c37dd5 | ||
|
|
cd21f45b30 | ||
|
|
c586dbbd58 | ||
|
|
05b2ff6c59 | ||
|
|
dfc6ce0626 | ||
|
|
eadc38cfda | ||
|
|
a9ecd1a4b8 | ||
|
|
968c6fa1ac | ||
|
|
9ed8b5d60a | ||
|
|
5e22abcc22 | ||
|
|
c0f6dc90a1 | ||
|
|
b341f75af6 | ||
|
|
db847bd2d8 | ||
|
|
27511a1893 | ||
|
|
425fb4d4a9 | ||
|
|
8194797989 | ||
|
|
0086973818 | ||
|
|
f247ec037a | ||
|
|
76308d1ec6 | ||
|
|
32cc3ec75e | ||
|
|
382569196a | ||
|
|
3b54a03b13 | ||
|
|
55f61d0903 | ||
|
|
b9dc44f127 | ||
|
|
7101573e91 | ||
|
|
bac0d9fa00 | ||
|
|
fd93271f87 | ||
|
|
ca8236836c | ||
|
|
86f4a7ad56 | ||
|
|
83397d7095 | ||
|
|
6b8925de51 |
+70
-35
@@ -1,4 +1,4 @@
|
|||||||
using Hi.Disp;
|
using Hi.Disp;
|
||||||
using Hi.Native;
|
using Hi.Native;
|
||||||
using Hi.PanelModels;
|
using Hi.PanelModels;
|
||||||
using System;
|
using System;
|
||||||
@@ -11,20 +11,20 @@ using System.Collections.Generic;
|
|||||||
using Hi.Geom;
|
using Hi.Geom;
|
||||||
using Microsoft.Win32; // Add this for SystemEvents
|
using Microsoft.Win32; // Add this for SystemEvents
|
||||||
|
|
||||||
namespace Hi.Wpf.Disp
|
namespace Hi.WpfPlus.Disp;
|
||||||
|
|
||||||
|
#region WPF Rendering Canvas
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a WPF rendering canvas for 3D visualization of HiAPI components.
|
||||||
|
/// Handles user interactions, rendering, and integration with the DispEngine system.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// 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.
|
||||||
|
/// </remarks>
|
||||||
|
public class RenderingCanvas : UserControl, IDisposable
|
||||||
{
|
{
|
||||||
#region WPF Rendering Canvas
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a WPF rendering canvas for 3D visualization of HiAPI components.
|
|
||||||
/// Handles user interactions, rendering, and integration with the DispEngine system.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// 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.
|
|
||||||
/// </remarks>
|
|
||||||
public class RenderingCanvas : UserControl, IDisposable
|
|
||||||
{
|
|
||||||
#region Core_Properties
|
#region Core_Properties
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The DispEngine instance that handles rendering and user interactions
|
/// The DispEngine instance that handles rendering and user interactions
|
||||||
@@ -297,12 +297,52 @@ namespace Hi.Wpf.Disp
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Keyboard_Events
|
#region Keyboard_Events
|
||||||
|
/// <summary>
|
||||||
|
/// Convert WPF Key to W3C KeyboardEvent.key string.
|
||||||
|
/// </summary>
|
||||||
|
static string WpfKeyToW3C(Key key) => key switch
|
||||||
|
{
|
||||||
|
Key.Home => "Home",
|
||||||
|
Key.End => "End",
|
||||||
|
Key.PageUp => "PageUp",
|
||||||
|
Key.PageDown => "PageDown",
|
||||||
|
Key.Left => "ArrowLeft",
|
||||||
|
Key.Right => "ArrowRight",
|
||||||
|
Key.Up => "ArrowUp",
|
||||||
|
Key.Down => "ArrowDown",
|
||||||
|
Key.LeftShift or Key.RightShift => "Shift",
|
||||||
|
Key.LeftCtrl or Key.RightCtrl => "Control",
|
||||||
|
Key.LeftAlt or Key.RightAlt => "Alt",
|
||||||
|
Key.Return => "Enter",
|
||||||
|
Key.Escape => "Escape",
|
||||||
|
Key.Back => "Backspace",
|
||||||
|
Key.Tab => "Tab",
|
||||||
|
Key.Delete => "Delete",
|
||||||
|
Key.Insert => "Insert",
|
||||||
|
Key.Space => " ",
|
||||||
|
Key.F1 => "F1",
|
||||||
|
Key.F2 => "F2",
|
||||||
|
Key.F3 => "F3",
|
||||||
|
Key.F4 => "F4",
|
||||||
|
Key.F5 => "F5",
|
||||||
|
Key.F6 => "F6",
|
||||||
|
Key.F7 => "F7",
|
||||||
|
Key.F8 => "F8",
|
||||||
|
Key.F9 => "F9",
|
||||||
|
Key.F10 => "F10",
|
||||||
|
Key.F11 => "F11",
|
||||||
|
Key.F12 => "F12",
|
||||||
|
>= Key.A and <= Key.Z => ((char)('a' + (key - Key.A))).ToString(),
|
||||||
|
>= Key.D0 and <= Key.D9 => ((char)('0' + (key - Key.D0))).ToString(),
|
||||||
|
_ => "Unidentified"
|
||||||
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles the key up event
|
/// Handles the key up event
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void RenderingCanvas_KeyUp(object sender, KeyEventArgs e)
|
private void RenderingCanvas_KeyUp(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
DispEngine.KeyUp((long)e.Key);
|
DispEngine.KeyUp(WpfKeyToW3C(e.Key));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -310,27 +350,23 @@ namespace Hi.Wpf.Disp
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void RenderingCanvas_KeyDown(object sender, KeyEventArgs e)
|
private void RenderingCanvas_KeyDown(object sender, KeyEventArgs e)
|
||||||
{
|
{
|
||||||
DispEngine.KeyDown((long)e.Key);
|
string key = WpfKeyToW3C(e.Key);
|
||||||
|
DispEngine.KeyDown(key);
|
||||||
// Map specific keys for view transformation
|
|
||||||
long key = (long)e.Key;
|
|
||||||
if (key == (long)Key.RightShift)
|
|
||||||
key = (long)Key.LeftShift;
|
|
||||||
|
|
||||||
DispEngine.KeyDownTransform(key, new key_table__transform_view_by_key_pressing_t()
|
DispEngine.KeyDownTransform(key, new key_table__transform_view_by_key_pressing_t()
|
||||||
{
|
{
|
||||||
HOME = (long)Key.Home,
|
HOME = "Home",
|
||||||
PAGE_UP = (long)Key.PageUp,
|
PAGE_UP = "PageUp",
|
||||||
PAGE_DOWN = (long)Key.PageDown,
|
PAGE_DOWN = "PageDown",
|
||||||
F1 = (long)Key.F1,
|
F1 = "F1",
|
||||||
F2 = (long)Key.F2,
|
F2 = "F2",
|
||||||
F3 = (long)Key.F3,
|
F3 = "F3",
|
||||||
F4 = (long)Key.F4,
|
F4 = "F4",
|
||||||
SHIFT = (long)Key.LeftShift,
|
SHIFT = "Shift",
|
||||||
ARROW_LEFT = (long)Key.Left,
|
ARROW_LEFT = "ArrowLeft",
|
||||||
ARROW_RIGHT = (long)Key.Right,
|
ARROW_RIGHT = "ArrowRight",
|
||||||
ARROW_DOWN = (long)Key.Down,
|
ARROW_DOWN = "ArrowDown",
|
||||||
ARROW_UP = (long)Key.Up
|
ARROW_UP = "ArrowUp"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -433,6 +469,5 @@ namespace Hi.Wpf.Disp
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
using Hi.Disp;
|
using Hi.Disp;
|
||||||
using Hi.Licenses;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Hi.Wpf.Disp
|
namespace Hi.WpfPlus.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Window for 3D rendering.
|
||||||
|
/// </summary>
|
||||||
|
public class RenderingWindow : Window, IGetDispEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Window for 3D rendering.
|
|
||||||
/// </summary>
|
|
||||||
public class RenderingWindow : Window, IGetDispEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the rendering canvas control used for displaying 3D content.
|
/// Gets the rendering canvas control used for displaying 3D content.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -52,5 +51,4 @@ namespace Hi.Wpf.Disp
|
|||||||
RenderingCanvas.DispEngine.SetViewToHomeView();
|
RenderingCanvas.DispEngine.SetViewToHomeView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
using Hi.Disp;
|
||||||
|
using Hi.Geom;
|
||||||
|
using Hi.Licenses;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Windows;
|
||||||
|
|
||||||
|
namespace Hi.WpfPlus.Disp;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers WPF as the display framework for <see cref="DispFrameUtil"/>,
|
||||||
|
/// supporting multiple windows identified by key.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// <para>
|
||||||
|
/// Usage pattern: call <see cref="DispFrameUtil.Call"/> to queue display content,
|
||||||
|
/// then call <see cref="RunApplication()"/> to start the WPF application and show windows.
|
||||||
|
/// </para>
|
||||||
|
/// <para>
|
||||||
|
/// Each unique key creates a separate <see cref="RenderingWindow"/>.
|
||||||
|
/// Calling <see cref="DispFrameUtil.Call"/> with the same key updates the existing window.
|
||||||
|
/// </para>
|
||||||
|
/// <example>
|
||||||
|
/// <code>
|
||||||
|
/// // Queue display content (before or after Run)
|
||||||
|
/// DispFrameUtil.CallDispFrame("Window1", displayee1);
|
||||||
|
/// DispFrameUtil.CallDispFrame("Window2", displayee2);
|
||||||
|
/// // Start the WPF application (blocks until all windows are closed)
|
||||||
|
/// DispFrameWpf.Run();
|
||||||
|
/// </code>
|
||||||
|
/// </example>
|
||||||
|
/// </remarks>
|
||||||
|
public static class WpfDispUtil
|
||||||
|
{
|
||||||
|
static readonly ConcurrentDictionary<string, RenderingWindow> KeyToWindowDictionary = new();
|
||||||
|
|
||||||
|
static WpfDispUtil()
|
||||||
|
{
|
||||||
|
DispFrameUtil.UpdateByDispEngineConfigFunc = ApplyConfig;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the display engine.
|
||||||
|
/// </summary>
|
||||||
|
public static void Init() {
|
||||||
|
DispEngine.Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ApplyConfig(string key, DispEngineConfig config)
|
||||||
|
{
|
||||||
|
if (!KeyToWindowDictionary.TryGetValue(key, out var window))
|
||||||
|
{
|
||||||
|
window = new RenderingWindow() { Title = key };
|
||||||
|
window.Closed += (s, e) => KeyToWindowDictionary.TryRemove(key, out _);
|
||||||
|
KeyToWindowDictionary[key] = window;
|
||||||
|
window.Show();
|
||||||
|
}
|
||||||
|
|
||||||
|
var dispEngine = window.GetDispEngine();
|
||||||
|
if (config.Displayee != null)
|
||||||
|
dispEngine.Displayee = config.Displayee;
|
||||||
|
if (config.SketchView == null)
|
||||||
|
config.SketchView = config.Displayee?.GetBox3d()?.FrontView;
|
||||||
|
if (config.SketchView != null)
|
||||||
|
dispEngine.SketchView = config.SketchView;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the display engine with the specified displayees for the given title.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">The title/key to identify the display window.</param>
|
||||||
|
/// <param name="displayees">The displayees to be configured.</param>
|
||||||
|
/// <returns>The display engine configuration.</returns>
|
||||||
|
public static DispEngineConfig Call(
|
||||||
|
string title, params IDisplayee[] displayees)=>
|
||||||
|
DispFrameUtil.Call(title, displayees);
|
||||||
|
/// <summary>
|
||||||
|
/// Configures the display engine with the specified displayees and starts the WPF application.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="title">The title/key to identify the display window.</param>
|
||||||
|
/// <param name="displayees">The displayees to be configured.</param>
|
||||||
|
public static void RunApplication(string title, params IDisplayee[] displayees)
|
||||||
|
{
|
||||||
|
DispFrameUtil.Call(title, displayees);
|
||||||
|
RunApplication();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the WPF application and shows all configured windows.
|
||||||
|
/// Blocks until all windows are closed.
|
||||||
|
/// </summary>
|
||||||
|
public static void RunApplication()
|
||||||
|
{
|
||||||
|
Application app = new Application()
|
||||||
|
{
|
||||||
|
ShutdownMode = ShutdownMode.OnLastWindowClose
|
||||||
|
};
|
||||||
|
//app.Exit += (o, e) =>
|
||||||
|
//{
|
||||||
|
// License.LogOutAll();
|
||||||
|
//};
|
||||||
|
app.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,17 +3,18 @@
|
|||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net9.0-windows</TargetFramework>
|
<TargetFramework>net10.0-windows</TargetFramework>
|
||||||
<Platforms>x64</Platforms>
|
<Platforms>x64</Platforms>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AssemblyName>Hi.Wpf</AssemblyName>
|
<AssemblyName>Hi.WpfPlus</AssemblyName>
|
||||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||||
<Description>
|
<Description>
|
||||||
HiAPI wpf canvas.
|
HiAPI wpf canvas.
|
||||||
</Description>
|
</Description>
|
||||||
<Configurations>Debug;Release</Configurations>
|
<Configurations>Debug;Release</Configurations>
|
||||||
<VersionBuild>69</VersionBuild>
|
<VersionBuild>160</VersionBuild>
|
||||||
<VersionPrefix>3.1.$(VersionBuild)</VersionPrefix>
|
<VersionPrefix>3.1.$(VersionBuild)</VersionPrefix>
|
||||||
|
<PackageId>Hi.WpfPlus</PackageId>
|
||||||
<PackageTags>HiAPI</PackageTags>
|
<PackageTags>HiAPI</PackageTags>
|
||||||
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
|
||||||
<Product>$(AssemblyName)</Product>
|
<Product>$(AssemblyName)</Product>
|
||||||
@@ -21,7 +22,7 @@
|
|||||||
<Copyright>Copyright 2025 Tech Coordinate Co., Ltd.</Copyright>
|
<Copyright>Copyright 2025 Tech Coordinate Co., Ltd.</Copyright>
|
||||||
<Company>Tech Coordinate Co., Ltd.</Company>
|
<Company>Tech Coordinate Co., Ltd.</Company>
|
||||||
<Authors>Tech Coordinate Co., Ltd.</Authors>
|
<Authors>Tech Coordinate Co., Ltd.</Authors>
|
||||||
<StartupObject>Hi.Wpf.Program</StartupObject>
|
<StartupObject>Hi.WpfPlus.Program</StartupObject>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<Import Project="..\acc\common_info.props" />
|
<Import Project="..\acc\common_info.props" />
|
||||||
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
<ItemGroup Condition="'$(Configuration)'=='Debug'">
|
||||||
@@ -2,7 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.5.2.0
|
VisualStudioVersion = 17.5.2.0
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hi.Wpf", "Hi.Wpf.csproj", "{91AB5E3A-A30A-6142-C83E-5EE726B5FA0C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Hi.WpfPlus", "Hi.WpfPlus.csproj", "{91AB5E3A-A30A-6142-C83E-5EE726B5FA0C}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
+4
-2
@@ -2,17 +2,19 @@
|
|||||||
using Hi.Disp.Flag;
|
using Hi.Disp.Flag;
|
||||||
using Hi.Geom;
|
using Hi.Geom;
|
||||||
using Hi.Licenses;
|
using Hi.Licenses;
|
||||||
using Hi.Wpf.Disp;
|
using Hi.WpfPlus.Disp;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Hi.Wpf
|
namespace Hi.WpfPlus
|
||||||
{
|
{
|
||||||
static class Program
|
static class Program
|
||||||
{
|
{
|
||||||
[STAThread]
|
[STAThread]
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
|
License.AbortMessageAction += Console.WriteLine;
|
||||||
License.LogInAll();
|
License.LogInAll();
|
||||||
DispEngine.Init();
|
DispEngine.Init();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user