Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions NativeWpf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Native WPF implementation

This directory is self-contained. It adds a native WPF implementation without changing the repository's existing WinForms library, WinForms demo, legacy WPF host demo, or original solution.

## Projects

- `ST.Library.UI.WPF`: dependency-free native WPF controls rendered through the original `System.Drawing.Graphics` contract and presented by a DPI-aware WPF `WriteableBitmap`.
- `WpfNodeEditorDemo`: full-window node canvas with context menus, automatic layout, save/open actions, an execution command, and a node-anchored reflection property panel provided by the `ColorVision.UI` 1.5.7 NuGet package.
- `STNodeEditor.Wpf.sln`: standalone solution for the two projects above.

The control library has no NuGet dependency and does not reference `System.Windows.Forms`, `WindowsFormsIntegration`, or a third-party rendering package. The demo uses a native WPF visual tree with no `WindowsFormsHost`; only the demo references `ColorVision.UI` for its reflection-based property editors and theme resources.

Node creation is available from the integrated `+` button and the canvas context menu, so the demo does not reserve space for a node tree. Selecting one node opens its reflected `STNodePropertyAttribute` properties beside the node while leaving the rest of the window available to the canvas.

The demo uses direct cursor-centered wheel zoom in `0.05` steps across the editor's full `0.2` to `5.0` scale range. The canvas lock button controls blank-area left-drag explicitly: unlocked pans the canvas, locked draws a selection rectangle, and middle-button drag always pans. Manual lock state is not changed by clicking a node.

The demo keeps the historical `WpfNodeEdittorDemo` assembly name so existing STND files retain the same node module identity; only the project folder and UI namespace use the corrected spelling.

## Run

Open `STNodeEditor.Wpf.sln`, select `WpfNodeEditorDemo`, and press F5. From PowerShell, the equivalent commands are:

```powershell
dotnet build .\STNodeEditor.Wpf.sln
dotnet run --project .\WpfNodeEditorDemo\WpfNodeEditorDemo.csproj
```

The WPF library targets both `net8.0-windows` and `net10.0-windows`; the demo targets `net8.0-windows` and runs as x64 because the published `ColorVision.UI` assemblies are AMD64. This does not alter the target framework or source of any existing project.
39 changes: 39 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/Lang.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Resources;

namespace ST.Library.UI;

public static class Lang
{
private static readonly List<ResourceManager> _externalManagers = new();

public static void RegisterResourceManager(ResourceManager manager)
{
if (manager != null && !_externalManagers.Contains(manager))
{
_externalManagers.Add(manager);
}
}

public static string Get(string key)
{
return GetOrDefault(key);
}

public static string GetOrDefault(string key)
{
for (int i = _externalManagers.Count - 1; i >= 0; i--)
{
try
{
string value = _externalManagers[i].GetString(key);
if (value != null) return value;
}
catch { }
}

return key;
}

}
14 changes: 14 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/AlertLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace ST.Library.UI.NodeEditor;

public enum AlertLocation
{
Left,
Top,
Right,
Bottom,
Center,
LeftTop,
RightTop,
RightBottom,
LeftBottom
}
8 changes: 8 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/CanvasMoveArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace ST.Library.UI.NodeEditor;

public enum CanvasMoveArgs
{
Left = 1,
Top = 2,
All = 4
}
8 changes: 8 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/ConnectionInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace ST.Library.UI.NodeEditor;

public struct ConnectionInfo
{
public STNodeOption Input;

public STNodeOption Output;
}
35 changes: 35 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/ConnectionStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.ComponentModel;

namespace ST.Library.UI.NodeEditor;

public enum ConnectionStatus
{
[Description("不存在所有者")]
NoOwner,
[Description("相同的所有者")]
SameOwner,
[Description("均为输入或者输出选项")]
SameInputOrOutput,
[Description("不同的数据类型")]
ErrorType,
[Description("单连接节点")]
SingleOption,
[Description("出现环形路径")]
Loop,
[Description("已存在的连接")]
Exists,
[Description("空白选项")]
EmptyOption,
[Description("已经连接")]
Connected,
[Description("连接被断开")]
DisConnected,
[Description("节点被锁定")]
Locked,
[Description("操作被拒绝")]
Reject,
[Description("正在被连接")]
Connecting,
[Description("正在断开连接")]
DisConnecting
}
12 changes: 12 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/DrawingTools.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System.Drawing;

namespace ST.Library.UI.NodeEditor;

public struct DrawingTools
{
public Graphics Graphics;

public Pen Pen;

public SolidBrush SolidBrush;
}
12 changes: 12 additions & 0 deletions NativeWpf/ST.Library.UI.WPF/NodeEditor/NodeFindInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace ST.Library.UI.NodeEditor;

public struct NodeFindInfo
{
public STNode Node;

public STNodeOption NodeOption;

public string Mark;

public string[] MarkLines;
}
Loading