English | 简体中文
This guide explains the project boundaries, module onboarding flow, localization resources, and release checks for developers learning Avalonia + Prism modular application design.
The solution is organized into four areas:
CodeWF.Toolbox: desktop entry point, AppBuilder setup, application shell, main window, menu, settings, themes, login window, icon, manifest, publish profiles, and Prism module catalog.CodeWF.Core: shared abstractions, file chooser, notifications, tool menu service, region names, and TabControl region adapter.CodeWF.Modules.*: feature modules. Each module owns its menu entries, views, view models, and resources. Current modules include converters, log viewing, development tools, web helpers, security tools, and XML localization management.docs/tests/publish: documentation, unit tests, and publishing scripts.
At startup, App.ConfigureModuleCatalog adds modules to the Prism catalog. A module constructor registers tool entries through IToolMenuService; OnInitialized registers views with RegionNames.ContentRegion. When the user chooses a menu item, the shell asks Prism Region navigation to display the target view.
- Menu names and descriptions should use generated
Localization.*resource keys. - View names should use
nameof(MyToolView)to avoid string drift. - Modules should depend on
CodeWF.Coreabstractions, not on shell internals. - Tool status should be expressed with
ToolStatus:Planned,Developing, orComplete. - Complex control initialization may live in the View code-behind, while business behavior should stay in the ViewModel.
- Shared capabilities should be introduced through
CodeWF.Coreinterfaces and service implementations.
- Create
src/CodeWF.Modules.YourModule. - Reference
CodeWF.Coreand the Prism/Avalonia packages used by the solution. - Create
YourModule : IModule. - Register groups and tool items through
IToolMenuService. - Register views with
RegisterViewWithRegion<TView>(RegionNames.ContentRegion). - Register special view models, dialogs, or services in
RegisterTypes. - Add
I18n/*.xmland generate or updateI18n/Language.cs. - Add the module to
CodeWF.Toolbox/App.axaml.cs.
Example:
public class SampleModule : IModule
{
public SampleModule(IToolMenuService toolMenuService)
{
var groupName = Localization.SampleModule.Title;
toolMenuService.AddSeparator();
toolMenuService.AddGroup(groupName, Icons.Sample);
toolMenuService.AddItem(
Localization.SampleView.Title,
groupName,
Localization.SampleView.Description,
nameof(SampleView),
Icons.Sample,
ToolStatus.Developing);
}
public void OnInitialized(IContainerProvider containerProvider)
{
var regionManager = containerProvider.Resolve<IRegionManager>();
regionManager.RegisterViewWithRegion<SampleView>(RegionNames.ContentRegion);
}
public void RegisterTypes(IContainerRegistry containerRegistry)
{
}
}Each module owns its resource files, for example:
I18n/YourModule.zh-CN.xmlI18n/YourModule.en-US.xmlI18n/YourModule.ja-JP.xmlI18n/YourModule.zh-Hant.xml
Keep all language files structurally aligned. Menus, buttons, prompts, and error messages should use resource keys instead of fixed text in XAML or ViewModels. Short fallback text is acceptable for development diagnostics.
Before submitting changes, run:
dotnet restore CodeWF.Toolbox.slnx
dotnet build CodeWF.Toolbox.slnx
dotnet test src/CodeWF.Toolbox.Tests/CodeWF.Toolbox.Tests.csprojCheck that:
- New tools can be found through menu search and navigate correctly.
- Groups and separators never trigger empty navigation.
- File chooser, clipboard, and drag/drop flows handle cancellation and null values.
- ViewModel async methods either await work or explicitly return
Task.CompletedTask. - Localization displays correctly in at least Chinese and English.
- Large text viewers should keep business logic in ViewModels and use shared editor helpers for selection, font, and scroll behavior.
The repository keeps publish.bat, publish_win-x64.bat, publish_all.bat, and several publish profiles. Before publishing, verify:
Directory.Build.propscontains the intended Avalonia/DataGrid versions and platform constant.GlobalAssemblies/GlobalAssembly.cshas the expected version and product description.- The output directory will not overwrite a release that should be preserved.
- Reduce the remaining nullable warnings, especially in the XML translation manager module.
- Add stricter input validation and failure messages for each tool.
- Expand unit tests for core services and conversion logic.
- Consolidate publishing scripts into cross-platform PowerShell or CI workflows.