mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-04 17:34:07 +02:00
Refactor resource handler related extension methods
This commit is contained in:
parent
22f491d98a
commit
f3f5b88550
Core
@ -139,7 +139,7 @@ protected FormNotificationBase(FormBrowser owner, bool enableContextMenu){
|
|||||||
|
|
||||||
DpiScale = this.GetDPIScale();
|
DpiScale = this.GetDPIScale();
|
||||||
|
|
||||||
browser.GetHandlerFactory().RegisterHandler(TwitterUtils.TweetDeckURL, this.resourceHandler);
|
browser.SetupResourceHandler(TwitterUtils.TweetDeckURL, this.resourceHandler);
|
||||||
|
|
||||||
Controls.Add(browser);
|
Controls.Add(browser);
|
||||||
|
|
||||||
|
@ -178,16 +178,7 @@ private void UserConfig_SoundNotificationInfoChanged(object sender, EventArgs e)
|
|||||||
bool hasCustomSound = Program.UserConfig.IsCustomSoundNotificationSet;
|
bool hasCustomSound = Program.UserConfig.IsCustomSoundNotificationSet;
|
||||||
|
|
||||||
if (prevSoundNotificationPath != Program.UserConfig.NotificationSoundPath){
|
if (prevSoundNotificationPath != Program.UserConfig.NotificationSoundPath){
|
||||||
DefaultResourceHandlerFactory handlerFactory = browser.GetHandlerFactory();
|
browser.SetupResourceHandler(soundUrl, hasCustomSound ? SoundNotification.CreateFileHandler(Program.UserConfig.NotificationSoundPath) : null);
|
||||||
IResourceHandler resourceHandler = hasCustomSound ? SoundNotification.CreateFileHandler(Program.UserConfig.NotificationSoundPath) : null;
|
|
||||||
|
|
||||||
if (resourceHandler != null){
|
|
||||||
handlerFactory.RegisterHandler(soundUrl, resourceHandler);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
handlerFactory.UnregisterHandler(soundUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
prevSoundNotificationPath = Program.UserConfig.NotificationSoundPath;
|
prevSoundNotificationPath = Program.UserConfig.NotificationSoundPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,8 +38,15 @@ public static ChromiumWebBrowser AsControl(this IWebBrowser browserControl){
|
|||||||
return (ChromiumWebBrowser)browserControl;
|
return (ChromiumWebBrowser)browserControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DefaultResourceHandlerFactory GetHandlerFactory(this ChromiumWebBrowser browser){
|
public static void SetupResourceHandler(this ChromiumWebBrowser browser, string url, IResourceHandler handler){
|
||||||
return (DefaultResourceHandlerFactory)browser.ResourceHandlerFactory;
|
DefaultResourceHandlerFactory factory = (DefaultResourceHandlerFactory)browser.ResourceHandlerFactory;
|
||||||
|
|
||||||
|
if (handler == null){
|
||||||
|
factory.UnregisterHandler(url);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
factory.RegisterHandler(url, handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string TwitterTrackingUrl = "t.co";
|
private const string TwitterTrackingUrl = "t.co";
|
||||||
|
Loading…
Reference in New Issue
Block a user