plugins loading now

This commit is contained in:
WeeXnes 2025-04-08 13:26:38 +02:00
parent b832aafa7c
commit 6e60333fdf
8 changed files with 142 additions and 0 deletions

View file

@ -0,0 +1,21 @@
using System;
using WXPlugin.PluginCore;
namespace ExamplePlugin
{
public class ExamplePlugin : IPluginBase
{
public String Name { get; set; } = "Example Plugin";
public String Description { get; set; } = "This is an example plugin.";
public void Execute()
{
throw new NotImplementedException();
}
public void Initialize()
{
throw new NotImplementedException();
}
}
}

View file

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ExamplePlugin</RootNamespace>
<AssemblyName>ExamplePlugin</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="ExamplePlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WXPlugin\WXPlugin.csproj">
<Project>{56bfe4e0-0d30-474a-b57b-cf08515ff66e}</Project>
<Name>WXPlugin</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View file

@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Update", "Update\Update.csp
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WXPlugin", "WXPlugin\WXPlugin.csproj", "{56BFE4E0-0D30-474A-B57B-CF08515FF66E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WXPlugin", "WXPlugin\WXPlugin.csproj", "{56BFE4E0-0D30-474A-B57B-CF08515FF66E}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExamplePlugin", "ExamplePlugin\ExamplePlugin.csproj", "{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -36,5 +38,9 @@ Global
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Debug|Any CPU.Build.0 = Debug|Any CPU {56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.ActiveCfg = Release|Any CPU {56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.Build.0 = Release|Any CPU {56BFE4E0-0D30-474A-B57B-CF08515FF66E}.Release|Any CPU.Build.0 = Release|Any CPU
{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}.Debug|Any CPU.Build.0 = Debug|Any CPU
{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}.Release|Any CPU.ActiveCfg = Release|Any CPU
{910F0FC8-B73D-449F-ADD7-C6CA147D9F05}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -51,6 +51,18 @@ namespace WeeXnes
LoadSettings(); LoadSettings();
SaveSettingsHandler.SetupSaveEvents(); SaveSettingsHandler.SetupSaveEvents();
LoadFiles(); LoadFiles();
LoadPluginManager();
}
private void LoadPluginManager()
{
string pluginsPath = Path.Combine(Environment.CurrentDirectory, "plugins");
if (!Directory.Exists(pluginsPath))
Directory.CreateDirectory(pluginsPath);
PluginManager manager = new PluginManager(pluginsPath);
manager.LoadPlugins();
} }
private void CheckUpdatedFiles() private void CheckUpdatedFiles()

View file

@ -13,11 +13,15 @@ public class PluginManager
public HashSet<IPluginBase> CurrentPlugins { get; set; } = new HashSet<IPluginBase>(); public HashSet<IPluginBase> CurrentPlugins { get; set; } = new HashSet<IPluginBase>();
public PluginManager(String pluginPath) public PluginManager(String pluginPath)
{ {
Console.WriteLine("Plugin Manager Initialized");
Directories.Add(pluginPath); Directories.Add(pluginPath);
} }
public void LoadPlugins() public void LoadPlugins()
{ {
Console.WriteLine("Plugin Manager Loading Plugins");
CurrentPlugins = new HashSet<IPluginBase>(); CurrentPlugins = new HashSet<IPluginBase>();
foreach (var dir in Directories) foreach (var dir in Directories)
{ {
@ -36,6 +40,7 @@ public class PluginManager
null, null,
null) null)
as IPluginBase; as IPluginBase;
Console.WriteLine("Loaded: " + newPlugin.Name);
CurrentPlugins.Add(newPlugin); CurrentPlugins.Add(newPlugin);
} }
} }

View file

@ -0,0 +1,21 @@
<Page x:Class="WeeXnes.Views.PluginManager.PluginManagerView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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:WeeXnes.Views.PluginManager"
mc:Ignorable="d"
Title="PluginManagerView" Height="450" Width="800">
<Grid>
<ListView ItemsSource="{Binding Plugin}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}"/>
<TextBlock Text="{Binding Description}"/>
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</Page>

View file

@ -0,0 +1,13 @@
using System.Windows.Controls;
namespace WeeXnes.Views.PluginManager;
public partial class PluginManagerView : Page
{
public PluginManagerView()
{
InitializeComponent();
}
}

View file

@ -111,6 +111,9 @@
<Compile Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml.cs"> <Compile Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml.cs">
<DependentUpon>SaveToKeyManagerView.xaml</DependentUpon> <DependentUpon>SaveToKeyManagerView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Views\PluginManager\PluginManagerView.xaml.cs">
<DependentUpon>PluginManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\InboxView.xaml.cs"> <Compile Include="Views\ProfileView\InboxView.xaml.cs">
<DependentUpon>InboxView.xaml</DependentUpon> <DependentUpon>InboxView.xaml</DependentUpon>
</Compile> </Compile>
@ -168,6 +171,7 @@
<Page Include="Views\PasswordGenerator\PasswordGenView.xaml" /> <Page Include="Views\PasswordGenerator\PasswordGenView.xaml" />
<Page Include="Views\PasswordGenerator\SavePasswordView.xaml" /> <Page Include="Views\PasswordGenerator\SavePasswordView.xaml" />
<Page Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml" /> <Page Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml" />
<Page Include="Views\PluginManager\PluginManagerView.xaml" />
<Page Include="Views\ProfileView\InboxView.xaml" /> <Page Include="Views\ProfileView\InboxView.xaml" />
<Page Include="Views\ProfileView\LicenseView.xaml" /> <Page Include="Views\ProfileView\LicenseView.xaml" />
<Page Include="Views\ProfileView\LoginError.xaml" /> <Page Include="Views\ProfileView\LoginError.xaml" />