add:初始化仓库;

当前具备功能
master
zxl 2025-01-21 14:26:54 +08:00
commit e1e3f1d410
36 changed files with 1004 additions and 0 deletions

71
.gitignore vendored Normal file
View File

@ -0,0 +1,71 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/
/[Pp]rojectSettings/
/[Pp]ackages/
# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/
# Recordings can get excessive in size
/[Rr]ecordings/
# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*
# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*
# Visual Studio cache directory
.vs/
.idea/
# Gradle cache directory
.gradle/
# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db
# Unity3D generated meta files
# Unity3D generated file on crash reports
sysinfo.txt
# Builds
# Crashlytics generated file
crashlytics-build.properties
# Packed Addressables
# 管理界面项目资产文件不跟踪
/ZTools/bin
/ZTools/obj

20
ZTools/App.axaml Normal file
View File

@ -0,0 +1,20 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ZTools.App"
xmlns:local="using:ZTools"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.DataTemplates>
<local:ViewLocator />
</Application.DataTemplates>
<Application.Styles>
<FluentTheme />
<StyleInclude Source="../Assets/Icon.axaml"></StyleInclude>
</Application.Styles>
<Application.Resources>
<!-- <Bitmap x:Key="MyIcon" Uri="avares://ZTools/Assets/icon.png" /> -->
</Application.Resources>
</Application>

47
ZTools/App.axaml.cs Normal file
View File

@ -0,0 +1,47 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using System.Linq;
using Avalonia.Markup.Xaml;
using ZTools.ViewModels;
using ZTools.Views;
namespace ZTools;
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
// Avoid duplicate validations from both Avalonia and the CommunityToolkit.
// More info: https://docs.avaloniaui.net/docs/guides/development-guides/data-validation#manage-validationplugins
DisableAvaloniaDataAnnotationValidation();
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(),
};
}
base.OnFrameworkInitializationCompleted();
}
private void DisableAvaloniaDataAnnotationValidation()
{
// Get an array of plugins to remove
var dataValidationPluginsToRemove =
BindingPlugins.DataValidators.OfType<DataAnnotationsValidationPlugin>().ToArray();
// remove each entry found
foreach (var plugin in dataValidationPluginsToRemove)
{
BindingPlugins.DataValidators.Remove(plugin);
}
}
}

24
ZTools/Assets/Icon.axaml Normal file
View File

