Skip to content
This repository has been archived by the owner on Nov 17, 2022. It is now read-only.

Commit

Permalink
feat(Talk) added download popup and prevent windows notification whil…
Browse files Browse the repository at this point in the history
…e app is open
  • Loading branch information
Eidenz committed Dec 30, 2021
1 parent d5423f6 commit 7c76c3b
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
34 changes: 34 additions & 0 deletions Talk/MyCustomDownloadHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using CefSharp;
using System;

namespace Talk
{
class MyCustomDownloadHandler : IDownloadHandler
{
public event EventHandler<DownloadItem> OnBeforeDownloadFired;

public event EventHandler<DownloadItem> OnDownloadUpdatedFired;

public void OnBeforeDownload(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IBeforeDownloadCallback callback)
{
OnBeforeDownloadFired?.Invoke(this, downloadItem);

if (!callback.IsDisposed)
{
using (callback)
{
callback.Continue(
downloadItem.SuggestedFileName,
showDialog: true
);
}
}
}

/// https://cefsharp.github.io/api/51.0.0/html/T_CefSharp_DownloadItem.htm
public void OnDownloadUpdated(IWebBrowser chromiumWebBrowser, IBrowser browser, DownloadItem downloadItem, IDownloadItemCallback callback)
{
OnDownloadUpdatedFired?.Invoke(this, downloadItem);
}
}
}
12 changes: 8 additions & 4 deletions Talk/Talk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ private void Talk_Load(object sender, EventArgs e)
getConversationsAsync();
checkMessages.Enabled = true;
login.Load(website + "/apps/spreed/");
login.DownloadHandler = new MyCustomDownloadHandler();
login.Visible = true;
}
}
Expand Down Expand Up @@ -247,10 +248,13 @@ private async void checkMessages_TickAsync(object sender, EventArgs e)
}
}

notifications.BalloonTipTitle = balloonTitle;
notifications.BalloonTipText = balloonText;
notifications.Icon = Properties.Resources.notif;
notifications.ShowBalloonTip(60000); //for old Windows versions. Lucky...
if (!this.Visible)
{
notifications.BalloonTipTitle = balloonTitle;
notifications.BalloonTipText = balloonText;
notifications.Icon = Properties.Resources.notif;
notifications.ShowBalloonTip(60000); //for old Windows versions. Lucky...
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Talk/Talk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MyCustomDownloadHandler.cs" />
<Compile Include="Talk.cs">
<SubType>Form</SubType>
</Compile>
Expand Down

0 comments on commit 7c76c3b

Please sign in to comment.