mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-30 14:34:09 +02:00
Remove ITweetDeckBrowser
This commit is contained in:
parent
f5bfb35867
commit
5bcc8ac2e0
@ -14,7 +14,6 @@
|
|||||||
using TweetDuck.Core.Other.Settings.Dialogs;
|
using TweetDuck.Core.Other.Settings.Dialogs;
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
using TweetDuck.Plugins;
|
using TweetDuck.Plugins;
|
||||||
using TweetDuck.Plugins.Enums;
|
|
||||||
using TweetDuck.Plugins.Events;
|
using TweetDuck.Plugins.Events;
|
||||||
using TweetDuck.Updates;
|
using TweetDuck.Updates;
|
||||||
|
|
||||||
@ -79,11 +78,9 @@ public FormBrowser(){
|
|||||||
this.updateBridge.UpdateDelayed += updateBridge_UpdateDelayed;
|
this.updateBridge.UpdateDelayed += updateBridge_UpdateDelayed;
|
||||||
this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed;
|
this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed;
|
||||||
|
|
||||||
this.browser = new TweetDeckBrowser(this, new TweetDeckBridge.Browser(this, notification), updateBridge);
|
this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification), updateBridge);
|
||||||
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||||
|
|
||||||
this.plugins.Register(browser, PluginEnvironment.Browser, this, true);
|
|
||||||
|
|
||||||
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
|
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
|
||||||
|
|
||||||
Disposed += (sender, args) => {
|
Disposed += (sender, args) => {
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
using TweetDuck.Core.Bridge;
|
using TweetDuck.Core.Bridge;
|
||||||
using TweetDuck.Core.Controls;
|
using TweetDuck.Core.Controls;
|
||||||
using TweetDuck.Core.Handling;
|
using TweetDuck.Core.Handling;
|
||||||
using TweetDuck.Core.Other.Interfaces;
|
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
using TweetDuck.Data;
|
using TweetDuck.Data;
|
||||||
using TweetDuck.Plugins;
|
using TweetDuck.Plugins;
|
||||||
@ -13,7 +12,7 @@
|
|||||||
using TweetDuck.Resources;
|
using TweetDuck.Resources;
|
||||||
|
|
||||||
namespace TweetDuck.Core.Notification{
|
namespace TweetDuck.Core.Notification{
|
||||||
abstract partial class FormNotificationMain : FormNotificationBase, ITweetDeckBrowser{
|
abstract partial class FormNotificationMain : FormNotificationBase{
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
private readonly int timerBarHeight;
|
private readonly int timerBarHeight;
|
||||||
|
|
||||||
@ -84,34 +83,12 @@ protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, b
|
|||||||
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||||
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||||
|
|
||||||
plugins.Register(this, PluginEnvironment.Notification, this);
|
plugins.Register(browser, PluginEnvironment.Notification, this);
|
||||||
|
|
||||||
mouseHookDelegate = MouseHookProc;
|
mouseHookDelegate = MouseHookProc;
|
||||||
Disposed += (sender, args) => StopMouseHook(true);
|
Disposed += (sender, args) => StopMouseHook(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// implementation of ITweetDeckBrowser
|
|
||||||
|
|
||||||
bool ITweetDeckBrowser.IsTweetDeckWebsite => IsNotificationVisible;
|
|
||||||
|
|
||||||
void ITweetDeckBrowser.RegisterBridge(string name, object obj){
|
|
||||||
browser.RegisterAsyncJsObject(name, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITweetDeckBrowser.OnFrameLoaded(Action<IFrame> callback){
|
|
||||||
browser.FrameLoadEnd += (sender, args) => {
|
|
||||||
IFrame frame = args.Frame;
|
|
||||||
|
|
||||||
if (frame.IsMain && browser.Address != "about:blank"){
|
|
||||||
callback(frame);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITweetDeckBrowser.ExecuteFunction(string name, params object[] args){
|
|
||||||
browser.ExecuteScriptAsync(name, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// mouse wheel hook
|
// mouse wheel hook
|
||||||
|
|
||||||
private void StartMouseHook(){
|
private void StartMouseHook(){
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
using System;
|
|
||||||
using CefSharp;
|
|
||||||
|
|
||||||
namespace TweetDuck.Core.Other.Interfaces{
|
|
||||||
interface ITweetDeckBrowser{
|
|
||||||
bool IsTweetDeckWebsite { get; }
|
|
||||||
|
|
||||||
void RegisterBridge(string name, object obj);
|
|
||||||
void OnFrameLoaded(Action<IFrame> callback);
|
|
||||||
void ExecuteFunction(string name, params object[] args);
|
|
||||||
}
|
|
||||||
}
|
|
@ -10,12 +10,13 @@
|
|||||||
using TweetDuck.Core.Handling;
|
using TweetDuck.Core.Handling;
|
||||||
using TweetDuck.Core.Handling.General;
|
using TweetDuck.Core.Handling.General;
|
||||||
using TweetDuck.Core.Notification;
|
using TweetDuck.Core.Notification;
|
||||||
using TweetDuck.Core.Other.Interfaces;
|
|
||||||
using TweetDuck.Core.Utils;
|
using TweetDuck.Core.Utils;
|
||||||
|
using TweetDuck.Plugins;
|
||||||
|
using TweetDuck.Plugins.Enums;
|
||||||
using TweetDuck.Resources;
|
using TweetDuck.Resources;
|
||||||
|
|
||||||
namespace TweetDuck.Core{
|
namespace TweetDuck.Core{
|
||||||
sealed class TweetDeckBrowser : ITweetDeckBrowser, IDisposable{
|
sealed class TweetDeckBrowser : IDisposable{
|
||||||
private static UserConfig Config => Program.Config.User;
|
private static UserConfig Config => Program.Config.User;
|
||||||
|
|
||||||
public bool Ready { get; private set; }
|
public bool Ready { get; private set; }
|
||||||
@ -41,7 +42,7 @@ public bool IsTweetDeckWebsite{
|
|||||||
|
|
||||||
private string prevSoundNotificationPath = null;
|
private string prevSoundNotificationPath = null;
|
||||||
|
|
||||||
public TweetDeckBrowser(FormBrowser owner, TweetDeckBridge tdBridge, UpdateBridge updateBridge){
|
public TweetDeckBrowser(FormBrowser owner, PluginManager plugins, TweetDeckBridge tdBridge, UpdateBridge updateBridge){
|
||||||
RequestHandlerBrowser requestHandler = new RequestHandlerBrowser();
|
RequestHandlerBrowser requestHandler = new RequestHandlerBrowser();
|
||||||
|
|
||||||
this.browser = new ChromiumWebBrowser(TwitterUtils.TweetDeckURL){
|
this.browser = new ChromiumWebBrowser(TwitterUtils.TweetDeckURL){
|
||||||
@ -71,6 +72,7 @@ public TweetDeckBrowser(FormBrowser owner, TweetDeckBridge tdBridge, UpdateBridg
|
|||||||
this.browser.SetupZoomEvents();
|
this.browser.SetupZoomEvents();
|
||||||
|
|
||||||
owner.Controls.Add(browser);
|
owner.Controls.Add(browser);
|
||||||
|
plugins.Register(browser, PluginEnvironment.Browser, owner, true);
|
||||||
|
|
||||||
Config.MuteToggled += Config_MuteToggled;
|
Config.MuteToggled += Config_MuteToggled;
|
||||||
Config.SoundNotificationChanged += Config_SoundNotificationInfoChanged;
|
Config.SoundNotificationChanged += Config_SoundNotificationInfoChanged;
|
||||||
@ -96,24 +98,6 @@ public void Dispose(){
|
|||||||
|
|
||||||
browser.Dispose();
|
browser.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ITweetDeckBrowser.RegisterBridge(string name, object obj){
|
|
||||||
browser.RegisterAsyncJsObject(name, obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITweetDeckBrowser.OnFrameLoaded(Action<IFrame> callback){
|
|
||||||
browser.FrameLoadEnd += (sender, args) => {
|
|
||||||
IFrame frame = args.Frame;
|
|
||||||
|
|
||||||
if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)){
|
|
||||||
callback(frame);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void ITweetDeckBrowser.ExecuteFunction(string name, params object[] args){
|
|
||||||
browser.ExecuteScriptAsync(name, args);
|
|
||||||
}
|
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using TweetDuck.Core.Other.Interfaces;
|
using TweetDuck.Core.Utils;
|
||||||
using TweetDuck.Data;
|
using TweetDuck.Data;
|
||||||
using TweetDuck.Plugins.Enums;
|
using TweetDuck.Plugins.Enums;
|
||||||
using TweetDuck.Plugins.Events;
|
using TweetDuck.Plugins.Events;
|
||||||
@ -34,7 +34,7 @@ sealed class PluginManager{
|
|||||||
private readonly Dictionary<int, Plugin> tokens = new Dictionary<int, Plugin>();
|
private readonly Dictionary<int, Plugin> tokens = new Dictionary<int, Plugin>();
|
||||||
private readonly Random rand = new Random();
|
private readonly Random rand = new Random();
|
||||||
|
|
||||||
private ITweetDeckBrowser mainBrowser;
|
private IWebBrowser mainBrowser;
|
||||||
|
|
||||||
public PluginManager(string rootPath, string configPath){
|
public PluginManager(string rootPath, string configPath){
|
||||||
this.rootPath = rootPath;
|
this.rootPath = rootPath;
|
||||||
@ -47,9 +47,16 @@ public PluginManager(string rootPath, string configPath){
|
|||||||
Config.PluginChangedState += Config_PluginChangedState;
|
Config.PluginChangedState += Config_PluginChangedState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Register(ITweetDeckBrowser browser, PluginEnvironment environment, Control sync, bool asMainBrowser = false){
|
public void Register(IWebBrowser browser, PluginEnvironment environment, Control sync, bool asMainBrowser = false){
|
||||||
browser.OnFrameLoaded(frame => ExecutePlugins(frame, environment, sync));
|
browser.FrameLoadEnd += (sender, args) => {
|
||||||
browser.RegisterBridge("$TDP", bridge);
|
IFrame frame = args.Frame;
|
||||||
|
|
||||||
|
if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)){
|
||||||
|
ExecutePlugins(frame, environment, sync);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
browser.RegisterAsyncJsObject("$TDP", bridge);
|
||||||
|
|
||||||
if (asMainBrowser){
|
if (asMainBrowser){
|
||||||
mainBrowser = browser;
|
mainBrowser = browser;
|
||||||
@ -57,7 +64,7 @@ public void Register(ITweetDeckBrowser browser, PluginEnvironment environment, C
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Config_PluginChangedState(object sender, PluginChangedStateEventArgs e){
|
private void Config_PluginChangedState(object sender, PluginChangedStateEventArgs e){
|
||||||
mainBrowser?.ExecuteFunction("TDPF_setPluginState", e.Plugin, e.IsEnabled);
|
mainBrowser?.ExecuteScriptAsync("TDPF_setPluginState", e.Plugin, e.IsEnabled);
|
||||||
Config.Save(configPath);
|
Config.Save(configPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +82,7 @@ public bool IsPluginConfigurable(Plugin plugin){
|
|||||||
|
|
||||||
public void ConfigurePlugin(Plugin plugin){
|
public void ConfigurePlugin(Plugin plugin){
|
||||||
if (bridge.WithConfigureFunction.Contains(plugin)){
|
if (bridge.WithConfigureFunction.Contains(plugin)){
|
||||||
mainBrowser?.ExecuteFunction("TDPF_configurePlugin", plugin);
|
mainBrowser?.ExecuteScriptAsync("TDPF_configurePlugin", plugin);
|
||||||
}
|
}
|
||||||
else if (plugin.HasConfig){
|
else if (plugin.HasConfig){
|
||||||
if (File.Exists(plugin.ConfigPath)){
|
if (File.Exists(plugin.ConfigPath)){
|
||||||
|
@ -95,7 +95,6 @@
|
|||||||
<Compile Include="Core\Handling\RequestHandlerBase.cs" />
|
<Compile Include="Core\Handling\RequestHandlerBase.cs" />
|
||||||
<Compile Include="Core\Handling\RequestHandlerBrowser.cs" />
|
<Compile Include="Core\Handling\RequestHandlerBrowser.cs" />
|
||||||
<Compile Include="Core\Handling\ResourceHandlerNotification.cs" />
|
<Compile Include="Core\Handling\ResourceHandlerNotification.cs" />
|
||||||
<Compile Include="Core\Other\Interfaces\ITweetDeckBrowser.cs" />
|
|
||||||
<Compile Include="Core\Management\ContextInfo.cs" />
|
<Compile Include="Core\Management\ContextInfo.cs" />
|
||||||
<Compile Include="Core\Notification\Example\FormNotificationExample.cs">
|
<Compile Include="Core\Notification\Example\FormNotificationExample.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
Loading…
Reference in New Issue
Block a user