实现了多画布下,节点的复制粘贴功能

This commit is contained in:
fengjiayi
2025-05-27 18:32:40 +08:00
parent 7ad6041be6
commit 7848af0363
53 changed files with 1187 additions and 499 deletions

View File

@@ -6,19 +6,20 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using static System.Windows.Forms.AxHost;
namespace Serein.Workbench.Services
{
delegate void KeyDownEventHandler(Key key);
delegate void KeyUpEventHandler(Key key);
public delegate void KeyDownEventHandler(Key key);
public delegate void KeyUpEventHandler(Key key);
/// <summary>
/// 全局事件服务
/// 全局按键事件服务
/// </summary>
internal interface IKeyEventService
public interface IKeyEventService
{
event KeyDownEventHandler KeyDown;
event KeyUpEventHandler KeyUp;
event KeyDownEventHandler OnKeyDown;
event KeyUpEventHandler OnKeyUp;
/// <summary>
/// 获取某个按键状态
@@ -26,27 +27,34 @@ namespace Serein.Workbench.Services
/// <param name="key"></param>
/// <returns></returns>
bool GetKeyState(Key key);
/// <summary>
/// 设置某个按键的状态
/// 按下了某个键
/// </summary>
/// <param name="key"></param>
/// <param name="state"></param>
void SetKeyState(Key key, bool statestate);
void KeyDown(Key key);
/// <summary>
/// 抬起了某个键
/// </summary>
/// <param name="key"></param>
void KeyUp(Key key);
}
/// <summary>
/// 管理按键状态
/// </summary>
internal class KeyEventService : IKeyEventService
public class KeyEventService : IKeyEventService
{
/// <summary>
/// 按键按下
/// </summary>
public event KeyDownEventHandler KeyDown;
public event KeyDownEventHandler OnKeyDown;
/// <summary>
/// 按键松开
/// </summary>
public event KeyUpEventHandler KeyUp;
public event KeyUpEventHandler OnKeyUp;
public KeyEventService()
{
@@ -62,18 +70,23 @@ namespace Serein.Workbench.Services
{
return KeysState[(int)key];
}
public void SetKeyState(Key key, bool state)
public void KeyDown(Key key)
{
if (state)
{
KeyDown?.Invoke(key);
}
else
{
KeyUp?.Invoke(key);
}
//Debug.WriteLine($"按键事件:{key} - {state}");
KeysState[(int)key] = state;
KeysState[(int)key] = true;
OnKeyDown?.Invoke(key);
Debug.WriteLine($"按键按下事件:{key}");
}
public void KeyUp(Key key)
{
KeysState[(int)key] = false;
OnKeyUp?.Invoke(key);
Debug.WriteLine($"按键抬起事件:{key}");
}
}
}