1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-04-23 21:15:49 +02:00

Show waiting cursor while taking a tweet screenshot

This commit is contained in:
chylex 2017-07-20 16:29:39 +02:00
parent d1b1dd539f
commit 7c87856b4d
2 changed files with 35 additions and 6 deletions
Core

View File

@ -25,6 +25,23 @@ namespace TweetDuck.Core{
sealed partial class FormBrowser : Form{
private static UserConfig Config => Program.UserConfig;
public bool IsWaiting{
set{
if (value){
browser.Enabled = false;
Cursor = Cursors.WaitCursor;
}
else{
browser.Enabled = true;
Cursor = Cursors.Default;
if (Focused){ // re-focus browser only if the window or a child is activated
browser.Focus();
}
}
}
}
public string UpdateInstallerPath { get; private set; }
private readonly ChromiumWebBrowser browser;
@ -225,6 +242,10 @@ private void FormBrowser_Activated(object sender, EventArgs e){
if (!isLoaded)return;
trayIcon.HasNotifications = false;
if (!browser.Enabled){ // when taking a screenshot, the window is unfocused and
browser.Enabled = true; // the browser is disabled; if the user clicks back into
} // the window, enable the browser again
}
private void FormBrowser_LocationChanged(object sender, EventArgs e){

View File

@ -8,14 +8,14 @@
namespace TweetDuck.Core.Notification.Screenshot{
sealed class TweetScreenshotManager : IDisposable{
private readonly Form owner;
private readonly FormBrowser owner;
private readonly PluginManager plugins;
private readonly Timer timeout;
private readonly Timer disposer;
private FormNotificationScreenshotable screenshot;
public TweetScreenshotManager(Form owner, PluginManager pluginManager){
public TweetScreenshotManager(FormBrowser owner, PluginManager pluginManager){
this.owner = owner;
this.plugins = pluginManager;
@ -28,8 +28,7 @@ public TweetScreenshotManager(Form owner, PluginManager pluginManager){
private void timeout_Tick(object sender, EventArgs e){
timeout.Stop();
screenshot.Location = ControlExtensions.InvisibleLocation;
disposer.Start();
OnFinished();
}
private void disposer_Tick(object sender, EventArgs e){
@ -50,6 +49,10 @@ public void Trigger(string html, int width, int height){
screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, 0, string.Empty, string.Empty), width, height);
screenshot.Show();
timeout.Start();
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
owner.IsWaiting = true;
#endif
}
private void Callback(){
@ -61,14 +64,19 @@ private void Callback(){
screenshot.TakeScreenshot();
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
screenshot.Location = ControlExtensions.InvisibleLocation;
disposer.Start();
OnFinished();
#else
screenshot.MoveToVisibleLocation();
screenshot.FormClosed += (sender, args) => disposer.Start();
#endif
}
private void OnFinished(){
screenshot.Location = ControlExtensions.InvisibleLocation;
owner.IsWaiting = false;
disposer.Start();
}
public void Dispose(){
timeout.Dispose();
disposer.Dispose();