Skip to content

Commit

Permalink
Added Mutex application
Browse files Browse the repository at this point in the history
  • Loading branch information
DJZK committed Feb 10, 2022
1 parent f15a800 commit 76d3ccd
Show file tree
Hide file tree
Showing 5 changed files with 647 additions and 3 deletions.
35 changes: 35 additions & 0 deletions Telegram/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Telegram/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace Telegram
{
public partial class MainWindow : Form
{

private bool bypass;
private bool first = true;
private FormWindowState windowState;
public MainWindow()
{
InitializeComponent();
Expand All @@ -38,6 +42,7 @@ private void MainWindow_Resize(object sender, EventArgs e)
private void TelegramBrowser_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
TelegramBrowser.CoreWebView2.Settings.AreDevToolsEnabled = false;
TelegramBrowser.CoreWebView2.IsMuted = false;
TelegramBrowser.CoreWebView2.Settings.AreDefaultContextMenusEnabled = false;
TelegramBrowser.ZoomFactor = 0.9;
TelegramBrowser.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
Expand All @@ -47,5 +52,38 @@ private void CoreWebView2_NewWindowRequested(object sender, Microsoft.Web.WebVie
System.Diagnostics.Process.Start(e.Uri);
e.Handled = true;
}

private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{

Show();
WindowState = windowState;
}

private void ExitApplication_Click(object sender, EventArgs e)
{
bypass = true;
Application.Exit();
}

private void MainWindow_FormClosing(object sender, FormClosingEventArgs e)
{
if (!bypass)
{
e.Cancel = true;
windowState = this.WindowState;
WindowState = FormWindowState.Minimized;
Hide();
notifyIcon1.Visible = true;

if (first)
{
notifyIcon1.ShowBalloonTip(1000);
first = false;
}

}

}
}
}
Loading

0 comments on commit 76d3ccd

Please sign in to comment.