@ -0,0 +1,24 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style>
<Style.Resources>
<StreamGeometry x:Key="send_logging_regular">M18.748832,2.99956021 C19.9914727,2.99956021 20.998832,4.00691952 20.998832,5.24956021 L20.998832,18.7518356 C20.998832,19.9944763 19.9914727,21.0018356 18.748832,21.0018356 L5.25,21.0018356 C4.00735931,21.0018356 3,19.9944763 3,18.7518356 L3,5.24956021 C3,4.00691952 4.00735931,2.99956021 5.25,2.99956021 L18.748832,2.99956021 Z M18.748832,4.49956021 L5.25,4.49956021 C4.83578644,4.49956021 4.5,4.83534665 4.5,5.24956021 L4.5,18.7518356 C4.5,19.1660492 4.83578644,19.5018356 5.25,19.5018356 L18.748832,19.5018356 C19.1630456,19.5018356 19.498832,19.1660492 19.498832,18.7518356 L19.498832,5.24956021 C19.498832,4.83534665 19.1630456,4.49956021 18.748832,4.49956021 Z M8.25507761,11.4999967 L9.81174873,7.94888912 C10.0630538,7.37560677 10.8475273,7.35429655 11.145068,7.868508 L11.1949016,7.97119427 L13.5761806,13.9178842 L14.5794436,11.9142083 C14.6906734,11.6920648 14.9033214,11.5415417 15.1449533,11.5073819 L15.2500731,11.4999967 L17.25,11.4999967 C17.6642136,11.4999967 18,11.8357864 18,12.25 C18,12.6296958 17.7178461,12.9434882 17.3517706,12.9931501 L17.25,12.9999967 L15.7133039,12.9999967 L14.1706295,16.0809663 C13.8980768,16.6252975 13.1407496,16.626412 12.852137,16.1240614 L12.8037476,16.0239803 L10.4673733,10.1894297 L9.43210271,12.5511109 C9.32749499,12.7897442 9.1080278,12.9544474 8.85530846,12.9918946 L8.74520225,12.9999967 L6.75,12.9999967 C6.33578644,12.9999967 6,12.6642136 6,12.25 C6,11.8703042 6.28215388,11.5565063 6.64822944,11.5068434 L6.75,11.4999967 L8.25507761,11.4999967 L9.81174873,7.94888912 L8.25507761,11.4999967 Z</StreamGeometry>
<StreamGeometry x:Key="check">M512 21.333333C782.976 21.333333 1002.666667 241.024 1002.666667 512S782.976 1002.666667 512 1002.666667 21.333333 782.976 21.333333 512 241.024 21.333333 512 21.333333z m211.925333 337.408a35.029333 35.029333 0 0 0-49.536 0l-222.805333 222.72-90.026667-90.026666a35.072 35.072 0 1 0-49.578666 49.621333l111.530666 111.573333a35.413333 35.413333 0 0 0 11.605334 9.770667 35.029333 35.029333 0 0 0 47.573333-12.8l241.237333-241.322667a35.029333 35.029333 0 0 0 0-49.578666z</StreamGeometry>
<StreamGeometry x:Key="add_square_regular">M800 96H224c-70.4 0-128 57.6-128 128v576c0 70.4 57.6 128 128 128h576c70.4 0 128-57.6 128-128V224c0-70.4-57.6-128-128-128zM672 544H544v128c0 17.6-14.4 32-32 32s-32-14.4-32-32V544H352c-17.6 0-32-14.4-32-32s14.4-32 32-32h128V352c0-17.6 14.4-32 32-32s32 14.4 32 32v128h128c17.6 0 32 14.4 32 32s-14.4 32-32 32z</StreamGeometry>
<StreamGeometry x:Key="delete_regular">M24,7.25 C27.1017853,7.25 29.629937,9.70601719 29.7458479,12.7794443 L29.75,13 L37,13 C37.6903559,13 38.25,13.5596441 38.25,14.25 C38.25,14.8972087 37.7581253,15.4295339 37.1278052,15.4935464 L37,15.5 L35.909,15.5 L34.2058308,38.0698451 C34.0385226,40.2866784 32.1910211,42 29.9678833,42 L18.0321167,42 C15.8089789,42 13.9614774,40.2866784 13.7941692,38.0698451 L12.09,15.5 L11,15.5 C10.3527913,15.5 9.8204661,15.0081253 9.75645361,14.3778052 L9.75,14.25 C9.75,13.6027913 10.2418747,13.0704661 10.8721948,13.0064536 L11,13 L18.25,13 C18.25,9.82436269 20.8243627,7.25 24,7.25 Z M33.4021054,15.5 L14.5978946,15.5 L16.2870795,37.8817009 C16.3559711,38.7945146 17.116707,39.5 18.0321167,39.5 L29.9678833,39.5 C30.883293,39.5 31.6440289,38.7945146 31.7129205,37.8817009 L33.4021054,15.5 Z M27.25,20.75 C27.8972087,20.75 28.4295339,21.2418747 28.4935464,21.8721948 L28.5,22 L28.5,33 C28.5,33.6903559 27.9403559,34.25 27.25,34.25 C26.6027913,34.25 26.0704661,33.7581253 26.0064536,33.1278052 L26,33 L26,22 C26,21.3096441 26.5596441,20.75 27.25,20.75 Z M20.75,20.75 C21.3972087,20.75 21.9295339,21.2418747 21.9935464,21.8721948 L22,22 L22,33 C22,33.6903559 21.4403559,34.25 20.75,34.25 C20.1027913,34.25 19.5704661,33.7581253 19.5064536,33.1278052 L19.5,33 L19.5,22 C19.5,21.3096441 20.0596441,20.75 20.75,20.75 Z M24,9.75 C22.2669685,9.75 20.8507541,11.1064548 20.7551448,12.8155761 L20.75,13 L27.25,13 C27.25,11.2050746 25.7949254,9.75 24,9.75 Z</StreamGeometry>
<StreamGeometry x:Key="arrow_left_square">M317.220571 800.182857h389.229715c69.778286 0 105.764571-35.949714 105.764571-104.740571V304.237714c0-68.754286-35.986286-104.777143-105.764571-104.777143H317.220571c-69.449143 0-105.764571 35.693714-105.764571 104.777143v391.204572c0 68.754286 36.315429 104.777143 105.764571 104.777143z m4.169143-63.926857c-29.586286 0-45.970286-15.433143-45.970285-46.628571V310.016c0-31.158857 16.384-46.592 45.970285-46.592h380.891429c29.257143 0 45.970286 15.433143 45.970286 46.628571v379.611429c0 31.158857-16.713143 46.592-45.970286 46.592H321.389714z m24.758857-237.238857c0 9.325714 3.84 16.420571 10.934858 23.149714l108.982857 107.373714c5.449143 5.485714 11.556571 8.045714 19.565714 8.045715a25.892571 25.892571 0 0 0 26.038857-26.697143 25.965714 25.965714 0 0 0-8.667428-19.602286l-38.912-36.937143-35.986286-29.257143 65.901714 2.889143h156.854857c16.384 0 27.940571-12.251429 27.940572-28.635428 0-16.713143-11.556571-28.891429-27.940572-28.891429h-156.891428l-65.828572 2.852572 36.278857-28.891429 38.582858-37.632a26.624 26.624 0 0 0 8.667428-19.602286 25.6 25.6 0 0 0-26.038857-26.331428c-8.045714 0-14.116571 2.56-19.602286 7.68l-108.982857 107.666285c-7.350857 7.424-10.898286 14.153143-10.898286 22.820572z</StreamGeometry>
<StreamGeometry x:Key="arrow_right_square">M317.220571 800.182857h389.229715c69.778286 0 105.764571-35.949714 105.764571-104.740571V304.237714c0-68.754286-35.986286-104.777143-105.764571-104.777143H317.220571c-69.449143 0-105.764571 35.693714-105.764571 104.777143v391.204572c0 68.754286 36.315429 104.777143 105.764571 104.777143z m4.169143-63.926857c-29.586286 0-45.970286-15.433143-45.970285-46.628571V310.016c0-31.158857 16.384-46.592 45.970285-46.592h380.891429c29.257143 0 45.970286 15.433143 45.970286 46.628571v379.611429c0 31.158857-16.713143 46.592-45.970286 46.592H321.389714z m356.790857-237.238857c0-8.667429-3.547429-15.396571-10.605714-22.784l-109.275428-107.702857a26.916571 26.916571 0 0 0-19.638858-7.68c-14.774857 0-25.709714 11.227429-25.709714 26.331428 0 8.045714 3.218286 14.774857 8.374857 19.602286l38.582857 37.595429 36.315429 28.928-65.901714-2.889143h-156.891429c-16.054857 0-27.940571 12.214857-27.940571 28.928 0 16.384 11.593143 28.635429 27.977143 28.635428H530.285714l66.194286-2.925714-36.315429 29.257143-38.875428 36.973714a25.709714 25.709714 0 0 0-8.374857 19.602286c0 15.104 10.971429 26.697143 25.746285 26.697143a25.965714 25.965714 0 0 0 19.602286-8.045715l109.275429-107.373714c6.729143-6.729143 10.605714-13.824 10.605714-23.149714z</StreamGeometry>
<StreamGeometry x:Key="info">M512 128a384 384 0 1 1-0.042667 768.042667A384 384 0 0 1 512 128z m-19.2 553.258667l76.501333-248.362667-16-1.408-91.52 11.690667-4.693333 13.994666c3.754667 0.085333 6.954667 0.256 9.6 0.512a17.066667 17.066667 0 0 1 13.226667 7.253334c2.986667 4.266667 4.266667 9.088 3.84 14.293333-0.725333 8.277333-3.584 20.48-8.533334 36.565333l-51.754666 166.954667c-4.181333 13.312-6.656 24.277333-7.424 33.109333-1.152 13.226667 1.28 24.533333 7.338666 33.792a33.28 33.28 0 0 0 26.282667 15.402667c30.08 2.645333 61.098667-26.112 93.269333-86.229333l-8.362666-7.936c-13.141333 22.016-24.106667 37.077333-32.853334 45.184-3.285333 3.328-6.4 4.864-9.429333 4.565333-1.834667-0.128-3.413333-1.365333-4.778667-3.797333a12.714667 12.714667 0 0 1-1.706666-7.509334c0.384-4.437333 2.688-13.866667 6.954666-28.074666zM554.496 384a41.301333 41.301333 0 0 0 30.293333-12.458667A41.301333 41.301333 0 0 0 597.333333 341.333333a41.429333 41.429333 0 0 0-12.373333-30.208 41.344 41.344 0 0 0-30.421333-12.458666 40.96 40.96 0 0 0-30.165334 12.458666A41.429333 41.429333 0 0 0 512 341.333333c0 11.776 4.138667 21.845333 12.501333 30.208 8.405333 8.277333 18.346667 12.458667 30.037334 12.458667z</StreamGeometry>
<StreamGeometry x:Key="edit">M800 960 224 960c-52.928 0-96-43.072-96-96L128 224c0-52.928 43.072-96 96-96l448 0c17.696 0 32 14.336 32 32s-14.304 32-32 32L224 192C206.368 192 192 206.368 192 224l0 640c0 17.664 14.368 32 32 32l576 0c17.664 0 32-14.336 32-32L832 352c0-17.664 14.304-32 32-32s32 14.336 32 32l0 512C896 916.928 852.928 960 800 960zM612 448c-8.192 0-16.384-3.136-22.624-9.376-12.512-12.512-12.512-32.736 0-45.248l318.016-318.016c12.512-12.512 32.736-12.512 45.248 0s12.512 32.736 0 45.248l-318.016 318.016C628.384 444.896 620.192 448 612 448zM480 448 288 448c-17.664 0-32-14.336-32-32s14.336-32 32-32l192 0c17.664 0 32 14.336 32 32S497.664 448 480 448zM672 640 288 640c-17.664 0-32-14.304-32-32s14.336-32 32-32l384 0c17.696 0 32 14.304 32 32S689.696 640 672 640z</StreamGeometry>
<StreamGeometry x:Key="duigou">M800 960 224 960c-52.928 0-96-43.072-96-96L128 224c0-52.928 43.072-96 96-96l448 0c17.696 0 32 14.336 32 32s-14.304 32-32 32L224 192C206.368 192 192 206.368 192 224l0 640c0 17.664 14.368 32 32 32l576 0c17.664 0 32-14.336 32-32L832 352c0-17.664 14.304-32 32-32s32 14.336 32 32l0 512C896 916.928 852.928 960 800 960zM612 448c-8.192 0-16.384-3.136-22.624-9.376-12.512-12.512-12.512-32.736 0-45.248l318.016-318.016c12.512-12.512 32.736-12.512 45.248 0s12.512 32.736 0 45.248l-318.016 318.016C628.384 444.896 620.192 448 612 448zM480 448 288 448c-17.664 0-32-14.336-32-32s14.336-32 32-32l192 0c17.664 0 32 14.336 32 32S497.664 448 480 448zM672 640 288 640c-17.664 0-32-14.304-32-32s14.336-32 32-32l384 0c17.696 0 32 14.304 32 32S689.696 640 672 640z</StreamGeometry>
<StreamGeometry x:Key="pin_regular">M13.5538 2.66232C14.4174 1.85314 15.75 1.85663 16.6089 2.64211L16.7341 2.7658L21.4991 7.85135C21.6191 7.97942 21.7237 8.12108 21.8108 8.27345C22.4005 9.30545 22.0832 10.6078 21.1103 11.2587L20.9736 11.3433L16.0771 14.1413C15.9593 14.2086 15.8626 14.3062 15.7964 14.4232L15.7526 14.5144L13.9505 19.028C13.7641 19.4949 13.1888 19.6418 12.8033 19.3497L12.7237 19.2804L9.48597 16.0442L4.53489 21.0033L3.46997 21L3.47201 19.9449L8.42497 14.9832L5.22008 11.7804C4.86452 11.425 4.95639 10.8384 5.37685 10.5992L5.47194 10.5535L9.96721 8.7569C10.0987 8.70436 10.2119 8.61598 10.2946 8.50278L10.3506 8.4134L13.1069 3.24538C13.2229 3.02786 13.3739 2.83088 13.5538 2.66232ZM20.4045 8.87696L15.6395 3.7914C15.3563 3.48914 14.8817 3.4737 14.5794 3.75691C14.5394 3.79437 14.5037 3.83604 14.4729 3.88114L14.4304 3.95127L11.6742 9.11929C11.4521 9.53569 11.1055 9.87036 10.685 10.078L10.5239 10.1498L7.08541 11.524L12.9793 17.4151L14.3596 13.9582C14.5246 13.5449 14.8079 13.1911 15.172 12.9401L15.3329 12.8389L20.2293 10.0409C20.589 9.83544 20.7139 9.3773 20.5084 9.01766L20.4606 8.94427L20.4045 8.87696Z</StreamGeometry>
</Style.Resources>
</Style>
</Styles>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 KiB

