plugin prototype working
This commit is contained in:
parent
6e60333fdf
commit
9e8b3b89f8
12 changed files with 97 additions and 11 deletions
|
@ -1,4 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using Wpf.Ui.Common;
|
||||||
|
using Wpf.Ui.Controls;
|
||||||
using WXPlugin.PluginCore;
|
using WXPlugin.PluginCore;
|
||||||
|
|
||||||
namespace ExamplePlugin
|
namespace ExamplePlugin
|
||||||
|
@ -8,6 +11,15 @@ namespace ExamplePlugin
|
||||||
public String Name { get; set; } = "Example Plugin";
|
public String Name { get; set; } = "Example Plugin";
|
||||||
public String Description { get; set; } = "This is an 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()
|
public void Execute()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
@ -15,7 +27,7 @@ namespace ExamplePlugin
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
//throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -33,13 +33,24 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System"/>
|
<Reference Include="System"/>
|
||||||
<Reference Include="System.Core"/>
|
<Reference Include="System.Core"/>
|
||||||
<Reference Include="System.Data"/>
|
<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="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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="ExamplePlugin.cs" />
|
<Compile Include="ExamplePlugin.cs" />
|
||||||
|
<Compile Include="ExampleUi.xaml.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -48,6 +59,12 @@
|
||||||
<Name>WXPlugin</Name>
|
<Name>WXPlugin</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Page Include="ExampleUi.xaml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
13
ExamplePlugin/ExampleUi.xaml
Normal file
13
ExamplePlugin/ExampleUi.xaml
Normal 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>
|
13
ExamplePlugin/ExampleUi.xaml.cs
Normal file
13
ExamplePlugin/ExampleUi.xaml.cs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace ExamplePlugin
|
||||||
|
{
|
||||||
|
public partial class ExampleUi : Page
|
||||||
|
{
|
||||||
|
public ExampleUi()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using Wpf.Ui.Controls;
|
||||||
|
|
||||||
namespace WXPlugin.PluginCore
|
namespace WXPlugin.PluginCore
|
||||||
{
|
{
|
||||||
|
@ -6,6 +8,8 @@ namespace WXPlugin.PluginCore
|
||||||
{
|
{
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public String Description { get; set; }
|
public String Description { get; set; }
|
||||||
|
public Page UiPage { get; set; }
|
||||||
|
public NavigationItem NavIcon { get; set; }
|
||||||
public void Initialize();
|
public void Initialize();
|
||||||
public void Execute();
|
public void Execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,15 +34,27 @@
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="PresentationFramework" />
|
||||||
<Reference Include="System"/>
|
<Reference Include="System"/>
|
||||||
<Reference Include="System.Core"/>
|
<Reference Include="System.Core"/>
|
||||||
<Reference Include="System.Data"/>
|
<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="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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="PluginCore\IPluginBase.cs" />
|
<Compile Include="PluginCore\IPluginBase.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs"/>
|
<Compile Include="Properties\AssemblyInfo.cs"/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- 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.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|
|
@ -3,6 +3,7 @@ using System.ComponentModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Nocksoft.IO.ConfigFiles;
|
using Nocksoft.IO.ConfigFiles;
|
||||||
|
@ -57,12 +58,14 @@ namespace WeeXnes
|
||||||
|
|
||||||
private void LoadPluginManager()
|
private void LoadPluginManager()
|
||||||
{
|
{
|
||||||
string pluginsPath = Path.Combine(Environment.CurrentDirectory, "plugins");
|
if (!Directory.Exists(Global.Defaults.DefaultPathPlugins))
|
||||||
if (!Directory.Exists(pluginsPath))
|
Directory.CreateDirectory(Global.Defaults.DefaultPathPlugins);
|
||||||
Directory.CreateDirectory(pluginsPath);
|
|
||||||
PluginManager manager = new PluginManager(pluginsPath);
|
Global.pluginManager.LoadPlugins();
|
||||||
manager.LoadPlugins();
|
foreach (var plugin in Global.pluginManager.CurrentPlugins)
|
||||||
|
{
|
||||||
|
plugin.Initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckUpdatedFiles()
|
private void CheckUpdatedFiles()
|
||||||
|
|
|
@ -8,13 +8,14 @@ namespace WeeXnes.Core
|
||||||
{
|
{
|
||||||
public class Information
|
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 EncryptionHash = "8zf5#RdyQ]$4x4_";
|
||||||
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Global
|
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 string AppDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "WeeXnes");
|
||||||
public static UpdateVar<string> AppDataPathRPC = new UpdateVar<string>();
|
public static UpdateVar<string> AppDataPathRPC = new UpdateVar<string>();
|
||||||
public static UpdateVar<string> AppDataPathKEY = 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 DefaultPathRPC = Path.Combine(AppDataPath, "RPC");
|
||||||
public static string DefaultPathKEY = Path.Combine(AppDataPath, "Keys");
|
public static string DefaultPathKEY = Path.Combine(AppDataPath, "Keys");
|
||||||
|
public static string DefaultPathPlugins = Path.Combine(Environment.CurrentDirectory, "plugins");
|
||||||
}
|
}
|
||||||
public static void ForceClose()
|
public static void ForceClose()
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ public class PluginManager
|
||||||
null)
|
null)
|
||||||
as IPluginBase;
|
as IPluginBase;
|
||||||
Console.WriteLine("Loaded: " + newPlugin.Name);
|
Console.WriteLine("Loaded: " + newPlugin.Name);
|
||||||
|
Console.WriteLine(newPlugin.UiPage.Content.ToString());
|
||||||
CurrentPlugins.Add(newPlugin);
|
CurrentPlugins.Add(newPlugin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
Background="{DynamicResource ApplicationBackgroundBrush}"
|
Background="{DynamicResource ApplicationBackgroundBrush}"
|
||||||
ExtendsContentIntoTitleBar="True"
|
ExtendsContentIntoTitleBar="True"
|
||||||
WindowBackdropType="Mica"
|
WindowBackdropType="Mica"
|
||||||
WindowStartupLocation="CenterScreen">
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Loaded="MainWindow_OnLoaded">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
@ -64,6 +65,7 @@
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<ui:NavigationStore
|
<ui:NavigationStore
|
||||||
|
Name="NavBar"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Frame="{Binding ElementName=MainFrame}"
|
Frame="{Binding ElementName=MainFrame}"
|
||||||
SelectedPageIndex="0">
|
SelectedPageIndex="0">
|
||||||
|
|
|
@ -60,7 +60,14 @@ namespace WeeXnes
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (var plugin in Global.pluginManager.CurrentPlugins)
|
||||||
|
{
|
||||||
|
NavBar.Items.Add(plugin.NavIcon);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<Version>4.5.2.1</Version>
|
<Version>4.6</Version>
|
||||||
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<RootNamespace>WeeXnes</RootNamespace>
|
<RootNamespace>WeeXnes</RootNamespace>
|
||||||
|
|
Loading…
Add table
Reference in a new issue