Skip to content

[WIP] 添加对 Avalonia 的支持 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added AXNode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 50 additions & 0 deletions AXNode/AXNode.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<ApplicationManifest>app.manifest</ApplicationManifest>
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.0"/>
<PackageReference Include="Avalonia.Desktop" Version="11.1.0"/>
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.0"/>
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.0"/>
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.0"/>
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.1.0.7"/>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XLib.Animate\XLib.Animate.csproj"/>
<ProjectReference Include="..\XLib.AvaloniaControl\XLib.AvaloniaControl.csproj"/>
<ProjectReference Include="..\XLib.Avalonia\XLib.Avalonia.csproj"/>
<ProjectReference Include="..\XLib.Base\XLib.Base.csproj"/>
<ProjectReference Include="..\XLib.Drawing\XLib.Drawing.csproj"/>
<ProjectReference Include="..\XLib.Math\XLib.Math.csproj"/>
<ProjectReference Include="..\XLib.Node\XLib.Node.csproj"/>
</ItemGroup>


<ItemGroup>
<AvaloniaResource Include="Assets\Cursor\CanNotMove.cur"/>
<AvaloniaResource Include="Assets\Cursor\*.cur"/>
<AvaloniaResource Include="Assets\Font\simsun.ttc"/>
<AvaloniaResource Include="Assets\Icon15\*.png"/>
<AvaloniaResource Include="Assets\Icon16\Node\*.png"/>
<AvaloniaResource Include="Assets\Icon16\*.png"/>
<AvaloniaResource Include="SubSystem\NodeEditSystem\Control\Image\*.png"/>
<AvaloniaResource Include="SubSystem\WindowSystem\Image\*.png"/>
</ItemGroup>


<ItemGroup>
<Folder Include="Interactivity\"/>
</ItemGroup>


</Project>
17 changes: 17 additions & 0 deletions AXNode/App.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AXNode.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="Assets/PinIcons.axaml"></ResourceInclude>

</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
41 changes: 41 additions & 0 deletions AXNode/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Markup.Xaml;
using AXNode.AppTool;
using XLib.Animate;

namespace AXNode;

public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);

// AnimationEngine.Instance.Start();
Init();
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow();
}

base.OnFrameworkInitializationCompleted();
}

private void Init()
{
// 初始化应用程序代理
AppDelegate.Init();

// 初始化系统数据
SystemDataDelegate.Instance.Init();
// 启动系统服务
SystemServiceDelegate.Instance.Start();
// 初始化系统工具
SystemToolDelegate.Instance.Init();
}
}
32 changes: 32 additions & 0 deletions AXNode/AppTool/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Windows;
using Avalonia;
using Avalonia.Threading;

namespace AXNode.AppTool
{
/// <summary>
/// 应用程序代理
/// </summary>
public class AppDelegate
{
public static App Main { get; set; }

public static string AppTitle => "XNode 1.0.3 Alpha";

public static void Init()
{
if (Application.Current is App app) Main = app;
}

public static void Invoke(Action action)
{
Dispatcher.UIThread.Invoke(action);
}

public static void BeginInvoke(Action action)
{
Dispatcher.UIThread.Invoke(action);
}
}
}
22 changes: 22 additions & 0 deletions AXNode/AppTool/ClassExtension.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using XLib.Node;
using AXNode.SubSystem.NodeEditSystem.Define;

namespace AXNode.AppTool
{
public static class ClassExtension
{
/// <summary>
/// 获取引脚路径
/// </summary>
public static PinPath GetPinPath(this PinBase pin)
{
return new PinPath
{
NodeVersion = pin.OwnerGroup.OwnerNode.Version,
NodeID = pin.OwnerGroup.OwnerNode.ID,
GroupIndex = pin.OwnerGroup.Index,
PinIndex = pin.OwnerGroup.GetPinIndex(pin)
};
}
}
}
6 changes: 6 additions & 0 deletions AXNode/AppTool/ProjectDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace AXNode.AppTool
{
class ProjectDelegate
{
}
}
64 changes: 64 additions & 0 deletions AXNode/AppTool/SystemDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using XLib.Animate;
using XLib.Base.AppFrame;
using AXNode.SubSystem.CacheSystem;
using AXNode.SubSystem.ControlSystem;
using AXNode.SubSystem.EventSystem;
using AXNode.SubSystem.NodeLibSystem;
using AXNode.SubSystem.OptionSystem;
using AXNode.SubSystem.ResourceSystem;
using AXNode.SubSystem.TimerSystem;

