更新了生产过程
This commit is contained in:
13
BITKit/Scripts/Components/OpenPath.cs
Normal file
13
BITKit/Scripts/Components/OpenPath.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public partial class OpenPath:Node,IAction
|
||||
{
|
||||
[Export] private string path;
|
||||
public void Execute()
|
||||
{
|
||||
BIT4Log.Log<OpenPath>($"正在打开路径:{path}");
|
||||
BITApp.Open(path);
|
||||
}
|
||||
}
|
13
BITKit/Scripts/Components/OpenUrl.cs
Normal file
13
BITKit/Scripts/Components/OpenUrl.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Godot;
|
||||
|
||||
namespace BITKit;
|
||||
public partial class OpenUrl : Node,IAction
|
||||
{
|
||||
[Export] private string url;
|
||||
public void Execute()
|
||||
{
|
||||
BIT4Log.Log<OpenUrl>($"正在打开网址:{url}");
|
||||
|
||||
OS.ShellOpen(url);
|
||||
}
|
||||
}
|
30
BITKit/Scripts/Components/RuntimeNode.cs
Normal file
30
BITKit/Scripts/Components/RuntimeNode.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace BITKit;
|
||||
public partial class RuntimeNode : Node
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnEnableEventHandler();
|
||||
[Signal]
|
||||
public delegate void OnDisableEventHandler();
|
||||
[Signal]
|
||||
public delegate void OnUpdateEventHandler();
|
||||
private void Enable()
|
||||
{
|
||||
if (Engine.IsEditorHint() is false)
|
||||
EmitSignal(nameof(OnEnable));
|
||||
}
|
||||
private void Disable()
|
||||
{
|
||||
if (Engine.IsEditorHint() is false)
|
||||
EmitSignal(nameof(OnDisable));
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Engine.IsEditorHint() is false)
|
||||
EmitSignal(nameof(OnUpdate));
|
||||
}
|
||||
}
|
17
BITKit/Scripts/Components/VisibleNode.cs
Normal file
17
BITKit/Scripts/Components/VisibleNode.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Godot;
|
||||
using System;
|
||||
namespace BITKit;
|
||||
public partial class VisibleNode : Control
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnVisibleEventHandler();
|
||||
[Signal]
|
||||
public delegate void OnInvisibleEventHandler();
|
||||
private bool isVisible;
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (isVisible == Visible) return;
|
||||
EmitSignal(Visible ? nameof(OnVisibleEventHandler) : nameof(OnInvisibleEventHandler));
|
||||
isVisible = Visible;
|
||||
}
|
||||
}
|
@@ -1,8 +1,19 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BITKit;
|
||||
|
||||
public class SqlLiteContext<T> : DbContext where T : class
|
||||
public interface IDatabaseContext<T> where T : class
|
||||
{
|
||||
void Add(T entity);
|
||||
void Remove(T entity);
|
||||
T[] GetArray();
|
||||
bool TrySearch(Func<T, bool> searchFactory, out T result);
|
||||
bool TrySearchArray(Func<T, bool> searchFactory, out T[] result);
|
||||
}
|
||||
|
||||
public class SqlLiteContext<T> : DbContext,IDatabaseContext<T> where T : class
|
||||
{
|
||||
private const string _database = "Database";
|
||||
public DbSet<T> context { get; private set; }
|
||||
@@ -14,4 +25,34 @@ public class SqlLiteContext<T> : DbContext where T : class
|
||||
BIT4Log.Log<T>($"已创建数据库链接:{path}");
|
||||
optionsBuilder.UseSqlite(sql);
|
||||
}
|
||||
public virtual void Add(T entity)
|
||||
{
|
||||
context.Add(entity);
|
||||
SaveChanges();
|
||||
}
|
||||
public virtual void Remove(T entity)
|
||||
{
|
||||
context.Remove(entity);
|
||||
SaveChanges();
|
||||
}
|
||||
public virtual T[] GetArray()
|
||||
{
|
||||
return context.ToArray();
|
||||
}
|
||||
public virtual bool TrySearch(Func<T,bool> searchFactory,out T result)
|
||||
{
|
||||
result = context.FirstOrDefault(searchFactory);
|
||||
return result != null;
|
||||
}
|
||||
/// <summary>
|
||||
/// 搜索数组
|
||||
/// </summary>
|
||||
/// <param name="searchFactory"></param>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public virtual bool TrySearchArray(Func<T, bool> searchFactory, out T[] result)
|
||||
{
|
||||
result = context.Where(searchFactory).ToArray();
|
||||
return result.Length > 0;
|
||||
}
|
||||
}
|
@@ -1,3 +1,4 @@
|
||||
using System.Diagnostics;
|
||||
using Godot;
|
||||
|
||||
namespace BITKit;
|
||||
@@ -16,6 +17,7 @@ public partial class UXContainer:Control,IUXContainer
|
||||
[Export] public Label titleLabel;
|
||||
[Export] public TextureRect icon;
|
||||
[Export] public Button button;
|
||||
[Export] public Node contextContainer;
|
||||
[ExportCategory("Label")]
|
||||
[Export] public Label updateTimeLabel;
|
||||
[Export] public Label createTimeLabel;
|
||||
@@ -46,6 +48,19 @@ public partial class UXContainer:Control,IUXContainer
|
||||
Text=text;
|
||||
}
|
||||
|
||||
public void AddContainer(Node node)
|
||||
{
|
||||
contextContainer.AddChild(node);
|
||||
}
|
||||
|
||||
public void ClearContainer()
|
||||
{
|
||||
foreach (var x in contextContainer.GetChildren())
|
||||
{
|
||||
x.QueueFree();
|
||||
}
|
||||
}
|
||||
|
||||
public Texture2D Icon
|
||||
{
|
||||
get => icon.Texture;
|
||||
|
Reference in New Issue
Block a user