mirror of
https://github.com/openbullet/openbullet.git
synced 2023-10-21 07:33:42 -05:00
Added PluginsSection View and hooked it to the loader
This commit is contained in:
@@ -88,6 +88,7 @@
|
|||||||
<Label x:Name="menuOptionConfigCreator" Content="Configs" MouseDown="menuOptionConfigCreator_MouseDown" />
|
<Label x:Name="menuOptionConfigCreator" Content="Configs" MouseDown="menuOptionConfigCreator_MouseDown" />
|
||||||
<Label x:Name="menuOptionHitsDatabase" Content="Hits DB" MouseDown="menuOptionHitsDatabase_MouseDown" />
|
<Label x:Name="menuOptionHitsDatabase" Content="Hits DB" MouseDown="menuOptionHitsDatabase_MouseDown" />
|
||||||
<Label x:Name="menuOptionTools" Content="Tools" MouseDown="menuOptionTools_MouseDown" />
|
<Label x:Name="menuOptionTools" Content="Tools" MouseDown="menuOptionTools_MouseDown" />
|
||||||
|
<Label x:Name="menuOptionPlugins" Content="Plugins" MouseDown="menuOptionPlugins_MouseDown" />
|
||||||
<Label x:Name="menuOptionSettings" Content="Settings" MouseDown="menuOptionSettings_MouseDown" />
|
<Label x:Name="menuOptionSettings" Content="Settings" MouseDown="menuOptionSettings_MouseDown" />
|
||||||
<Label x:Name="menuOptionAbout" Content="About" MouseDown="menuOptionAbout_MouseDown" />
|
<Label x:Name="menuOptionAbout" Content="About" MouseDown="menuOptionAbout_MouseDown" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -19,6 +19,9 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
using OpenBullet.Plugins;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenBullet.Views.UserControls;
|
||||||
|
|
||||||
namespace OpenBullet
|
namespace OpenBullet
|
||||||
{
|
{
|
||||||
@@ -38,6 +41,7 @@ namespace OpenBullet
|
|||||||
public HitsDB HitsDBPage { get; set; }
|
public HitsDB HitsDBPage { get; set; }
|
||||||
public Settings OBSettingsPage { get; set; }
|
public Settings OBSettingsPage { get; set; }
|
||||||
public ToolsSection ToolsPage { get; set; }
|
public ToolsSection ToolsPage { get; set; }
|
||||||
|
public PluginsSection PluginsPage { get; set; }
|
||||||
public About AboutPage { get; set; }
|
public About AboutPage { get; set; }
|
||||||
public Rectangle Bounds { get; private set; }
|
public Rectangle Bounds { get; private set; }
|
||||||
|
|
||||||
@@ -59,8 +63,8 @@ namespace OpenBullet
|
|||||||
titleLabel.Content = title;
|
titleLabel.Content = title;
|
||||||
|
|
||||||
// Make sure all folders are there or recreate them
|
// Make sure all folders are there or recreate them
|
||||||
var folders = new string[] { "Captchas", "ChromeExtensions", "Configs", "DB", "Screenshots", "Settings", "Sounds", "Wordlists" };
|
var folders = new string[] { "Captchas", "ChromeExtensions", "Configs", "DB", "Plugins", "Screenshots", "Settings", "Sounds", "Wordlists" };
|
||||||
foreach (var folder in folders.Select(f => System.IO.Path.Combine(Directory.GetCurrentDirectory(), f)))
|
foreach (var folder in folders.Select(f => Path.Combine(Directory.GetCurrentDirectory(), f)))
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(folder))
|
if (!Directory.Exists(folder))
|
||||||
Directory.CreateDirectory(folder);
|
Directory.CreateDirectory(folder);
|
||||||
@@ -140,6 +144,9 @@ namespace OpenBullet
|
|||||||
|
|
||||||
Topmost = OB.OBSettings.General.AlwaysOnTop;
|
Topmost = OB.OBSettings.General.AlwaysOnTop;
|
||||||
|
|
||||||
|
// Load Plugins
|
||||||
|
var plugins = Loader.LoadPlugins(OB.pluginsFolder);
|
||||||
|
|
||||||
// ViewModels
|
// ViewModels
|
||||||
OB.RunnerManager = new RunnerManagerViewModel();
|
OB.RunnerManager = new RunnerManagerViewModel();
|
||||||
OB.ProxyManager = new ProxyManagerViewModel();
|
OB.ProxyManager = new ProxyManagerViewModel();
|
||||||
@@ -164,6 +171,8 @@ namespace OpenBullet
|
|||||||
OB.Logger.LogInfo(Components.Main, "Initialized Settings");
|
OB.Logger.LogInfo(Components.Main, "Initialized Settings");
|
||||||
ToolsPage = new ToolsSection();
|
ToolsPage = new ToolsSection();
|
||||||
OB.Logger.LogInfo(Components.Main, "Initialized Tools");
|
OB.Logger.LogInfo(Components.Main, "Initialized Tools");
|
||||||
|
PluginsPage = new PluginsSection(plugins);
|
||||||
|
OB.Logger.LogInfo(Components.Main, "Initialized Plugins");
|
||||||
AboutPage = new About();
|
AboutPage = new About();
|
||||||
|
|
||||||
menuOptionRunner_MouseDown(this, null);
|
menuOptionRunner_MouseDown(this, null);
|
||||||
@@ -284,6 +293,12 @@ namespace OpenBullet
|
|||||||
menuOptionSelected(menuOptionTools);
|
menuOptionSelected(menuOptionTools);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void menuOptionPlugins_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
{
|
||||||
|
Main.Content = PluginsPage;
|
||||||
|
menuOptionSelected(menuOptionPlugins);
|
||||||
|
}
|
||||||
|
|
||||||
private void menuOptionSettings_MouseDown(object sender, MouseButtonEventArgs e)
|
private void menuOptionSettings_MouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
Main.Content = OBSettingsPage;
|
Main.Content = OBSettingsPage;
|
||||||
|
|||||||
@@ -47,5 +47,6 @@ namespace OpenBullet
|
|||||||
public static readonly string licenseFile = @"Settings/License.txt";
|
public static readonly string licenseFile = @"Settings/License.txt";
|
||||||
public static readonly string logFile = @"Log.txt";
|
public static readonly string logFile = @"Log.txt";
|
||||||
public static readonly string configFolder = @"Configs";
|
public static readonly string configFolder = @"Configs";
|
||||||
|
public static readonly string pluginsFolder = @"Plugins";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,6 +239,9 @@
|
|||||||
<Compile Include="LoadingWindow.xaml.cs">
|
<Compile Include="LoadingWindow.xaml.cs">
|
||||||
<DependentUpon>LoadingWindow.xaml</DependentUpon>
|
<DependentUpon>LoadingWindow.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Views\Main\PluginsSection.xaml.cs">
|
||||||
|
<DependentUpon>PluginsSection.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Views\UserControls\ButtonContainer.xaml.cs">
|
<Compile Include="Views\UserControls\ButtonContainer.xaml.cs">
|
||||||
<DependentUpon>ButtonContainer.xaml</DependentUpon>
|
<DependentUpon>ButtonContainer.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -412,8 +415,8 @@
|
|||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\Main\Tools.xaml.cs">
|
<Compile Include="Views\Main\ToolsSection.xaml.cs">
|
||||||
<DependentUpon>Tools.xaml</DependentUpon>
|
<DependentUpon>ToolsSection.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Views\Main\Tools\ListGenerator.xaml.cs">
|
<Compile Include="Views\Main\Tools\ListGenerator.xaml.cs">
|
||||||
<DependentUpon>ListGenerator.xaml</DependentUpon>
|
<DependentUpon>ListGenerator.xaml</DependentUpon>
|
||||||
@@ -542,6 +545,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Main\PluginsSection.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Main\RunnerManager.xaml">
|
<Page Include="Views\Main\RunnerManager.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
@@ -721,7 +728,7 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
<Page Include="Views\Main\Tools.xaml">
|
<Page Include="Views\Main\ToolsSection.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@@ -68,12 +68,18 @@ namespace OpenBullet.Plugins
|
|||||||
|
|
||||||
// Get the first attribute
|
// Get the first attribute
|
||||||
var attribute = method.GetCustomAttribute<Button>();
|
var attribute = method.GetCustomAttribute<Button>();
|
||||||
|
var parameters = method.GetParameters();
|
||||||
|
|
||||||
// TEMPORARY!!!
|
// Check if it accepts 0 or 1 parameters
|
||||||
// Check if it accepts an ILogger
|
if (parameters.Length > 1)
|
||||||
if (!method.GetParameters().Any(p => p.ParameterType == typeof(ILogger)))
|
|
||||||
{
|
{
|
||||||
throw new Exception("A Button method must support an ILogger");
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the method accepts 1 parameter, check that its type is IApplication
|
||||||
|
if (parameters.Length == 1 && !parameters.Any(p => p.ParameterType == typeof(IApplication)))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ namespace OpenBullet.Plugins
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="folder">The folder where plugins are located</param>
|
/// <param name="folder">The folder where plugins are located</param>
|
||||||
/// <returns>A collection of plugin controls.</returns>
|
/// <returns>A collection of plugin controls.</returns>
|
||||||
public static IEnumerator<PluginControl> LoadPlugins(string folder)
|
public static IEnumerable<PluginControl> LoadPlugins(string folder)
|
||||||
{
|
{
|
||||||
|
var plugins = new List<PluginControl>();
|
||||||
|
|
||||||
foreach (var dll in Directory.GetFiles(folder, "*.dll"))
|
foreach (var dll in Directory.GetFiles(folder, "*.dll"))
|
||||||
{
|
{
|
||||||
var asm = Assembly.LoadFrom(dll);
|
var asm = Assembly.LoadFrom(dll);
|
||||||
@@ -39,10 +41,12 @@ namespace OpenBullet.Plugins
|
|||||||
// If it implements the IPlugin interface
|
// If it implements the IPlugin interface
|
||||||
if (type.GetInterface("IPlugin") == typeof(IPlugin))
|
if (type.GetInterface("IPlugin") == typeof(IPlugin))
|
||||||
{
|
{
|
||||||
yield return new PluginControl(type);
|
plugins.Add(new PluginControl(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ namespace OpenBullet.Repositories
|
|||||||
Directory.CreateDirectory(Path.Combine(BaseFolder, entity.Category));
|
Directory.CreateDirectory(Path.Combine(BaseFolder, entity.Category));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
IOManager.SaveConfig(entity.Config, path);
|
IOManager.SaveConfig(entity.Config, path);
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<Page x:Class="OpenBullet.Views.Main.PluginsSection"
|
||||||
|
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:OpenBullet.Views.Main"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
Title="Plugins">
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="30" />
|
||||||
|
<RowDefinition Height="*" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<StackPanel x:Name="topMenu" Orientation="Horizontal">
|
||||||
|
<Label Content="Selected Plugin:" />
|
||||||
|
<ComboBox x:Name="pluginSelector" Width="200" Margin="5 0 0 0" SelectionChanged="pluginSelector_SelectionChanged" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<Frame Grid.Row="1" x:Name="Main" NavigationUIVisibility="Hidden" />
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using OpenBullet.Views.UserControls;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace OpenBullet.Views.Main
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Logica di interazione per PluginsSection.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class PluginsSection : Page
|
||||||
|
{
|
||||||
|
private List<PluginControl> controls;
|
||||||
|
|
||||||
|
public PluginsSection(IEnumerable<PluginControl> controls)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.controls = controls.ToList();
|
||||||
|
|
||||||
|
foreach (var control in this.controls)
|
||||||
|
{
|
||||||
|
pluginSelector.Items.Add(control.Plugin.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.controls.Count > 0)
|
||||||
|
{
|
||||||
|
pluginSelector.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pluginSelector_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
Main.Content = controls.First(c => c.Plugin.Name == (string)pluginSelector.SelectedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,12 +10,9 @@
|
|||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="auto" />
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition Height="auto" />
|
<RowDefinition Height="auto" />
|
||||||
<RowDefinition Height="auto" />
|
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Border Grid.RowSpan="3" BorderBrush="{DynamicResource ForegroundMain}" BorderThickness="2" />
|
<Label Grid.Row="0" FontWeight="Bold" Content="{Binding Plugin.Name}" />
|
||||||
|
|
||||||
<Label FontWeight="Bold" Content="{Binding Plugin.Name}" />
|
|
||||||
<ItemsControl Grid.Row="1" ItemsSource="{Binding Controls}" Padding="5"/>
|
<ItemsControl Grid.Row="1" ItemsSource="{Binding Controls}" Padding="5"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
Reference in New Issue
Block a user