add:插件
屎山
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ink_Canvas.Plugins
|
||||
{
|
||||
public interface IInkCanvasService
|
||||
{
|
||||
void OpenWhiteboard();
|
||||
void CloseWhiteboard();
|
||||
Task OpenWhiteboardAsync(int delayMilliseconds = 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
|
||||
namespace Ink_Canvas.Plugins
|
||||
{
|
||||
public interface IPlugin
|
||||
{
|
||||
string Id { get; }
|
||||
string Name { get; }
|
||||
string Version { get; }
|
||||
string Description { get; }
|
||||
string Author { get; }
|
||||
int Order { get; }
|
||||
|
||||
void Initialize(IPluginHost host);
|
||||
void Shutdown();
|
||||
object GetMainView();
|
||||
object GetSettingsView();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace Ink_Canvas.Plugins
|
||||
{
|
||||
public interface IPluginHost
|
||||
{
|
||||
void Log(string message);
|
||||
void LogError(string message, Exception ex = null);
|
||||
T GetService<T>() where T : class;
|
||||
void RegisterService<T>(T service) where T : class;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
<RootNamespace>Ink_Canvas.Plugins</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
|
||||
namespace Ink_Canvas.Plugins
|
||||
{
|
||||
public abstract class PluginBase : IPlugin
|
||||
{
|
||||
protected IPluginHost Host { get; private set; }
|
||||
|
||||
public abstract string Id { get; }
|
||||
public abstract string Name { get; }
|
||||
public abstract string Version { get; }
|
||||
public abstract string Description { get; }
|
||||
public abstract string Author { get; }
|
||||
public abstract int Order { get; }
|
||||
|
||||
public virtual void Initialize(IPluginHost host)
|
||||
{
|
||||
Host = host;
|
||||
}
|
||||
|
||||
public virtual void Shutdown()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual object GetMainView()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public virtual object GetSettingsView()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void Log(string message)
|
||||
{
|
||||
if (Host != null)
|
||||
{
|
||||
Host.Log(message);
|
||||
}
|
||||
}
|
||||
|
||||
protected void LogError(string message, Exception ex = null)
|
||||
{
|
||||
if (Host != null)
|
||||
{
|
||||
Host.LogError(message, ex);
|
||||
}
|
||||
}
|
||||
|
||||
protected T GetService<T>() where T : class
|
||||
{
|
||||
if (Host != null)
|
||||
{
|
||||
return Host.GetService<T>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace Ink_Canvas.Plugins
|
||||
{
|
||||
public class PluginInfo
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Version { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string Author { get; set; }
|
||||
public int Order { get; set; }
|
||||
public IPlugin Instance { get; set; }
|
||||
public bool IsLoaded { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user