BIN
ZTools/Assets/对.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
ZTools/Assets/对勾.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

62
ZTools/Models/Log.cs Normal file
View File

@ -0,0 +1,62 @@
using System;
using System.Text;
namespace ZTools;
public enum LogLevel
{
Error,
Warning,
Info,
Debug,
}
public static class Log
{
private static StringBuilder _logBuilder;
private static StringBuilder _tmp;
internal static StringBuilder LogBuilder => _logBuilder;
public delegate void LogDelegate(string msg);
public static LogDelegate LogCallback;
static Log()
{
_logBuilder = new StringBuilder();
_tmp = new StringBuilder();
}
public static void Debug(object message)
{
Write(message, LogLevel.Debug);
}
public static void Info(object message)
{
Write(message, LogLevel.Info);
}
public static void Error(object message)
{
Write(message, LogLevel.Error);
}
public static void Warning(object message)
{
Write(message, LogLevel.Warning);
}
static void Write(object message, LogLevel level = LogLevel.Debug)
{
// var bytes = Encoding.UTF8.GetBytes(message.ToString() ?? string.Empty);
// var s = Encoding.UTF8.GetString(bytes);
_tmp.Clear();
_tmp.Append($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff}] {level}: {message}");
var format = _tmp.ToString();
_logBuilder.AppendLine(format);
Console.WriteLine(format);
LogCallback?.Invoke(format);
}
}

