mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-29 11:34:07 +02:00
Swap notification windows when taking a screenshot, and make screenshot window unmovable
This commit is contained in:
parent
68fa3294d4
commit
cac6d1f889
@ -28,6 +28,7 @@ private static UserConfig Config{
|
|||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
private readonly UpdateHandler updates;
|
private readonly UpdateHandler updates;
|
||||||
|
private readonly FormNotification notification;
|
||||||
|
|
||||||
private FormSettings currentFormSettings;
|
private FormSettings currentFormSettings;
|
||||||
private FormAbout currentFormAbout;
|
private FormAbout currentFormAbout;
|
||||||
@ -45,9 +46,9 @@ public FormBrowser(PluginManager pluginManager){
|
|||||||
this.plugins.Reloaded += plugins_Reloaded;
|
this.plugins.Reloaded += plugins_Reloaded;
|
||||||
this.plugins.PluginChangedState += plugins_PluginChangedState;
|
this.plugins.PluginChangedState += plugins_PluginChangedState;
|
||||||
|
|
||||||
FormNotification notification = CreateNotificationForm(NotificationFlags.AutoHide);
|
this.notification = CreateNotificationForm(NotificationFlags.AutoHide);
|
||||||
notification.CanMoveWindow = () => false;
|
this.notification.CanMoveWindow = () => false;
|
||||||
notification.Show();
|
this.notification.Show();
|
||||||
|
|
||||||
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
||||||
MenuHandler = new ContextMenuBrowser(this),
|
MenuHandler = new ContextMenuBrowser(this),
|
||||||
@ -296,12 +297,29 @@ public void OnTweetScreenshotReady(string html, int width, int height){
|
|||||||
FormNotification dummyWindow = CreateNotificationForm(NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu);
|
FormNotification dummyWindow = CreateNotificationForm(NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu);
|
||||||
|
|
||||||
dummyWindow.ShowNotificationForScreenshot(new TweetNotification(html, string.Empty, 0), width, height, () => {
|
dummyWindow.ShowNotificationForScreenshot(new TweetNotification(html, string.Empty, 0), width, height, () => {
|
||||||
|
Point? prevNotificationLocation = null;
|
||||||
|
bool prevFreezeTimer = false;
|
||||||
|
|
||||||
|
if (notification.IsNotificationVisible){
|
||||||
|
prevNotificationLocation = notification.Location;
|
||||||
|
prevFreezeTimer = notification.FreezeTimer;
|
||||||
|
|
||||||
|
notification.Location = new Point(-32000, -32000);
|
||||||
|
notification.FreezeTimer = true;
|
||||||
|
}
|
||||||
|
|
||||||
dummyWindow.TakeScreenshot();
|
dummyWindow.TakeScreenshot();
|
||||||
dummyWindow.Hide();
|
dummyWindow.Hide();
|
||||||
dummyWindow.Close();
|
dummyWindow.Close();
|
||||||
// dummyWindow.Dispose(); // TODO something freezes the program sometimes
|
// dummyWindow.Dispose(); // TODO something freezes the program sometimes
|
||||||
});
|
|
||||||
|
|
||||||
|
if (prevNotificationLocation.HasValue){
|
||||||
|
notification.Location = prevNotificationLocation.Value;
|
||||||
|
notification.FreezeTimer = prevFreezeTimer;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dummyWindow.CanMoveWindow = () => false;
|
||||||
dummyWindow.Show();
|
dummyWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
using TweetDck.Configuration;
|
using TweetDck.Configuration;
|
||||||
using TweetDck.Core.Controls;
|
|
||||||
using TweetDck.Core.Handling;
|
using TweetDck.Core.Handling;
|
||||||
using TweetDck.Resources;
|
using TweetDck.Resources;
|
||||||
using TweetDck.Core.Utils;
|
using TweetDck.Core.Utils;
|
||||||
@ -22,6 +21,12 @@ sealed partial class FormNotification : Form{
|
|||||||
|
|
||||||
public Func<bool> CanMoveWindow = () => true;
|
public Func<bool> CanMoveWindow = () => true;
|
||||||
|
|
||||||
|
public bool IsNotificationVisible{
|
||||||
|
get{
|
||||||
|
return Location.X != -32000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Form owner;
|
private readonly Form owner;
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
|
Loading…
Reference in New Issue
Block a user