namespace AXNode.AppTool
{
/// <summary>
/// 系统数据代理
/// </summary>
public class SystemDataDelegate : ManagerDelegate
{
private SystemDataDelegate()
{
// 选项、缓存
ManagerList.Add(OptionManager.Instance);
ManagerList.Add(CacheManager.Instance);
// 资源、节点库
ManagerList.Add(ResourceManager.Instance);
ManagerList.Add(NodeLibManager.Instance);
}

public static SystemDataDelegate Instance { get; } = new SystemDataDelegate();
}

/// <summary>
/// 系统服务代理
/// </summary>
public class SystemServiceDelegate : ServiceDelegate
{
private SystemServiceDelegate()
{
// 时间引擎
ServiceList.Add(TimeEngine.Instance);
// 应用定时器
ServiceList.Add(AppTimer.Instance);
// 控制引擎
ServiceList.Add(ControlEngine.Instance);
// 动画引擎
ServiceList.Add(AnimationEngine.Instance);
}

public static SystemServiceDelegate Instance { get; } = new SystemServiceDelegate();
}

/// <summary>
/// 系统工具代理
/// </summary>
public class SystemToolDelegate : ManagerDelegate
{
private SystemToolDelegate()
{
// 事件管理器
ManagerList.Add(EM.Instance);
}

public static SystemToolDelegate Instance { get; } = new SystemToolDelegate();
}
}
Binary file added AXNode/Assets/Cursor/CanNotMove.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Cross.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Disable.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/DragObject.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Draw.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Insert.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Move.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/MoveBottom.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/MoveSelected.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/MoveTop.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/MoveX.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/MoveY.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/OnOff.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/ResizeDownUp.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/ResizeUpDown.cur
Binary file not shown.
Binary file added AXNode/Assets/Cursor/Select.cur
Binary file not shown.
Binary file added AXNode/Assets/Font/simsun.ttc
Binary file not shown.
Binary file added AXNode/Assets/Icon15/Add.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Browse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Clear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/ControlBoard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Delete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/EmptyFolder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/File.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Lib.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Node.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/NodePreset.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Remove.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon15/Rename.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/AlignCenter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/AlignLeft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/AlignRight.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/ClearConsole.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/CloseFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/Console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/ExpandAll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/FurlAll.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/NewFile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/Node/CPU.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added AXNode/Assets/Icon16/Node/Calculator.png
Binary file added AXNode/Assets/Icon16/Node/Chip.png
Binary file added AXNode/Assets/Icon16/Node/Delay.png
Binary file added AXNode/Assets/Icon16/Node/Fan.png
Binary file added AXNode/Assets/Icon16/Node/Flow.png
Binary file added AXNode/Assets/Icon16/Node/FrameDriver.png
Binary file added AXNode/Assets/Icon16/Node/Function.png
Binary file added AXNode/Assets/Icon16/Node/Key.png
Binary file added AXNode/Assets/Icon16/Node/Loop.png
Binary file added AXNode/Assets/Icon16/Node/Message.png
Binary file added AXNode/Assets/Icon16/Node/Midi.png
Binary file added AXNode/Assets/Icon16/Node/Net.png
Binary file added AXNode/Assets/Icon16/Node/Node.png
Binary file added AXNode/Assets/Icon16/Node/Pause.png
Binary file added AXNode/Assets/Icon16/Node/Spectrum.png
Binary file added AXNode/Assets/Icon16/Node/Timer.png
Binary file added AXNode/Assets/Icon16/Node/Variate.png
Binary file added AXNode/Assets/Icon16/Node/Volume.png
Binary file added AXNode/Assets/Icon16/OpenFile.png
Binary file added AXNode/Assets/Icon16/Redo.png
Binary file added AXNode/Assets/Icon16/Rename.png
Binary file added AXNode/Assets/Icon16/Revert.png
Binary file added AXNode/Assets/Icon16/Save.png
Binary file added AXNode/Assets/Icon16/SaveAll.png
Binary file added AXNode/Assets/Icon16/SaveAs.png
Binary file added AXNode/Assets/Icon16/Undo.png
6 changes: 6 additions & 0 deletions AXNode/Assets/PinIcons.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Polygon x:Key="PinIcons.ExecutePin" StrokeThickness="1" Points="0,0 7,1 10,5 7,10 0,10"></Polygon>
<Polygon x:Key="PinIcons.DataPin" StrokeThickness="1" Points="5,0 10,5 5,10 0,5"></Polygon>

</ResourceDictionary>
24 changes: 24 additions & 0 deletions AXNode/CoreEditer.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<UserControl x:Class="AXNode.CoreEditer"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:AXNode"
xmlns:nesp="clr-namespace:AXNode.SubSystem.NodeEditSystem.Panel"
xmlns:nls="clr-namespace:AXNode.SubSystem.NodeLibSystem"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid RowDefinitions="Auto,*">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="2" />
<ColumnDefinition Width="300" />
</Grid.ColumnDefinitions>
<Grid Grid.Row="1" x:Name="LeftPanel" Background="#262626">
<nesp:EditPanel x:Name="Panel_NodeEditer" />
</Grid>
<Grid Grid.Row="1" x:Name="RightPanel" Background="#262626" Grid.Column="2">
<nls:NodeLibPanel x:Name="Panel_NodeLib" />
</Grid>
</Grid>
</UserControl>
79 changes: 79 additions & 0 deletions AXNode/CoreEditer.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Windows;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using XLib.Node;
using AXNode.SubSystem.NodeEditSystem.Define;
using AXNode.SubSystem.ProjectSystem;
using XLib.Base;
using XLib.Base.VirtualDisk;

namespace AXNode
{
public partial class CoreEditer : UserControl
{
#region 属性

/// <summary>节点列表</summary>
public List<NodeBase> NodeList => Panel_NodeEditer.NodeList;

#endregion

#region 构造方法

public CoreEditer()
{
InitializeComponent();
Loaded += CoreEditer_Loaded;
}

#endregion

#region 公开方法

/// <summary>
/// 重置编辑器
/// </summary>
public void ResetEditer() => Panel_NodeEditer.Reset();

/// <summary>
/// 加载节点
/// </summary>
public void LoadNode(NodeBase node) => Panel_NodeEditer.LoadNode(node);

/// <summary>
/// 查找引脚
/// </summary>
public PinBase? FindPin(PinPath path) => Panel_NodeEditer.FindPin(path);

#endregion

#region 控件事件

private void CoreEditer_Loaded(object sender, RoutedEventArgs e)
{
Init();
ProjectManager.Instance.NewProject();
ProjectManager.Instance.Saved = true;
}

#endregion

#region 私有方法

/// <summary>
/// 初始化核心编辑器
/// </summary>
private void Init()
{
// 初始化编辑器面板
Panel_NodeEditer.Init();
// 初始化节点库面板
Panel_NodeLib.Init();
}

#endregion
}
}
Loading