View File

@ -0,0 +1,21 @@
using System.Windows.Input;
using Avalonia.Media.Imaging;
using ZTools.ViewModels;
namespace ZTools.Models;
public class MenuButtonItem
{
public Bitmap Icon { get; set; }
public string Content { get; set; }
public ICommand CommandEvent { get; set; }
public PageViewModelBase PageView { get; set; }
public MenuButtonItem(Bitmap icon, string content, ICommand commandEvent, PageViewModelBase pageView)
{
Icon = icon;
Content = content;
CommandEvent = commandEvent;
PageView = pageView;
}
}

21
ZTools/Program.cs Normal file
View File

@ -0,0 +1,21 @@
using Avalonia;
using System;
namespace ZTools;
sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);
// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}

View File

@ -0,0 +1,16 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<!-- Add Controls for Previewer Here -->
</Border>
</Design.PreviewWith>
<!-- Add Styles Here -->
<Style>
<Style.Resources>
<StreamGeometry x:Key="speaker_off_regular">M28 29.7678L41.8661 43.6339C42.3543 44.122 43.1457 44.122 43.6339 43.6339C44.122 43.1457 44.122 42.3543 43.6339 41.8661L6.13388 4.36612C5.64573 3.87796 4.85427 3.87796 4.36611 4.36612C3.87796 4.85427 3.87796 5.64573 4.36611 6.13388L13.2322 15H9C6.10051 15 3.75 17.3505 3.75 20.25V27.75C3.75 30.6495 6.10051 33 9 33H13.702C14.8734 33 16.0034 33.4328 16.875 34.2153L25.081 41.5815C26.2077 42.5929 28 41.7933 28 40.2793V29.7678ZM25.5 27.2678V38.5981L18.5451 32.3549C17.2146 31.1606 15.4898 30.5 13.702 30.5H9C7.48122 30.5 6.25 29.2688 6.25 27.75V20.25C6.25 18.7312 7.48122 17.5 9 17.5H13.702C14.3147 17.5 14.92 17.4224 15.5046 17.2723L25.5 27.2678Z M19.8115 14.5082L18.0412 12.7379L25.081 6.41847C26.2076 5.40709 28 6.20669 28 7.72074V22.6967L25.5 20.1967V9.40185L19.8115 14.5082Z M36.1857 30.8824L34.335 29.0317C34.966 27.7376 35.5 26.0404 35.5 24C35.5 21.5224 34.7127 19.5507 33.9203 18.1923C33.5242 17.5133 33.1298 16.9931 32.8397 16.6477C32.695 16.4754 32.577 16.3476 32.499 16.2664C32.46 16.2259 32.4311 16.197 32.414 16.1802L32.3972 16.164L32.398 16.1646C31.8935 15.6947 31.8647 14.9048 32.334 14.3994C32.8038 13.8935 33.5947 13.8642 34.1006 14.334L33.25 15.25C34.1006 14.334 34.1014 14.3347 34.1014 14.3347L34.1022 14.3356L34.1042 14.3374L34.1092 14.3421L34.1228 14.355C34.1336 14.3653 34.1476 14.3788 34.1646 14.3955C34.1987 14.4289 34.245 14.4753 34.3018 14.5343C34.4152 14.6524 34.5707 14.8215 34.754 15.0398C35.1202 15.4757 35.6008 16.1117 36.0797 16.9327C37.0373 18.5743 38 20.9776 38 24C38 26.9108 37.1071 29.2474 36.1857 30.8824Z M41.0185 35.7152L39.1733 33.87C40.3712 31.5479 41.5 28.2383 41.5 24C41.5 19.4474 40.1976 15.9662 38.906 13.6297C38.2594 12.46 37.6157 11.5776 37.1403 10.9943C36.9028 10.7028 36.708 10.4867 36.5767 10.3474C36.511 10.2777 36.4614 10.2274 36.4303 10.1965C36.4148 10.181 36.4039 10.1704 36.398 10.1648L36.3949 10.1617L36.393 10.16C35.8916 9.68785 35.8665 8.89867 36.3376 8.39562C36.8094 7.89169 37.6004 7.8657 38.1044 8.33755L37.2501 9.24987C38.1044 8.33755 38.1053 8.33839 38.1053 8.33839L38.1063 8.33935L38.1087 8.34162L38.115 8.34761L38.1336 8.36536C38.1485 8.37975 38.1685 8.39926 38.1932 8.42388C38.2427 8.4731 38.3112 8.54276 38.396 8.6327C38.5655 8.81253 38.8003 9.07375 39.0784 9.41509C39.6343 10.0974 40.3656 11.1025 41.094 12.4203C42.5524 15.0587 44 18.9526 44 24C44 29.0474 42.5524 32.9412 41.094 35.5797L41.0739 35.6159L41.0185 35.7152Z</StreamGeometry>
<StreamGeometry x:Key="speaker_regular">M25.081 6.41848C26.2076 5.4071 28 6.2067 28 7.72074V40.2793C28 41.7933 26.2077 42.5929 25.081 41.5815L16.875 34.2153C16.0034 33.4328 14.8734 33 13.702 33H9C6.10051 33 3.75 30.6495 3.75 27.75V20.25C3.75 17.3505 6.10051 15 9 15H13.702C14.8734 15 16.0034 14.5672 16.875 13.7847L25.081 6.41848ZM25.5 9.40186L18.5451 15.6451C17.2146 16.8394 15.4898 17.5 13.702 17.5H9C7.48122 17.5 6.25 18.7312 6.25 20.25V27.75C6.25 29.2688 7.48122 30.5 9 30.5H13.702C15.4898 30.5 17.2146 31.1606 18.5451 32.3549L25.5 38.5982V9.40186Z M36.3376 8.39563C36.8095 7.8917 37.6005 7.86571 38.1044 8.33757L38.1053 8.3384C38.1053 8.3384 37.7675 8 38.1151 8.34762L38.1336 8.36537C38.1485 8.37976 38.1685 8.39927 38.1933 8.42389C38.2428 8.47311 38.3113 8.54277 38.396 8.63271C38.5655 8.81254 38.8004 9.07377 39.0785 9.4151C39.6344 10.0974 40.3656 11.1025 41.094 12.4203C42.5525 15.0588 44.0001 18.9526 44.0001 24C44.0001 29.0474 42.5525 32.9413 41.094 35.5797C40.3656 36.8975 39.6344 37.9027 39.0785 38.5849C38.8004 38.9262 38.5655 39.1875 38.396 39.3673C38.3714 39.3935 38.3481 39.4179 38.3262 39.4407C38.273 39.4961 38.2284 39.5412 38.1933 39.5761C38.1685 39.6007 38.1485 39.6202 38.1336 39.6346L38.1151 39.6524L38.1088 39.6584L38.1063 39.6607L38.1053 39.6616C38.1053 39.6616 38.2392 39.5277 38.3262 39.4407C38.4326 39.3343 38.4688 39.298 38.1044 39.6624C37.6005 40.1343 36.8095 40.1083 36.3376 39.6044C35.8666 39.1013 35.8917 38.3122 36.3931 37.84L36.3949 37.8383L36.3981 37.8352C36.404 37.8296 36.4148 37.819 36.4304 37.8035C36.4614 37.7726 36.5111 37.7223 36.5767 37.6526C36.708 37.5133 36.9029 37.2972 37.1404 37.0057C37.6157 36.4224 38.2595 35.54 38.9061 34.3703C40.1976 32.0338 41.5001 28.5526 41.5001 24C41.5001 19.4474 40.1976 15.9663 38.9061 13.6297C38.2595 12.46 37.6157 11.5776 37.1404 10.9943C36.9029 10.7028 36.708 10.4867 36.5767 10.3474C36.5111 10.2777 36.4614 10.2274 36.4304 10.1965C36.4148 10.181 36.404 10.1705 36.3981 10.1648L36.3949 10.1617L36.3931 10.16C35.8917 9.68786 35.8666 8.89869 36.3376 8.39563Z M32.3341 14.3994C32.8038 13.8936 33.5947 13.8643 34.1006 14.334C34.1008 14.3342 34.1014 14.3348 34.1014 14.3348L34.1023 14.3356L34.1043 14.3374L34.1092 14.3421L34.1229 14.355C34.1336 14.3653 34.1477 14.3788 34.1647 14.3955C34.1988 14.429 34.2451 14.4753 34.3018 14.5344C34.4152 14.6524 34.5707 14.8215 34.7541 15.0398C35.1202 15.4757 35.6009 16.1117 36.0798 16.9327C37.0374 18.5743 38.0001 20.9776 38.0001 24C38.0001 27.0224 37.0374 29.4257 36.0798 31.0673C35.6009 31.8883 35.1202 32.5243 34.7541 32.9602C34.5707 33.1785 34.4152 33.3476 34.3018 33.4656C34.2451 33.5247 34.1988 33.5711 34.1647 33.6045L34.1452 33.6235L34.1229 33.645L34.1092 33.6579L34.1043 33.6626L34.1015 33.6652L34.1006 33.666C33.5947 34.1357 32.8038 34.1065 32.3341 33.6006C31.8653 33.0958 31.8935 32.3072 32.3962 31.8371L32.3979 31.8355L32.414 31.8198C32.4312 31.803 32.4601 31.7741 32.4991 31.7336C32.5771 31.6524 32.695 31.5246 32.8398 31.3523C33.1299 31.0069 33.5242 30.4867 33.9203 29.8077C34.7127 28.4493 35.5001 26.4776 35.5001 24C35.5001 21.5224 34.7127 19.5507 33.9203 18.1923C33.5242 17.5133 33.1299 16.9931 32.8398 16.6477C32.695 16.4754 32.5771 16.3476 32.4991 16.2664C32.4601 16.2259 32.4312 16.197 32.414 16.1802L32.3973 16.164L32.3981 16.1647C31.8929 15.6949 31.8645 14.9051 32.3341 14.3994Z</StreamGeometry>
</Style.Resources>
</Style>
</Styles>

