SuncodeSoftware.SuperSDK.UI 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SuncodeSoftware.SuperSDK.UI --version 2.2.0
                    
NuGet\Install-Package SuncodeSoftware.SuperSDK.UI -Version 2.2.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SuncodeSoftware.SuperSDK.UI" Version="2.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuncodeSoftware.SuperSDK.UI" Version="2.2.0" />
                    
Directory.Packages.props
<PackageReference Include="SuncodeSoftware.SuperSDK.UI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SuncodeSoftware.SuperSDK.UI --version 2.2.0
                    
#r "nuget: SuncodeSoftware.SuperSDK.UI, 2.2.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SuncodeSoftware.SuperSDK.UI@2.2.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SuncodeSoftware.SuperSDK.UI&version=2.2.0
                    
Install as a Cake Addin
#tool nuget:?package=SuncodeSoftware.SuperSDK.UI&version=2.2.0
                    
Install as a Cake Tool

SuperSDK.UI

Avalonia UI 通用组件库,提供常用的 UI 组件和工具。

🎯 核心功能

  • ViewModelBase - ReactiveUI 基类,自动集成 MessageBus 清理
  • GzNotification - 通知管理器(单例模式,支持多窗口)
  • UIHelper - 统一风格的对话框工具
  • UIThreadHelper - UI 线程调度工具

📦 依赖

  • SuperSDK.Core (MessageBus 集成)
  • Avalonia 11.2.2
  • Avalonia.ReactiveUI 11.2.2

🚀 快速开始

1. ViewModelBase 使用

using SuperSDK.UI;
using ReactiveUI;

public class MyViewModel : ViewModelBase
{
    private string _name = "";
    
    public string Name
    {
        get => _name;
        set => this.RaiseAndSetIfChanged(ref _name, value);
    }
    
    public override void RegisterMsg()
    {
        // 注册消息订阅(析构时自动取消订阅)
        MessageBus.Subscribe<MyMessage>(this, OnMyMessage);
    }
    
    private void OnMyMessage(MyMessage msg)
    {
        Name = msg.Value;
    }
}

2. GzNotification 通知系统

初始化(在主窗口):

using SuperSDK.UI;

public class MainWindow : Window
{
    public MainWindow()
    {
        InitializeComponent();
        
        // ⚠️ 重要:设置通知的TopLevel
        GzNotification.Instance.SetTopLevel(this);
    }
}

显示通知:

using Avalonia.Controls.Notifications;
using SuperSDK.UI;

// 成功通知
GzNotification.Instance.Show(
    "操作成功", 
    "数据已成功保存", 
    NotificationType.Success
);

// 错误通知
GzNotification.Instance.Show(
    "操作失败", 
    "无法连接到数据库", 
    NotificationType.Error
);

// 警告通知
GzNotification.Instance.Show(
    "警告", 
    "配置文件缺失,使用默认配置", 
    NotificationType.Warning
);

// 信息通知
GzNotification.Instance.Show(
    "提示", 
    "系统正在更新...", 
    NotificationType.Information
);

3. UIHelper 对话框

using SuperSDK.UI;

// 错误对话框(红色风格)
await UIHelper.GzShowErrorMsg(
    "加载错误", 
    "文件不存在或已损坏",
    parentWindow: this,
    logSource: "MyApp"
);

// 警告对话框(黄色风格)
await UIHelper.GzShowWarningMsg(
    "警告", 
    "此操作无法撤销,是否继续?"
);

// 信息对话框(蓝色风格)
await UIHelper.GzShowInfoMsg(
    "提示", 
    "文件已成功保存"
);

自动功能:

  • ✅ 自动记录日志到 MessageBus
  • ✅ 统一的 Material Design 风格
  • ✅ 圆角、阴影、动画效果
  • ✅ 自动居中显示
  • ✅ 阻塞式等待用户确认

4. UIThreadHelper 线程调度

using SuperSDK.UI;

// 在 UI 线程上执行操作
await UIThreadHelper.RunOnUIThread(() =>
{
    StatusText = "更新完成";
    ProgressValue = 100;
});

// 从后台线程更新 UI
Task.Run(async () =>
{
    var result = await DoHeavyWork();
    
    await UIThreadHelper.RunOnUIThread(() =>
    {
        ResultText = result;
    });
});

🔧 高级功能

多窗口通知支持

// 为每个窗口设置通知管理器
public class SettingsWindow : Window
{
    public SettingsWindow()
    {
        InitializeComponent();
        GzNotification.Instance.SetTopLevel(this);
    }
}

// 指定目标窗口显示通知
GzNotification.Instance.Show(
    "设置已保存", 
    "配置将在下次启动时生效",
    NotificationType.Success,
    targetTopLevel: settingsWindow
);

自定义通知位置

using Avalonia.Controls.Notifications;

GzNotification.Instance.Show(
    "新消息", 
    "您有一条新的系统消息",
    NotificationType.Information,
    position: NotificationPosition.BottomRight
);

📝 架构说明

MessageBus 集成:

  • ViewModelBase 析构时自动调用 MessageBus.UnsubscribeAll(this)
  • UIHelper 对话框自动通过 MessageBus.Pub() 发送日志
  • 所有 UI 组件无缝集成消息总线

线程安全:

  • GzNotification 采用单例模式(线程安全)
  • UIThreadHelper 确保 UI 操作在主线程执行
  • 支持多窗口场景的通知管理

📝 License

MIT License - See LICENSE file for details

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on SuncodeSoftware.SuperSDK.UI:

Package Downloads
SuncodeSoftware.SuperSDK.App

Application foundation framework for Avalonia-based Goes applications

SuncodeSoftware.SuperSDK.Canvas

SuperSDK Canvas - 开箱即用的 Avalonia 画布组件,支持设备绘制、连线管理、缩放平移等功能

GoesSoftware.SuperSDK.Canvas

SuperSDK Canvas - 开箱即用的 Avalonia 画布组件,支持设备绘制、连线管理、缩放平移等功能

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.3.0 33 1/16/2026
2.2.0 30 1/16/2026
2.1.0 36 1/16/2026
2.0.8 41 1/15/2026
2.0.7 37 1/15/2026
2.0.6 46 1/15/2026
2.0.5 41 1/15/2026
2.0.4 43 1/15/2026
2.0.3 47 1/15/2026
2.0.2 42 1/15/2026
2.0.1 45 1/15/2026
2.0.0 47 1/15/2026
1.2.6 199 12/23/2025
1.2.5 195 12/23/2025
1.2.4 193 12/23/2025
1.2.2 193 12/23/2025
1.2.1 199 12/22/2025
1.2.0 193 12/22/2025
1.1.8 185 12/22/2025
1.1.7 192 12/22/2025
1.1.6 187 12/22/2025
1.1.5 188 12/22/2025
1.1.4 198 12/22/2025
1.1.3 198 12/22/2025
1.1.2 195 12/22/2025
1.1.1 194 12/22/2025
1.0.7 277 12/16/2025
1.0.6 278 12/16/2025
1.0.5 278 12/16/2025
1.0.4 282 12/16/2025
1.0.3 278 12/16/2025
1.0.2 279 12/16/2025
1.0.1 241 12/15/2025
1.0.0 220 12/15/2025

all bring readme