├── .editorconfig
├── .gitignore
├── CodeWF.Toolbox.sln
├── Directory.Build.props
├── LICENSE
├── README-zh_CN.md
├── README.md
├── UpdateLog.md
├── src
├── CodeWF.Controls
│ └── CodeWF.Controls.csproj
├── CodeWF.Core
│ ├── CodeWF.Core.csproj
│ ├── ConfigDB
│ │ └── DBConst.cs
│ ├── DialogNames.cs
│ ├── HostIds.cs
│ ├── IServices
│ │ ├── IApplicationService.cs
│ │ ├── IFileChooserService.cs
│ │ └── INotificationService.cs
│ ├── IToolMenuService.cs
│ ├── Models
│ │ ├── ToolMenuItem.cs
│ │ └── ToolStatus.cs
│ ├── RegionAdapters
│ │ └── TabControlRegionAdapter.cs
│ ├── RegionNames.cs
│ ├── Services
│ │ ├── FileChooserService.cs
│ │ └── NotificationService.cs
│ └── ToolMenuService.cs
├── CodeWF.Modules.AI
│ ├── AIModule.cs
│ ├── CodeWF - Backup.Modules.AI.csproj
│ ├── CodeWF.Modules.AI.csproj
│ ├── Entities
│ │ └── TranslateLanguageEntity.cs
│ ├── Helpers
│ │ ├── ApiClient.cs
│ │ └── ConfigHelper.cs
│ ├── I18n
│ │ ├── AIModule.en-US.xml
│ │ ├── AIModule.ja-JP.xml
│ │ ├── AIModule.zh-CN.xml
│ │ ├── AIModule.zh-Hant.xml
│ │ ├── Language.cs
│ │ └── Language.tt
│ ├── Icons.cs
│ ├── Imports.cs
│ ├── Models
│ │ ├── AskBotRequest.cs
│ │ ├── ChatGptOptions.cs
│ │ ├── PolyTranslateRequest.cs
│ │ └── Title2SlugRequest.cs
│ ├── ViewModels
│ │ ├── AskBotViewModel.cs
│ │ ├── ChoiceLanguagesViewModel.cs
│ │ ├── PolyTranslateViewModel.cs
│ │ └── Title2SlugViewModel.cs
│ └── Views
│ │ ├── AskBotView.axaml
│ │ ├── AskBotView.axaml.cs
│ │ ├── ChoiceLanguagesView.axaml
│ │ ├── ChoiceLanguagesView.axaml.cs
│ │ ├── PolyTranslateView.axaml
│ │ ├── PolyTranslateView.axaml.cs
│ │ ├── Title2SlugView.axaml
│ │ └── Title2SlugView.axaml.cs
├── CodeWF.Modules.Converter
│ ├── CodeWF.Modules.Converter.csproj
│ ├── ConverterModule.cs
│ ├── I18n
│ │ ├── ConverterModule.en-US.xml
│ │ ├── ConverterModule.ja-JP.xml
│ │ ├── ConverterModule.zh-CN.xml
│ │ ├── ConverterModule.zh-Hant.xml
│ │ ├── Language.cs
│ │ └── Language.tt
│ ├── Icons.cs
│ ├── Models
│ │ └── IconSize.cs
│ ├── ViewModels
│ │ ├── DateTimeConverterViewModel.cs
│ │ ├── ImageToIconViewModel.cs
│ │ ├── JsonToYamlViewModel.cs
│ │ └── YamlToJsonViewModel.cs
│ └── Views
│ │ ├── DateTimeConverterView.axaml
│ │ ├── DateTimeConverterView.axaml.cs
│ │ ├── ImageToIconView.axaml
│ │ ├── ImageToIconView.axaml.cs
│ │ ├── JsonToYamlView.axaml
│ │ ├── JsonToYamlView.axaml.cs
│ │ ├── YamlToJsonView.axaml
│ │ └── YamlToJsonView.axaml.cs
├── CodeWF.Modules.Development
│ ├── Assets
│ │ ├── OvertimeAlarm.png
│ │ ├── OvertimeAll.png
│ │ └── OvertimeNormal.png
│ ├── CodeWF.Modules.Development.csproj
│ ├── Converters
│ │ ├── WarningKindDescriptionConverter.cs
│ │ └── WarningKindImageConverter.cs
│ ├── DevelopmentModule.cs
│ ├── Entities
│ │ └── JsonPrettifyEntity.cs
│ ├── Helpers
│ │ └── ConfigHelper.cs
│ ├── I18n
│ │ ├── DevelopmentModule.en-US.xml
│ │ ├── DevelopmentModule.ja-JP.xml
│ │ ├── DevelopmentModule.zh-CN.xml
│ │ ├── DevelopmentModule.zh-Hant.xml
│ │ ├── Language.cs
│ │ └── Language.tt
│ ├── Icons.cs
│ ├── Jobs
│ │ ├── DailyTimeJob.cs
│ │ └── UpdateTimeJob.cs
│ ├── Models
│ │ └── WarningKind.cs
│ ├── ViewModels
│ │ ├── JsonPrettifyViewModel.cs
│ │ ├── TestViewModel.cs
│ │ └── YamlPrettifyViewModel.cs
│ └── Views
│ │ ├── JsonPrettifyView.axaml
│ │ ├── JsonPrettifyView.axaml.cs
│ │ ├── TestView.axaml
│ │ ├── TestView.axaml.cs
│ │ ├── YamlPrettifyView.axaml
│ │ └── YamlPrettifyView.axaml.cs
├── CodeWF.Modules.XmlTranslatorManager
│ ├── CodeWF.Modules.XmlTranslatorManager.csproj
│ ├── I18n
│ │ ├── Language.cs
│ │ ├── Language.tt
│ │ ├── XmlTranslatorManagerModule.en-US.xml
│ │ ├── XmlTranslatorManagerModule.ja-JP.xml
│ │ ├── XmlTranslatorManagerModule.zh-CN.xml
│ │ └── XmlTranslatorManagerModule.zh-Hant.xml
│ ├── Icons.cs
│ ├── Models
│ │ ├── Consts.cs
│ │ ├── LanguageClassModel.cs
│ │ ├── LanguageProperty.cs
│ │ ├── LanguageXmlFileInfo.cs
│ │ └── LanguageXmlModel.cs
│ ├── README.zh-CN.md
│ ├── ViewModels
│ │ ├── ManageXMLFilesViewModel.cs
│ │ └── MergeXMLFilesViewModel.cs
│ ├── Views
│ │ ├── ManageXMLFilesView.axaml
│ │ ├── ManageXMLFilesView.axaml.cs
│ │ ├── MergeXMLFilesView.axaml
│ │ └── MergeXMLFilesView.axaml.cs
│ └── XmlTranslatorManagerModule.cs
├── CodeWF.Toolbox.Desktop
│ ├── App.config
│ ├── CodeWF.Toolbox.Desktop.csproj
│ ├── Program.cs
│ ├── Roots.xml
│ ├── app.manifest
│ └── logo.ico
└── CodeWF.Toolbox
│ ├── App.axaml
│ ├── App.axaml.cs
│ ├── Assets
│ ├── datetime-converter.png
│ ├── logo.ico
│ ├── logo.png
│ ├── slug-converter.png
│ ├── wechatowner.jpg
│ └── wechatpublic.jpg
│ ├── CodeWF.Toolbox.csproj
│ ├── Commands
│ ├── ChangeApplicationStatusCommand.cs
│ └── ChangeToolMenuCommand.cs
│ ├── Converters
│ └── IconConverter.cs
│ ├── I18n
│ ├── Language.cs
│ ├── Language.tt
│ ├── MainModule.en-US.xml
│ ├── MainModule.ja-JP.xml
│ ├── MainModule.zh-CN.xml
│ └── MainModule.zh-Hant.xml
│ ├── Icons.cs
│ ├── MainModule.cs
│ ├── Models
│ ├── ConstDatas.cs
│ └── ThemeItem.cs
│ ├── Services
│ └── ApplicationService.cs
│ ├── Styles
│ └── Index.axaml
│ ├── ViewModels
│ ├── AboutViewModel.cs
│ ├── CommonSettingViewModel.cs
│ ├── DashboardViewModel.cs
│ ├── ExitOptionViewModel.cs
│ ├── MainContentViewModel.cs
│ ├── MainMenuViewModel.cs
│ ├── MainViewModel.cs
│ ├── SettingViewModel.cs
│ ├── UpdateLogViewModel.cs
│ └── ViewModelBase.cs
│ └── Views
│ ├── AboutView.axaml
│ ├── AboutView.axaml.cs
│ ├── CommonSettingView.axaml
│ ├── CommonSettingView.axaml.cs
│ ├── DashboardView.axaml
│ ├── DashboardView.axaml.cs
│ ├── ExitOptionView.axaml
│ ├── ExitOptionView.axaml.cs
│ ├── MainContentView.axaml
│ ├── MainContentView.axaml.cs
│ ├── MainMenuView.axaml
│ ├── MainMenuView.axaml.cs
│ ├── MainView.axaml
│ ├── MainView.axaml.cs
│ ├── MainWindow.axaml
│ ├── MainWindow.axaml.cs
│ ├── SettingView.axaml
│ ├── SettingView.axaml.cs
│ ├── UpdateLogView.axaml
│ └── UpdateLogView.axaml.cs
└── tests
├── AvaloniaAotDemo
├── App.axaml
├── App.axaml.cs
├── Assets
│ └── avalonia-logo.ico
├── AvaloniaAotDemo.csproj
├── Commands
│ └── ChangeTimeCommand.cs
├── Program.cs
├── ViewLocator.cs
├── ViewModels
│ ├── MainWindowViewModel.cs
│ └── ViewModelBase.cs
├── Views
│ ├── MainWindow.axaml
│ └── MainWindow.axaml.cs
└── app.manifest
├── ConsoleAotDemo
├── ConsoleAotDemo.csproj
├── DBHeper.cs
├── Dtos
│ └── Person.cs
└── Program.cs
└── WinFormsAotDemo
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
└── WinFormsAotDemo.csproj
/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 | CodeWF Toolbox
4 | codewf.com
5 | Copyright © 2024 codewf.com. All rights reserved.
6 | 使用.NET 9 + Avalonia UI + Prism开发的工具客户端,支持AOT发布,目前测试可在Windows 7\Windows Server 2019\Windows 10\Windows 11\macOS 11+等平台运行
7 | 0.0.1.1
8 | 0.0.1.1
9 | 0.0.1.1
10 | 0.0.1.1
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2024 Dotnet9(dotnet9.com)
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README-zh_CN.md:
--------------------------------------------------------------------------------
1 | # CodeWF Toolbox
2 |
3 | 简体中文 | [English](README.md)
4 |
5 | 使用.NET 9 + Avalonia UI + Prism开发的工具客户端,支持AOT发布,目前测试可在Windows 7\Windows Server 2019\Windows 10\Windows 11\macOS 11+平台运行
6 |
7 | **解决方案截图**
8 |
9 | 
10 |
11 | **AOT发布后目录**
12 |
13 | 
14 |
15 | **黑白主题切换**
16 |
17 | 
18 |
19 | **国际化**
20 |
21 | 
22 | 同时,包含实用的 Json 美化工具和 YAML 转 Json 工具,分别如下图所示:
23 |
24 | **Json 美化工具**
25 |
26 | 
27 |
28 | **YAML转Json工具**
29 |
30 | 
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 码界工坊工具箱
2 |
3 | English | [简体中文](README-zh_CN.md)
4 |
5 | Use. NET 9+Avalonia UI+Prism developed tool client, supports AOT publishing, currently tested to run on Windows 7 \ Windows Server 2019 \ Windows 10 \ Windows 11 \ macOS 11+platforms
6 |
7 | **Solution screenshot**
8 |
9 | 
10 |
11 | **Directory after AOT release**
12 |
13 | 
14 |
15 | **Black and White Theme Switching**
16 |
17 | 
18 |
19 | **Internationalization**
20 |
21 | 
22 | At the same time, it includes practical Json beautification tools and YAML to Json tools, as shown in the following figures:
23 |
24 | **Json Beautification Tool**
25 |
26 | 
27 |
28 | **YAML to JSON conversion tool**
29 |
30 | 
--------------------------------------------------------------------------------
/UpdateLog.md:
--------------------------------------------------------------------------------
1 | ## 更新日志
2 |
3 | ### V0.0.1.1(2024-12-28)
4 | - 🔨使用MarkdownAIRender渲染Markdown
5 |
6 | ### V0.0.1.0(2024-12-25)
7 | - 😄添加更新日志
8 | - 🔨导出Excel默认覆盖已有文件
9 | - 🐛修复只能导出渲染表格数据的问题
--------------------------------------------------------------------------------
/src/CodeWF.Controls/CodeWF.Controls.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/CodeWF.Core/CodeWF.Core.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/src/CodeWF.Core/ConfigDB/DBConst.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Core.ConfigDB;
2 |
3 | public class DBConst
4 | {
5 | public const string DBConnectionString = "Data Source=CodeWF.Toolbox.db";
6 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/DialogNames.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Core;
2 |
3 | public static class DialogNames
4 | {
5 | public const string Setting = nameof(Setting);
6 | public const string ChoiceLanguages = nameof(ChoiceLanguages);
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/HostIds.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Core;
2 |
3 | public static class HostIds
4 | {
5 | public const string Main = "Main";
6 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/IServices/IApplicationService.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Core.IServices;
2 |
3 | public interface IApplicationService
4 | {
5 | public bool HideTrayIconOnClose { get; set; }
6 | public bool NeedExitDialogOnClose { get; set; }
7 | void Load();
8 | string GetTheme();
9 | void SetTheme(string theme);
10 | string GetCulture();
11 | void SetCulture(string culture);
12 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/IServices/IFileChooserService.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Platform.Storage;
3 |
4 | namespace CodeWF.Core.IServices;
5 |
6 | public interface IFileChooserService
7 | {
8 | void SetHostWindow(TopLevel level);
9 |
10 | Task?> OpenFileAsync(string title, bool allowMultiple,
11 | IReadOnlyList? fileTypeFilters);
12 |
13 | Task SaveFileAsync(string title, IReadOnlyList? fileTypeFilters);
14 |
15 | Task?> OpenFolderAsync(string title, bool allowMultiple = false);
16 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/IServices/INotificationService.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Controls.Notifications;
3 |
4 | namespace CodeWF.Core.IServices;
5 |
6 | public interface INotificationService
7 | {
8 | void SetHostWindow(TopLevel level);
9 | void Show(string title, string message, NotificationType type = NotificationType.Information);
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/IToolMenuService.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.Models;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace CodeWF.Core;
5 |
6 | public interface IToolMenuService
7 | {
8 | ObservableCollection MenuItems { get; }
9 | event Action? ToolMenuChanged;
10 |
11 | void AddGroup(string name, string? icon = null);
12 |
13 | void AddItem(string name, string? parentName = null, string? description = null, string? viewName = null,
14 | string? icon = null, ToolStatus? status = null);
15 |
16 | void AddSeparator();
17 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/Models/ToolMenuItem.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.ObjectModel;
2 |
3 | namespace CodeWF.Core.Models;
4 |
5 | public class ToolMenuItem
6 | {
7 | public int Level { get; set; }
8 | public string? Name { get; set; }
9 | public string? Description { get; set; }
10 | public string? ViewName { get; set; }
11 | public ToolStatus? Status { get; set; }
12 | public string? Icon { get; set; }
13 | public bool IsSeparator { get; set; }
14 | public ObservableCollection Children { get; set; } = new();
15 |
16 | public override string ToString()
17 | {
18 | return $"{Name}";
19 | }
20 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/Models/ToolStatus.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace CodeWF.Core.Models;
4 |
5 | public enum ToolStatus
6 | {
7 | [Description("计划中")] Planned,
8 | [Description("开发中")] Developing,
9 | [Description("开发完成")] Complete
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/RegionAdapters/TabControlRegionAdapter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using AvaloniaXmlTranslator.Markup;
3 | using System.Collections.Specialized;
4 |
5 | namespace CodeWF.Core.RegionAdapters;
6 |
7 | public interface ITabItemBase
8 | {
9 | public string? TitleKey { get; set; }
10 | public string MessageKey { get; set; }
11 | }
12 |
13 | public class TabControlRegionAdapter : RegionAdapterBase
14 | {
15 | public TabControlRegionAdapter(IRegionBehaviorFactory regionBehaviorFactory) : base(regionBehaviorFactory)
16 | {
17 | }
18 |
19 | protected override void Adapt(IRegion region, TabControl regionTarget)
20 | {
21 | if (region == null)
22 | throw new ArgumentNullException(nameof(region));
23 |
24 | if (regionTarget == null)
25 | throw new ArgumentNullException(nameof(regionTarget));
26 |
27 | regionTarget.SelectionChanged += (s, e) =>
28 | {
29 | if (regionTarget.SelectedItem is TabItem { Content: UserControl { DataContext: ITabItemBase vm } })
30 | {
31 | regionTarget.Tag = vm.MessageKey;
32 | }
33 | };
34 |
35 | region.Views.CollectionChanged += (s, e) =>
36 | {
37 | switch (e.Action)
38 | {
39 | case NotifyCollectionChangedAction.Add:
40 | {
41 | if (e.NewItems != null)
42 | {
43 | foreach (var item in e.NewItems)
44 | {
45 | var header = item is UserControl { DataContext: ITabItemBase tabItem }
46 | ? tabItem.TitleKey
47 | : item?.GetType().ToString();
48 | var newTabItem = new TabItem { Content = item };
49 | newTabItem.Bind(TabItem.HeaderProperty, new I18nBinding(header));
50 | regionTarget.Items.Add(newTabItem);
51 | }
52 | }
53 |
54 | break;
55 | }
56 | case NotifyCollectionChangedAction.Remove:
57 | {
58 | if (e.OldItems != null)
59 | {
60 | foreach (var item in e.OldItems)
61 | {
62 | var tabToDelete = regionTarget.Items.OfType()
63 | .FirstOrDefault(n => n.Content == item);
64 | regionTarget.Items.Remove(tabToDelete);
65 | }
66 | }
67 |
68 | break;
69 | }
70 | }
71 | };
72 | }
73 |
74 | protected override IRegion CreateRegion() => new SingleActiveRegion();
75 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/RegionNames.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Core;
2 |
3 | public static class RegionNames
4 | {
5 | /// Main Window's Footer Status Bar.
6 | public const string FooterRegion = nameof(FooterRegion);
7 |
8 | /// Left Side Bar.
9 | public const string LeftRegion = nameof(LeftRegion);
10 |
11 | /// Main Window's content region
12 | public const string ContentRegion = nameof(ContentRegion);
13 |
14 | /// Right Side Bar.
15 | public const string RightRegion = nameof(RightRegion);
16 |
17 | /// Right Side Bar.
18 | public const string SettingRegion = nameof(SettingRegion);
19 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/Services/FileChooserService.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Platform.Storage;
3 | using CodeWF.Core.IServices;
4 |
5 | namespace CodeWF.Core.Services;
6 |
7 | public class FileChooserService : IFileChooserService
8 | {
9 | private IStorageProvider? _storageProvider;
10 |
11 | public void SetHostWindow(TopLevel level)
12 | {
13 | _storageProvider = level?.StorageProvider;
14 | }
15 |
16 | public async Task?> OpenFileAsync(string title, bool allowMultiple,
17 | IReadOnlyList? fileTypeFilters)
18 | {
19 | var result = await _storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions()
20 | {
21 | Title = title, FileTypeFilter = fileTypeFilters, AllowMultiple = allowMultiple,
22 | });
23 |
24 | return result.Any() ? result.Select(file => file.TryGetLocalPath()).ToList() : default;
25 | }
26 |
27 | public async Task SaveFileAsync(string title, IReadOnlyList? fileTypeFilters)
28 | {
29 | var result = await _storageProvider.SaveFilePickerAsync(new FilePickerSaveOptions()
30 | {
31 | Title = title, FileTypeChoices = fileTypeFilters
32 | });
33 |
34 | return result == null ? default : result.TryGetLocalPath();
35 | }
36 |
37 | public async Task?> OpenFolderAsync(string title, bool allowMultiple = false)
38 | {
39 | var result = await _storageProvider.OpenFolderPickerAsync(new FolderPickerOpenOptions()
40 | {
41 | Title = title, AllowMultiple = allowMultiple,
42 | });
43 |
44 | return result.Any() ? result.Select(file => file.TryGetLocalPath()).ToList() : default;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/Services/NotificationService.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Controls.Notifications;
3 | using CodeWF.Core.IServices;
4 |
5 | namespace CodeWF.Core.Services;
6 |
7 | public class NotificationService : INotificationService
8 | {
9 | private WindowNotificationManager? _notificationManager;
10 |
11 | public void SetHostWindow(TopLevel level)
12 | {
13 | _notificationManager = new WindowNotificationManager(level)
14 | {
15 | Position = NotificationPosition.BottomRight, MaxItems = 4, Margin = new Avalonia.Thickness(0, 0, 15, 40)
16 | };
17 | }
18 |
19 | public void Show(string title, string message, NotificationType type = NotificationType.Information)
20 | {
21 | _notificationManager?.Show(new Notification(title, message, type, TimeSpan.FromSeconds(10)));
22 | }
23 | }
--------------------------------------------------------------------------------
/src/CodeWF.Core/ToolMenuService.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.Models;
2 | using System.Collections.ObjectModel;
3 |
4 | namespace CodeWF.Core;
5 |
6 | public class ToolMenuService : IToolMenuService
7 | {
8 | public ObservableCollection MenuItems { get; } = [];
9 | public event Action? ToolMenuChanged;
10 |
11 | public void AddItem(string name, string? parentName = null, string? description = null, string? viewName = null,
12 | string? icon = null, ToolStatus? status = null)
13 | {
14 | ToolMenuItem? parent = null;
15 | if (parentName != null)
16 | {
17 | parent = MenuItems.FirstOrDefault(item => item.Name == parentName) ??
18 | new ToolMenuItem { Name = parentName, Children = [] };
19 | }
20 |
21 | var toolMenuItem = new ToolMenuItem()
22 | {
23 | Name = name,
24 | Description = description,
25 | ViewName = viewName,
26 | Status = status,
27 | Icon = icon
28 | };
29 | if (parent == null)
30 | {
31 | MenuItems.Add(toolMenuItem);
32 | }
33 | else
34 | {
35 | parent.Children.Add(toolMenuItem);
36 | }
37 |
38 | ToolMenuChanged?.Invoke();
39 | }
40 |
41 | public void AddSeparator()
42 | {
43 | MenuItems.Add(new ToolMenuItem() { IsSeparator = true });
44 | }
45 |
46 | public void AddGroup(string name, string? icon = null)
47 | {
48 | MenuItems.Add(new ToolMenuItem() { Name = name, Icon = icon });
49 | }
50 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/AIModule.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core;
2 | using CodeWF.Core.Models;
3 | using CodeWF.Modules.AI.Helpers;
4 | using CodeWF.Modules.AI.Views;
5 | using Ursa.PrismExtension;
6 |
7 | namespace CodeWF.Modules.AI;
8 |
9 | public class AIModule : IModule
10 | {
11 | public AIModule(IToolMenuService toolMenuService)
12 | {
13 | var groupName = Localization.AIModule.Title;
14 | toolMenuService.AddSeparator();
15 | toolMenuService.AddGroup(groupName, Icons.AI);
16 | toolMenuService.AddItem(Localization.AskBotView.Title, groupName, Localization.AskBotView.Description, nameof(AskBotView),
17 | Icons.AskBot,
18 | ToolStatus.Developing);
19 | toolMenuService.AddItem(Localization.PolyTranslateView.Title, groupName, Localization.PolyTranslateView.Description,
20 | nameof(PolyTranslateView),
21 | Icons.PolyTranslate,
22 | ToolStatus.Complete);
23 | toolMenuService.AddItem(Localization.Title2SlugView.Title, groupName, Localization.Title2SlugView.Description, nameof(Title2SlugView),
24 | Icons.Title2Slug,
25 | ToolStatus.Complete);
26 | }
27 |
28 | public void OnInitialized(IContainerProvider containerProvider)
29 | {
30 | IRegionManager? regionManager = containerProvider.Resolve();
31 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
32 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
33 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
34 | }
35 |
36 | public void RegisterTypes(IContainerRegistry containerRegistry)
37 | {
38 | containerRegistry.Register();
39 | containerRegistry.RegisterScoped();
40 | containerRegistry.RegisterUrsaDialogView(DialogNames.ChoiceLanguages);
41 | }
42 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/CodeWF - Backup.Modules.AI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | True
22 | True
23 | Language.tt
24 |
25 |
26 |
27 |
28 |
29 | TextTemplatingFileGenerator
30 | Language.cs
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 | True
41 | True
42 | Language.tt
43 |
44 |
45 | True
46 | True
47 | Resources.resx
48 |
49 |
50 |
51 |
52 |
53 | ResXFileCodeGenerator
54 | Resources.Designer.cs
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/CodeWF.Modules.AI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 | $(InterceptorsPreviewNamespaces);Dapper.AOT
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 | True
26 | True
27 | Language.tt
28 |
29 |
30 |
31 |
32 |
33 | PreserveNewest
34 |
35 |
36 | PreserveNewest
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 | TextTemplatingFileGenerator
43 | Language.cs
44 |
45 |
46 | PreserveNewest
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 | True
57 | True
58 | Language.tt
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Entities/TranslateLanguageEntity.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.AI.Entities;
2 |
3 | public class TranslateLanguageEntity
4 | {
5 | public string? Languages { get; set; }
6 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Helpers/ConfigHelper.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.ConfigDB;
2 | using CodeWF.Modules.AI.Entities;
3 | using Dapper;
4 | using Microsoft.Data.Sqlite;
5 |
6 | namespace CodeWF.Modules.AI.Helpers;
7 |
8 | public static class ConfigHelper
9 | {
10 | [DapperAot]
11 | public static bool EnsureTableIsCreated()
12 | {
13 | try
14 | {
15 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
16 | connection.Open();
17 |
18 | const string sql = $@"
19 | CREATE TABLE IF NOT EXISTS {nameof(TranslateLanguageEntity)}(
20 | {nameof(TranslateLanguageEntity.Languages)} VARCHAR(3072)
21 | )";
22 |
23 | using var command = new SqliteCommand(sql, connection);
24 | return command.ExecuteNonQuery() > 0;
25 | }
26 | catch (Exception ex)
27 | {
28 | return false;
29 | }
30 | }
31 |
32 | [DapperAot]
33 | public static List? GetTranslateLanguages()
34 | {
35 | try
36 | {
37 | EnsureTableIsCreated();
38 |
39 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
40 | connection.Open();
41 |
42 | const string sql =
43 | $@"SELECT {nameof(TranslateLanguageEntity.Languages)} FROM {nameof(TranslateLanguageEntity)}";
44 | var config = connection.QueryFirstOrDefault(sql);
45 |
46 | return config?.Languages?.Split(',').ToList();
47 | }
48 | catch (Exception ex)
49 | {
50 | return default;
51 | }
52 | }
53 |
54 | [DapperAot]
55 | public static bool UpdateTranslateLanguages(List? languages)
56 | {
57 | try
58 | {
59 | EnsureTableIsCreated();
60 |
61 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
62 | connection.Open();
63 | connection.Execute($"DELETE FROM {nameof(TranslateLanguageEntity)}");
64 | if (languages?.Any() != true)
65 | {
66 | return false;
67 | }
68 |
69 | var languageStr = string.Join(",", languages)!;
70 | var result = connection.Execute(
71 | @$"INSERT INTO {nameof(TranslateLanguageEntity)}({nameof(TranslateLanguageEntity.Languages)})
72 | VALUES(@{nameof(TranslateLanguageEntity.Languages)})",
73 | new { Languages = languageStr });
74 | return result > 0;
75 | }
76 | catch (Exception ex)
77 | {
78 | return false;
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/AIModule.en-US.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AI
6 |
7 |
8 | Intelligent Question and Answer Assistant
9 | Ask questions with one click and get answers immediately. The intelligent question and answer assistant will help you solve your doubts.
10 |
11 |
12 | AI One-Click Multi-language Translation Tool
13 | Easily achieve one-click translation, support mutual translation among multiple languages, and make communication without boundaries!
14 |
15 |
16 | AI One-Click Conversion to URL Slug
17 | Effortlessly convert article titles in Chinese, English and other languages into English URL Slugs with just one click.
18 |
19 |
20 | Language
21 | Selectable
22 | Selected
23 |
24 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/AIModule.ja-JP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AI(人工知能)
6 |
7 |
8 | 知能質問応答アシスタント
9 | ワンクリックで質問を投げると、すぐに回答を得ることができます。知能質問応答アシスタントがあなたの疑問を解決します。
10 |
11 |
12 | AIワンクリック多言語翻訳ツール
13 | 簡単にワンクリック翻訳が可能で、多言語間の相互翻訳をサポートし、コミュニケーションに境界を設けません!
14 |
15 |
16 | AIワンクリックでURLスラグに変換
17 | 簡単に中国語、英語などの記事タイトルをワンクリックで英語のURLスラグに変換できます。
18 |
19 |
20 | 言語
21 | 選択可能な
22 | 選択された
23 |
24 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/AIModule.zh-CN.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | AI
6 |
7 |
8 | 智能问答助手
9 | 一键提问,即刻获取答案,智能问答助手为您解惑。
10 |
11 |
12 | AI一键多语种翻译神器
13 | 轻松实现一键翻译,支持多种语言互译,让沟通无界限!
14 |
15 |
16 | AI一键转URL Slug
17 | 轻松将中文、英文等文章标题一键转换成英文URL Slug。
18 |
19 |
20 | 语言
21 | 可选择的
22 | 已选择
23 |
24 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/AIModule.zh-Hant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 人工智能
6 |
7 |
8 | 智能問答助手
9 | 一鍵提問,即刻獲取答案,智能問答助手為您解惑。
10 |
11 |
12 | 人工智能一鍵多語種翻譯神器
13 | 輕鬆實現一鍵翻譯,支持多種語言互譯,讓溝通無界限!
14 |
15 |
16 | 人工智能一鍵轉URL Slug
17 | 輕鬆將中文、英文等文章標題一鍵轉換成英文URL Slug。
18 |
19 |
20 | 語言
21 | 可選擇的
22 | 已選擇
23 |
24 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/Language.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Changes to this file may cause incorrect behavior and will be lost if
5 | // the code is regenerated.
6 | //
7 | //------------------------------------------------------------------------------
8 | namespace Localization
9 | {
10 | public static class AIModule
11 | {
12 | public static readonly string Title = "Localization.AIModule.Title";
13 | }
14 | }
15 | namespace Localization
16 | {
17 | public static class AskBotView
18 | {
19 | public static readonly string Title = "Localization.AskBotView.Title";
20 | public static readonly string Description = "Localization.AskBotView.Description";
21 | }
22 | }
23 | namespace Localization
24 | {
25 | public static class PolyTranslateView
26 | {
27 | public static readonly string Title = "Localization.PolyTranslateView.Title";
28 | public static readonly string Description = "Localization.PolyTranslateView.Description";
29 | }
30 | }
31 | namespace Localization
32 | {
33 | public static class Title2SlugView
34 | {
35 | public static readonly string Title = "Localization.Title2SlugView.Title";
36 | public static readonly string Description = "Localization.Title2SlugView.Description";
37 | }
38 | }
39 | namespace Localization
40 | {
41 | public static class ChoiceLanguagesView
42 | {
43 | public static readonly string LanguageKey = "Localization.ChoiceLanguagesView.LanguageKey";
44 | public static readonly string Selectable = "Localization.ChoiceLanguagesView.Selectable";
45 | public static readonly string Selected = "Localization.ChoiceLanguagesView.Selected";
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/I18n/Language.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="true" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ assembly name="System.Xml" #>
4 | <#@ assembly name="System.Xml.Linq" #>
5 | <#@ import namespace="System.Linq" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Collections.Generic" #>
8 | <#@ import namespace="System.Xml.Linq" #>
9 | <#@ import namespace="System.IO" #>
10 | <#@ output extension=".cs" #>
11 | //------------------------------------------------------------------------------
12 | //
13 | // This code was generated by a tool.
14 | // Changes to this file may cause incorrect behavior and will be lost if
15 | // the code is regenerated.
16 | //
17 | //------------------------------------------------------------------------------
18 | <#
19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault();
21 | if (xmlFilePath!= null)
22 | {
23 | XDocument xdoc = XDocument.Load(xmlFilePath);
24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList();
25 | foreach (var classNode in classNodes)
26 | {
27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName);
28 | string namespaceName = string.Join(".", namespaceSegments);
29 | GenerateClasses(classNode, namespaceName);
30 | }
31 | }
32 | else
33 | {
34 | Write("XML file not found, please ensure that there is an XML file in the current directory");
35 | }
36 |
37 | void GenerateClasses(XElement element, string namespaceName)
38 | {
39 | string className = element.Name.LocalName;
40 | StringBuilder classBuilder = new StringBuilder();
41 | classBuilder.AppendLine($"namespace {namespaceName}");
42 | classBuilder.AppendLine("{");
43 | classBuilder.AppendLine($" public static class {className}");
44 | classBuilder.AppendLine(" {");
45 | var fieldNodes = element.Elements();
46 | foreach (var fieldNode in fieldNodes)
47 | {
48 | var propertyName = fieldNode.Name.LocalName;
49 | var languageKey = $"{namespaceName}.{className}.{propertyName}";
50 | classBuilder.AppendLine($" public static readonly string {propertyName} = \"{languageKey}\";");
51 | }
52 | classBuilder.AppendLine(" }");
53 | classBuilder.AppendLine("}");
54 | Write(classBuilder.ToString());
55 | }
56 | #>
57 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Icons.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.AI;
2 |
3 | internal class Icons
4 | {
5 | public const string AI =
6 | "M512 85.333333c235.648 0 426.666667 191.018667 426.666667 426.666667s-191.018667 426.666667-426.666667 426.666667S85.333333 747.648 85.333333 512 276.352 85.333333 512 85.333333z m0 85.333334a341.333333 341.333333 0 1 0 0 682.666666 341.333333 341.333333 0 0 0 0-682.666666z m-40.405333 156.586666l121.856 369.706667h-83.968l-27.050667-89.685333H361.898667l-27.648 89.685333H256L378.453333 327.253333h93.141334z m256.213333 0v369.706667h-78.549333V327.253333h78.506666z m-303.36 75.562667H420.693333l-43.306666 144.64h89.898666L424.448 402.773333z";
7 |
8 | public const string AskBot =
9 | "M682.592 341.408l0-255.904-597.088 0 0 460.608 255.904 0 0 255.904 354.016 0 136.48 136.448 21.28 0 0-136.448 85.312 0 0-460.608-255.904 0zM119.616 512l0-392.384 528.864 0 0 221.792-307.072 0 0 170.592-221.792 0zM904.384 767.904l-85.312 0 0 109.504-109.536-109.504-334.048 0 0-392.384 528.864 0 0 392.384z";
10 |
11 | public const string PolyTranslate =
12 | "M744.448 478.122667l149.333333 384a32 32 0 0 1-59.648 23.210666l-37.674666-96.810666H632.746667l-37.546667 96.810666a32 32 0 0 1-37.290667 19.498667l-4.181333-1.28a32 32 0 0 1-18.218667-41.386667l149.333334-384c10.581333-27.221333 49.066667-27.221333 59.648 0zM160.042667 650.666667a32 32 0 0 1 32 32v96.085333c0 27.605333 20.992 50.346667 47.914666 53.077333l5.418667 0.256a32 32 0 1 1 0 64 117.333333 117.333333 0 0 1-117.333333-117.333333V682.666667a32 32 0 0 1 32-32z m554.581333-72.618667l-57.045333 146.474667h114.005333l-56.96-146.474667zM341.333333 127.829333a32 32 0 0 1 32 32v21.461334l74.666667 0.042666a96 96 0 0 1 96 96v85.333334a96 96 0 0 1-96 96H373.333333v102.528a32 32 0 1 1-64 0V458.666667l-74.666666 0.042666A96 96 0 0 1 138.666667 362.666667v-85.333334A96 96 0 0 1 234.666667 181.333333h74.666666v-21.504a32 32 0 0 1 32-32zM309.333333 245.333333L234.666667 245.333333a32 32 0 0 0-32 32v85.333334c0 17.664 14.336 32 32 32h74.666666v-149.333334z m138.666667 0.042667H373.333333v149.333333h74.666667a32 32 0 0 0 32-32v-85.333333a32 32 0 0 0-32-32z m330.666667-117.504A117.333333 117.333333 0 0 1 896 245.162667V341.333333a32 32 0 0 1-64 0V245.162667a53.333333 53.333333 0 0 0-47.914667-53.034667l-5.461333-0.298667a32 32 0 1 1 0-64z";
13 |
14 | public const string Title2Slug = "M682.666667 256h-128v81.066667h128a174.933333 174.933333 0 0 1 174.933333 174.933333 174.933333 174.933333 0 0 1-174.933333 174.933333h-128V768h128a256 256 0 0 0 256-256c0-141.653333-114.773333-256-256-256M166.4 512A174.933333 174.933333 0 0 1 341.333333 337.066667h128V256H341.333333a256 256 0 0 0-256 256 256 256 0 0 0 256 256h128v-81.066667H341.333333c-96.426667 0-174.933333-78.506667-174.933333-174.933333M341.333333 554.666667h341.333334v-85.333334H341.333333v85.333334z";
15 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Imports.cs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Models/AskBotRequest.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.AI.Models;
2 |
3 | public record AskBotRequest(string Content);
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Models/ChatGptOptions.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 |
3 | namespace CodeWF.Modules.AI.Models;
4 |
5 | internal class ChatGptOptions
6 | {
7 | private const string BaseUrl = "https://dotnet9.com/";
8 |
9 | public string AskBotHttpUrl { get; set; } = $"{BaseUrl}ai/askbot";
10 | public string PolyTranslateHttpUrl { get; set; } = $"{BaseUrl}ai/polytranslate";
11 | public string Title2SlugHttpUrl { get; set; } = $"{BaseUrl}ai/title2slug";
12 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Models/PolyTranslateRequest.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.AI.Models;
2 |
3 | public record PolyTranslateRequest(string Content, List Languages);
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Models/Title2SlugRequest.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.AI.Models;
2 |
3 | public record Title2SlugRequest(string Content);
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/ViewModels/AskBotViewModel.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Modules.AI.Helpers;
2 | using CodeWF.Modules.AI.Models;
3 | using ReactiveUI;
4 | using System.Reactive;
5 |
6 | namespace CodeWF.Modules.AI.ViewModels;
7 |
8 | public class AskBotViewModel : ReactiveObject
9 | {
10 | private readonly ApiClient _apiClient;
11 | private readonly ChatGptOptions _chatGptOptions = new();
12 |
13 | public AskBotViewModel(ApiClient apiClient)
14 | {
15 | _apiClient = apiClient;
16 | RaiseAskAICommand = ReactiveCommand.CreateFromTask(RaiseAskAICommandHandlerAsync);
17 | }
18 |
19 | private string? _askContent;
20 |
21 | public string? AskContent
22 | {
23 | get => _askContent;
24 | set => this.RaiseAndSetIfChanged(ref _askContent, value);
25 | }
26 |
27 | private string? _responseContent;
28 |
29 | public string? ResponseContent
30 | {
31 | get => _responseContent;
32 | set => this.RaiseAndSetIfChanged(ref _responseContent, value);
33 | }
34 |
35 | public ReactiveCommand RaiseAskAICommand { get; }
36 |
37 | private async Task RaiseAskAICommandHandlerAsync()
38 | {
39 | if (string.IsNullOrWhiteSpace(AskContent))
40 | {
41 | return;
42 | }
43 |
44 | if (!string.IsNullOrWhiteSpace(ResponseContent))
45 | {
46 | ResponseContent = "";
47 | }
48 |
49 | try
50 | {
51 | await _apiClient.CreateChatGptClient(_chatGptOptions.AskBotHttpUrl, new AskBotRequest(AskContent), result =>
52 | {
53 | ResponseContent += result;
54 | }, status =>
55 | {
56 | //AskContent = string.Empty;
57 | });
58 | }
59 | catch (Exception ex)
60 | {
61 | ResponseContent = ex.Message;
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/ViewModels/ChoiceLanguagesViewModel.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.AvaloniaControls.Extensions;
2 |
3 | namespace CodeWF.Modules.AI.ViewModels;
4 |
5 | public class ChoiceLanguagesViewModel
6 | {
7 | public RangeObservableCollection SelectedLanguages { get; set; }
8 |
9 | public RangeObservableCollection AllLanguages { get; set; }
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/ViewModels/Title2SlugViewModel.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Modules.AI.Helpers;
2 | using CodeWF.Modules.AI.Models;
3 | using ReactiveUI;
4 | using System.Reactive;
5 |
6 | namespace CodeWF.Modules.AI.ViewModels;
7 |
8 | public class Title2SlugViewModel : ReactiveObject
9 | {
10 | private readonly ApiClient _apiClient;
11 | private readonly ChatGptOptions _chatGptOptions = new();
12 |
13 | public Title2SlugViewModel(ApiClient apiClient)
14 | {
15 | _apiClient = apiClient;
16 | RaiseConvertCommand = ReactiveCommand.CreateFromTask(RaiseConvertCommandHandlerAsync);
17 | }
18 |
19 | private string? _askContent;
20 |
21 | public string? AskContent
22 | {
23 | get => _askContent;
24 | set => this.RaiseAndSetIfChanged(ref _askContent, value);
25 | }
26 |
27 | private string? _responseContent;
28 |
29 | public string? ResponseContent
30 | {
31 | get => _responseContent;
32 | set => this.RaiseAndSetIfChanged(ref _responseContent, value);
33 | }
34 |
35 | public ReactiveCommand RaiseConvertCommand { get; }
36 |
37 | private async Task RaiseConvertCommandHandlerAsync()
38 | {
39 | if (string.IsNullOrWhiteSpace(AskContent))
40 | {
41 | return;
42 | }
43 |
44 | if (!string.IsNullOrWhiteSpace(ResponseContent))
45 | {
46 | ResponseContent = "";
47 | }
48 |
49 | try
50 | {
51 | await _apiClient.CreateChatGptClient(_chatGptOptions.Title2SlugHttpUrl, new Title2SlugRequest(AskContent),
52 | result =>
53 | {
54 | ResponseContent += result;
55 | }, status =>
56 | {
57 | //AskContent = string.Empty;
58 | });
59 | }
60 | catch (Exception ex)
61 | {
62 | ResponseContent = ex.Message;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/AskBotView.axaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/AskBotView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Modules.AI.Views;
4 |
5 | public partial class AskBotView : UserControl
6 | {
7 | public AskBotView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/ChoiceLanguagesView.axaml:
--------------------------------------------------------------------------------
1 |
12 |
17 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/ChoiceLanguagesView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Modules.AI.Views;
4 |
5 | public partial class ChoiceLanguagesView : UserControl
6 | {
7 | public ChoiceLanguagesView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/PolyTranslateView.axaml:
--------------------------------------------------------------------------------
1 |
18 |
22 |
23 |
28 |
29 |
37 |
38 |
44 |
45 |
53 |
54 |
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/PolyTranslateView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace CodeWF.Modules.AI.Views;
6 |
7 | public partial class PolyTranslateView : UserControl
8 | {
9 | public PolyTranslateView()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | private void InitializeComponent()
15 | {
16 | AvaloniaXamlLoader.Load(this);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/Title2SlugView.axaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.AI/Views/Title2SlugView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace CodeWF.Modules.AI.Views;
6 |
7 | public partial class Title2SlugView : UserControl
8 | {
9 | public Title2SlugView()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | private void InitializeComponent()
15 | {
16 | AvaloniaXamlLoader.Load(this);
17 | }
18 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/CodeWF.Modules.Converter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 | True
12 | True
13 | Language.tt
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | True
32 | True
33 | Language.tt
34 |
35 |
36 |
37 |
38 |
39 | PreserveNewest
40 |
41 |
42 | PreserveNewest
43 |
44 |
45 | PreserveNewest
46 |
47 |
48 | TextTemplatingFileGenerator
49 | Language.cs
50 |
51 |
52 | PreserveNewest
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/ConverterModule.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core;
2 | using CodeWF.Core.Models;
3 | using CodeWF.Modules.Converter.ViewModels;
4 | using CodeWF.Modules.Converter.Views;
5 |
6 | namespace CodeWF.Modules.Converter;
7 |
8 | public class ConverterModule : IModule
9 | {
10 | public ConverterModule(IToolMenuService toolMenuService)
11 | {
12 | var groupName = Localization.ConverterModule.Title;
13 | toolMenuService.AddSeparator();
14 | toolMenuService.AddGroup(groupName, Icons.Converter);
15 | toolMenuService.AddItem(Localization.DateTimeConverterView.Title, groupName,
16 | Localization.DateTimeConverterView.Description,
17 | nameof(DateTimeConverterView),
18 | Icons.Timestamp,
19 | ToolStatus.Developing);
20 | toolMenuService.AddItem(Localization.YamlToJsonView.Title, groupName, Localization.YamlToJsonView.Description,
21 | nameof(YamlToJsonView),
22 | Icons.Yaml,
23 | ToolStatus.Complete);
24 | toolMenuService.AddItem(Localization.JsonToYamlView.Title, groupName, Localization.JsonToYamlView.Description,
25 | nameof(JsonToYamlView),
26 | Icons.Json,
27 | ToolStatus.Complete);
28 | toolMenuService.AddItem(Localization.ImageToIconView.Title, groupName,
29 | Localization.ImageToIconView.MemoContent1, nameof(ImageToIconView),
30 | Icons.Icon,
31 | ToolStatus.Developing);
32 | }
33 |
34 | public void OnInitialized(IContainerProvider containerProvider)
35 | {
36 | IRegionManager? regionManager = containerProvider.Resolve();
37 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
38 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
39 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
40 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
41 | }
42 |
43 | public void RegisterTypes(IContainerRegistry containerRegistry)
44 | {
45 | ViewModelLocationProvider.Register();
46 | }
47 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/ConverterModule.en-US.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Converter
6 |
7 |
8 | Date and Time Converter
9 | Convert date and time into various different formats.
10 |
11 |
12 | JSON to YAML Converter
13 | Use the online converter to convert JSON into YAML.
14 | Original Json format:
15 | Converted Yaml format:
16 | Copy
17 | Clear
18 |
19 |
20 | YAML to JSON Converter
21 | Use this online converter to convert YAML into JSON.
22 | Original YAML format:
23 | Converted Json format:
24 | Copy
25 | Clear
26 |
27 |
28 | Convert Image to ICO Icon
29 | Image files (formats: png, jpg, jpeg, ico, webp)
30 | Please select the image to be converted
31 | Target Size
32 | Merge and Generate ICO Icon
33 | Generate ICO Icon Separately
34 | Note
35 | ICO files are generally used for web page logos and application logos.
36 | When using an ICO file on a web page, usually name the generated ICO file as "favicon.ico", put it in the root directory of the website, and then add the following code to the <head> tag of the page: <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
37 |
38 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/ConverterModule.ja-JP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | コンバーター
6 |
7 |
8 | 日付と時刻のコンバーター
9 | 日付と時刻をさまざまな形式に変換します。
10 |
11 |
12 | JSONからYAMLへのコンバーター
13 | オンラインコンバーターを使ってJSONをYAMLに変換します。
14 | 元のJson形式:
15 | 変換後のYaml形式:
16 | コピー
17 | クリア
18 |
19 |
20 | YAMLからJSONへのコンバーター
21 | このオンラインコンバーターを使ってYAMLをJSONに変換します。
22 | 元のYAML形式:
23 | 変換後のJson形式:
24 | コピー
25 | クリア
26 |
27 |
28 | 画像をICOアイコンに変換
29 | 画像ファイル(形式: png、jpg、jpeg、ico、webp)
30 | 変換する画像を選択してください
31 | 目標サイズ
32 | ICOアイコンをマージ生成
33 | ICOアイコンを個別生成
34 | 説明
35 | ICOファイルは一般的に、ウェブページのロゴやアプリケーションのロゴに使用されます。
36 | ウェブページでICOファイルを使用する場合、通常は生成したICOファイルを「favicon.ico」と命名し、ウェブサイトのルートディレクトリに配置し、次のコードをページの<head>タグ内に追加します: <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
37 |
38 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/ConverterModule.zh-CN.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 转换器
6 |
7 |
8 | 日期时间转换器
9 | 将日期和时间转换为各种不同的格式
10 |
11 |
12 | JSON到YAML转换器
13 | 在线转换将JSON转换为YAML。
14 | 原始Json格式:
15 | 转换后的Yaml格式:
16 | 复制
17 | 清空
18 |
19 |
20 | YAML到JSON转换器
21 | 使用此在线转换器将YAML转换为JSON。
22 | 原始YAML格式:
23 | 转换后的Json格式:
24 | 复制
25 | 清空
26 |
27 |
28 | 图片转 ico 图标
29 | 图片文件(格式:png、jpg、jpeg、ico、webp)
30 | 请选择需要转换的图片
31 | 目标尺寸
32 | 合并生成 ico 图标
33 | 单独生成 ico 图标
34 | 说明
35 | ico 文件一般可以用在网页的 logo 和应用程序的 logo。
36 | ico 文件用在网页,一般是把生成的 ico 文件,命名成 favicon.ico,并放到网站的根目录,然后在页面的 head 标签内加入以下代码:
37 |
38 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/ConverterModule.zh-Hant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 轉換器
6 |
7 |
8 | 日期時間轉換器
9 | 將日期和時間轉換為各種不同的格式。
10 |
11 |
12 | JSON到YAML轉換器
13 | 在線轉換將JSON轉換為YAML。
14 | 原始Json格式:
15 | 轉換後的Yaml格式:
16 | 複製
17 | 清空
18 |
19 |
20 | YAML到JSON轉換器
21 | 使用此在線轉換器將YAML轉換為JSON。
22 | 原始YAML格式:
23 | 轉換後的Json格式:
24 | 複製
25 | 清空
26 |
27 |
28 | 圖片轉ico圖標
29 | 圖片文件(格式:png、jpg、jpeg、ico、webp)
30 | 請選擇需要轉換的圖片
31 | 目標尺寸
32 | 合併生成ico圖標
33 | 單獨生成ico圖標
34 | 說明
35 | ico文件一般可以用在網頁的logo和應用程序的logo。
36 | ico文件用在網頁,一般是把生成的ico文件,命名成favicon.ico,並放到網站的根目錄,然後在頁面的head標籤內加入以下代碼:<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
37 |
38 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/Language.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Changes to this file may cause incorrect behavior and will be lost if
5 | // the code is regenerated.
6 | //
7 | //------------------------------------------------------------------------------
8 | namespace Localization
9 | {
10 | public static class ConverterModule
11 | {
12 | public static readonly string Title = "Localization.ConverterModule.Title";
13 | }
14 | }
15 | namespace Localization
16 | {
17 | public static class DateTimeConverterView
18 | {
19 | public static readonly string Title = "Localization.DateTimeConverterView.Title";
20 | public static readonly string Description = "Localization.DateTimeConverterView.Description";
21 | }
22 | }
23 | namespace Localization
24 | {
25 | public static class JsonToYamlView
26 | {
27 | public static readonly string Title = "Localization.JsonToYamlView.Title";
28 | public static readonly string Description = "Localization.JsonToYamlView.Description";
29 | public static readonly string RawJson = "Localization.JsonToYamlView.RawJson";
30 | public static readonly string AfterYaml = "Localization.JsonToYamlView.AfterYaml";
31 | public static readonly string Copy = "Localization.JsonToYamlView.Copy";
32 | public static readonly string Clear = "Localization.JsonToYamlView.Clear";
33 | }
34 | }
35 | namespace Localization
36 | {
37 | public static class YamlToJsonView
38 | {
39 | public static readonly string Title = "Localization.YamlToJsonView.Title";
40 | public static readonly string Description = "Localization.YamlToJsonView.Description";
41 | public static readonly string RawYaml = "Localization.YamlToJsonView.RawYaml";
42 | public static readonly string AfterJson = "Localization.YamlToJsonView.AfterJson";
43 | public static readonly string Copy = "Localization.YamlToJsonView.Copy";
44 | public static readonly string Clear = "Localization.YamlToJsonView.Clear";
45 | }
46 | }
47 | namespace Localization
48 | {
49 | public static class ImageToIconView
50 | {
51 | public static readonly string Title = "Localization.ImageToIconView.Title";
52 | public static readonly string ChoiceSourceImageDescription = "Localization.ImageToIconView.ChoiceSourceImageDescription";
53 | public static readonly string ChoiceSourceImageDialogTitle = "Localization.ImageToIconView.ChoiceSourceImageDialogTitle";
54 | public static readonly string DestImageSize = "Localization.ImageToIconView.DestImageSize";
55 | public static readonly string MergeGenerateButtonContent = "Localization.ImageToIconView.MergeGenerateButtonContent";
56 | public static readonly string SeparateGenerateButtonContent = "Localization.ImageToIconView.SeparateGenerateButtonContent";
57 | public static readonly string MemoTitle = "Localization.ImageToIconView.MemoTitle";
58 | public static readonly string MemoContent1 = "Localization.ImageToIconView.MemoContent1";
59 | public static readonly string MemoContent2 = "Localization.ImageToIconView.MemoContent2";
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/I18n/Language.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="true" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ assembly name="System.Xml" #>
4 | <#@ assembly name="System.Xml.Linq" #>
5 | <#@ import namespace="System.Linq" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Collections.Generic" #>
8 | <#@ import namespace="System.Xml.Linq" #>
9 | <#@ import namespace="System.IO" #>
10 | <#@ output extension=".cs" #>
11 | //------------------------------------------------------------------------------
12 | //
13 | // This code was generated by a tool.
14 | // Changes to this file may cause incorrect behavior and will be lost if
15 | // the code is regenerated.
16 | //
17 | //------------------------------------------------------------------------------
18 | <#
19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault();
21 | if (xmlFilePath!= null)
22 | {
23 | XDocument xdoc = XDocument.Load(xmlFilePath);
24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList();
25 | foreach (var classNode in classNodes)
26 | {
27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName);
28 | string namespaceName = string.Join(".", namespaceSegments);
29 | GenerateClasses(classNode, namespaceName);
30 | }
31 | }
32 | else
33 | {
34 | Write("XML file not found, please ensure that there is an XML file in the current directory");
35 | }
36 |
37 | void GenerateClasses(XElement element, string namespaceName)
38 | {
39 | string className = element.Name.LocalName;
40 | StringBuilder classBuilder = new StringBuilder();
41 | classBuilder.AppendLine($"namespace {namespaceName}");
42 | classBuilder.AppendLine("{");
43 | classBuilder.AppendLine($" public static class {className}");
44 | classBuilder.AppendLine(" {");
45 | var fieldNodes = element.Elements();
46 | foreach (var fieldNode in fieldNodes)
47 | {
48 | var propertyName = fieldNode.Name.LocalName;
49 | var languageKey = $"{namespaceName}.{className}.{propertyName}";
50 | classBuilder.AppendLine($" public static readonly string {propertyName} = \"{languageKey}\";");
51 | }
52 | classBuilder.AppendLine(" }");
53 | classBuilder.AppendLine("}");
54 | Write(classBuilder.ToString());
55 | }
56 | #>
57 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Models/IconSize.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Tools.Extensions;
2 | using ReactiveUI;
3 | using System.ComponentModel;
4 |
5 | namespace CodeWF.Modules.Converter.Models;
6 |
7 | public enum IconSize
8 | {
9 | [Description("16x16")] Size16 = 16,
10 | [Description("24x24")] Size24 = 24,
11 | [Description("32x32")] Size32 = 32,
12 | [Description("48x48")] Size48 = 48,
13 | [Description("64x64")] Size64 = 64,
14 | [Description("128x128")] Size128 = 128,
15 | [Description("256x256")] Size256 = 256
16 | }
17 |
18 | public class IconSizeItem(IconSize size) : ReactiveObject
19 | {
20 | private bool _isSelected = true;
21 |
22 | public bool IsSelected
23 | {
24 | get => _isSelected;
25 | set => this.RaiseAndSetIfChanged(ref _isSelected, value);
26 | }
27 |
28 | public string Content { get; set; } = size.GetDescription();
29 | public IconSize Size { get; set; } = size;
30 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/ViewModels/DateTimeConverterViewModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace CodeWF.Modules.Converter.ViewModels;
4 |
5 | internal class DateTimeConverterViewModel : ReactiveObject
6 | {
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/ViewModels/JsonToYamlViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using AvaloniaEdit;
3 | using CodeWF.Tools.Extensions;
4 | using ReactiveUI;
5 | using System.Reactive;
6 | using System.Reactive.Linq;
7 |
8 | namespace CodeWF.Modules.Converter.ViewModels;
9 |
10 | public class JsonToYamlViewModel : ReactiveObject
11 | {
12 | public TextEditor? JsonEditor { get; set; }
13 | public TextEditor? YamlEditor { get; set; }
14 |
15 | public JsonToYamlViewModel()
16 | {
17 | RaiseClearCommand = ReactiveCommand.CreateFromTask(RaiseClearHandlerAsync);
18 | RaiseCopyCommand = ReactiveCommand.CreateFromTask(RaiseCopyHandlerAsync);
19 | }
20 |
21 | public void StartListen()
22 | {
23 | this.WhenAnyValue(x => x.JsonString)
24 | .Throttle(TimeSpan.FromMilliseconds(400))
25 | .ObserveOn(RxApp.MainThreadScheduler)
26 | .Subscribe(_ => JsonChanged());
27 | JsonEditor!.TextChanged += (s, e) => JsonString = JsonEditor.Text;
28 | }
29 |
30 | private string? _jsonString;
31 |
32 | public string? JsonString
33 | {
34 | get => _jsonString;
35 | set => this.RaiseAndSetIfChanged(ref _jsonString, value);
36 | }
37 |
38 | private string? _errorMessage;
39 |
40 | public string? ErrorMessage
41 | {
42 | get => _errorMessage;
43 | set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
44 | }
45 |
46 | public ReactiveCommand RaiseClearCommand { get; }
47 | public ReactiveCommand RaiseCopyCommand { get; }
48 |
49 | private void JsonChanged()
50 | {
51 | if (JsonEditor == null || YamlEditor == null)
52 | {
53 | return;
54 | }
55 |
56 | if (JsonString.JsonToYaml(out var jsonString, out string? errorMsg))
57 | {
58 | YamlEditor.Text = jsonString;
59 | ErrorMessage = default;
60 | }
61 | else
62 | {
63 | YamlEditor.Text = default;
64 | ErrorMessage = errorMsg;
65 | }
66 | }
67 |
68 | private async Task RaiseClearHandlerAsync()
69 | {
70 | JsonEditor?.Clear();
71 | }
72 |
73 | private async Task RaiseCopyHandlerAsync()
74 | {
75 | TopLevel.GetTopLevel(YamlEditor)?.Clipboard?.SetTextAsync(YamlEditor.Text);
76 | }
77 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/ViewModels/YamlToJsonViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using AvaloniaEdit;
3 | using CodeWF.Tools.Extensions;
4 | using ReactiveUI;
5 | using System.Reactive;
6 | using System.Reactive.Linq;
7 |
8 | namespace CodeWF.Modules.Converter.ViewModels;
9 |
10 | public class YamlToJsonViewModel : ReactiveObject
11 | {
12 | public TextEditor? JsonEditor { get; set; }
13 | public TextEditor? YamlEditor { get; set; }
14 |
15 | public YamlToJsonViewModel()
16 | {
17 | RaiseClearCommand = ReactiveCommand.CreateFromTask(RaiseClearHandlerAsync);
18 | RaiseCopyCommand = ReactiveCommand.CreateFromTask(RaiseCopyHandlerAsync);
19 | }
20 |
21 | public void StartListen()
22 | {
23 | this.WhenAnyValue(x => x.YamlString)
24 | .Throttle(TimeSpan.FromMilliseconds(400))
25 | .ObserveOn(RxApp.MainThreadScheduler)
26 | .Subscribe(_ => YamlChanged());
27 | YamlEditor!.TextChanged += (s, e) => YamlString = YamlEditor.Text;
28 | }
29 |
30 | private string? _yamlString;
31 |
32 | public string? YamlString
33 | {
34 | get => _yamlString;
35 | set => this.RaiseAndSetIfChanged(ref _yamlString, value);
36 | }
37 |
38 |
39 | private string? _errorMessage;
40 |
41 | public string? ErrorMessage
42 | {
43 | get => _errorMessage;
44 | set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
45 | }
46 |
47 | public ReactiveCommand RaiseClearCommand { get; }
48 | public ReactiveCommand RaiseCopyCommand { get; }
49 |
50 | private void YamlChanged()
51 | {
52 | if (JsonEditor == null || YamlEditor == null)
53 | {
54 | return;
55 | }
56 |
57 | if (YamlString.YamlToJson(out var jsonString, out string? errorMsg))
58 | {
59 | JsonEditor.Text = jsonString;
60 | ErrorMessage = default;
61 | }
62 | else
63 | {
64 | JsonEditor.Text = default;
65 | ErrorMessage = errorMsg;
66 | }
67 | }
68 |
69 | private async Task RaiseClearHandlerAsync()
70 | {
71 | YamlEditor?.Clear();
72 | }
73 |
74 | private async Task RaiseCopyHandlerAsync()
75 | {
76 | TopLevel.GetTopLevel(JsonEditor)?.Clipboard?.SetTextAsync(JsonEditor.Text);
77 | }
78 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/DateTimeConverterView.axaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/DateTimeConverterView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace CodeWF.Modules.Converter.Views;
5 |
6 | public partial class DateTimeConverterView : UserControl
7 | {
8 | public DateTimeConverterView()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/ImageToIconView.axaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
40 |
43 |
44 |
45 |
47 |
48 |
49 |
50 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/ImageToIconView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Modules.Converter;
4 |
5 | public partial class ImageToIconView : UserControl
6 | {
7 | public ImageToIconView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/JsonToYamlView.axaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
25 |
26 |
33 |
34 |
44 |
45 |
51 |
52 |
56 |
57 |
64 |
65 |
76 |
77 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/JsonToYamlView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using AvaloniaEdit;
4 | using AvaloniaEdit.TextMate;
5 | using CodeWF.Modules.Converter.ViewModels;
6 | using TextMateSharp.Grammars;
7 |
8 | namespace CodeWF.Modules.Converter.Views;
9 |
10 | public partial class JsonToYamlView : UserControl
11 | {
12 | public JsonToYamlView()
13 | {
14 | InitializeComponent();
15 |
16 | //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
17 | var jsonEditor = this.FindControl("JsonEditor");
18 | var yamlEditor = this.FindControl("YamlEditor");
19 |
20 | //Here we initialize RegistryOptions with the theme we want to use.
21 | var registryOptions = new RegistryOptions(ThemeName.DarkPlus);
22 |
23 | //Initial setup of TextMate.
24 | var jsonTextMateInstallation = jsonEditor.InstallTextMate(registryOptions);
25 | var yamlTextMateInstallation = yamlEditor.InstallTextMate(registryOptions);
26 |
27 | //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
28 | //And that's all ??, you are ready to use AvaloniaEdit with syntax highlighting!
29 | jsonTextMateInstallation.SetGrammar(
30 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
31 | yamlTextMateInstallation.SetGrammar(
32 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
33 |
34 | if (DataContext is not JsonToYamlViewModel vm)
35 | {
36 | return;
37 | }
38 |
39 | vm.JsonEditor = jsonEditor;
40 | vm.YamlEditor = yamlEditor;
41 | vm.StartListen();
42 | }
43 |
44 | private void InitializeComponent()
45 | {
46 | AvaloniaXamlLoader.Load(this);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/YamlToJsonView.axaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
25 |
26 |
33 |
34 |
44 |
45 |
51 |
52 |
56 |
57 |
64 |
65 |
75 |
76 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Converter/Views/YamlToJsonView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using AvaloniaEdit;
4 | using AvaloniaEdit.TextMate;
5 | using CodeWF.Modules.Converter.ViewModels;
6 | using TextMateSharp.Grammars;
7 |
8 | namespace CodeWF.Modules.Converter.Views;
9 |
10 | public partial class YamlToJsonView : UserControl
11 | {
12 | public YamlToJsonView()
13 | {
14 | InitializeComponent();
15 |
16 | //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
17 | var jsonEditor = this.FindControl("JsonEditor");
18 | var yamlEditor = this.FindControl("YamlEditor");
19 |
20 | //Here we initialize RegistryOptions with the theme we want to use.
21 | var registryOptions = new RegistryOptions(ThemeName.DarkPlus);
22 |
23 | //Initial setup of TextMate.
24 | var jsonTextMateInstallation = jsonEditor.InstallTextMate(registryOptions);
25 | var yamlTextMateInstallation = yamlEditor.InstallTextMate(registryOptions);
26 |
27 | //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
28 | //And that's all ??, you are ready to use AvaloniaEdit with syntax highlighting!
29 | jsonTextMateInstallation.SetGrammar(
30 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
31 | yamlTextMateInstallation.SetGrammar(
32 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
33 |
34 | if (DataContext is not YamlToJsonViewModel vm)
35 | {
36 | return;
37 | }
38 |
39 | vm.JsonEditor = jsonEditor;
40 | vm.YamlEditor = yamlEditor;
41 | vm.StartListen();
42 | }
43 |
44 | private void InitializeComponent()
45 | {
46 | AvaloniaXamlLoader.Load(this);
47 | }
48 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Assets/OvertimeAlarm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Modules.Development/Assets/OvertimeAlarm.png
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Assets/OvertimeAll.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Modules.Development/Assets/OvertimeAll.png
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Assets/OvertimeNormal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Modules.Development/Assets/OvertimeNormal.png
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/CodeWF.Modules.Development.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 | $(InterceptorsPreviewNamespaces);Dapper.AOT
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | True
18 | True
19 | Language.tt
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | True
39 | True
40 | Language.tt
41 |
42 |
43 |
44 |
45 |
46 | PreserveNewest
47 |
48 |
49 | PreserveNewest
50 |
51 |
52 | PreserveNewest
53 |
54 |
55 | TextTemplatingFileGenerator
56 | Language.cs
57 |
58 |
59 | PreserveNewest
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Converters/WarningKindDescriptionConverter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Data.Converters;
2 | using AvaloniaXmlTranslator;
3 | using CodeWF.Modules.Development.Models;
4 | using CodeWF.Tools.Extensions;
5 | using System.Globalization;
6 |
7 | namespace CodeWF.Modules.Development.Converters;
8 |
9 | public class WarningKindDescriptionConverter : IValueConverter
10 | {
11 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
12 | {
13 | if (value is WarningKind kind)
14 | {
15 | return kind.GetDescription();
16 | }
17 |
18 | return "Nothing";
19 | }
20 |
21 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
22 | {
23 | throw new NotImplementedException();
24 | }
25 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Converters/WarningKindImageConverter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Data.Converters;
2 | using Avalonia.Media.Imaging;
3 | using Avalonia.Platform;
4 | using CodeWF.Modules.Development.Models;
5 | using System.Globalization;
6 |
7 | namespace CodeWF.Modules.Development.Converters;
8 |
9 | public class WarningKindImageConverter : IValueConverter
10 | {
11 | private static readonly Dictionary KindImages = new()
12 | {
13 | {
14 | WarningKind.All,
15 | new Bitmap(AssetLoader.Open(new Uri("avares://CodeWF.Modules.Development/Assets/OvertimeAll.png")))
16 | },
17 | {
18 | WarningKind.Warning,
19 | new Bitmap(AssetLoader.Open(new Uri("avares://CodeWF.Modules.Development/Assets/OvertimeAlarm.png")))
20 | },
21 | {
22 | WarningKind.Normal,
23 | new Bitmap(AssetLoader.Open(new Uri("avares://CodeWF.Modules.Development/Assets/OvertimeNormal.png")))
24 | }
25 | };
26 |
27 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
28 | {
29 | if (value is WarningKind kind)
30 | {
31 | return KindImages[kind];
32 | }
33 |
34 | return null;
35 | }
36 |
37 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
38 | {
39 | throw new NotImplementedException();
40 | }
41 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/DevelopmentModule.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core;
2 | using CodeWF.Core.Models;
3 | using CodeWF.Modules.Development.Views;
4 |
5 | namespace CodeWF.Modules.Development;
6 |
7 | public class DevelopmentModule : IModule
8 | {
9 | public DevelopmentModule(IToolMenuService toolMenuService)
10 | {
11 | var groupName = Localization.DevelopmentModule.Title;
12 | toolMenuService.AddSeparator();
13 | toolMenuService.AddGroup(groupName, Icons.Development);
14 | toolMenuService.AddItem(Localization.YamlPrettifyView.Title, groupName,
15 | Localization.YamlPrettifyView.Description, nameof(YamlPrettifyView),
16 | Icons.Yaml,
17 | ToolStatus.Complete);
18 | toolMenuService.AddItem(Localization.JsonPrettifyView.Title, groupName,
19 | Localization.JsonPrettifyView.Description, nameof(JsonPrettifyView),
20 | Icons.Json,
21 | ToolStatus.Complete);
22 | toolMenuService.AddItem(Localization.TestView.Title, groupName, Localization.TestView.Description,
23 | nameof(TestView),
24 | Icons.Json,
25 | ToolStatus.Developing);
26 | }
27 |
28 | public void OnInitialized(IContainerProvider containerProvider)
29 | {
30 | IRegionManager? regionManager = containerProvider.Resolve();
31 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
32 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
33 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
34 | }
35 |
36 | public void RegisterTypes(IContainerRegistry containerRegistry)
37 | {
38 | }
39 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Entities/JsonPrettifyEntity.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.Development.Entities;
2 |
3 | public class JsonPrettifyEntity
4 | {
5 | public bool IsSortKey { get; set; }
6 | public int IndentSize { get; set; }
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Helpers/ConfigHelper.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.ConfigDB;
2 | using CodeWF.Modules.Development.Entities;
3 | using Dapper;
4 | using Microsoft.Data.Sqlite;
5 |
6 | namespace CodeWF.Modules.Development.Helpers;
7 |
8 | public static class ConfigHelper
9 | {
10 | [DapperAot]
11 | public static bool EnsureTableIsCreated()
12 | {
13 | try
14 | {
15 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
16 | connection.Open();
17 |
18 | const string sql = $@"
19 | CREATE TABLE IF NOT EXISTS {nameof(JsonPrettifyEntity)}(
20 | {nameof(JsonPrettifyEntity.IsSortKey)} Bool,
21 | {nameof(JsonPrettifyEntity.IndentSize)} INTEGER
22 | )";
23 |
24 | using var command = new SqliteCommand(sql, connection);
25 | return command.ExecuteNonQuery() > 0;
26 | }
27 | catch (Exception ex)
28 | {
29 | return false;
30 | }
31 | }
32 |
33 | [DapperAot]
34 | public static JsonPrettifyEntity GetJsonPrettifyConfig()
35 | {
36 | try
37 | {
38 | EnsureTableIsCreated();
39 |
40 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
41 | connection.Open();
42 |
43 | const string sql =
44 | $@"SELECT {nameof(JsonPrettifyEntity.IsSortKey)},{nameof(JsonPrettifyEntity.IndentSize)} FROM {nameof(JsonPrettifyEntity)}";
45 | var config = connection.QueryFirstOrDefault(sql);
46 | config ??= new JsonPrettifyEntity() { IsSortKey = false, IndentSize = 2 };
47 |
48 | return config;
49 | }
50 | catch (Exception ex)
51 | {
52 | return new JsonPrettifyEntity() { IsSortKey = false, IndentSize = 2 };
53 | }
54 | }
55 |
56 | [DapperAot]
57 | public static bool UpdateJsonPrettifyConfig(JsonPrettifyEntity config)
58 | {
59 | try
60 | {
61 | EnsureTableIsCreated();
62 |
63 | using var connection = new SqliteConnection(DBConst.DBConnectionString);
64 | connection.Open();
65 | connection.Execute($"DELETE FROM {nameof(JsonPrettifyEntity)}");
66 | var result = connection.Execute(
67 | @$"INSERT INTO {nameof(JsonPrettifyEntity)}({nameof(JsonPrettifyEntity.IsSortKey)},{nameof(JsonPrettifyEntity.IndentSize)})
68 | VALUES(@{nameof(JsonPrettifyEntity.IsSortKey)},@{nameof(JsonPrettifyEntity.IndentSize)})",
69 | config);
70 | return result > 0;
71 | }
72 | catch (Exception ex)
73 | {
74 | return false;
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/DevelopmentModule.en-US.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Development
6 |
7 |
8 | YAML Beautification and Formatting
9 | Modify the YAML string into a user-friendly and readable format.
10 | Original Yaml format
11 | Beautified Yaml format
12 |
13 |
14 | JSON Beautification and Formatting
15 | Modify the JSON string into a user-friendly and readable format.
16 | Original Json format:
17 | Formatted Json format:
18 | Sort Keys:
19 | Indentation of fields:
20 |
21 |
22 | Test
23 | During the tool development process, test some functions.
24 | Compressed Files
25 | Decompressed Files
26 | Select the list of files to be compressed
27 | Save the compressed file
28 | Compressed File Exception
29 | Compressed File Exception: {0}
30 | Select the directory to save after decompression
31 | Select the directory to save after decompression
32 | Decompressed File Exception
33 | Decompressed File Exception: {0}
34 | Timeout Alarm
35 | Show All
36 | Filter Alarms
37 | Filter Normal
38 |
39 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/DevelopmentModule.ja-JP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 開発
6 |
7 |
8 | YAMLの美化とフォーマット
9 | YAML文字列を読みやすいフレンドリーな形式に整形します。
10 | 元のYaml形式
11 | 美化されたYaml形式
12 |
13 |
14 | JSONの美化とフォーマット
15 | JSON文字列を読みやすいフレンドリーな形式に整形します。
16 | 元のJson形式:
17 | フォーマットされたJson形式:
18 | キーの並び替え:
19 | フィールドのインデント:
20 |
21 |
22 | テスト
23 | ツール開発過程で、一部の機能をテストする。
24 | 圧縮ファイル
25 | 解凍ファイル
26 | 圧縮するファイルのリストを選択する
27 | 圧縮ファイルを保存する
28 | 圧縮ファイルのエラー
29 | 圧縮ファイルのエラー: {0}
30 | 解凍後に保存するディレクトリを選択する
31 | 解凍後に保存するディレクトリを選択する
32 | 解凍ファイルのエラー
33 | 解凍ファイルのエラー: {0}
34 | タイムアウトアラーム
35 | すべて表示
36 | アラームをフィルターする
37 | 正常をフィルターする
38 |
39 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/DevelopmentModule.zh-CN.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 开发
6 |
7 |
8 | YAML美化和格式化
9 | 将YAML字符串修饰为友好的可读格式。
10 | 原始Yaml格式
11 | 美化后的Yaml格式
12 |
13 |
14 | JSON美化和格式化
15 | 将JSON字符串修饰为友好的可读格式。
16 | 原始Json格式:
17 | 格式化后的Json格式:
18 | 对Key排序:
19 | 字段缩进:
20 |
21 |
22 | 测试
23 | 工具开发过程中,部分功能测试
24 | 压缩文件
25 | 解压文件
26 | 选择要压缩的文件列表
27 | 保存压缩文件
28 | 压缩文件异常
29 | 压缩文件异常: {0}
30 | 解压后选择要保存的目录
31 | 解压后选择要保存的目录
32 | 解压文件异常
33 | 解压文件异常: {0}
34 | 超时告警
35 | 显示全部
36 | 筛选告警
37 | 筛选正常
38 |
39 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/DevelopmentModule.zh-Hant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 開發
6 |
7 |
8 | YAML美化和格式化
9 | 將YAML字串修飾為友好的可讀格式。
10 | 原始Yaml格式
11 | 美化後的Yaml格式
12 |
13 |
14 | JSON美化和格式化
15 | 將JSON字串修飾為友好的可讀格式。
16 | 原始Json格式:
17 | 格式化後的Json格式:
18 | 對Key排序:
19 | 欄位縮進:
20 |
21 |
22 | 測試
23 | 工具開發過程中,部分功能測試
24 | 壓縮文件
25 | 解壓文件
26 | 選擇要壓縮的文件列表
27 | 保存壓縮文件
28 | 壓縮文件異常
29 | 壓縮文件異常: {0}
30 | 解壓後選擇要保存的目錄
31 | 解壓後選擇要保存的目錄
32 | 解壓文件異常
33 | 解壓文件異常: {0}
34 | 超時告警
35 | 顯示全部
36 | 篩選告警
37 | 篩選正常
38 |
39 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/Language.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Changes to this file may cause incorrect behavior and will be lost if
5 | // the code is regenerated.
6 | //
7 | //------------------------------------------------------------------------------
8 | namespace Localization
9 | {
10 | public class DevelopmentModule
11 | {
12 | public const string Title = "Localization.DevelopmentModule.Title";
13 | }
14 | }
15 | namespace Localization
16 | {
17 | public class YamlPrettifyView
18 | {
19 | public const string Title = "Localization.YamlPrettifyView.Title";
20 | public const string Description = "Localization.YamlPrettifyView.Description";
21 | public const string RawYaml = "Localization.YamlPrettifyView.RawYaml";
22 | public const string PrettifiedVersionYAML = "Localization.YamlPrettifyView.PrettifiedVersionYAML";
23 | }
24 | }
25 | namespace Localization
26 | {
27 | public class JsonPrettifyView
28 | {
29 | public const string Title = "Localization.JsonPrettifyView.Title";
30 | public const string Description = "Localization.JsonPrettifyView.Description";
31 | public const string RawJson = "Localization.JsonPrettifyView.RawJson";
32 | public const string PrettifiedVersionJSON = "Localization.JsonPrettifyView.PrettifiedVersionJSON";
33 | public const string SortKey = "Localization.JsonPrettifyView.SortKey";
34 | public const string IndentSize = "Localization.JsonPrettifyView.IndentSize";
35 | }
36 | }
37 | namespace Localization
38 | {
39 | public class TestView
40 | {
41 | public const string Title = "Localization.TestView.Title";
42 | public const string Description = "Localization.TestView.Description";
43 | public const string CompressFiles = "Localization.TestView.CompressFiles";
44 | public const string DecompressionFiles = "Localization.TestView.DecompressionFiles";
45 | public const string SelectCompressFiles = "Localization.TestView.SelectCompressFiles";
46 | public const string SaveCompressedFile = "Localization.TestView.SaveCompressedFile";
47 | public const string CompressFileExceptionTitle = "Localization.TestView.CompressFileExceptionTitle";
48 | public const string CompressFileExceptionContent = "Localization.TestView.CompressFileExceptionContent";
49 | public const string SelectDecompressionFile = "Localization.TestView.SelectDecompressionFile";
50 | public const string SelectDirectory = "Localization.TestView.SelectDirectory";
51 | public const string DecompressionFileExceptionTitle = "Localization.TestView.DecompressionFileExceptionTitle";
52 | public const string DecompressionFileExceptionContent = "Localization.TestView.DecompressionFileExceptionContent";
53 | public const string TimeoutAlarm = "Localization.TestView.TimeoutAlarm";
54 | public const string ShowAll = "Localization.TestView.ShowAll";
55 | public const string FilterAlarms = "Localization.TestView.FilterAlarms";
56 | public const string FilterNormal = "Localization.TestView.FilterNormal";
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/I18n/Language.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="true" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ assembly name="System.Xml" #>
4 | <#@ assembly name="System.Xml.Linq" #>
5 | <#@ import namespace="System.Linq" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Collections.Generic" #>
8 | <#@ import namespace="System.Xml.Linq" #>
9 | <#@ import namespace="System.IO" #>
10 | <#@ output extension=".cs" #>
11 | //------------------------------------------------------------------------------
12 | //
13 | // This code was generated by a tool.
14 | // Changes to this file may cause incorrect behavior and will be lost if
15 | // the code is regenerated.
16 | //
17 | //------------------------------------------------------------------------------
18 | <#
19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault();
21 | if (xmlFilePath!= null)
22 | {
23 | XDocument xdoc = XDocument.Load(xmlFilePath);
24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList();
25 | foreach (var classNode in classNodes)
26 | {
27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName);
28 | string namespaceName = string.Join(".", namespaceSegments);
29 | GenerateClasses(classNode, namespaceName);
30 | }
31 | }
32 | else
33 | {
34 | Write("XML file not found, please ensure that there is an XML file in the current directory");
35 | }
36 |
37 | void GenerateClasses(XElement element, string namespaceName)
38 | {
39 | string className = element.Name.LocalName;
40 | StringBuilder classBuilder = new StringBuilder();
41 | classBuilder.AppendLine($"namespace {namespaceName}");
42 | classBuilder.AppendLine("{");
43 | classBuilder.AppendLine($" public class {className}");
44 | classBuilder.AppendLine(" {");
45 | var fieldNodes = element.Elements();
46 | foreach (var fieldNode in fieldNodes)
47 | {
48 | var propertyName = fieldNode.Name.LocalName;
49 | var languageKey = $"{namespaceName}.{className}.{propertyName}";
50 | classBuilder.AppendLine($" public const string {propertyName} = \"{languageKey}\";");
51 | }
52 | classBuilder.AppendLine(" }");
53 | classBuilder.AppendLine("}");
54 | Write(classBuilder.ToString());
55 | }
56 | #>
57 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Jobs/DailyTimeJob.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Modules.Development.ViewModels;
2 | using Quartz;
3 |
4 | namespace CodeWF.Modules.Development.Jobs;
5 |
6 | internal class DailyTimeJob : IJob
7 | {
8 | public async Task Execute(IJobExecutionContext context)
9 | {
10 | await Task.Run(() =>
11 | {
12 | TestViewModel.Instance.DailyTimeTask = $"{DateTime.Now:yyyy:MM:dd HH:mm:ss}: The daily task has been triggered";
13 | });
14 | }
15 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Jobs/UpdateTimeJob.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Modules.Development.ViewModels;
2 | using Quartz;
3 |
4 | namespace CodeWF.Modules.Development.Jobs;
5 |
6 | internal class UpdateTimeJob : IJob
7 | {
8 | public async Task Execute(IJobExecutionContext context)
9 | {
10 | await Task.Run(() =>
11 | {
12 | TestViewModel.Instance.CurrentTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
13 | });
14 | }
15 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Models/WarningKind.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace CodeWF.Modules.Development.Models;
4 |
5 | public enum WarningKind
6 | {
7 | [Description(Localization.TestView.ShowAll)]
8 | All,
9 |
10 | [Description(Localization.TestView.FilterAlarms)]
11 | Warning,
12 |
13 | [Description(Localization.TestView.FilterNormal)]
14 | Normal
15 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/ViewModels/YamlPrettifyViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using AvaloniaEdit;
3 | using CodeWF.Tools.Extensions;
4 | using ReactiveUI;
5 | using System.Reactive;
6 | using System.Reactive.Linq;
7 |
8 | namespace CodeWF.Modules.Development.ViewModels;
9 |
10 | public class YamlPrettifyViewModel : ReactiveObject
11 | {
12 | public TextEditor? YamlTextEditor { get; set; }
13 |
14 | public YamlPrettifyViewModel()
15 | {
16 | RaiseCopyCommand = ReactiveCommand.CreateFromTask(RaiseCopyHandlerAsync);
17 |
18 | this.WhenAnyValue(x => x.RawYaml)
19 | .Throttle(TimeSpan.FromMilliseconds(400))
20 | .ObserveOn(RxApp.MainThreadScheduler)
21 | .Subscribe(RawYamlChanged);
22 | }
23 |
24 | private string? _rawYaml;
25 |
26 | public string? RawYaml
27 | {
28 | get => _rawYaml;
29 | set => this.RaiseAndSetIfChanged(ref _rawYaml, value);
30 | }
31 |
32 | private string? _errorMessage;
33 |
34 | public string? ErrorMessage
35 | {
36 | get => _errorMessage;
37 | set => this.RaiseAndSetIfChanged(ref _errorMessage, value);
38 | }
39 |
40 | public ReactiveCommand RaiseCopyCommand { get; }
41 |
42 | private void RawYamlChanged(string? newRawYaml)
43 | {
44 | if (RawYaml.YamlPrettify(out var newYaml, out var errorMessage))
45 | {
46 | YamlTextEditor!.Text = newYaml;
47 | ErrorMessage = default;
48 | }
49 | else
50 | {
51 | YamlTextEditor!.Text = string.Empty;
52 | ErrorMessage = errorMessage;
53 | }
54 | }
55 |
56 | private async Task RaiseCopyHandlerAsync()
57 | {
58 | TopLevel.GetTopLevel(YamlTextEditor)?.Clipboard?.SetTextAsync(YamlTextEditor.Text);
59 | }
60 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Views/JsonPrettifyView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using AvaloniaEdit;
4 | using AvaloniaEdit.TextMate;
5 | using CodeWF.Modules.Development.ViewModels;
6 | using TextMateSharp.Grammars;
7 |
8 | namespace CodeWF.Modules.Development.Views;
9 |
10 | public partial class JsonPrettifyView : UserControl
11 | {
12 | public JsonPrettifyView()
13 | {
14 | InitializeComponent();
15 |
16 | //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
17 | var formatEditor = this.FindControl("FormatEditor");
18 |
19 | //Here we initialize RegistryOptions with the theme we want to use.
20 | var registryOptions = new RegistryOptions(ThemeName.DarkPlus);
21 |
22 | //Initial setup of TextMate.
23 | var textMateInstallation = formatEditor.InstallTextMate(registryOptions);
24 |
25 | //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
26 | //And that's all ??, you are ready to use AvaloniaEdit with syntax highlighting!
27 | textMateInstallation.SetGrammar(
28 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
29 | ((DataContext as JsonPrettifyViewModel)!).FormatEditor = formatEditor;
30 |
31 |
32 | var noFormatEditor = this.FindControl("NoFormatEditor");
33 | ((DataContext as JsonPrettifyViewModel)!).NoFormatEditor = noFormatEditor;
34 | }
35 |
36 | private void InitializeComponent()
37 | {
38 | AvaloniaXamlLoader.Load(this);
39 | }
40 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Views/TestView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace CodeWF.Modules.Development.Views;
5 |
6 | public partial class TestView : UserControl
7 | {
8 | public TestView()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Views/YamlPrettifyView.axaml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
34 |
35 |
41 |
42 |
46 |
53 |
54 |
59 |
60 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.Development/Views/YamlPrettifyView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using AvaloniaEdit;
4 | using AvaloniaEdit.TextMate;
5 | using CodeWF.Modules.Development.ViewModels;
6 | using TextMateSharp.Grammars;
7 |
8 | namespace CodeWF.Modules.Development.Views;
9 |
10 | public partial class YamlPrettifyView : UserControl
11 | {
12 | public YamlPrettifyView()
13 | {
14 | InitializeComponent();
15 |
16 | //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
17 | var textEditor = this.FindControl("Editor");
18 |
19 | //Here we initialize RegistryOptions with the theme we want to use.
20 | var registryOptions = new RegistryOptions(ThemeName.DarkPlus);
21 |
22 | //Initial setup of TextMate.
23 | var textMateInstallation = textEditor.InstallTextMate(registryOptions);
24 |
25 | //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
26 | //And that's all ??, you are ready to use AvaloniaEdit with syntax highlighting!
27 | textMateInstallation.SetGrammar(registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
28 | ((DataContext as YamlPrettifyViewModel)!).YamlTextEditor = textEditor;
29 | }
30 |
31 | private void InitializeComponent()
32 | {
33 | AvaloniaXamlLoader.Load(this);
34 | }
35 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/CodeWF.Modules.XmlTranslatorManager.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 |
10 |
11 | True
12 | True
13 | Language.tt
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | True
36 | True
37 | Language.tt
38 |
39 |
40 |
41 |
42 |
43 | PreserveNewest
44 |
45 |
46 | PreserveNewest
47 |
48 |
49 | PreserveNewest
50 |
51 |
52 | TextTemplatingFileGenerator
53 | Language.cs
54 |
55 |
56 | PreserveNewest
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/Language.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Changes to this file may cause incorrect behavior and will be lost if
5 | // the code is regenerated.
6 | //
7 | //------------------------------------------------------------------------------
8 | namespace Localization
9 | {
10 | public static class XmlTranslatorManager
11 | {
12 | public static readonly string Title = "Localization.XmlTranslatorManager.Title";
13 | }
14 | }
15 | namespace Localization
16 | {
17 | public static class MergeXmlFilesView
18 | {
19 | public static readonly string Title = "Localization.MergeXmlFilesView.Title";
20 | public static readonly string Description = "Localization.MergeXmlFilesView.Description";
21 | public static readonly string SelectLanguageDirectory = "Localization.MergeXmlFilesView.SelectLanguageDirectory";
22 | public static readonly string InputMergedXmlFileName = "Localization.MergeXmlFilesView.InputMergedXmlFileName";
23 | public static readonly string MergeFiles = "Localization.MergeXmlFilesView.MergeFiles";
24 | public static readonly string NoLanguageFilesTitle = "Localization.MergeXmlFilesView.NoLanguageFilesTitle";
25 | public static readonly string NoLanguageFilesContent = "Localization.MergeXmlFilesView.NoLanguageFilesContent";
26 | public static readonly string WrongNewXmlFileNameTitle = "Localization.MergeXmlFilesView.WrongNewXmlFileNameTitle";
27 | public static readonly string WrongNewXmlFileNameContent = "Localization.MergeXmlFilesView.WrongNewXmlFileNameContent";
28 | public static readonly string MergeXmlFilesExceptionTitle = "Localization.MergeXmlFilesView.MergeXmlFilesExceptionTitle";
29 | public static readonly string MergeXmlFilesExceptionContent = "Localization.MergeXmlFilesView.MergeXmlFilesExceptionContent";
30 | public static readonly string ReadXmlFilesExceptionTitle = "Localization.MergeXmlFilesView.ReadXmlFilesExceptionTitle";
31 | public static readonly string ReadXmlFilesExceptionContent = "Localization.MergeXmlFilesView.ReadXmlFilesExceptionContent";
32 | }
33 | }
34 | namespace Localization
35 | {
36 | public static class ManageXmlFilesView
37 | {
38 | public static readonly string Title = "Localization.ManageXmlFilesView.Title";
39 | public static readonly string Description = "Localization.ManageXmlFilesView.Description";
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/Language.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="true" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ assembly name="System.Xml" #>
4 | <#@ assembly name="System.Xml.Linq" #>
5 | <#@ import namespace="System.Linq" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Collections.Generic" #>
8 | <#@ import namespace="System.Xml.Linq" #>
9 | <#@ import namespace="System.IO" #>
10 | <#@ output extension=".cs" #>
11 | //------------------------------------------------------------------------------
12 | //
13 | // This code was generated by a tool.
14 | // Changes to this file may cause incorrect behavior and will be lost if
15 | // the code is regenerated.
16 | //
17 | //------------------------------------------------------------------------------
18 | <#
19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault();
21 | if (xmlFilePath!= null)
22 | {
23 | XDocument xdoc = XDocument.Load(xmlFilePath);
24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList();
25 | foreach (var classNode in classNodes)
26 | {
27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName);
28 | string namespaceName = string.Join(".", namespaceSegments);
29 | GenerateClasses(classNode, namespaceName);
30 | }
31 | }
32 | else
33 | {
34 | Write("XML file not found, please ensure that there is an XML file in the current directory");
35 | }
36 |
37 | void GenerateClasses(XElement element, string namespaceName)
38 | {
39 | string className = element.Name.LocalName;
40 | StringBuilder classBuilder = new StringBuilder();
41 | classBuilder.AppendLine($"namespace {namespaceName}");
42 | classBuilder.AppendLine("{");
43 | classBuilder.AppendLine($" public static class {className}");
44 | classBuilder.AppendLine(" {");
45 | var fieldNodes = element.Elements();
46 | foreach (var fieldNode in fieldNodes)
47 | {
48 | var propertyName = fieldNode.Name.LocalName;
49 | var languageKey = $"{namespaceName}.{className}.{propertyName}";
50 | classBuilder.AppendLine($" public static readonly string {propertyName} = \"{languageKey}\";");
51 | }
52 | classBuilder.AppendLine(" }");
53 | classBuilder.AppendLine("}");
54 | Write(classBuilder.ToString());
55 | }
56 | #>
57 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/XmlTranslatorManagerModule.en-US.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XML Internationalization Management
6 |
7 |
8 | XML Multi-module File Merging
9 | Integrate XML language files, suitable for multi-module programs, such as programs using Prism. Please backup files before merging.
10 | Select Language Directory
11 | Please enter the file name of the merged XML language file
12 | Merge Files
13 | No Language Files
14 | Please select the language directory first and then perform the merge
15 | Wrong New XML Language File Name
16 | The input file name needs to meet the file name format
17 | Exception in Merging XML Language Files
18 | Please check whether the content of the existing XML language files is valid: {0}
19 | Exception in Reading XML Language Files
20 | Please check whether the content of the XML language files is valid: {0}
21 |
22 |
23 | XML Multilingual Management
24 | Centralize the management and maintenance of XML multilingual data.
25 |
26 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/XmlTranslatorManagerModule.ja-JP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XMLの国際化管理
6 |
7 |
8 | XMLの複数モジュールファイルのマージ
9 | XML言語ファイルを統合し、Prismを使用しているなどの複数モジュールのプログラムに適しています。マージ前にファイルのバックアップを行ってください。
10 | 言語ディレクトリを選択する
11 | マージ後の言語XMLファイル名を入力してください
12 | ファイルをマージする
13 | 言語ファイルがありません
14 | マージを実行する前に、まず言語ディレクトリを選択してください
15 | 新しいXML言語ファイル名が間違っています
16 | 入力するファイル名はファイル名のフォーマットを満たす必要があります
17 | XML言語ファイルのマージに異常が発生しました
18 | 既存のXML言語ファイルの内容が正しいかどうかを確認してください: {0}
19 | XML言語ファイルの読み取りに異常が発生しました
20 | XML言語ファイルの内容が正しいかどうかを確認してください: {0}
21 |
22 |
23 | XMLの多言語管理
24 | XMLの多言語データを集中的に管理およびメンテナンスします。
25 |
26 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/XmlTranslatorManagerModule.zh-CN.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XML国际化管理
6 |
7 |
8 | XML 多模块文件合并
9 | 整合 XML 语言文件,适合多模块程序,比如使用了Prism的程序,合并前注意文件备份
10 | 选择语言目录
11 | 请输入合并后的语言XML文件名
12 | 合并文件
13 | 没有语言文件
14 | 请先选择语言目录后再执行合并
15 | 错误的新XML语言文件名
16 | 输入文件名需要满足文件名格式
17 | 合并语言Xml文件异常
18 | 请检查已有XML语言文件内容是否合法: {0}
19 | 读取Xml语言文件异常
20 | 请检查XML语言文件内容是否合法: {0}
21 |
22 |
23 | XML 多语言管理
24 | 对 XML 多语言数据集中管理维护。
25 |
26 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/I18n/XmlTranslatorManagerModule.zh-Hant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XML國際化管理
6 |
7 |
8 | XML多模塊文件合併
9 | 整合XML語言文件,適用於多模塊程序,例如使用了Prism的程序,合併前注意文件備份。
10 | 選擇語言目錄
11 | 請輸入合併後的語言XML文件名
12 | 合併文件
13 | 沒有語言文件
14 | 請先選擇語言目錄後再執行合併
15 | 錯誤的新XML語言文件名
16 | 輸入文件名需要滿足文件名格式
17 | 合併語言Xml文件異常
18 | 請檢查已有XML語言文件內容是否合法: {0}
19 | 讀取Xml語言文件異常
20 | 請檢查XML語言文件內容是否合法: {0}
21 |
22 |
23 | XML多語言管理
24 | 對XML多語言數據集中管理維護。
25 |
26 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Icons.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager;
2 |
3 | internal class Icons
4 | {
5 | public const string XmlTranslatorManager =
6 | "M163.4 671.7H363c-5.5-40.2-9-83.2-10.1-127.9h-223c3.7 45.3 15.3 88.4 33.5 127.9z m37.2 64c54 75.2 133.5 128.4 223.6 149.8-20.6-38.3-37.9-89.6-50.3-149.8H200.6z m660.8-64c18.1-39.5 29.7-82.6 33.5-127.9h-223c-1 42.8-4.4 85.5-10.1 127.9h199.6z m-37.2 64H650.9c-12.4 60.2-29.7 111.5-50.3 149.8 90.1-21.4 169.5-74.6 223.6-149.8z m-399.1-64h174.5c4.5-39.5 7.4-82.6 8.4-127.9H416.7c1 45.3 3.9 88.4 8.4 127.9z m9.3 64c17.4 96.9 45.8 159.9 77.9 159.9 32.1 0 60.5-63.1 78-159.9H434.4zM129.9 479.8h223C354 435 357.5 392 363 351.9H163.4c-18.6 40.3-29.9 83.6-33.5 127.9z m765 0c-3.6-44.3-15-87.6-33.5-127.9H661.8c5.5 40.2 9 83.2 10.1 127.9h223z m-478.2 0H608c-0.8-42.8-3.6-85.5-8.4-127.9H425.1c-4.8 42.4-7.5 85.1-8.4 127.9z m-216.1-192h173.3c12.4-60.2 29.7-111.5 50.3-149.8-90.2 21.4-169.6 74.6-223.6 149.8z m623.6 0c-54-75.2-133.5-128.4-223.6-149.8 20.6 38.3 37.9 89.6 50.3 149.8h173.3z m-389.8 0h155.9c-17.4-96.9-45.8-159.9-78-159.9-32 0-60.4 63.1-77.9 159.9z m78 671.8c-247.3 0-447.8-200.5-447.8-447.8S265.1 64 512.4 64s447.8 200.5 447.8 447.8-200.5 447.8-447.8 447.8z m0 0";
7 |
8 | public const string MergeXMLFiles =
9 | "M1024 385.024l0 189.44-169.984 0q-12.288 0-16.896 5.12t-4.608 15.36l0 26.624q0 8.192-6.656 14.336t-16.896 8.192-22.528-1.024-23.552-14.336q-29.696-28.672-60.928-65.536t-57.856-66.56q-6.144-7.168-5.12-19.456t9.216-21.504q27.648-32.768 58.368-64.512l67.584-66.56q5.12-5.12 14.848-6.656t19.456-0.512 16.896 5.12 7.168 9.216l0 15.36q0 10.24 4.608 24.064t23.04 13.824l163.84 0zM63.488 574.464l0-189.44 163.84 0q17.408 0 22.528-7.68t5.12-17.92l0-16.384q0-12.288 7.168-18.944t16.896-8.192 19.456 1.024 14.848 7.68l67.584 66.56q30.72 31.744 58.368 64.512 8.192 9.216 9.216 21.504t-6.144 19.456q-26.624 29.696-57.856 66.56t-60.928 65.536q-11.264 11.264-23.552 15.36t-22.016 2.048-16.384-9.728-6.656-20.992l0-26.624q0-10.24-4.608-12.288t-17.92-2.048l-168.96 0zM896 63.488q26.624 0 49.664 10.24t40.448 27.648 27.648 40.448 10.24 49.664l0 128-128 0 0-128-320.512 0 0 576.512 320.512 0 0-128 128 0 0 128q0 26.624-10.24 49.664t-27.648 40.448-40.448 27.648-49.664 10.24l-704.512 0q-26.624 0-49.664-10.24t-40.448-27.648-27.648-40.448-10.24-49.664l0-128 128 0 0 128 320.512 0 0-576.512-320.512 0 0 128-128 0 0-128q0-26.624 10.24-49.664t27.648-40.448 40.448-27.648 49.664-10.24l704.512 0z";
10 |
11 | public const string ManageXMLFiles =
12 | "M460.9 551.8v-104c0-18.7-4.4-33.3-12.9-43.6-8.4-10.2-21.3-15.1-38.2-15.1-9.8 0-18.7 1.8-26.2 5.8-7.6 4-13.8 10.2-17.8 17.8h-2.2l-5.3-20.4H328v159.6h39.1v-75.1c0-18.7 2.7-32 7.6-40.4 4.9-8 12.9-12 24-12 8 0 13.8 2.7 17.8 8.4 3.6 5.8 5.8 14.2 5.8 25.8v93.3h38.6z m-167.1 0v-36.4h-68.4v-53.8H289v-36h-63.6v-45.8h68.4v-36H185.3v208h108.5z m163.5 266.6h-316c-38.2 0-69.3-31.1-69.3-69.3V160.2c0-38.7 31.1-69.3 69.3-69.3H488l21.3 114.2h373.3c38.2 0 69.3 31.1 69.3 69.3v589.3c0 38.2-31.1 69.3-69.3 69.3H432.4l24.9-114.6zM700 628.7c19.6 16.9 41.8 29.3 66.7 36.9l15.6 4.9-9.3 33.3-15.6-4.9c-29.8-9.3-57.3-24.9-80.9-45.8-21.8 19.6-47.6 34.7-75.6 44l21.8 121.8H492.9l-17.3 79.6h407.6c19.1 0 34.7-15.6 34.7-34.7V274.4c0-19.1-15.6-34.7-34.7-34.7h-364l27.1 151.1-0.9-0.4 3.1 16.4 0.4-2.2 7.6 43.1h84V413h64.9v34.7h108.4v34.7h-45.3c-15.2 60.9-38.3 109.8-68.5 146.3zM570.7 482.4h-8.4l32.4 180.4c21.3-7.6 40.9-19.1 58.2-34.2-17.8-21.3-32-45.3-43.1-70.7l34.2-4.4c9.3 19.1 20 36.4 32.4 51.1 25.3-30.7 44.4-71.6 58.2-122.7l-163.9 0.5z";
13 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Models/Consts.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager.Models;
2 |
3 | public static class Consts
4 | {
5 | public const string LanguageKey = "language";
6 | public const string DescriptionKey = "description";
7 | public const string CultureNameKey = "cultureName";
8 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Models/LanguageClassModel.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager.Models;
2 |
3 | public class LanguageClassModel
4 | {
5 | public string? Name { get; set; }
6 |
7 | public List? Properties { get; set; }
8 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Models/LanguageProperty.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager.Models;
2 |
3 | public class LanguageProperty
4 | {
5 | public string? Key { get; set; }
6 | public Dictionary? Values { get; set; }
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Models/LanguageXmlFileInfo.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager.Models;
2 |
3 | public class LanguageXmlFileInfo
4 | {
5 | public string? FileName { get; set; }
6 | public string? Language { get; set; }
7 | public string? Description { get; set; }
8 | public string? CultureName { get; set; }
9 | public string? FilePath { get; set; }
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Models/LanguageXmlModel.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Modules.XmlTranslatorManager.Models;
2 |
3 | public class LanguageXmlModel
4 | {
5 | public string? Name { get; set; }
6 | public List Files { get; set; }
7 |
8 | public List? Classes { get; set; }
9 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/README.zh-CN.md:
--------------------------------------------------------------------------------
1 | ## 1. XML合并
2 |
3 | 1. 选择语言目录
4 | 2. 列出XML文件树
5 | 3. 浏览XML内容(不支持编辑)
6 | 4. 提供合并文件名
7 |
8 | ## 2. 语言编辑
9 |
10 | 1. 选择语言目录
11 | 2. 列出类树
12 | 3. 列出语言表
13 | 4. 可编辑
14 | 5. AI翻译指定单元格
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Views/ManageXMLFilesView.axaml:
--------------------------------------------------------------------------------
1 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
50 |
51 |
52 |
54 |
55 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Views/ManageXMLFilesView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 |
4 | namespace CodeWF.Modules.XmlTranslatorManager.Views;
5 |
6 | public partial class ManageXmlFilesView : UserControl
7 | {
8 | public ManageXmlFilesView()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/Views/MergeXMLFilesView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Markup.Xaml;
3 | using AvaloniaEdit;
4 | using AvaloniaEdit.TextMate;
5 | using CodeWF.Modules.XmlTranslatorManager.ViewModels;
6 | using TextMateSharp.Grammars;
7 |
8 | namespace CodeWF.Modules.XmlTranslatorManager.Views;
9 |
10 | public partial class MergeXmlFilesView : UserControl
11 | {
12 | public MergeXmlFilesView()
13 | {
14 | InitializeComponent();
15 |
16 | //First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
17 | var textEditor = this.FindControl("Editor");
18 |
19 | //Here we initialize RegistryOptions with the theme we want to use.
20 | var registryOptions = new RegistryOptions(ThemeName.DarkPlus);
21 |
22 | //Initial setup of TextMate.
23 | var textMateInstallation = textEditor.InstallTextMate(registryOptions);
24 |
25 | //Here we are getting the language by the extension and right after that we are initializing grammar with this language.
26 | //And that's all ??, you are ready to use AvaloniaEdit with syntax highlighting!
27 | textMateInstallation.SetGrammar(
28 | registryOptions.GetScopeByLanguageId(registryOptions.GetLanguageByExtension(".cs").Id));
29 | ((DataContext as MergeXmlFilesViewModel)!).XmlTextEditor = textEditor;
30 | }
31 |
32 | private void InitializeComponent()
33 | {
34 | AvaloniaXamlLoader.Load(this);
35 | }
36 | }
--------------------------------------------------------------------------------
/src/CodeWF.Modules.XmlTranslatorManager/XmlTranslatorManagerModule.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core;
2 | using CodeWF.Core.Models;
3 | using CodeWF.Modules.XmlTranslatorManager.ViewModels;
4 | using CodeWF.Modules.XmlTranslatorManager.Views;
5 |
6 | namespace CodeWF.Modules.XmlTranslatorManager;
7 |
8 | public class XmlTranslatorManagerModule : IModule
9 | {
10 | public XmlTranslatorManagerModule(IToolMenuService toolMenuService)
11 | {
12 | var groupName = Localization.XmlTranslatorManager.Title;
13 | toolMenuService.AddSeparator();
14 | toolMenuService.AddGroup(groupName, Icons.XmlTranslatorManager);
15 | toolMenuService.AddItem(Localization.MergeXmlFilesView.Title, groupName,
16 | Localization.MergeXmlFilesView.Description,
17 | nameof(MergeXmlFilesView),
18 | Icons.MergeXMLFiles,
19 | ToolStatus.Complete);
20 | toolMenuService.AddItem(Localization.ManageXmlFilesView.Title, groupName,
21 | Localization.ManageXmlFilesView.Description, nameof(ManageXmlFilesView),
22 | Icons.ManageXMLFiles,
23 | ToolStatus.Developing);
24 | }
25 |
26 | public void OnInitialized(IContainerProvider containerProvider)
27 | {
28 | IRegionManager? regionManager = containerProvider.Resolve();
29 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
30 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
31 | }
32 |
33 | public void RegisterTypes(IContainerRegistry containerRegistry)
34 | {
35 | ViewModelLocationProvider.Register();
36 | ViewModelLocationProvider.Register();
37 | }
38 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/CodeWF.Toolbox.Desktop.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net9.0;net9.0-windows
5 | app.manifest
6 | logo.ico
7 | enable
8 | true
9 | true
10 | true
11 |
12 |
13 | true
14 | true
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 | PreserveNewest
32 |
33 |
34 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.ReactiveUI;
3 | using System;
4 |
5 | namespace CodeWF.Toolbox.Desktop;
6 |
7 | internal sealed class Program
8 | {
9 | // Initialization code. Don't use any Avalonia, third-party APIs or any
10 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
11 | // yet and stuff might break.
12 | [STAThread]
13 | public static void Main(string[] args) => BuildAvaloniaApp()
14 | .StartWithClassicDesktopLifetime(args);
15 |
16 | // Avalonia configuration, don't remove; also used by visual designer.
17 | public static AppBuilder BuildAvaloniaApp()
18 | => AppBuilder.Configure()
19 | .UsePlatformDetect()
20 | .UseReactiveUI()
21 | .LogToTrace();
22 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/Roots.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox.Desktop/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox.Desktop/logo.ico
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/App.axaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
23 |
24 |
25 |
26 |
28 |
29 |
30 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/datetime-converter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/datetime-converter.png
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/logo.ico
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/logo.png
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/slug-converter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/slug-converter.png
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/wechatowner.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/wechatowner.jpg
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Assets/wechatpublic.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/src/CodeWF.Toolbox/Assets/wechatpublic.jpg
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/CodeWF.Toolbox.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net9.0
4 | enable
5 | latest
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | True
22 | True
23 | Language.tt
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 | True
55 | True
56 | Language.tt
57 |
58 |
59 |
60 |
61 |
62 | TextTemplatingFileGenerator
63 | Language.cs
64 |
65 |
66 | PreserveNewest
67 |
68 |
69 | PreserveNewest
70 |
71 |
72 | PreserveNewest
73 |
74 |
75 | PreserveNewest
76 |
77 |
78 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Commands/ChangeApplicationStatusCommand.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.EventBus;
2 |
3 | namespace CodeWF.Toolbox.Commands;
4 |
5 | public class ChangeApplicationStatusCommand : Command
6 | {
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Commands/ChangeToolMenuCommand.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.Models;
2 | using CodeWF.EventBus;
3 |
4 | namespace CodeWF.Toolbox.Commands;
5 |
6 | public class ChangeToolMenuCommand : Command
7 | {
8 | public ChangeToolMenuCommand(ToolMenuItem toolMenuItem)
9 | {
10 | ToolMenuItem = toolMenuItem;
11 | }
12 |
13 | public ToolMenuItem ToolMenuItem { get; set; } = null!;
14 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Converters/IconConverter.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Data.Converters;
3 | using Avalonia.Media;
4 | using System;
5 | using System.Globalization;
6 |
7 | namespace CodeWF.Toolbox.Converters;
8 |
9 | public class IconConverter : IValueConverter
10 | {
11 | public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
12 | {
13 | if (value is string icon)
14 | {
15 | return StreamGeometry.Parse(icon);
16 | }
17 |
18 | return AvaloniaProperty.UnsetValue;
19 | }
20 |
21 | public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
22 | {
23 | return AvaloniaProperty.UnsetValue;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/I18n/Language.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="false" hostspecific="true" language="C#" #>
2 | <#@ assembly name="System.Core" #>
3 | <#@ assembly name="System.Xml" #>
4 | <#@ assembly name="System.Xml.Linq" #>
5 | <#@ import namespace="System.Linq" #>
6 | <#@ import namespace="System.Text" #>
7 | <#@ import namespace="System.Collections.Generic" #>
8 | <#@ import namespace="System.Xml.Linq" #>
9 | <#@ import namespace="System.IO" #>
10 | <#@ output extension=".cs" #>
11 | //------------------------------------------------------------------------------
12 | //
13 | // This code was generated by a tool.
14 | // Changes to this file may cause incorrect behavior and will be lost if
15 | // the code is regenerated.
16 | //
17 | //------------------------------------------------------------------------------
18 | <#
19 | string templateDirectory = Path.GetDirectoryName(Host.TemplateFile);
20 | string xmlFilePath = Directory.GetFiles(templateDirectory, "*.xml").FirstOrDefault();
21 | if (xmlFilePath!= null)
22 | {
23 | XDocument xdoc = XDocument.Load(xmlFilePath);
24 | var classNodes = xdoc.Nodes().OfType().DescendantsAndSelf().Where(e => e.Descendants().Count() == 0).Select(e => e.Parent).Distinct().ToList();
25 | foreach (var classNode in classNodes)
26 | {
27 | var namespaceSegments = classNode.Ancestors().Reverse().Select(node => node.Name.LocalName);
28 | string namespaceName = string.Join(".", namespaceSegments);
29 | GenerateClasses(classNode, namespaceName);
30 | }
31 | }
32 | else
33 | {
34 | Write("XML file not found, please ensure that there is an XML file in the current directory");
35 | }
36 |
37 | void GenerateClasses(XElement element, string namespaceName)
38 | {
39 | string className = element.Name.LocalName;
40 | StringBuilder classBuilder = new StringBuilder();
41 | classBuilder.AppendLine($"namespace {namespaceName}");
42 | classBuilder.AppendLine("{");
43 | classBuilder.AppendLine($" public static class {className}");
44 | classBuilder.AppendLine(" {");
45 | var fieldNodes = element.Elements();
46 | foreach (var fieldNode in fieldNodes)
47 | {
48 | var propertyName = fieldNode.Name.LocalName;
49 | var languageKey = $"{namespaceName}.{className}.{propertyName}";
50 | classBuilder.AppendLine($" public static readonly string {propertyName} = \"{languageKey}\";");
51 | }
52 | classBuilder.AppendLine(" }");
53 | classBuilder.AppendLine("}");
54 | Write(classBuilder.ToString());
55 | }
56 | #>
57 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/I18n/MainModule.en-US.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Toolbox of Code World Workshop
6 | Show main window
7 | Exit
8 |
9 |
10 | Search what you want
11 | No more prompts
12 | Are you sure you want to exit?
13 | You can find me on the tray icon!
14 |
15 |
16 | Homepage
17 | Author's WeChat ID
18 | Follow WeChat official account
19 | Everything you want is available. If not, please let us know.
20 | Access the online toolbox
21 | There's no tool I want...
22 |
23 |
24 | Settings
25 |
26 |
27 | General Settings
28 | The interface style setting
29 | Theme
30 | Choose a theme
31 | Follow the system
32 | Light
33 | Dark
34 | Aquatic
35 | Desert
36 | Dusk
37 | Night sky
38 | Language
39 | Choose a language
40 | Automatically open the toolbox at startup
41 | Hide the tray icon when closing the window
42 | Display a prompt when closing the window
43 | Turn on
44 | Turn off
45 |
46 |
47 | Update Log
48 | This document meticulously records the evolution of the toolbox. Every significant version upgrade, feature enhancement, and bug fix is presented here, enabling users to have a clear understanding of the toolbox's development and track its progress.
49 |
50 |
51 | About
52 | This project is only used for learning purposes.
53 |
54 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/I18n/MainModule.ja-JP.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | コードワールドワークショップのツールボックス
6 | メインウィンドウを表示する
7 | 終了する
8 |
9 |
10 | あなたが考えることを検索する
11 | もうメッセージを表示しない
12 | 本当に終了しますか?
13 | トレイアイコンで私を見つけることができます!
14 |
15 |
16 | ホームページ
17 | 著者のマイクロ信号
18 | ウィーチャットの公式アカウントに注目
19 | 欲しいものはすべてあります。ない場合はお知らせください。
20 | オンラインツールボックスにアクセスする
21 | 欲しいツールがありません...
22 |
23 |
24 | 設定
25 |
26 |
27 | 一般設定
28 | インタフェーススタイルの設定
29 | テーマ
30 | テーマを選ぶ
31 | システムに従う
32 | 昼間モード
33 | 夜間モード
34 | 水生(すいせい)
35 | 砂漠(さばく)
36 | 夕暮れ(ゆうぐれ)
37 | 夜空(よぞら)
38 | 言語
39 | 言語を選ぶ
40 | 起動時に自動的にツールボックスを開く
41 | ウィンドウを閉じるときにトレイアイコンを非表示にする
42 | ウィンドウを閉じるときにメッセージを表示する
43 | オンにする
44 | オフにする
45 |
46 |
47 | アップデートログ
48 | ここには、ツールボックスの更新履歴が詳細に記録されています。重要なバージョンアップ、機能強化、バグ修正など、すべてが忠実に反映され、ユーザーがツールボックスの進化を明確に把握し、その発展の流れを追跡できます。
49 |
50 |
51 | 関於
52 | このプロジェクトは学習用にのみ使用されます。
53 |
54 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/I18n/MainModule.zh-CN.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 码界工坊工具箱
6 | 显示主窗口
7 | 退出
8 |
9 |
10 | 搜你所想
11 | 不再提示
12 | 您确定要退出吗?
13 | 你可以在托盘图标上找到我!
14 |
15 |
16 | 首页
17 | 联系微信号
18 | 关注微信公众号
19 | 想要的都有,没有请告知。
20 | 访问在线工具箱
21 | 没有我要的工具...
22 |
23 |
24 | 设置
25 |
26 |
27 | 通用设置
28 | 界面风格设置
29 | 主题
30 | 选择一个主题
31 | 跟随系统
32 | 白天模式
33 | 黑夜模式
34 | 水生
35 | 沙漠
36 | 黄昏
37 | 夜空
38 | 语言
39 | 选择一个语言
40 | 开机时自动打开工具箱
41 | 关闭窗体时隐藏托盘图标
42 | 关闭窗体时显示提示
43 | 开启
44 | 关闭
45 |
46 |
47 | 更新日志
48 | 这里全方位展现了工具箱在发展进程中的每一步蜕变。无论是全新功能的重磅上线,让操作更加便捷高效;还是对既有功能的精细打磨,使其稳定性与兼容性大幅提升;亦或是针对用户反馈迅速开展的问题修复行动,点点滴滴都详尽记录于此。旨在为您拨开迷雾,精准洞悉工具箱的成长轨迹,使其更好地服务于您的需求。
49 |
50 |
51 | 关于
52 | 本项目只用于学习使用
53 |
54 |
55 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/I18n/MainModule.zh-Hant.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 碼界工坊工具箱
6 | 顯示主視窗
7 | 退出
8 |
9 |
10 | 搜尋你所想
11 | 不再提示
12 | 您確定要退出嗎?
13 | 你可以在托盤圖標上找到我!
14 |
15 |
16 | 首頁
17 | 作者微訊號
18 | 關注微信公眾號
19 | 想要的都有,沒有請告知。
20 | 訪問線上工具箱
21 | 沒有我要的工具...
22 |
23 |
24 | 設置
25 |
26 |
27 | 通用設置
28 | 介面風格設定
29 | 主題
30 | 選擇一個主題
31 | 跟隨系統
32 | 白天模式
33 | 黑夜模式
34 | 水生
35 | 沙漠
36 | 黃昏
37 | 夜空
38 | 語言
39 | 選擇一個語言
40 | 開機時自動打開工具箱
41 | 關閉窗體時隱藏托盤圖標
42 | 關閉窗體時顯示提示
43 | 開啟
44 | 關閉
45 |
46 |
47 | 更新日誌
48 | 此處詳細記錄了工具箱一路走來的更新歷程,每一次重要的版本迭代、功能增強以及問題修復都會如實呈現,方便使用者清晰了解工具箱的演進,跟蹤其發展脈絡。
49 |
50 |
51 | 關於
52 | 本項目只用於學習使用
53 |
54 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Icons.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Toolbox;
2 |
3 | internal class Icons
4 | {
5 | public const string Dashboard =
6 | "M155.584 342.56l312.874667-224.565333a74.666667 74.666667 0 0 1 87.082666 0l312.874667 224.565333A117.333333 117.333333 0 0 1 917.333333 437.866667V800c0 64.8-52.533333 117.333333-117.333333 117.333333H224c-64.8 0-117.333333-52.533333-117.333333-117.333333V437.877333a117.333333 117.333333 0 0 1 48.917333-95.317333z m37.322667 51.989333A53.333333 53.333333 0 0 0 170.666667 437.877333V800a53.333333 53.333333 0 0 0 53.333333 53.333333h576a53.333333 53.333333 0 0 0 53.333333-53.333333V437.877333a53.333333 53.333333 0 0 0-22.24-43.328L518.218667 169.984a10.666667 10.666667 0 0 0-12.437334 0L192.906667 394.56z";
7 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/MainModule.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core;
2 | using CodeWF.Core.Models;
3 | using CodeWF.Toolbox.Views;
4 | using Prism.Ioc;
5 | using Prism.Modularity;
6 | using Prism.Navigation.Regions;
7 | using Ursa.PrismExtension;
8 |
9 | namespace CodeWF.Toolbox;
10 |
11 | public class MainModule : IModule
12 | {
13 | public MainModule(IToolMenuService toolMenuService)
14 | {
15 | toolMenuService.AddItem(Localization.DashboardView.Title, parentName: null, null, nameof(DashboardView), Icons.Dashboard,
16 | ToolStatus.Developing);
17 | }
18 |
19 | public void OnInitialized(IContainerProvider containerProvider)
20 | {
21 | IRegionManager? regionManager = containerProvider.Resolve();
22 | regionManager.RegisterViewWithRegion(RegionNames.ContentRegion);
23 | regionManager.RegisterViewWithRegion(RegionNames.SettingRegion);
24 | regionManager.RegisterViewWithRegion(RegionNames.SettingRegion);
25 | regionManager.RegisterViewWithRegion(RegionNames.SettingRegion);
26 | }
27 |
28 | public void RegisterTypes(IContainerRegistry containerRegistry)
29 | {
30 | containerRegistry.RegisterUrsaDialogView(DialogNames.Setting);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Models/ConstDatas.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CodeWF.Toolbox.Models;
4 |
5 | public static class ConstDatas
6 | {
7 | public static Uri MainWebUrl = new Uri("https://dotnet9.com");
8 | public static Uri RespositoyUrl = new Uri("https://github.com/dotnet9/CodeWF.Toolbox");
9 | public static Uri OnlineToolUrl = new Uri("https://dotnet9.com/tool");
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Models/ThemeItem.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Styling;
2 |
3 | namespace CodeWF.Toolbox.Models;
4 |
5 | public class ThemeItem(string name, string key, ThemeVariant theme)
6 | {
7 | public string Name { get; set; } = name;
8 | public string Key { get; set; } = key;
9 | public ThemeVariant Theme { get; set; } = theme;
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Styles/Index.axaml:
--------------------------------------------------------------------------------
1 |
4 |
5 | 12
6 | Cascadia Code,Consolas,Menlo,Monospace
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/AboutViewModel.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.RegionAdapters;
2 | using CodeWF.Tools.Extensions;
3 | using System.Reflection;
4 |
5 | namespace CodeWF.Toolbox.ViewModels;
6 |
7 | public class AboutViewModel : ViewModelBase, ITabItemBase
8 | {
9 | public string? TitleKey { get; set; } = Localization.AboutView.Title;
10 | public string? AppName { get; set; }
11 | public string? Version { get; set; } = Assembly.GetExecutingAssembly().Version();
12 | public string? MessageKey { get; set; } = Localization.AboutView.Description;
13 |
14 | public string? CompileTime { get; set; } =
15 | Assembly.GetExecutingAssembly().CompileTime()?.ToString("yyyy-MM-dd HH:mm:ss");
16 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/DashboardViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Toolbox.ViewModels;
2 |
3 | public class DashboardViewModel : ViewModelBase
4 | {
5 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/ExitOptionViewModel.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace CodeWF.Toolbox.ViewModels;
4 |
5 | public class ExitOptionViewModel : ViewModelBase
6 | {
7 | private string? _message;
8 |
9 | public string? Message
10 | {
11 | get => _message;
12 | set => this.RaiseAndSetIfChanged(ref _message, value);
13 | }
14 |
15 |
16 | private string? _optionContent;
17 |
18 | public string? OptionContent
19 | {
20 | get => _optionContent;
21 | set => this.RaiseAndSetIfChanged(ref _optionContent, value);
22 | }
23 |
24 |
25 | private bool _option;
26 |
27 | public bool Option
28 | {
29 | get => _option;
30 | set => this.RaiseAndSetIfChanged(ref _option, value);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/MainContentViewModel.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls.Notifications;
2 | using CodeWF.Core.Models;
3 | using CodeWF.EventBus;
4 | using CodeWF.Toolbox.Commands;
5 | using ReactiveUI;
6 |
7 | namespace CodeWF.Toolbox.ViewModels;
8 |
9 | internal class MainContentViewModel : ViewModelBase
10 | {
11 | private bool _bordered;
12 |
13 | public bool Bordered
14 | {
15 | get => _bordered;
16 | set => this.RaiseAndSetIfChanged(ref _bordered, value);
17 | }
18 |
19 | private NotificationType _selectedType;
20 |
21 | public NotificationType SelectedType
22 | {
23 | get => _selectedType;
24 | set => this.RaiseAndSetIfChanged(ref _selectedType, value);
25 | }
26 |
27 | private ToolMenuItem? _selectedMenuItem;
28 |
29 | public ToolMenuItem? SelectedMenuItem
30 | {
31 | get => _selectedMenuItem;
32 | set => this.RaiseAndSetIfChanged(ref _selectedMenuItem, value);
33 | }
34 |
35 | public MainContentViewModel()
36 | {
37 | EventBus.EventBus.Default.Subscribe(this);
38 | }
39 |
40 | [EventHandler]
41 | private void ChangeToolMenuHandler(ChangeToolMenuCommand command)
42 | {
43 | SelectedMenuItem = command.ToolMenuItem;
44 | Bordered = SelectedMenuItem.Status == ToolStatus.Developing;
45 | SelectedType = SelectedMenuItem.Status == ToolStatus.Complete
46 | ? NotificationType.Success
47 | : NotificationType.Warning;
48 | }
49 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/MainViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Toolbox.ViewModels;
2 |
3 | public class MainViewModel : ViewModelBase
4 | {
5 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/SettingViewModel.cs:
--------------------------------------------------------------------------------
1 | namespace CodeWF.Toolbox.ViewModels;
2 |
3 | public class SettingViewModel : ViewModelBase
4 | {
5 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/UpdateLogViewModel.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.Core.RegionAdapters;
2 | using ReactiveUI;
3 | using System.IO;
4 |
5 | namespace CodeWF.Toolbox.ViewModels;
6 |
7 | public class UpdateLogViewModel : ViewModelBase, ITabItemBase
8 | {
9 | public UpdateLogViewModel()
10 | {
11 | var path = "UpdateLog.md";
12 | if (File.Exists(path))
13 | {
14 | UpdateLogMarkdownContent = File.ReadAllText(path);
15 | }
16 | else
17 | {
18 | UpdateLogMarkdownContent = "Empty";
19 | }
20 | }
21 |
22 | public string? TitleKey { get; set; } = Localization.UpdateLogView.Title;
23 | public string? MessageKey { get; set; } = Localization.UpdateLogView.Description;
24 |
25 | private string? _updateLogMarkdownContent;
26 |
27 | public string? UpdateLogMarkdownContent
28 | {
29 | get => _updateLogMarkdownContent;
30 | set => this.RaiseAndSetIfChanged(ref _updateLogMarkdownContent, value);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace CodeWF.Toolbox.ViewModels;
4 | public class ViewModelBase : ReactiveObject
5 | {
6 | }
7 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/AboutView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class AboutView : UserControl
6 | {
7 | public AboutView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/CommonSettingView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class CommonSettingView : UserControl
6 | {
7 | public CommonSettingView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/DashboardView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class DashboardView : UserControl
6 | {
7 | public DashboardView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/ExitOptionView.axaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
13 |
14 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/ExitOptionView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class ExitOptionView : UserControl
6 | {
7 | public ExitOptionView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainContentView.axaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
16 |
17 |
18 |
23 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainContentView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class MainContentView : UserControl
6 | {
7 | public MainContentView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainMenuView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 |
5 | public partial class MainMenuView : UserControl
6 | {
7 | public MainMenuView()
8 | {
9 | InitializeComponent();
10 | }
11 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainView.axaml:
--------------------------------------------------------------------------------
1 |
14 |
15 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 |
3 | namespace CodeWF.Toolbox.Views;
4 | public partial class MainView : UserControl
5 | {
6 | public MainView()
7 | {
8 | InitializeComponent();
9 | }
10 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
16 |
17 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/SettingView.axaml:
--------------------------------------------------------------------------------
1 |
21 |
22 |
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
47 |
50 |
51 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/SettingView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Markup.Xaml;
2 | using Ursa.Controls;
3 |
4 | namespace CodeWF.Toolbox.Views;
5 |
6 | public partial class SettingView : UrsaWindow
7 | {
8 | public SettingView()
9 | {
10 | InitializeComponent();
11 | }
12 |
13 | private void InitializeComponent()
14 | {
15 | AvaloniaXamlLoader.Load(this);
16 | }
17 | }
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/UpdateLogView.axaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/src/CodeWF.Toolbox/Views/UpdateLogView.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls;
3 | using Avalonia.Markup.Xaml;
4 |
5 | namespace CodeWF.Toolbox.Views;
6 |
7 | public partial class UpdateLogView : UserControl
8 | {
9 | public UpdateLogView()
10 | {
11 | InitializeComponent();
12 | }
13 | }
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/App.axaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/App.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.Controls.ApplicationLifetimes;
3 | using Avalonia.Markup.Xaml;
4 | using AvaloniaAotDemo.ViewModels;
5 | using AvaloniaAotDemo.Views;
6 |
7 | namespace AvaloniaAotDemo;
8 | public partial class App : Application
9 | {
10 | public override void Initialize()
11 | {
12 | AvaloniaXamlLoader.Load(this);
13 | }
14 |
15 | public override void OnFrameworkInitializationCompleted()
16 | {
17 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
18 | {
19 | desktop.MainWindow = new MainWindow
20 | {
21 | DataContext = new MainWindowViewModel(),
22 | };
23 | }
24 |
25 | base.OnFrameworkInitializationCompleted();
26 | }
27 | }
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/Assets/avalonia-logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet9/CodeWF.Toolbox/a4dbb253034e8a4719544645040440dce56fb3b9/tests/AvaloniaAotDemo/Assets/avalonia-logo.ico
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/AvaloniaAotDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net9.0-windows
5 | enable
6 | true
7 | app.manifest
8 | true
9 | true
10 |
11 |
12 | true
13 | true
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/Commands/ChangeTimeCommand.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.EventBus;
2 | using System;
3 |
4 | namespace AvaloniaAotDemo.Commands;
5 |
6 | internal class ChangeTimeCommand : Command
7 | {
8 | public DateTime Time { get; set; }
9 | }
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using Avalonia;
2 | using Avalonia.ReactiveUI;
3 | using System;
4 |
5 | namespace AvaloniaAotDemo;
6 |
7 | internal sealed class Program
8 | {
9 | // Initialization code. Don't use any Avalonia, third-party APIs or any
10 | // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
11 | // yet and stuff might break.
12 | [STAThread]
13 | public static void Main(string[] args) => BuildAvaloniaApp()
14 | .StartWithClassicDesktopLifetime(args);
15 |
16 | // Avalonia configuration, don't remove; also used by visual designer.
17 | public static AppBuilder BuildAvaloniaApp()
18 | => AppBuilder.Configure()
19 | .UsePlatformDetect()
20 | .WithInterFont()
21 | .LogToTrace()
22 | .UseReactiveUI();
23 | }
24 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/ViewLocator.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Controls.Templates;
3 | using AvaloniaAotDemo.ViewModels;
4 | using System;
5 |
6 | namespace AvaloniaAotDemo;
7 | public class ViewLocator : IDataTemplate
8 | {
9 | public Control? Build(object? data)
10 | {
11 | if (data is null)
12 | return null;
13 |
14 | var name = data.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
15 | var type = Type.GetType(name);
16 |
17 | if (type != null)
18 | {
19 | var control = (Control)Activator.CreateInstance(type)!;
20 | control.DataContext = data;
21 | return control;
22 | }
23 |
24 | return new TextBlock { Text = "Not Found: " + name };
25 | }
26 |
27 | public bool Match(object? data)
28 | {
29 | return data is ViewModelBase;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using AvaloniaAotDemo.Commands;
2 | using CodeWF.EventBus;
3 | using ReactiveUI;
4 | using System;
5 |
6 | namespace AvaloniaAotDemo.ViewModels;
7 |
8 | public class MainWindowViewModel : ViewModelBase
9 | {
10 | public MainWindowViewModel()
11 | {
12 | EventBus.Default.Subscribe(ReceiveEvent);
13 | }
14 |
15 | private string _greeting = "我擦勒,你是真的帅!";
16 |
17 | public string Greeting
18 | {
19 | get => _greeting;
20 | set => this.RaiseAndSetIfChanged(ref _greeting, value);
21 | }
22 |
23 |
24 | public void RaiseSendCommandHandler()
25 | {
26 | EventBus.Default.Publish(new ChangeTimeCommand() { Time = DateTime.Now });
27 | }
28 |
29 | private void ReceiveEvent(ChangeTimeCommand command)
30 | {
31 | Greeting = command.Time.ToString("yyyy-MM-dd HH:mm:ss fff");
32 | }
33 | }
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/ViewModels/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using ReactiveUI;
2 |
3 | namespace AvaloniaAotDemo.ViewModels;
4 | public class ViewModelBase : ReactiveObject
5 | {
6 | }
7 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/Views/MainWindow.axaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/Views/MainWindow.axaml.cs:
--------------------------------------------------------------------------------
1 | using Avalonia.Controls;
2 | using Avalonia.Interactivity;
3 | using AvaloniaAotDemo.Commands;
4 | using AvaloniaAotDemo.ViewModels;
5 | using CodeWF.EventBus;
6 | using System;
7 |
8 | namespace AvaloniaAotDemo.Views;
9 | public partial class MainWindow : Window
10 | {
11 | public MainWindow()
12 | {
13 | InitializeComponent();
14 | EventBus.Default.Subscribe(ReceiveEvent);
15 | }
16 |
17 | private void Button_OnClick(object? sender, RoutedEventArgs e)
18 | {
19 | EventBus.Default.Publish(new ChangeTimeCommand() { Time = DateTime.Now });
20 | }
21 |
22 | private void ReceiveEvent(ChangeTimeCommand command)
23 | {
24 | this.FindControl("Txt").Text = command.Time.ToString("yyyy-MM-dd HH:mm:ss fff");
25 | }
26 | }
--------------------------------------------------------------------------------
/tests/AvaloniaAotDemo/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/tests/ConsoleAotDemo/ConsoleAotDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Exe
4 | net9.0
5 | enable
6 | enable
7 |
8 |
9 | true
10 | 5.1
11 | true
12 | true
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/tests/ConsoleAotDemo/DBHeper.cs:
--------------------------------------------------------------------------------
1 | using Dapper;
2 | using Microsoft.Data.Sqlite;
3 |
4 | namespace ConsoleAotDemo
5 | {
6 | public static class DBHeper
7 | {
8 | public static void Test()
9 | {
10 | string connectionString = "Data Source=CodeWF.Toolbox.db";
11 | using (var connection = new SqliteConnection(connectionString))
12 | {
13 | connection.Open();
14 | var results = connection.Query("SELECT * FROM JsonPrettifyEntity");
15 | SqliteConnection.ClearPool(connection);
16 | }
17 | // 此时可以尝试删除数据库文件
18 | System.IO.File.Delete("CodeWF.Toolbox.db");
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tests/ConsoleAotDemo/Dtos/Person.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.NetWeaver.Base;
2 |
3 | namespace ConsoleAotDemo.Dtos;
4 |
5 | [NetHead(10, 1)]
6 | public class Person : INetObject
7 | {
8 | public string? Name { get; set; }
9 |
10 | public decimal Property { get; set; }
11 |
12 | public override string ToString()
13 | {
14 | return $"姓名:{Name}\r\n家产:{Property}万¥";
15 | }
16 | }
--------------------------------------------------------------------------------
/tests/ConsoleAotDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using CodeWF.NetWeaver;
2 | using CodeWF.NetWeaver.Base;
3 | using ConsoleAotDemo;
4 | using ConsoleAotDemo.Dtos;
5 | using System.Reflection;
6 |
7 | DBHeper.Test();
8 |
9 | var student = new Person { Name = "帅哥", Property = 100 };
10 | var properties = student.GetType().GetProperties(BindingFlags.Public|BindingFlags.Instance);
11 | Console.WriteLine($"帅哥信息如下({properties.Length}条):\r\n{student}");
12 |
13 | var buffer = student.Serialize(1);
14 | Console.WriteLine($"名下:{buffer?.Length}套房");
15 |
16 | int index = 0;
17 | if (buffer?.ReadHead(ref index, out NetHeadInfo head) == true)
18 | {
19 | Console.WriteLine($"哇,原来你是第{head.ObjectVersion}大帅哥");
20 | }
21 | else
22 | {
23 | Console.WriteLine("抱歉,无法详细了解你的帅");
24 | }
25 |
26 | Console.ReadLine();
27 |
28 |
--------------------------------------------------------------------------------
/tests/WinFormsAotDemo/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormsAotDemo;
2 |
3 | partial class Form1
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | label1 = new Label();
32 | SuspendLayout();
33 | //
34 | // label1
35 | //
36 | label1.AutoSize = true;
37 | label1.Location = new Point(86, 85);
38 | label1.Name = "label1";
39 | label1.Size = new Size(80, 17);
40 | label1.TabIndex = 0;
41 | label1.Text = "你真的是帅哥";
42 | //
43 | // Form1
44 | //
45 | AutoScaleDimensions = new SizeF(7F, 17F);
46 | AutoScaleMode = AutoScaleMode.Font;
47 | ClientSize = new Size(237, 170);
48 | Controls.Add(label1);
49 | Name = "Form1";
50 | Text = "Form1";
51 | ResumeLayout(false);
52 | PerformLayout();
53 | }
54 |
55 | #endregion
56 |
57 | private Label label1;
58 | }
59 |
--------------------------------------------------------------------------------
/tests/WinFormsAotDemo/Form1.cs:
--------------------------------------------------------------------------------
1 | namespace WinFormsAotDemo;
2 |
3 | public partial class Form1 : Form
4 | {
5 | public Form1()
6 | {
7 | InitializeComponent();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/tests/WinFormsAotDemo/Program.cs:
--------------------------------------------------------------------------------
1 | using System.Runtime.InteropServices;
2 |
3 | namespace WinFormsAotDemo;
4 |
5 | internal static class Program
6 | {
7 | ///
8 | /// The main entry point for the application.
9 | ///
10 | [STAThread]
11 | static void Main()
12 | {
13 | // To customize application configuration such as set high DPI settings or default font,
14 | // see https://aka.ms/applicationconfiguration.
15 |
16 | ComWrappers.RegisterForMarshalling(WinFormsComInterop.WinFormsComWrappers.Instance);
17 |
18 | ApplicationConfiguration.Initialize();
19 | Application.Run(new Form1());
20 | }
21 | }
--------------------------------------------------------------------------------
/tests/WinFormsAotDemo/WinFormsAotDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | WinExe
4 | net9.0-windows
5 | enable
6 | true
7 | enable
8 |
9 |
10 | true
11 | 5.1
12 | win-x64
13 | 5.1
14 | true
15 | <_SuppressWinFormsTrimError>true
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------