30
ZTools/ViewLocator.cs Normal file
View File

@ -0,0 +1,30 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Templates;
using ZTools.ViewModels;
namespace ZTools;
public class ViewLocator : IDataTemplate
{
public Control? Build(object? param)
{
if (param is null)
return null;
var name = param.GetType().FullName!.Replace("ViewModel", "View", StringComparison.Ordinal);
var type = Type.GetType(name);
if (type != null)
{
return (Control)Activator.CreateInstance(type)!;
}
return new TextBlock { Text = "Not Found: " + name };
}
public bool Match(object? data)
{
return data is ViewModelBase;
}
}

View File

@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using CommunityToolkit.Mvvm.ComponentModel;
using ZTools.Models;
using ZTools.Views;
namespace ZTools.ViewModels;
public partial class MainWindowItem : ObservableObject
{
private string itemIconName;
[ObservableProperty] private Bitmap itemIcon;
[ObservableProperty] private string itemName;
public MainWindowItem(string itemIcon, string itemName)
{
this.itemIconName = itemIcon;
var uri = itemIconName;
var bitmap = new Bitmap(AssetLoader.Open(new Uri(uri)));
this.itemIcon = bitmap;
this.itemName = itemName;
}
}
public partial class MainWindowViewModel : ViewModelBase
{
[ObservableProperty]
private ObservableCollection<MainWindowItem> _menuItems = new ObservableCollection<MainWindowItem>()
{
new MainWindowItem("avares://ZTools/Assets/Menu/个人.png","个人"),
new MainWindowItem("avares://ZTools/Assets/Menu/首页.png","首页"),
new MainWindowItem("avares://ZTools/Assets/Menu/消息.png","消息"),
new MainWindowItem("avares://ZTools/Assets/Menu/功能.png","功能"),
new MainWindowItem("avares://ZTools/Assets/Menu/其他.png","其他"),
};
private MainWindowItem selectedMenuItem;
public MainWindowItem SelectedMenuItem
{
get => selectedMenuItem;
set
{
selectedMenuItem = value;
// this.RaiseAndSetIfChanged(ref selectedMenuItem, value);
OnSelectedItemChanged();
}
}
private void OnSelectedItemChanged()
{
if (selectedMenuItem!= null)
{
Log.Debug($"Selected item in ViewModel: {selectedMenuItem.ItemName}");
switch (selectedMenuItem.ItemName)
{
case "个人":
new SettingWindow().Show();
break;
case "首页":
new SettingWindow().Show();
break;
case "消息":
new SettingWindow().Show();
break;
case "功能":
new SettingWindow().Show();
break;
case "其他":
new SettingWindow().Show();
break;
case "设置":
new SettingWindow().Show();
break;
default:
throw new NullReferenceException();
break;
}
}
else
{
Log.Debug("No item selected in ViewModel");
}
}
[ObservableProperty]
private ObservableCollection<MainWindowItem> _leftDownItems = new ObservableCollection<MainWindowItem>()
{
new MainWindowItem("avares://ZTools/Assets/Menu/设置.png","设置"),
};
}

