mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-02 02:34:08 +02:00
Show waiting cursor while taking a tweet screenshot
This commit is contained in:
parent
d1b1dd539f
commit
7c87856b4d
Core
@ -25,6 +25,23 @@ namespace TweetDuck.Core{
|
|||||||
sealed partial class FormBrowser : Form{
|
sealed partial class FormBrowser : Form{
|
||||||
private static UserConfig Config => Program.UserConfig;
|
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; }
|
public string UpdateInstallerPath { get; private set; }
|
||||||
|
|
||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
@ -225,6 +242,10 @@ private void FormBrowser_Activated(object sender, EventArgs e){
|
|||||||
if (!isLoaded)return;
|
if (!isLoaded)return;
|
||||||
|
|
||||||
trayIcon.HasNotifications = false;
|
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){
|
private void FormBrowser_LocationChanged(object sender, EventArgs e){
|
||||||
|
@ -8,14 +8,14 @@
|
|||||||
|
|
||||||
namespace TweetDuck.Core.Notification.Screenshot{
|
namespace TweetDuck.Core.Notification.Screenshot{
|
||||||
sealed class TweetScreenshotManager : IDisposable{
|
sealed class TweetScreenshotManager : IDisposable{
|
||||||
private readonly Form owner;
|
private readonly FormBrowser owner;
|
||||||
private readonly PluginManager plugins;
|
private readonly PluginManager plugins;
|
||||||
private readonly Timer timeout;
|
private readonly Timer timeout;
|
||||||
private readonly Timer disposer;
|
private readonly Timer disposer;
|
||||||
|
|
||||||
private FormNotificationScreenshotable screenshot;
|
private FormNotificationScreenshotable screenshot;
|
||||||
|
|
||||||
public TweetScreenshotManager(Form owner, PluginManager pluginManager){
|
public TweetScreenshotManager(FormBrowser owner, PluginManager pluginManager){
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.plugins = pluginManager;
|
this.plugins = pluginManager;
|
||||||
|
|
||||||
@ -28,8 +28,7 @@ public TweetScreenshotManager(Form owner, PluginManager pluginManager){
|
|||||||
|
|
||||||
private void timeout_Tick(object sender, EventArgs e){
|
private void timeout_Tick(object sender, EventArgs e){
|
||||||
timeout.Stop();
|
timeout.Stop();
|
||||||
screenshot.Location = ControlExtensions.InvisibleLocation;
|
OnFinished();
|
||||||
disposer.Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void disposer_Tick(object sender, EventArgs e){
|
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.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, 0, string.Empty, string.Empty), width, height);
|
||||||
screenshot.Show();
|
screenshot.Show();
|
||||||
timeout.Start();
|
timeout.Start();
|
||||||
|
|
||||||
|
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
|
||||||
|
owner.IsWaiting = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Callback(){
|
private void Callback(){
|
||||||
@ -61,14 +64,19 @@ private void Callback(){
|
|||||||
screenshot.TakeScreenshot();
|
screenshot.TakeScreenshot();
|
||||||
|
|
||||||
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
|
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
|
||||||
screenshot.Location = ControlExtensions.InvisibleLocation;
|
OnFinished();
|
||||||
disposer.Start();
|
|
||||||
#else
|
#else
|
||||||
screenshot.MoveToVisibleLocation();
|
screenshot.MoveToVisibleLocation();
|
||||||
screenshot.FormClosed += (sender, args) => disposer.Start();
|
screenshot.FormClosed += (sender, args) => disposer.Start();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnFinished(){
|
||||||
|
screenshot.Location = ControlExtensions.InvisibleLocation;
|
||||||
|
owner.IsWaiting = false;
|
||||||
|
disposer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
public void Dispose(){
|
public void Dispose(){
|
||||||
timeout.Dispose();
|
timeout.Dispose();
|
||||||
disposer.Dispose();
|
disposer.Dispose();
|
||||||
|
Loading…
Reference in New Issue
Block a user