mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-13 08:34:08 +02:00
Finish plugin reloading and add plugin counts to the UI
This commit is contained in:
parent
8bb69ef0ee
commit
d955713335
Core
Plugins/Controls
Resources/Scripts
@ -11,6 +11,7 @@
|
||||
using System.Drawing;
|
||||
using TweetDck.Updates;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Core{
|
||||
sealed partial class FormBrowser : Form{
|
||||
@ -62,6 +63,7 @@ public FormBrowser(PluginManager pluginManager){
|
||||
UpdateTrayIcon();
|
||||
|
||||
plugins = pluginManager;
|
||||
plugins.Reloaded += plugins_Reloaded;
|
||||
plugins.Config.PluginChangedState += plugins_PluginChangedState;
|
||||
|
||||
notification = CreateNotificationForm(true);
|
||||
@ -190,6 +192,10 @@ private void trayIcon_ClickClose(object sender, EventArgs e){
|
||||
|
||||
ForceClose();
|
||||
}
|
||||
|
||||
private void plugins_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
browser.ExecuteScriptAsync(plugins.GenerateScript(PluginEnvironment.Browser));
|
||||
}
|
||||
|
||||
private void plugins_PluginChangedState(object sender, PluginChangedStateEventArgs e){
|
||||
browser.ExecuteScriptAsync(PluginScriptGenerator.GenerateSetPluginState(e.Plugin,e.IsEnabled));
|
||||
|
@ -22,7 +22,7 @@ private void btnOpenFolder_Click(object sender, EventArgs e){
|
||||
|
||||
private void btnReload_Click(object sender, EventArgs e){
|
||||
pluginManager.Reload();
|
||||
pluginList.ReloadPlugins();
|
||||
pluginList.ReloadPluginTab();
|
||||
}
|
||||
|
||||
private void btnClose_Click(object sender, EventArgs e){
|
||||
|
8
Plugins/Controls/PluginListControl.Designer.cs
generated
8
Plugins/Controls/PluginListControl.Designer.cs
generated
@ -23,7 +23,7 @@ protected override void Dispose(bool disposing) {
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.flowLayoutPlugins = new PluginListFlowLayout();
|
||||
this.flowLayoutPlugins = new TweetDck.Plugins.Controls.PluginListFlowLayout();
|
||||
this.btnTabCustom = new TweetDck.Plugins.Controls.TabButton();
|
||||
this.btnTabOfficial = new TweetDck.Plugins.Controls.TabButton();
|
||||
this.SuspendLayout();
|
||||
@ -50,10 +50,10 @@ private void InitializeComponent() {
|
||||
this.btnTabCustom.FlatAppearance.MouseDownBackColor = System.Drawing.Color.White;
|
||||
this.btnTabCustom.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White;
|
||||
this.btnTabCustom.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
|
||||
this.btnTabCustom.Location = new System.Drawing.Point(80, 0);
|
||||
this.btnTabCustom.Location = new System.Drawing.Point(90, 0);
|
||||
this.btnTabCustom.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnTabCustom.Name = "btnTabCustom";
|
||||
this.btnTabCustom.Size = new System.Drawing.Size(81, 30);
|
||||
this.btnTabCustom.Size = new System.Drawing.Size(91, 30);
|
||||
this.btnTabCustom.TabIndex = 8;
|
||||
this.btnTabCustom.Text = "Custom";
|
||||
this.btnTabCustom.UseVisualStyleBackColor = true;
|
||||
@ -68,7 +68,7 @@ private void InitializeComponent() {
|
||||
this.btnTabOfficial.Location = new System.Drawing.Point(0, 0);
|
||||
this.btnTabOfficial.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.btnTabOfficial.Name = "btnTabOfficial";
|
||||
this.btnTabOfficial.Size = new System.Drawing.Size(81, 30);
|
||||
this.btnTabOfficial.Size = new System.Drawing.Size(91, 30);
|
||||
this.btnTabOfficial.TabIndex = 7;
|
||||
this.btnTabOfficial.Text = "Official";
|
||||
this.btnTabOfficial.UseVisualStyleBackColor = true;
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Plugins.Controls{
|
||||
sealed partial class PluginListControl : UserControl{
|
||||
@ -25,10 +26,18 @@ public void Initialize(PluginManager manager){
|
||||
}
|
||||
|
||||
this.pluginManager = manager;
|
||||
this.pluginManager.Reloaded += pluginManager_Reloaded;
|
||||
this.pluginManager_Reloaded(manager,null);
|
||||
|
||||
SelectTab(btnTabOfficial,PluginGroup.Official);
|
||||
}
|
||||
|
||||
public void ReloadPlugins(){
|
||||
private void pluginManager_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
btnTabOfficial.Text = "Official: "+pluginManager.CountPluginByGroup(PluginGroup.Official);
|
||||
btnTabCustom.Text = "Custom: "+pluginManager.CountPluginByGroup(PluginGroup.Custom);
|
||||
}
|
||||
|
||||
public void ReloadPluginTab(){
|
||||
if (!selectedGroup.HasValue)return;
|
||||
|
||||
flowLayoutPlugins.Controls.Clear();
|
||||
@ -59,7 +68,7 @@ private void SelectTab(Button button, PluginGroup group){
|
||||
|
||||
button.BackColor = Color.White;
|
||||
|
||||
ReloadPlugins();
|
||||
ReloadPluginTab();
|
||||
}
|
||||
|
||||
private void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
||||
|
@ -1,3 +1,13 @@
|
||||
var isReloading = "TD_PLUGINS" in window;
|
||||
|
||||
if (isReloading){
|
||||
window.TD_PLUGINS.installed.forEach(plugin => {
|
||||
if (!window.TD_PLUGINS.isDisabled(plugin)){
|
||||
plugin.obj.disabled();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class PluginBase{
|
||||
constructor(pluginSettings){
|
||||
this.$pluginSettings = pluginSettings || {};
|
||||
@ -59,4 +69,8 @@ var PLUGINS = {
|
||||
}
|
||||
};
|
||||
|
||||
window.TD_PLUGINS = PLUGINS;
|
||||
window.TD_PLUGINS = PLUGINS;
|
||||
|
||||
if (isReloading){
|
||||
window.location.reload();
|
||||
}
|
Loading…
Reference in New Issue
Block a user