View File

@ -0,0 +1,6 @@
namespace ZTools.ViewModels;
public class FeaturePageViewModel: PageViewModelBase
{
}

View File

@ -0,0 +1,26 @@
using System.Collections.ObjectModel;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using ZTools.Models;
namespace ZTools.ViewModels;
public partial class LogItem
{
public string Message { get; set; } = string.Empty;
}
public partial class LogViewModel : PageViewModelBase
{
[ObservableProperty] private ObservableCollection<LogItem> _myLogs = new ObservableCollection<LogItem>();
public LogViewModel()
{
Log.LogCallback += UpdateLog;
}
private void UpdateLog(string obj)
{
MyLogs.Add(new LogItem() { Message = obj });
}
}

View File

@ -0,0 +1,6 @@
namespace ZTools.ViewModels;
public abstract class PageViewModelBase : ViewModelBase
{
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using CommunityToolkit.Mvvm.ComponentModel;
namespace ZTools.ViewModels;
public partial class Item1: ObservableObject
{
[ObservableProperty]
private string _name;
[ObservableProperty]
private DateTime _bornDate;
public override string ToString()
{
return $"Name: {_name}, BornDate: {_bornDate}";
}
}
public partial class SettingViewModel: PageViewModelBase
{
private bool _isOpenLog;
private bool _isOnTop;
public bool IsOpenLog => _isOpenLog;
public bool IsOnTop => _isOnTop;
}

View File

@ -0,0 +1,8 @@
using Avalonia.Markup.Xaml.MarkupExtensions;
namespace ZTools.ViewModels;
public partial class TestWindowViewModel : ViewModelBase
{
// public object wc=>Resources.GetResourceObservable("TheKey");
}

View File

@ -0,0 +1,7 @@
using CommunityToolkit.Mvvm.ComponentModel;
namespace ZTools.ViewModels;
public class ViewModelBase : ObservableObject
{
}

View File

@ -0,0 +1,9 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZTools.Views.FeaturePage"
Title="FeaturePage">
Welcome to Avalonia!
</Window>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace ZTools.Views;
public partial class FeaturePage : Window
{
public FeaturePage()
{
InitializeComponent();
}
}

View File

@ -0,0 +1,32 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="using:ZTools.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="200" d:DesignHeight="450"
x:Class="ZTools.Views.LogWindow"
x:DataType="vm:LogViewModel"
Title="LogWindow">
<Window.DataContext>
<vm:LogViewModel />
</Window.DataContext>
<DockPanel>
<Border Background="Gold"
BorderBrush="Black"
BorderThickness="1"
CornerRadius="0"
Padding="1">
<ListBox ItemsSource="{Binding MyLogs}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBox IsReadOnly="True"
TextWrapping="Wrap"
Text="{Binding Message }">
</TextBox>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Border>
</DockPanel>
</Window>

View File

@ -0,0 +1,20 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace ZTools.Views;
public partial class LogWindow : Window
{
public LogWindow()
{
InitializeComponent();
}
private void Button_OnClick(object? sender, RoutedEventArgs e)
{
Log.Debug("Click");
}
}

View File

@ -0,0 +1,127 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ZTools.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZTools.Views.MainWindow"
x:DataType="vm:MainWindowViewModel"
Title="ZTools">
<Design.DataContext>
<!-- This only sets the DataContext for the previewer in an IDE,
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
<vm:MainWindowViewModel />
</Design.DataContext>
<DockPanel Name="MainDockPanel">
<!-- 菜单 -->
<DockPanel Name="MenuDockPanel"
Width="70"
Dock="Left">
<Grid>
<ListBox SelectionMode="Single"
ItemsSource="{Binding MenuItems}"
SelectedItem="{Binding SelectedMenuItem}"
VerticalAlignment="Top">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="40,40" RowDefinitions="Auto,Auto" VerticalAlignment="Center"
HorizontalAlignment="Center">
<Image Grid.Row="0" Grid.Column="0" Width="20" Height="20"
Source="{Binding ItemIcon}" />
<TextBlock Grid.Row="1" Grid.Column="0" Width="20" FontSize="10"
Text="{Binding ItemName}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<ListBox Name="leftDownList"
SelectionMode="Single"
ItemsSource="{Binding LeftDownItems}"
SelectedItem="{Binding SelectedMenuItem}"
VerticalAlignment="Bottom">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ColumnDefinitions="40,40" RowDefinitions="Auto,Auto" VerticalAlignment="Center"
HorizontalAlignment="Center">
<Image Grid.Row="0" Grid.Column="0" Width="20" Height="20"
Source="{Binding ItemIcon}" />
<TextBlock Grid.Row="1" Grid.Column="0" Width="20" FontSize="10"
Text="{Binding ItemName}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>
</DockPanel>
<!-- <Border x:Name="Menu" -->
<!-- Width="70" -->
<!-- Background="Gainsboro" -->
<!-- BorderBrush="Black" -->
<!-- BorderThickness="0,0,2,0" -->
<!-- CornerRadius="3" -->
<!-- DockPanel.Dock="Left"> -->
<!-- <DockPanel> -->
<!-- -->
<!-- </DockPanel> -->
<!-- </Border> -->
<Border Name="resizeThumb"
Width="5"
Background="Gray"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
</Border>
<!-- 二级菜单 -->
<DockPanel Name="SecondMenuDockPanel"
Background="Blue"
Width="240"
Dock="Left">
<!-- 功能 -->
<Grid Name="myGrid" HorizontalAlignment="Left" VerticalAlignment="Top">
<!-- <Grid.ColumnDefinitions> -->
<!-- <ColumnDefinition Width="Auto" /> -->
<!-- <ColumnDefinition Width="Auto" /> -->
<!-- <ColumnDefinition Width="Auto" /> -->
<!-- ~1~ 这里可以添加更多列,或者根据需要在代码中动态添加 @1@ -->
<!-- </Grid.ColumnDefinitions> -->
</Grid>
</DockPanel>
<!-- <Border Width="240" -->
<!-- Background="Gainsboro" -->
<!-- BorderBrush="Black" -->
<!-- BorderThickness="0,0,2,0" -->
<!-- CornerRadius="3" -->
<!-- DockPanel.Dock="Left"> -->
<!-- </Border> -->
<Border Name="resizeThumb1"
Width="5"
Background="Gray"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
</Border>
<!-- 具体功能区 -->
<DockPanel Name="FunctionDockPanel"
Background="Orange"
Dock="Left">
<Border
Background="MistyRose"
HorizontalAlignment="Left"
VerticalAlignment="Stretch">
<TextBlock>ccccc</TextBlock>
</Border>
</DockPanel>
<!-- <Border Background="Gainsboro" -->
<!-- BorderBrush="Black" -->
<!-- Padding="10" -->
<!-- CornerRadius="3" -->
<!-- DockPanel.Dock="Left"> -->
<!-- </Border> -->
</DockPanel>
</Window>

View File

@ -0,0 +1,144 @@
using System.Collections.ObjectModel;
using System.Linq;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Shapes;
using Avalonia.Interactivity;
using Avalonia.Layout;
using Avalonia.Media;
namespace ZTools.Views;
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
AddColumns();
// AutoWeight();
InitAutoDrag();
}
private void Button_OpenSetting(object? sender, RoutedEventArgs e)
{
var settingWindow = new SettingWindow();
settingWindow.Show();
}
private void Button_OpenLog(object? sender, RoutedEventArgs e)
{
new LogWindow().Show();
}
private void Button_OpenTest(object? sender, RoutedEventArgs e)
{
new TestWindow().Show();
}
double _dragStartX;
double _initialWidth;
double _initialRightWidth;
bool _isResizing = false;
void InitAutoDrag()
{
// MainDockPanel.Children.Add(resizeThumb);
//
// MainDockPanel.Children.Add(resizeThumb1);
// 监听拖拽区域的PointerPressed事件
resizeThumb.PointerPressed += (sender, e) =>
{
if (e.GetCurrentPoint(MainDockPanel).Properties.IsLeftButtonPressed)
{
_dragStartX = e.GetPosition(this).X;
_initialWidth = MenuDockPanel.Width;
_initialRightWidth = SecondMenuDockPanel.Width;
_isResizing = true;
e.Handled = true;
}
};
resizeThumb1.PointerPressed += (sender, e) =>
{
if (e.GetCurrentPoint(SecondMenuDockPanel).Properties.IsLeftButtonPressed)
{
_dragStartX = e.GetPosition(this).X;
_initialWidth = SecondMenuDockPanel.Width;
_initialRightWidth = FunctionDockPanel.Width;
_isResizing = true;
e.Handled = true;
}
};
// 监听鼠标移动事件实时更新左侧Panel的宽度
resizeThumb.PointerMoved += (sender, e) =>
{
if (_isResizing)
{
var currentX = e.GetPosition(this).X;
var delta = currentX - _dragStartX;
var updateLeft = _initialWidth + delta;
var updateRight = _initialRightWidth - delta;
MenuDockPanel.Width = updateLeft > 1 ? updateLeft : 1; // 更新左侧Panel的宽度
SecondMenuDockPanel.Width = updateRight > 1 ? updateRight : 1;
e.Handled = true;
}
};
resizeThumb1.PointerMoved += (sender, e) =>
{
if (_isResizing)
{
var currentX = e.GetPosition(this).X;
var delta = currentX - _dragStartX;
var updateLeft = _initialWidth + delta;
var updateRight = _initialRightWidth - delta;
SecondMenuDockPanel.Width = updateLeft > 1 ? updateLeft : 1; // 更新左侧Panel的宽度
FunctionDockPanel.Width = _initialRightWidth - delta; // updateRight > 1 ? updateRight : 1;
e.Handled = true;
}
};
// 监听鼠标释放事件,结束拖拽
resizeThumb.PointerReleased += (sender, e) => { _isResizing = false; };
resizeThumb1.PointerReleased += (sender, e) => { _isResizing = false; };
}
private void AddColumns()
{
// Grid myGrid = this.FindControl<Grid>("myGrid");
int count = 4;
for (int i = 0; i < 19; i++) // 添加 5 列
{
var hang = i / count;
var lie = i % count;
Log.Debug($"{hang} : {lie}");
if (this.myGrid.RowDefinitions.Count < hang + 1)
this.myGrid.RowDefinitions.Add(new RowDefinition(new GridLength(hang, GridUnitType.Auto)));
if (this.myGrid.ColumnDefinitions.Count < lie + 1)
myGrid.ColumnDefinitions.Add(new ColumnDefinition(new GridLength(lie, GridUnitType.Auto)));
Border border = new Border()
{
Width = 60,
Height = 40,
BorderBrush = Brushes.Black, // 设置边框颜色
BorderThickness = new Thickness(2), // 设置边框厚度
Padding = new Thickness(2), // 设置内部填充
Background = Brushes.LightGray, // 设置背景颜色
HorizontalAlignment = HorizontalAlignment.Stretch,
VerticalAlignment = VerticalAlignment.Stretch,
};
var textBlock = new TextBlock
{
Text = $"{hang} : {lie}",
HorizontalAlignment = HorizontalAlignment.Center,
Background = i % 2 == 0 ? Brushes.Red : Brushes.Green,
};
border.Child = textBlock;
this.myGrid.Children.Add(border);
Grid.SetRow(border, hang);
Grid.SetColumn(border, lie);
}
}
}

