plugin prototype working

This commit is contained in:
WeeXnes 2025-04-09 08:05:58 +02:00
parent 6e60333fdf
commit 9e8b3b89f8
12 changed files with 97 additions and 11 deletions

View file

@ -1,4 +1,7 @@
using System;
using System.Windows.Controls;
using Wpf.Ui.Common;
using Wpf.Ui.Controls;
using WXPlugin.PluginCore;
namespace ExamplePlugin
@ -8,6 +11,15 @@ namespace ExamplePlugin
public String Name { get; set; } = "Example Plugin";
public String Description { get; set; } = "This is an example plugin.";
public Page UiPage { get; set; } = new ExampleUi();
public NavigationItem NavIcon { get; set; } = new NavigationItem
{
Content = "Plugin",
Icon = SymbolRegular.Syringe20,
PageTag = "examplePlugin",
PageType = typeof(ExampleUi),
};
public void Execute()
{
throw new NotImplementedException();
@ -15,7 +27,7 @@ namespace ExamplePlugin
public void Initialize()
{
throw new NotImplementedException();
//throw new NotImplementedException();
}
}
}

View file

@ -33,13 +33,24 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml"/>
<Reference Include="WindowsBase" />
<Reference Include="Wpf.Ui, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WPF-UI.2.0.3\lib\net48\Wpf.Ui.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ExamplePlugin.cs" />
<Compile Include="ExampleUi.xaml.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
@ -48,6 +59,12 @@
<Name>WXPlugin</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Page Include="ExampleUi.xaml" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</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.

View file

@ -0,0 +1,13 @@
<Page x:Class="ExamplePlugin.ExampleUi"
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"
mc:Ignorable="d"
Title="HomeView" Height="Auto" Width="Auto">
<Grid>
<StackPanel>
<TextBlock Foreground="White">This is a Test Ui for the Example Plugin</TextBlock>
</StackPanel>
</Grid>
</Page>

View file

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

View file

@ -1,4 +1,6 @@
using System;
using System.Windows.Controls;
using Wpf.Ui.Controls;
namespace WXPlugin.PluginCore
{
@ -6,6 +8,8 @@ namespace WXPlugin.PluginCore
{
public String Name { get; set; }
public String Description { get; set; }
public Page UiPage { get; set; }
public NavigationItem NavIcon { get; set; }
public void Initialize();
public void Execute();
}

View file

@ -34,15 +34,27 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Drawing.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Drawing.Common.6.0.0\lib\net461\System.Drawing.Common.dll</HintPath>
</Reference>
<Reference Include="System.Xml"/>
<Reference Include="WindowsBase" />
<Reference Include="Wpf.Ui, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\WPF-UI.2.0.3\lib\net48\Wpf.Ui.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="PluginCore\IPluginBase.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</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.

View file

@ -3,6 +3,7 @@ using System.ComponentModel;
using System.Windows;
using System.IO;
using System.Net;
using System.Runtime.CompilerServices;
using System.Windows.Media;
using Newtonsoft.Json.Linq;
using Nocksoft.IO.ConfigFiles;
@ -57,12 +58,14 @@ namespace WeeXnes
private void LoadPluginManager()
{
string pluginsPath = Path.Combine(Environment.CurrentDirectory, "plugins");
if (!Directory.Exists(pluginsPath))
Directory.CreateDirectory(pluginsPath);
PluginManager manager = new PluginManager(pluginsPath);
manager.LoadPlugins();
if (!Directory.Exists(Global.Defaults.DefaultPathPlugins))
Directory.CreateDirectory(Global.Defaults.DefaultPathPlugins);
Global.pluginManager.LoadPlugins();
foreach (var plugin in Global.pluginManager.CurrentPlugins)
{
plugin.Initialize();
}
}
private void CheckUpdatedFiles()

View file

@ -8,13 +8,14 @@ namespace WeeXnes.Core
{
public class Information
{
public const string Version = "4.5.2.1";
public const string Version = "4.6";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
}
public class Global
{
public static PluginManager pluginManager = new PluginManager(Path.Combine(Environment.CurrentDirectory, "plugins"));
public static string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
public static UpdateVar<string> AppDataPathRPC = new UpdateVar<string>();
public static UpdateVar<string> AppDataPathKEY = new UpdateVar<string>();
@ -24,6 +25,7 @@ namespace WeeXnes.Core
{
public static string DefaultPathRPC = Path.Combine(AppDataPath, "RPC");
public static string DefaultPathKEY = Path.Combine(AppDataPath, "Keys");
public static string DefaultPathPlugins = Path.Combine(Environment.CurrentDirectory, "plugins");
}
public static void ForceClose()
{

View file

@ -41,6 +41,7 @@ public class PluginManager
null)
as IPluginBase;
Console.WriteLine("Loaded: " + newPlugin.Name);
Console.WriteLine(newPlugin.UiPage.Content.ToString());
CurrentPlugins.Add(newPlugin);
}
}

View file

@ -18,7 +18,8 @@
Background="{DynamicResource ApplicationBackgroundBrush}"
ExtendsContentIntoTitleBar="True"
WindowBackdropType="Mica"
WindowStartupLocation="CenterScreen">
WindowStartupLocation="CenterScreen"
Loaded="MainWindow_OnLoaded">
<Grid>
<Grid.RowDefinitions>
@ -64,6 +65,7 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ui:NavigationStore
Name="NavBar"
Grid.Column="0"
Frame="{Binding ElementName=MainFrame}"
SelectedPageIndex="0">

View file

@ -61,6 +61,13 @@ namespace WeeXnes
Environment.Exit(0);
}
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
{
foreach (var plugin in Global.pluginManager.CurrentPlugins)
{
NavBar.Items.Add(plugin.NavIcon);
}
}
}
}

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.5.2.1</Version>
<Version>4.6</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>