mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-30 14:34:08 +02:00
Show official & custom plugins on one page
This commit is contained in:
parent
c8ab26275c
commit
c2b1aef810
22
Core/Other/FormPlugins.Designer.cs
generated
22
Core/Other/FormPlugins.Designer.cs
generated
@ -26,7 +26,7 @@ private void InitializeComponent() {
|
|||||||
this.btnClose = new System.Windows.Forms.Button();
|
this.btnClose = new System.Windows.Forms.Button();
|
||||||
this.btnReload = new System.Windows.Forms.Button();
|
this.btnReload = new System.Windows.Forms.Button();
|
||||||
this.btnOpenFolder = new System.Windows.Forms.Button();
|
this.btnOpenFolder = new System.Windows.Forms.Button();
|
||||||
this.tabPanelPlugins = new TweetDuck.Core.Controls.TabPanel();
|
this.flowLayoutPlugins = new TweetDuck.Plugins.Controls.PluginListFlowLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// btnClose
|
// btnClose
|
||||||
@ -68,22 +68,26 @@ private void InitializeComponent() {
|
|||||||
this.btnOpenFolder.UseVisualStyleBackColor = true;
|
this.btnOpenFolder.UseVisualStyleBackColor = true;
|
||||||
this.btnOpenFolder.Click += new System.EventHandler(this.btnOpenFolder_Click);
|
this.btnOpenFolder.Click += new System.EventHandler(this.btnOpenFolder_Click);
|
||||||
//
|
//
|
||||||
// tabPanelPlugins
|
// flowLayoutPlugins
|
||||||
//
|
//
|
||||||
this.tabPanelPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.flowLayoutPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.tabPanelPlugins.Location = new System.Drawing.Point(12, 12);
|
this.flowLayoutPlugins.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||||
this.tabPanelPlugins.Name = "tabPanelPlugins";
|
this.flowLayoutPlugins.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||||
this.tabPanelPlugins.Size = new System.Drawing.Size(680, 421);
|
this.flowLayoutPlugins.Location = new System.Drawing.Point(12, 12);
|
||||||
this.tabPanelPlugins.TabIndex = 0;
|
this.flowLayoutPlugins.Name = "flowLayoutPlugins";
|
||||||
|
this.flowLayoutPlugins.Size = new System.Drawing.Size(680, 421);
|
||||||
|
this.flowLayoutPlugins.TabIndex = 0;
|
||||||
|
this.flowLayoutPlugins.WrapContents = false;
|
||||||
|
this.flowLayoutPlugins.Resize += new System.EventHandler(this.flowLayoutPlugins_Resize);
|
||||||
//
|
//
|
||||||
// FormPlugins
|
// FormPlugins
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(704, 474);
|
this.ClientSize = new System.Drawing.Size(704, 474);
|
||||||
this.Controls.Add(this.tabPanelPlugins);
|
this.Controls.Add(this.flowLayoutPlugins);
|
||||||
this.Controls.Add(this.btnOpenFolder);
|
this.Controls.Add(this.btnOpenFolder);
|
||||||
this.Controls.Add(this.btnReload);
|
this.Controls.Add(this.btnReload);
|
||||||
this.Controls.Add(this.btnClose);
|
this.Controls.Add(this.btnClose);
|
||||||
@ -101,6 +105,6 @@ private void InitializeComponent() {
|
|||||||
private System.Windows.Forms.Button btnClose;
|
private System.Windows.Forms.Button btnClose;
|
||||||
private System.Windows.Forms.Button btnReload;
|
private System.Windows.Forms.Button btnReload;
|
||||||
private System.Windows.Forms.Button btnOpenFolder;
|
private System.Windows.Forms.Button btnOpenFolder;
|
||||||
private TweetDuck.Core.Controls.TabPanel tabPanelPlugins;
|
private Plugins.Controls.PluginListFlowLayout flowLayoutPlugins;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,19 +3,12 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using TweetDuck.Core.Controls;
|
|
||||||
using TweetDuck.Plugins;
|
using TweetDuck.Plugins;
|
||||||
using TweetDuck.Plugins.Controls;
|
using TweetDuck.Plugins.Controls;
|
||||||
using TweetDuck.Plugins.Enums;
|
|
||||||
using TweetDuck.Plugins.Events;
|
|
||||||
|
|
||||||
namespace TweetDuck.Core.Other{
|
namespace TweetDuck.Core.Other{
|
||||||
sealed partial class FormPlugins : Form{
|
sealed partial class FormPlugins : Form{
|
||||||
private readonly PluginManager pluginManager;
|
private readonly PluginManager pluginManager;
|
||||||
private readonly TabButton tabBtnOfficial, tabBtnCustom;
|
|
||||||
private readonly PluginListFlowLayout flowLayoutPlugins;
|
|
||||||
|
|
||||||
private PluginGroup? selectedGroup;
|
|
||||||
|
|
||||||
public FormPlugins(){
|
public FormPlugins(){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -25,47 +18,23 @@ public FormPlugins(){
|
|||||||
|
|
||||||
public FormPlugins(PluginManager pluginManager) : this(){
|
public FormPlugins(PluginManager pluginManager) : this(){
|
||||||
this.pluginManager = pluginManager;
|
this.pluginManager = pluginManager;
|
||||||
this.pluginManager.Reloaded += pluginManager_Reloaded;
|
|
||||||
|
|
||||||
this.flowLayoutPlugins = new PluginListFlowLayout();
|
|
||||||
this.flowLayoutPlugins.Resize += flowLayoutPlugins_Resize;
|
|
||||||
|
|
||||||
this.tabPanelPlugins.SetupTabPanel(90);
|
|
||||||
this.tabPanelPlugins.ReplaceContent(flowLayoutPlugins);
|
|
||||||
|
|
||||||
this.tabBtnOfficial = tabPanelPlugins.AddButton("", () => SelectGroup(PluginGroup.Official));
|
|
||||||
this.tabBtnCustom = tabPanelPlugins.AddButton("", () => SelectGroup(PluginGroup.Custom));
|
|
||||||
|
|
||||||
this.pluginManager_Reloaded(pluginManager, null);
|
|
||||||
|
|
||||||
Shown += (sender, args) => {
|
Shown += (sender, args) => {
|
||||||
Program.UserConfig.PluginsWindow.Restore(this, false);
|
Program.UserConfig.PluginsWindow.Restore(this, false);
|
||||||
this.tabPanelPlugins.SelectTab(tabBtnOfficial);
|
ReloadPluginTab();
|
||||||
};
|
};
|
||||||
|
|
||||||
FormClosed += (sender, args) => {
|
FormClosed += (sender, args) => {
|
||||||
Program.UserConfig.PluginsWindow.Save(this);
|
Program.UserConfig.PluginsWindow.Save(this);
|
||||||
Program.UserConfig.Save();
|
Program.UserConfig.Save();
|
||||||
};
|
};
|
||||||
|
|
||||||
Disposed += (sender, args) => this.pluginManager.Reloaded -= pluginManager_Reloaded;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SelectGroup(PluginGroup group){
|
|
||||||
if (selectedGroup.HasValue && selectedGroup == group)return;
|
|
||||||
|
|
||||||
selectedGroup = group;
|
|
||||||
|
|
||||||
ReloadPluginTab();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadPluginTab(){
|
public void ReloadPluginTab(){
|
||||||
if (!selectedGroup.HasValue)return;
|
|
||||||
|
|
||||||
flowLayoutPlugins.SuspendLayout();
|
flowLayoutPlugins.SuspendLayout();
|
||||||
flowLayoutPlugins.Controls.Clear();
|
flowLayoutPlugins.Controls.Clear();
|
||||||
|
|
||||||
Plugin[] plugins = pluginManager.GetPluginsByGroup(selectedGroup.Value).OrderBy(plugin => !plugin.CanRun ? 0 : pluginManager.Config.IsEnabled(plugin) ? 1 : 2).ThenBy(plugin => plugin.Name).ToArray();
|
Plugin[] plugins = pluginManager.Plugins.OrderBy(plugin => !plugin.CanRun ? 0 : pluginManager.Config.IsEnabled(plugin) ? 1 : 2).ThenBy(plugin => plugin.Name).ToArray();
|
||||||
|
|
||||||
for(int index = 0; index < plugins.Length; index++){
|
for(int index = 0; index < plugins.Length; index++){
|
||||||
flowLayoutPlugins.Controls.Add(new PluginControl(pluginManager, plugins[index]));
|
flowLayoutPlugins.Controls.Add(new PluginControl(pluginManager, plugins[index]));
|
||||||
@ -82,11 +51,6 @@ public void ReloadPluginTab(){
|
|||||||
flowLayoutPlugins_Resize(flowLayoutPlugins, new EventArgs());
|
flowLayoutPlugins_Resize(flowLayoutPlugins, new EventArgs());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void pluginManager_Reloaded(object sender, PluginErrorEventArgs e){
|
|
||||||
tabBtnOfficial.Text = "Official: "+pluginManager.CountPluginByGroup(PluginGroup.Official);
|
|
||||||
tabBtnCustom.Text = "Custom: "+pluginManager.CountPluginByGroup(PluginGroup.Custom);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
private void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
||||||
if (flowLayoutPlugins.Controls.Count == 0){
|
if (flowLayoutPlugins.Controls.Count == 0){
|
||||||
return;
|
return;
|
||||||
|
@ -62,14 +62,6 @@ public bool IsPluginInstalled(string identifier){
|
|||||||
return plugins.Any(plugin => plugin.Identifier.Equals(identifier));
|
return plugins.Any(plugin => plugin.Identifier.Equals(identifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Plugin> GetPluginsByGroup(PluginGroup group){
|
|
||||||
return plugins.Where(plugin => plugin.Group == group);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int CountPluginByGroup(PluginGroup group){
|
|
||||||
return plugins.Count(plugin => plugin.Group == group);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasAnyPlugin(PluginEnvironment environment){
|
public bool HasAnyPlugin(PluginEnvironment environment){
|
||||||
return plugins.Any(plugin => plugin.Environments.HasFlag(environment));
|
return plugins.Any(plugin => plugin.Environments.HasFlag(environment));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user