View File

@ -0,0 +1,63 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:ZTools.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
xmlns:objectModel="clr-namespace:System.Collections.ObjectModel;assembly=System.ObjectModel"
mc:Ignorable="d" d:DesignWidth="400" d:DesignHeight="300"
x:Class="ZTools.Views.SettingWindow"
Title="SettingWindow"
x:DataType="vm:SettingViewModel">
<!-- Test Instance of ViewModel -->
<Window.DataContext>
<vm:SettingViewModel />
</Window.DataContext>
<Design.DataContext>
<vm:SettingViewModel>
<!-- <vm:SettingViewModel.ThemeChanged>False</vm:SettingViewModel.ThemeChanged> -->
<!-- <vm:SettingViewModel.ThemeName> -->
<!-- <system:String>LightOrDark</system:String> -->
<!-- </vm:SettingViewModel.ThemeName> -->
<!-- <vm:SettingViewModel.Themes> -->
<!-- <objectModel:ObservableCollection x:TypeArguments="vm:Item1"> -->
<!-- <vm:Item1 Name="job" BornDate="2014/09/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="John" BornDate="2024/12/03 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="Bob" BornDate="2002/01/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="job" BornDate="2014/09/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="John" BornDate="2024/12/03 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="Bob" BornDate="2002/01/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="job" BornDate="2014/09/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="John" BornDate="2024/12/03 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="Bob" BornDate="2002/01/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="job" BornDate="2014/09/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="John" BornDate="2024/12/03 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="Bob" BornDate="2002/01/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="job" BornDate="2014/09/23 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="John" BornDate="2024/12/03 23:09:19"></vm:Item1> -->
<!-- <vm:Item1 Name="Bob" BornDate="2002/01/23 23:09:19"></vm:Item1> -->
<!-- </objectModel:ObservableCollection> -->
<!-- </vm:SettingViewModel.Themes> -->
</vm:SettingViewModel>
</Design.DataContext>
<DockPanel>
<ListBox VerticalAlignment="Center" HorizontalAlignment="Center">
<ToggleButton IsCheckedChanged="ToggleButton_OnIsCheckedChanged">
<Panel>
<PathIcon Data="{DynamicResource duigou}">
</PathIcon>
</Panel>
<!-- <Panel> -->
<!-- <Image Width="20" Height="20" Source="../Assets/对勾.png"></Image> -->
<!-- </Panel> -->
</ToggleButton>
<TextBlock Text="是否打开日志"></TextBlock>
</ListBox>
</DockPanel>
</Window>

