1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-05 20:34:07 +02:00

Swap notification windows when taking a screenshot, and make screenshot window unmovable

This commit is contained in:
chylex 2016-12-23 15:13:34 +01:00
parent 68fa3294d4
commit cac6d1f889
2 changed files with 28 additions and 5 deletions

View File

@ -28,6 +28,7 @@ private static UserConfig Config{
private readonly ChromiumWebBrowser browser;
private readonly PluginManager plugins;
private readonly UpdateHandler updates;
private readonly FormNotification notification;
private FormSettings currentFormSettings;
private FormAbout currentFormAbout;
@ -45,9 +46,9 @@ public FormBrowser(PluginManager pluginManager){
this.plugins.Reloaded += plugins_Reloaded;
this.plugins.PluginChangedState += plugins_PluginChangedState;
FormNotification notification = CreateNotificationForm(NotificationFlags.AutoHide);
notification.CanMoveWindow = () => false;
notification.Show();
this.notification = CreateNotificationForm(NotificationFlags.AutoHide);
this.notification.CanMoveWindow = () => false;
this.notification.Show();
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
MenuHandler = new ContextMenuBrowser(this),
@ -296,12 +297,29 @@ public void OnTweetScreenshotReady(string html, int width, int height){
FormNotification dummyWindow = CreateNotificationForm(NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu);
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.Hide();
dummyWindow.Close();
// dummyWindow.Dispose(); // TODO something freezes the program sometimes
});
if (prevNotificationLocation.HasValue){
notification.Location = prevNotificationLocation.Value;
notification.FreezeTimer = prevFreezeTimer;
}
});
dummyWindow.CanMoveWindow = () => false;
dummyWindow.Show();
}

View File

@ -5,7 +5,6 @@
using CefSharp;
using CefSharp.WinForms;
using TweetDck.Configuration;
using TweetDck.Core.Controls;
using TweetDck.Core.Handling;
using TweetDck.Resources;
using TweetDck.Core.Utils;
@ -22,6 +21,12 @@ sealed partial class FormNotification : Form{
public Func<bool> CanMoveWindow = () => true;
public bool IsNotificationVisible{
get{
return Location.X != -32000;
}
}
private readonly Form owner;
private readonly PluginManager plugins;
private readonly ChromiumWebBrowser browser;