View File

@ -0,0 +1,25 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
namespace ZTools.Views;
public partial class SettingWindow : Window
{
public SettingWindow()
{
InitializeComponent();
}
private void ToggleButton_OnIsCheckedThemeChanged(object? sender, RoutedEventArgs e)
{
// e.Handled
Log.Debug(e.Handled);
}
private void ToggleButton_OnIsCheckedChanged(object? sender, RoutedEventArgs e)
{
}
}

View File

@ -0,0 +1,30 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vm="using:ZTools.ViewModels"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZTools.Views.TestWindow"
x:DataType="vm:TestWindowViewModel"
Title="Test">
<Window.DataContext>
<vm:TestWindowViewModel />
</Window.DataContext>
<Design.DataContext>
<vm:TestWindowViewModel>
</vm:TestWindowViewModel>
</Design.DataContext>
<DockPanel>
<ListBox VerticalAlignment="Center" HorizontalAlignment="Left">
<Image Width="40" Height="40" Source="../Assets/Menu/个人.png"></Image>
<TextBlock Name="myTextBlock" Width="40" Height="40" Text="123"></TextBlock>
<Image Name="img" Width="40" Height="40"></Image>
<PathIcon Name="ico" Width="40" Height="40" Data="{DynamicResource check}"></PathIcon>
</ListBox>
</DockPanel>
</Window>

View File

@ -0,0 +1,33 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
namespace ZTools.Views;
public partial class TestWindow : Window
{
public TestWindow()
{
InitializeComponent();
// found1 = false | result1 = null
var found1 = this.TryGetResource("TheKey", this.ActualThemeVariant, out var result1);
// found2 = true | result2 = "Hello World"
var found2 = this.TryFindResource("TheKey", this.ActualThemeVariant, out var result2);
// 从代码中找到资源并将其绑定到 TextBlock
myTextBlock.Bind(TextBlock.TextProperty, Resources.GetResourceObservable("TheKey"));
var uri = "avares://ZTools/Assets/Menu/其他.png";
var bitmap = new Bitmap(AssetLoader.Open(new Uri(uri)));
img.Source=bitmap;
// 通过绑定的 observable 更新 myTextBlock.Text
this.Resources["TheKey"] = "Hello from code behind";
}
}

18
ZTools/app.manifest Normal file
View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="ZTools.Desktop"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on
and is designed to work with. Uncomment the appropriate elements
and Windows will automatically select the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>